I am trying to get latlang of a marker so I can use it and fly to later.
map.flyTo(myLayer.getLatLng() ,16);
But why do I get getLatLng() not a function?
leaflet
I am trying to get latlang of a marker so I can use it and fly to later.
map.flyTo(myLayer.getLatLng() ,16);
But why do I get getLatLng() not a function?
Best Answer
getLatLng()
is not a method ofL.geoJSON
. As far as I can see you have three options (in the order of what I would do):1. Directly access the coordinates of the
geojsonFeature
:2. Use the
getBounds()
method:3. Fly to the circle marker at (actually before) creation:
PS.: Your codepen example has a typo:
getLatLang()
should begetLatLng()
.Edit: Include @til_b's hint on
LatLngBounds
getCenter()
.