is it possible to limit Google map v3 to a certain area? I want to allow displaying only some area (e.g. a country) and disallow the user to slide elsewhere. Also I want to restrict the zoom level – e.g. only between levels 6 and 9. And I want to use all the base map types.
Is there any way to achieve this?
I had a partial success with limiting zoom level by using StyledMap, but I succeeded only with restricting ROADMAP, I wasn’t able to limit zoom on other basic types this way.
Thanks for any help
You can listen to the
dragendevent, and if the map is dragged outside the allowed bounds, move it back inside. You can define your allowed bounds in aLatLngBoundsobject and then use thecontains()method to check if the new lat/lng center is within the bounds.You can also limit the zoom level very easily.
Consider the following example: Fiddle Demo
Screenshot from the above example. The user will not be able to drag further south or far east in this case: