Opening PopupBox brings "invalid LatLng object (NaN, 11.3850302945) in LatLng.js:32
See original GitHub issueOpening a popup box which is bound to an marker show the following error:
LatLng.js:32 Uncaught Error: Invalid LatLng object: (NaN, 11.385030294575534)
at new LatLng (LatLng.js:32:9)
at Object.unproject (Projection.SphericalMercator.js:35:10)
at Object.pointToLatLng (CRS.js:41:26)
at NewClass.unproject (Map.js:987:27)
at NewClass.panInside (Map.js:536:20)
at NewClass._panOnFocus (Marker.js:397:7)
at HTMLDivElement.handler (DomEvent.js:108:13)
LatLng @ LatLng.js:32
unproject @ Projection.SphericalMercator.js:35
pointToLatLng @ CRS.js:41
unproject @ Map.js:987
panInside @ Map.js:536
_panOnFocus @ Marker.js:397
handler @ DomEvent.js:108
First, this behaviour is new since Leaflet 1.8.0 and second in the whole data there is no such longitude " 11.385030294575534". I think this is somewhere calculated. With Leaflet 1.7.1 I don’t get this error.
Environment
- Leaflet version: 1.8.0
- Browser (with version): Chromium 99.0.4844.84 / FireFox 99.0
- OS/Platform (with version): Ubuntu 18.04 (64-Bit)
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
leaflet.js: Uncaught Error: Invalid LatLng object: (NaN, NaN)
I'm using Leaflet library to mark the coordinates in Google maps using node js and mongo db. My map.pug file is extends layout.pug...
Read more >Uncaught Error: Invalid LatLng object: (NaN, NaN)
Hi! first thanks for the plugin. I have a error clicking the tabs, the error is: Uncaught Error: Invalid LatLng object: (NaN, NaN)...
Read more >Map is panned to show markers when they're focused #8042
So maybe the logic has to check if there's a popup bound and open, grab its size, ... Opening PopupBox brings "invalid LatLng...
Read more >T269376 Error: Invalid LatLng object: (NaN, NaN)
Invalid LatLng object sounds like an error from the Leaflet.js library (which is used by Kartographer to produce interactive maps). I thought this...
Read more >Opening PopupBox brings "invalid LatLng object (NaN ...
Opening PopupBox brings "invalid LatLng object (NaN, 11.3850302945) in LatLng.js:32 #8162. Opening a popup box which is bound to an marker show the ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@juedan Thanks! That certainly clarifies things.
However, I’ll close this bug as “user not following the API reference”. The
iconSize
option is supposed to be aL.Point
, or an array of two numbers (and it should be obvious that the"auto"
string is not a number). The fact that this way of defining icon sizes work at all is a chain of coincidences:L.Point
is not enforcing any strict type checksHTMLImageElement
at …https://github.com/Leaflet/Leaflet/blob/da386bec18d2e103acb207e97cf332bd388bb575/src/layer/marker/Icon.js#L145
…, the “sum” of
"auto" + "px"
is calculated as"autopx"
(because that’s how ECMAscript works);"autopx"
for the CSS property “height”, the browser silently ignores that invalid value, and sets the CSS property “height” to a value of""
HTMLImageElement
to the DOM with an empty value for the height, its height is calculated from the intrinsic image heightAll things considered, I think the bug is invalid because it relies on passing values contrary to what’s specified in the API documentation. Fetching the icon size from the intrinsic image dimensions is a possibility but is (a) out of the scope of this bug and (b) a potential source of asynchronous hell.
As a side note: You just provided a reproducible use case, and I replied deciding that the bug is invalid… and maybe that makes you feel bad, or you feel that you wasted time on that reproducible use case. But: Please don’t! These things are informative, and clarifying, and overall good, and I do appreciate it!
As promised here an link for the test code: https://juedan.nerdcamp.net/Test/test_leaflet.html If the iconSize is set to
[<pixel number>, "auto"]
then an error is thrown. But with Leaflet 1.7.1 this works without any issues.