Last active
March 19, 2022 21:18
-
-
Save nedSaf/9c19cb8662eb4ddc3cd8 to your computer and use it in GitHub Desktop.
Get center of a layer (GeoJson) in leaflet map.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assuming you are inside an event (Mouseover, Click). | |
// Layer comes from the event. | |
// Get the bounds of the layer to display the popup on the north-east bounds. | |
var bounds = layer.getBounds(); | |
var latLng = bounds.getCenter(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@pshassett I'm glad.
@ohoroyoi Sorry, I missed this, if I remember correctly, this scope was something to do with Angular, it should be just any variable.
I'll change it.