[OpenLayers-Users] OverviewMap map based on tiles?

Michael Katz michaeladamkatz at yahoo.com
Fri Oct 21 21:29:05 EDT 2011


I am using OpenLayers 2.11. 

I'm trying to understand if OverviewMap control works when its internal map is a tile-based map, such as Google Streets. 

So if I have: 


function init()
{ var maxExtent = new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508), restrictedExtent = maxExtent.clone(), maxResolution = 156543.0339; var overviewLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} ); /* var overviewLayer = new OpenLayers.Layer.Google( "Google Streets", { sphericalMercator: true } ); */ var overviewOptions = { layers: [ overviewLayer.clone() ], minRatio: 8, maxRatio: 128 }; var options = { projection: new OpenLayers.Projection( "EPSG:900913" ), displayProjection: new OpenLayers.Projection( "EPSG:4326" ), units: "m", numZoomLevels: 19, controls: [ // new OpenLayers.Control.Navigation(), new OpenLayers.Control.PanZoomBar( { "panIcons" : false } ), new OpenLayers.Control.LayerSwitcher(), // { "ascending" : false }  new OpenLayers.Control.ScaleLine(), new OpenLayers.Control.OverviewMap( overviewOptions ), new OpenLayers.Control.KeyboardDefaults() ], maxResolution:
 maxResolution, maxExtent: maxExtent, restrictedExtent: restrictedExtent }; map = new OpenLayers.Map('map', options); 
that works. But if I change the top lines to 


/* var overviewLayer = new OpenLayers.Layer.WMS( "OpenLayers WMS", "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} ); */ var overviewLayer = new OpenLayers.Layer.Google( "Google Streets", { sphericalMercator: true } ); 
what I get in the overview image is a just part of a tile: I 
can only see the the lower part of Africa, Australia, and a bit of 
Antarctica. When I then pan and zoom in the main map, the red rectangle 
in the overview map sort of tries to follow me around, but it's 
confused. It keeps that one fixed partial tile in view, so for instance 
when I zoom into the United States the overview map's red rectangle 
shows me somewhere in lower Africa. 

I don't know if there's something else I need to do to make a tile-based map work as the overview map? 

If I were get that working, a secondary question I have is how I
 can change the overview map's layer dynamically. For instance, if my 
application lets the user switch between Google Roads and Yahoo Roads in
 the main view, can I make the overview map follow suit? Would I want to
 create the overview maps with all layers that might be required, and 
force it to switch layers when I detect that the user has changed the 
main map's basemap? Or would it be better just to destroy and recreate 
the overview map control at that time? 

Thanks for any help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111021/6677acd5/attachment.html


More information about the Users mailing list