Ben Ben - 1 year ago 105
CoffeeScript Question

Is there a way to ensure an open popup is within the view after doing fitbounds

So I have too points:
a = fixed location, with open popup "Destination"
b = user's current location, no popup

I know I can easily call (conceptually)

map.fitbound([latlng of a, latlng of b])

and that will zoom my map to contain the two points, the trouble is that it doesn't account for the open popup. As I have no idea of the user's location, direction from the fix point, or distance, I don't think that using padding possible.

Any hints on how to solve this?

Here's a fiddle that demonstrates the issue.

I've looked at couple of the posts about centering popups, but the javascript there is slightly about me, and the js2coffee converter doesn't like it.

Answer Source

You can explore a solution where popups are always visible without having to move the map.

For example:

Here is how I use it:

Move the map to have a marker near an edge, hover or click on it, the popup is always visible.

popup above popup right popup below

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download