Popup on GeoJSON polygon is not centered on the polygon center but on its border
See original GitHub issueThe layers are created with L.geoJson
. On each feature, a popup is binded : layer.bindPopup(popup_string)
. When layer.openPopup()
is called, the popup is open but centered on the border of the polygon (in the middle of the line).
I didn’t understand how the position of the popup is computed for this case. If you explain it to me I can try to create a patch.
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
tooltip's aren't "centered" despite direction: center being set
If I can get this working I'll hide the marker by doing {opacity: 0} but if I do that now it'll look off...
Read more >Leaflet: popup showing information on the polygon [closed]
I have a Leaflet map. To the map I load two JavaScript files (A.js & B.js) which both consist of only polygons. Now...
Read more >Chapter 8 Symbology and Interactivity | Introduction to Web ...
In the first CSS rule, we set properties for the legend as a whole, referring to .legend . We are setting padding, background...
Read more >Documentation - a JavaScript library for interactive maps
initialize the map on the "map" div with a given center and zoom var map ... Returns a GeoJSON representation of the polygon...
Read more >Chapter 8 Symbology and Interactivity | Introduction to Web ...
This sets the default Leaflet style for all polygons—blue border and ... just use the text-align property (Section 2.8.3.4) to make the popup...
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
@marcu it’s the way popup works on polygon in the stable version, but it has been improved in master version — now proper polygon center is calculated.
https://github.com/Leaflet/Leaflet/blob/master/src/layer/vector/Polygon.js#L11-30