[OpenLayers-Users] problem with map.setCenter and zoom

Steve.Toutant at inspq.qc.ca Steve.Toutant at inspq.qc.ca
Wed Jul 15 12:06:10 EDT 2009


Hello,
My app uses google Map as a baseMap. On some computers (not clear yet if 
it is the browser version or computer...) my app loads with Google MAp 
zoomed at his max resolution (zoom=19 in this case). Sometimes it loads at 
zoom = 2 as specified.
Perhaps there is something wrong on the way I create the map. Here is the 
code I use. Is it the appropriate way to do it?
Thank you for your help,
Steve

var mapOptions = 
{
        projection: "EPSG:900913",
        displayProjection: new OpenLayers.Projection("EPSG:4326"), //Pour 
afficher les coord lat long
                units: "m",
        maxExtent: new OpenLayers.Bounds(-9239517, 5465442, -5565974, 
9349764),
        maxResolution: "auto",
        controls: [],
        numZoomLevels: 20
};
map = new OpenLayers.Map('mapDiv', mapOptions);

// create Google Mercator layers
var googleM = new OpenLayers.Layer.Google( "Google Map", { minZoomLevel: 
5, type: G_NORMAL_MAP, 'sphericalMercator': true} );
//Empty baseMap
var aucunContexte = new OpenLayers.Layer("AucunContexte",{isBaseLayer: 
true});
 
map.addLayers([aucunContexte, googleM]);

var myzoom = 2; //Means zoom = 7 since minzoomlevel = 5
var lonCenter = -73.696289;
var latCenter = 47.606163;

point = new OpenLayers.Geometry.Point(lonCenter, latCenter); 
OpenLayers.Projection.transform(point, map.displayProjection, 
map.getProjectionObject()); 
map.setCenter(new OpenLayers.LonLat(point.x, point.y), myzoom);


Steve Toutant, M. Sc.
Analyste en géomatique
Secteur environnement
Direction des risques biologiques, environnementaux et occupationnels
Institut national de santé publique du Québec
945, avenue Wolfe
Québec, Qc G1V 5B3 
Tél.: (418) 650-5115 #5281
Fax.: (418) 654-3144
steve.toutant at inspq.qc.ca
http://www.inspq.qc.ca
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090715/cabaf704/attachment.html


More information about the Users mailing list