Mapbox-gl-js: Distorted Polygon

Created on 26 Aug 2016  路  2Comments  路  Source: mapbox/mapbox-gl-js

I have problems with polygons. When I draw a new polygon, it distort with zoom level. I don't know if I'm doing something wrong. I'm using mapbox gl v0.22.1.

http://codepen.io/Naimikan/pen/mENbEj

map.addSource("markers", {
   "type": "geojson",
   "data": {
      "type": 'Feature',
      "geometry": {
         "type": 'Polygon',
         "coordinates": [[[-1.8035947381652875,40.2803612648338],[-1.8100962483371745,40.27866598480085],[-1.8119729101643145,40.27655793855459],[-1.8087571228122101,40.276212586829075],[-1.804852911774958,40.27685292509017]]]
      }
   }
});

map.addLayer({
   id: 'test',
   type: 'fill',
   source: 'markers',
   interactive: true,
   paint: {
      'fill-color': '#12A5CC',
      'fill-opacity': 0.5
   }
});

Most helpful comment

That GeoJSON is invalid:

  • A "Feature" type must have a "properties" value.
  • The "coordinates" of "Polygon" geometry must be _closed_, having a final coordinate whose value is equal to the initial coordinate.

If you correct these issues, in particular the latter one, then you will observe the desired behavior.

All 2 comments

That GeoJSON is invalid:

  • A "Feature" type must have a "properties" value.
  • The "coordinates" of "Polygon" geometry must be _closed_, having a final coordinate whose value is equal to the initial coordinate.

If you correct these issues, in particular the latter one, then you will observe the desired behavior.

@jfirebaugh Thanks! It works!

Was this page helpful?
0 / 5 - 0 ratings