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.

`Circle.getBounds()` throws error

See original GitHub issue

This bug was already fixed in previous version https://github.com/Leaflet/Leaflet/issues/1068. But it occurs in new leaflet version.

Here is fiddle - https://jsfiddle.net/kecmw7ms/7/ Tested in Chrome Version 53, Firefox Version 47, Safari Version 10.0

Notes:

  • Adding circle to the map makes it work
  • Removing setView from map breaks it again

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
IvanSanchezcommented, Sep 30, 2016

so it also expected that getBounds throws error when view was not set on map

OK, that might be a bug. The calls to this._map.layerPointToLatLng() might be able to be changed into this._map.options.crs.project().

0reactions
ibesoracommented, Jun 19, 2022

Having found this bug recently and seeing there has been discussion about this since 2012 (https://github.com/Leaflet/Leaflet/issues/1068) without solving the issue, I’d like to propose the following:

  • Use the current implementation (which uses the map CRS) of Circle.getBounds() when the circle has been added to a map
  • Use the approximation found here by @mourner when the circle hasn’t yet been added to the map
  • Update the documentation to reflect this behaviour

Even if it’s not the optimal solution I think we can all agree that Circle.getBounds() crashing when it hasn’t been added to a map is less than ideal. Polyline, Polygon and FeatureGroups (that don’t contain Circles) do not exhibit this behaviour.

Related issues:

Read more comments on GitHub >

github_iconTop Results From Across the Web

leaflet - Error when using Circle getBounds() and contains()
Show activity on this post. I'm getting the error below when trying to run getBounds() and contains() with a Circle shape.
Read more >
Can Leaflet method .getBounds() be used on a layer to ...
I am currently getting a leaflet-src.js:1873 Uncaught TypeError: Cannot read property 'lat' of undefined error, but I think I am just doing ...
Read more >
Coordinates | Maps JavaScript API - Google Developers
These are automatically converted to LatLngBounds objects. All south , west , north and east must be set, otherwise an exception is thrown....
Read more >
Advanced geospatial analysis - Turf.js
Takes a Point and calculates the circle polygon given a radius in degrees, radians, ... Throws. Error - if geoJson is invalid. npm...
Read more >
javax.swing.JLabel.getBounds java code examples - Tabnine
draw a circle around the question mark Rectangle cc = new Rectangle(symbol. ... {@inheritDoc} */ @Override public Rectangle getBounds() { if (bounds ...
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