How to draw a rectangle on a Leaflet map from GeoJSON data

المشرف العام

Administrator
طاقم الإدارة
I am trying to draw a rectangle on a Leaflet map with JSON data which looks like this.

var geojsonfeatures = {"type":"FeatureCollection","features":[ {"type":"Feature", "geometry":{"type":"Polygon", "coordinates":"[[354,844],[425,933]]"}, "properties":{"name":"area1"} } ]};The coordinates need to be transformed which if it was a Point could be done like this:

coordsToLatLng: function (newcoords) { return (map.unproject([newcoords[0], newcoords[1]], map.getMaxZoom())); }I am lost as to how to do this for an array of Points. coordsToLatLngs look like it would be the right one but not sure how to use it. Or is it geometryToLayer?



أكثر...
 
أعلى