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.

Calling circle and then getDiameter causes an exception

See original GitHub issue

The 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:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bassenacommented, May 23, 2017

@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.

0reactions
perliedmancommented, Aug 16, 2016

@bassena can you specify more exactly what problem you’re running into? Ideally a runnable example to illustrate the problem.

Read more comments on GitHub >

github_iconTop 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 >

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