How to calculate infoBoxClearance correctly?

1,310 views
Skip to first unread message

RidderGraniet

unread,
Feb 22, 2012, 6:52:32 PM2/22/12
to google-maps-uti...@googlegroups.com
Given the following demo website: http://labs.shifthappens.nl/vagabond/pilot/ . How do I make sure that the infoboxes that are opened, are always panned next to the sidebar element with all the widgets?

I already calculate the distance between the edge of the map and the X offset of the sidebar element + 20px. That is the amount of pixels the infobox needs to move to the left, coming from the right. However, InfoBox does this clearance also on the left side of the map, so when you click the same, open marker again, the map pans some pixels to the other direction again because there is not enough room on the left side of the infobox.

How do I stop the infobox from bouncing the panning from left to right on every click? I have to somehow prevent the infobox to fall behind the sidebar and at the same time make sure there is enough distance between an infobox and the left side of the map when a marker is opened there, too.

I've been trying to wrap my head around this one for quite some time now, please can someone help?

RidderGraniet

unread,
Feb 22, 2012, 9:08:35 PM2/22/12
to google-maps-uti...@googlegroups.com
OK I got a temporary solution to the problem: I have a placeholder div (invisible) that grows with the page (a content div about 650px wide left next to the sidebar). I subtract the pixel position of the marker clicked by the x offset of this placeholder and set that as the offset that the map needs to pan.

Might be the only good solution so far?
Reply all
Reply to author
Forward
0 new messages