Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaflet Error: Invalid LatLng object: (, NaN)

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().

like image 573
JsonMraz Avatar asked Mar 09 '23 23:03

JsonMraz


2 Answers

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.

like image 113
JsonMraz Avatar answered Mar 19 '23 18:03

JsonMraz


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

like image 24
cdagli Avatar answered Mar 19 '23 17:03

cdagli