Calling circle and then getDiameter causes an exception
See original GitHub issueThe following code breaks in In 1.0.0-rc1 (was working in the latest stable version):
var circle = L.circle([-37.814, 144.963], 10000); circle.getBounds();
This throws an exception: Uncaught TypeError: Cannot read property 'layerPointToLatLng' of undefined
The getBounds function is defined as:
getBounds: function () {
var half = [this._radius, this._radiusY || this._radius];
return new L.LatLngBounds(
this._map.layerPointToLatLng(this._point.subtract(half)),
this._map.layerPointToLatLng(this._point.add(half)));
},
this._map
is undefined here because the circle hasn’t been added to the map.
Looking at the source for 0.7.7, the code is as follows (with no reference to this._map
):
getBounds: function () {
var lngRadius = this._getLngRadius(),
latRadius = (this._mRadius / 40075017) * 360,
latlng = this._latlng;
return new L.LatLngBounds(
[latlng.lat - latRadius, latlng.lng - lngRadius],
[latlng.lat + latRadius, latlng.lng + lngRadius]);
},
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
c# - Circle set and get - Stack Overflow
In your constructor you are changing value of your public field not the property so your setter method is never executed.
Read more >Processing - Chapter 10 - Lab - Calvin Computer Science
The Circle class maintains the integrity of each circle object, throwing exceptions when problems are found; the calling program deals with the exceptions...
Read more >Lecture Notes Chapter #9_b Inheritance & Polymorphism
System.out.println(“The circle is created “ + getDateCreated( ) + ... invoking a superclass constructor name in a subclass causes a syntax error.
Read more >Module 1 Flashcards - Quizlet
Study with Quizlet and memorize flashcards containing terms like What shell command would you use to display the path of the current working...
Read more >Solved Pages 1003, 1004, and 1005 - Rectangle (Version 3)
This will require creating a NegativeRadius class in the Circle class as shown on ... If the radius is negative then throws an...
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
@perliedman , sorry for the very belated reply. In coming up with a JSFiddle for you, I happened to pinpoint my issue. It related to not having called
setView()
initially on my map object. Go figure. We’ve been using an older version of leaflet (which we did not have this issue before), but now after updating the library this issue came about.@bassena can you specify more exactly what problem you’re running into? Ideally a runnable example to illustrate the problem.