Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an OpenLayers project that is using Google Maps for the base layer. Maybe I'm going about this the wrong way, but I think what I'm trying to do is pretty simple. I just need to set the minimum zoom level of a Google map dynamically based on a given bounding box.

This document describes how to set zoom levels, but it seems that for 3rd party layers like Gmaps, you can't use the minExtent/maxExtent features (this would be ideal).

Also, is there a way to figure out which Google zoom level corresponds to a given bounding box before the map is initialized?

I tried:


... but this throws an exception if called before the map is initialized. I can call it after the map is initialized, but then there seems to be no way to set the minZoomLevel on the Gmap without completely borking the zoom consistency between layers and ending up with something like this (where there is clearly no zoom consistency between layers):

See a jsfiddle example here

enter image description here

share|improve this question
do you have a live link? think the projection/transform needs to be set. like – Mapperz Mar 14 '13 at 14:15
probably this could help:… 1. get the current bounding box 2. access to the google map layer, set it's min zoom level please do let me know if i'm wrong, just trying to help. ;) – nasrulhazim Mar 15 '13 at 3:00
Mapperz, I added a jsfiddle example of what I'm talking about. As soon as you zoom in or out on the map, the zoom consistency between layers is off. – Joel Mar 15 '13 at 17:38
nasrulhazim, This is exactly what I tried and it is causing the zoom level inconsistency between layers. Check out the jsfiddle example I added to the problem description: – Joel Mar 15 '13 at 17:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.