The OpenLayers overview map control works great when I use standard options. I would like to limit the overview to one resolution, but I can't seem to find the right combination of values for the properties and mapOptions. Is there a way to force the overview map to stay at a single zoom level?
The example code below uses the "numZoomLevels : 1" option, but this has no effect.
function init() {
// start with a browser check. If it's IE6, transparent png's are not supported
var ua = $j.browser;
if(ua.msie && ua.version.slice(0, 1) == "6") {
var imgtype = 'image/gif';
} else {
var imgtype = 'image/png';
}
// Define a projection for the map
var proj = new OpenLayers.Projection("EPSG:4326");
// Define the map options and start with an empty control set
var mapOptions = {
controls: [],
projection : new OpenLayers.Projection("EPSG:900913"),
displayProjection : proj,
units : "m",
numZoomLevels : 20
};
// Create the map object
var map = new OpenLayers.Map('map', mapOptions);
// Define the overview map options
var overviewOptions = {
size : new OpenLayers.Size(300, 200),
maximized : true,
minRectSize : 0,
autoPan : true,
mapOptions : {
projection : new OpenLayers.Projection("EPSG:900913"),
displayProjection : proj,
units : "m",
resolutions : [90],
numZoomLevels : 1 // this has no effect, the ov map still zooms in and out with the map
}
};
// Add controls to the map
map.addControl(new OpenLayers.Control.OverviewMap(overviewOptions));
map.addControl(new OpenLayers.Control.Navigation());
map.addControl(new OpenLayers.Control.PanZoomBar({panIcons : false}));
map.addControl(new OpenLayers.Control.ScaleLine());
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.Scale($('scale')));
map.addControl(new OpenLayers.Control.MousePosition({
element : $('location')
}));
// Add layers
var gmap = new OpenLayers.Layer.Google("Google Streets", {
numZoomLevels : 20
});
map.addLayers([gmap]);
// Start the map at a particular point
var point = new OpenLayers.LonLat(-118, 34);
point.transform(proj, map.getProjectionObject());
map.setCenter(point, 16);
}; // Ends the init()
Answer
Try commenting out the resolutions
attribute in the mapOptions
object. I created an example based off your code (with some changes, I had trouble getting the Google layer to work, so I subbed in the http://osgeo.org/ world layer) and when I get rid of the resolutions
attribute, the overview map works as intended.
No comments:
Post a Comment