1

I have a full screen Google Map along with control divs overlaid on top.

-----------------------------------------------------
|         |                                         |
|         |                                         |
|         |             Map                         |
| Sidebar |                                         |
|         |                                         |
|         |                                         |
|         |=========================================|
|         |              Controls                   |
----------------------------------------------------|

The sidebar and controls at the bottom are able to slide in and out and there is usable map behind it. The problem is when I go to fit the bounds for a set of markers and center on the map, sometimes markers get put behind the sidebar and controls divs. I'm guessing because it is technically part of the map behind it.

Is there a way to have a full screen map but tell Google Maps that only part of the screen is considered "usable" for doing bounds and centering?

Brandon
  • 1,997
  • 3
  • 24
  • 33

1 Answers1

1

There is no built in way to achieve what you want. Youll have to implement that yourself. Here is a post which will aid in calculation the latlng distance to pixels: Google Maps API 3: Calculating length of polygon in pixels

Community
  • 1
  • 1
Th 00 mÄ s
  • 3,776
  • 1
  • 27
  • 46
  • So once I have my overlay, how would I make my markers fit in that area? – Brandon May 07 '13 at 14:49
  • 1
    Since you know how high and wide the area is which is hidden by your controls you can calculate an polygon which contains the visible space. Now you will have to move the polygon so your most top left marker is the top left of the polygon . Now you have to check if all points are contained in the polygon . If they do, move the center of the map. If not you need to decrease the zoom level and try the previous again. See https://github.com/tparkin/Google-Maps-Point-in-Polygon to check if points are in polygon. – Th 00 mÄ s May 09 '13 at 12:03