-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
At some zoom levels, holes in geojson features are rendered wrong #2975
Comments
It looks to me as though you are trying to render a complex polygon. Mapbox GL JS's behavior in this case is undefined. |
Yes, it is a complex polygon. i.e. is has holes. I was expecting it to work since it is supported in the GeoJSON spec, http://geojson.org/geojson-spec.html#id4. Also, other geojson rendering tools I have tried does this successfully; Openlayers, Leaflet. There are even bugs that have been fixed on mapbox-gl-js that support holes; #1202. I stumbled upon this bug just because we are rendering at this precis zoom level. (And regarding the #1202 issue, I suspect that this is not a polygon winding issue, as I tried rewinding just in case without luck.) Also, here is a jsbin link for the curious; https://output.jsbin.com/joruwi/5. Try zooming in and out until the rendering changes. |
The problem isn't the holes -- we support those! The problem seems to be that the that the 2nd ring is outside of the 1st ring. The 1st ring defines the outer perimeter of the polygon and subsequent rings define holes in the polygon, subject to the even-odd rule. It is unfortunate that other map renderers, including Leaflet, differ in behaviour in this case. |
@kretz Is your desired effect a solid polygon and a diamond-shaped stroke? |
The reason for the weirdly shaped polygon is that this was the only way I could get the effect. It is a simplified version of a more complex shape of a building. |
Would it be accurate to say that you want the 2nd ring to "subtract" from the 1st ring? |
Yep, exactly. |
Unfortunately the spec we are working from doesn't allow interior rings to be coincident with the exterior ring. You need to do this subtraction operation outside of GL JS https://www.mapbox.com/vector-tiles/specification/#winding-order |
Alright, thanks for taking the time to explain it! |
mapbox-gl-js version: 0.21.0
Steps to Trigger Behavior
I use geojson data like below, which is one feauture consiting of a polygon with a hole. I render it in mapbox.
Expected Behavior
The hole should always be rendered correctly, like the image below. This is zoom level 18.
![screenshot 2016-08-10 17 48 41](https://cloud.githubusercontent.com/assets/154819/17560542/c161f5be-5f22-11e6-976e-a1e67f7d0d2a.png)
### Actual BehaviorAt certain zoom levels, the hole is not like to should. This is zoom level 17.
The text was updated successfully, but these errors were encountered: