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

ibrahimsaricicek ibrahimsaricicek at gmail.com
Fri Dec 25 07:39:54 EST 2009


Hi all,,

I have a similar problem;

map.setCenter(userExtentCenterLonLat,userExtentZoom, false, true);

On Google It shows the whole world, but it should be a placemark in Turkey.
A zoom in and out solves the problem.

But if the basemap is wms (Mapserver) there is no problem, sets the center
where we want...
Any commend??


Steve.Toutant wrote:
> 
> 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
>  
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> 

-- 
View this message in context: http://n2.nabble.com/problem-with-map-setCenter-and-zoom-tp3264159p4215879.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list