[OpenLayers-Users] zoomToExtent not working
Toni Martínez
tmartinh at gmail.com
Fri Sep 30 06:18:04 EDT 2011
Hi all,
I have been trying for a long time to accomplish something which should be
simple but it seems today it's not my day.
I just want to zoom my map to a BBOX value that I am getting from Postgis in
order to present a certain feature so I am using map.zoomToExtent(new
OpenLayers.Bounds(533052, 22268, 533052, 22268)); in the following way but
no zoom is being made.. map is being displayed at its maxim extent as
defined.. does anyone have a clue?
Thanks!
function makeMap() {
var maximExtent = new OpenLayers.Bounds(521500,15000,556500,40000);
//andorra
var resolutions =
[68.359375,34.1796875,17.08984375,8.544921875,4.2724609375,2.13623046875,1.068115234375];
var genericMapOptions = {
maxExtent: new OpenLayers.Bounds(521500, 15000, 556500, 40000),
maxResolution: 'auto',
units: 'meters',
projection: 'EPSG:27573'
}
var overviewMapSize = new OpenLayers.Size(128, 123);
var url = "http://xxxxx/tilecache.py?";
var urlNoCache = "http://xxxxxx";
var geoLayers = ['corbes_5', 'corbes_25', 'corbes_100',
'carreteres', 'rius', 'limit_pais', 'edificis']
var orto_andorra = new OpenLayers.Layer.WMS("Ortofoto", "
http://www.ideandorra.ad/wmsorto2003/request.aspx?", {layers:
"masaic_5m"},{isBaseLayer: true, resolutions: resolutions,
transitionEffect:'resize'} )
var molleres = new OpenLayers.Layer.WMS("molleres", urlNoCache,
{layers: "molleres",transparent:"true"},{resolutions: resolutions,
transitionEffect:'resize'} )
var geografia = new OpenLayers.Layer.WMS("geografia", urlNoCache,
{layers: geoLayers,transparent:"true"},{resolutions: resolutions,
transitionEffect:'resize'} )
var layers = [orto_andorra,molleres,geografia];
var mapControls = [
new OpenLayers.Control.Navigation(),
new OpenLayers.Control.PanZoomBar(),
new OpenLayers.Control.MousePosition()
];
var mapOptions = OpenLayers.Util.extend({
resolutions: resolutions,
controls: mapControls,
restrictedExtent: maximExtent
}, genericMapOptions);
map = new OpenLayers.Map("mapa", mapOptions);
map.addLayers(layers);
map.zoomToExtent(new OpenLayers.Bounds(533052, 22268, 533052, 22268));
return map;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110930/c884f7a1/attachment.html
More information about the Users
mailing list