Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Alaska and Hawaii rendering after upgrading to version 3.2.0 #1315

Closed
cherihung opened this issue Jun 14, 2013 · 2 comments
Closed

Comments

@cherihung
Copy link

I just upgraded the d3.js on my site to the latest 3.2.0 release. And I noticed that Alaska and Hawaii are showing up as rectangles in maps implemented using a FeaturesCollection json file. They are not rendering according to the MultiPolygon coordinates in the json file.

I'm basically using the same code as this example, http://bl.ocks.org/mbostock/2206590, which is also showing the same problem.

@jasondavies
Copy link
Contributor

That example appears to contain three tiny counterclockwise polygons, which D3 treats as covering most of the sphere. In version 3.2, we modified the clockwise/counterclockwise detection slightly to be more accurate.

An example offending polygon appears in Virginia (as part of a MultiPolygon):

[[
  [-76.016553, 37.95325],
  [-75.994645, 37.95325],
  [-76.043938, 37.95325],
  [-76.016553, 37.95325]]]

At first glance, you might expect it to have zero area because the latitudes are all equal, but line segments are geodesics in D3, thus it actually has non-zero, negative area, which we treat as counterclockwise.

Leaving this open so @mbostock knows to update the example; I’d recommend using TopoJSON e.g. as used by more recent examples.

@cherihung
Copy link
Author

Thanks @jasondavies! That fixed the problem for the existing maps I had.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants