I'm displaying a custom layer on top of the standard google map (v3). Now the users can pan out of the extents of my custom layer.
Is it possible to constrain the viewable area to a square given by the top-left and bottom right coordinates?
I'm displaying a custom layer on top of the standard google map (v3). Now the users can pan out of the extents of my custom layer.
Is it possible to constrain the viewable area to a square given by the top-left and bottom right coordinates?
What you could do is prevent the user being able to pan the map at all. Set draggable:false
in the mapOptions, and perhaps remove the pan control as well - panControl:false
Another idea; you could allow the user to drag/pan the map, but then if they move it outwith your bounds, you could call the panToBounds
function on the map to move it back to where you want it.