简体   繁体   中英

Leaflet marker popup extends past the map

I had to change the default size of the marker popup to accommodate the data I wanted to put in it. I changed some map settings so it always bounces back to a max bound when the user drags it out of view. The issue I have is that for markers close to the edge, when its popup opens, it is not fully visible, as in it hides behind the edges of the container for the map.

Q: What would be the fix to this? Can I get the popup to show the full content?

In this Leaflet tutorial they have an option to offset the popup anchor. You could do an if statement that if true would offset the popup anchor by enough to display properly on the screen.

Pseudo code:

if (latlng of point clicked < rightBounds of map) {
  popupOptions = {
    offset: (-popupwidth,0)
  }
} ...

You could also try experimenting with the various popup options in the API .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM