I am trying to create a circle with leaflet and I am getting this error:
Error: Invalid LatLng object: (50.5, NaN)
I am using this code in Angular 2 to create my circle:
L.circle([50.5, 30.5], {radius: 200}).addTo(map);
I don't know why but this code below is OK:
L.circleMarker([50.5, 30.5], {radius: 200}).addTo(map);
But I want to use L.circle()
function and not L.circleMarker()
.
Here is the solution:
I simply updated leaflet
from 0.7.7 to the most recent (1.0.3) in my package.json
and I ran npm install
.
Btw, this is happened because you probably used the documentation of v1.x.x. It is used as below for 0.7.7;
L.circle([50.5, 30.5], 200).addTo(map);
http://leafletjs.com/reference-0.7.7.html#circle
Error message is a little bit misleading; https://github.com/Leaflet/Leaflet/issues/4235
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With