tags:

views:

730

answers:

4

Hi, I have two maps on a page, one is a map of the world, and the other is a closeup of the current place they picked on the map of the world. I would like to set different zoom min/max levels for each map but:

G_NORMAL_MAP.getMinimumResolution = function(){return 11};

Seems to set the same min/max for both maps, I can't set them to different levels.

A: 

Do you need 2 different maps? You can use the Map2.showMapBlowup() function to show a subarea which will be a zoomed in section on the current map.

I'm sorry I don't know if you can actually do it with 2 different maps.

http://code.google.com/apis/maps/documentation/reference.html#GMap2.showMapBlowup

Alex
Yeah we need to maps. Essentially we have one grid that we draw some overlays on, and if you zoom out too much there is far too many overlays. So we made a smaller world map with no overlays so that you could quickly navigate to another point and the 'details' map would show you that area with the overlays.
Codezy
A: 

You could use a custom map type and copy the G_NORMAL_MAP members of using a library like Prototype.

var G_MY_MAP = Class.create(G_NORMAL_MAP, {
    getMinimumResolution: function()
    {
     return 11;
    }
});

Then on your second map:

secondMap.addMapType(G_MY_MAP); 
secondMap.setMapType(G_MY_MAP);

No idea if this will work, just a brain storm.....

Steve Echols
+1  A: 

I think the problem is probably elsewhere in your code - I'm not sure exactly how you're using that function.

Here is a method that will work. You can re-write it to have less duplication.

map1 = new GMap2(document.getElementById("map1"));
map1.addControl(new GLargeMapControl3D());
map1.addControl(new GMenuMapTypeControl());

var mt = map1.getMapTypes();
// Overwrite the getMinimumResolution() and getMaximumResolution() methods
for (var i=0; i<mt.length; i++) {
    mt[i].getMinimumResolution = function() {return 7;}
    mt[i].getMaximumResolution = function() {return 11;}
}
map1.setCenter(new GLatLng(40,-100), 8);    


map2 = new GMap2(document.getElementById("map2"));
map2.addControl(new GLargeMapControl3D());
map2.addControl(new GMenuMapTypeControl());

var mt = map2.getMapTypes();
// Overwrite the getMinimumResolution() and getMaximumResolution() methods
for (var i=0; i<mt.length; i++) {
    mt[i].getMinimumResolution = function() {return 2;}
    mt[i].getMaximumResolution = function() {return 6;}
}

map2.setCenter(new GLatLng(40,-100), 4);
Chris B
A: 

the answer suggested by Chris B did not work for two maps on a same page with same map type having different zoom properties.

Any other solution??

Kelaiya K