JasonSanford / leaflet-vector-layers

A little help to viewing ArcGIS Server, Geocommons, Arc2Earth, CartoDB, GIS Cloud, etc. vector data in a Leaflet map
http://jasonsanford.github.io/leaflet-vector-layers
BSD 2-Clause "Simplified" License
216 stars 61 forks source link

EsriJSONLayer incorrectly calls "x" and "y" properties of "points" array in MultiPoint Geometry return #51

Open jonfrench opened 11 years ago

jonfrench commented 11 years ago

Hello. Thank you for the great Plugin.

In src/layer/EsriJSONLayer.js:24 of the v1.4 release, the plugin invokes the "x" and "y" properties on the values of the geometry.points array. Although single point Geometries returned from the ArcGIS web service do have these two properties, MultiPoints do not and cause "undefined" to be passed to L.LatLng.

See the 9.3 ESRI documentation showing the structure of the "points" array. The structure is the same for 10.x too:

http://resources.esri.com/help/9.3/arcgisserver/apis/rest/geometry.html (scroll down to "Multipoint")

The fix is:

for (var i = 0, len = geometry.points.length; i < len; i++) {
     var point = geometry.points[i];
     vectors.push(new L.Marker(new L.LatLng(point[1], point[0]), opts));
}