Leaflet has a method built into the polyline class to return an array of all LatLng coordinates of the line. It would look something like:
var latlngArray = polyline.getLatLngs();
Esri-leaflet, the Esri plugin that allows for interaction with ArcGIS Online and ArcGIS REST services has a separate class--Layer--that, it seems, it uses for all hosted feature types--points, lines, polygons, etc. Used in Esri-leaflet, it's constructed with L.esri.featureLayer.
I'm essentially trying to take the latitude and longitude of the feature vertices and perform a custom transformation on them point by point before placing them on the map without altering their values on the server. By using the pointToLayer option I've been able to retrieve and manipulate the latlng values for points. This would be fairly simple if I could call .getLatLngs()
on the feature layer.
Is there a way I can do something similar with a polyline?
L.geoJson
objects, so you should be able to access the coordinates using each feature's.geometry.coordinates
. See this answer, for example. Though it may require some reformatting of the nested arrays to get what you want, and I haven't checked it fully, here is an example based on one of the examples from the esri.featurelayer site: fiddle.jshell.net/nathansnider/8k7tLsf7