question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

L.Map.fitBounds() with invalid bounds error message could be better

See original GitHub issue

Uncaught TypeError: Cannot read property 'lat' of undefinedo.LatLngBounds.getNorth @ leaflet.js:6o.LatLngBounds.getNorthWest @ leaflet.js:6o.Map.o.Class.extend.getBoundsZoom @ leaflet.js:6o.Map.o.Class.extend.fitBounds @ leaflet.js:6wikibase.queryService.ui.resultBrowser.CoordinateResultBrowser.SELF.draw @ CoordinateResultBrowser.js:64(anonymous function) @ App.js:411

http://tinyurl.com/jbxrwlv

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ghybscommented, Jun 15, 2017

Hi,

It is true that it is strange to perform a sanity check (introduced by PR https://github.com/Leaflet/Leaflet/pull/4353) before _getBoundsCenterZoom, which does its own conversion to LatLngBounds and even accepts an object with getBounds method (e.g. a Feature Group, an Image Overlay, a Polyline / Polygon / Rectangle, or a Circle), even though this is not documented in the public API.

The preceding conversion to LatLngBounds (introduced by PR https://github.com/Leaflet/Leaflet/pull/4375) is similarly strange, since it duplicates this conversion, while being less permissive.

Finally, flyToBounds also makes use of _getBoundsCenterZoom but does not implement those 2 modifications, which is inconsistent.

Therefore it seems to me that if this were to be changed, it would be more consistent to implement the sanity check directly within _getBoundsCenterZoom, so that all public methods that use it can benefit, and it also avoids the double / less permissive conversion.

That being said, I do not see how any of this code can work with an array of markers. Were you referring to a Feature Group?

0reactions
andrzej-wislacommented, Jul 13, 2019

Uncaught Error: fitBounds: latLngBounds must be of type LatLngBounds. What does it means ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet map won't fit bounds - Stack Overflow
I keep getting the error Error: Bounds are not valid. leaflet.js:5:21909 even though the markers are added to the map and are valid...
Read more >
L.geoJson() - Error: Bounds are not valid - GIS Stack Exchange
With every iteration, on success, I pass to L.geojson(). After the last iteration I call map.fitBounds(jsonLayer). Then this error: ...Uncaught ...
Read more >
Maps JavaScript API | Google Developers
The bounds will be fit in the part of the map that remains after padding is removed. A number value will yield the...
Read more >
Leaflet API reference - Data Online BMKG
A value of 0 means the zoom level will not be snapped after fitBounds or a pinch-zoom. ... L.Marker is used to display...
Read more >
L.Map - WRLD3D
A value of 0 means the zoom level will not be snapped after fitBounds or a ... zoom level will change after a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found