tags:

views:

163

answers:

1

Hi,

i want to set the center of a map in javascript. I can only find some code with Markers in it, but i want the client side code for this:

(this is server side code)

GMap1.setCenter(latlng, zoomLevel, mapType );

I would like to do this (it's non working code :-))

subgurim_GMap1.SetCenter(47.1, 2.3, 6)

where 47.1 and 2.3 are the lat/lng and 6 is the zoomlevel

Michel

+2  A: 

Try this:

map.setZoom(6);
var point = new GLatLng(26.228595038041917, 50.54535984992981);
map.setCenter(point);
karim79
wow, that was quick!Do you also happen to know how to get the current lat/lng and zoomlevel in javascript? Want to set a cookie with the current values, so they can go to that position later.
Michel
GMap1.getZoomLevel() or GMap2.getZoom()
karim79
and getCoordX() and getCoordY() to get the lat/long
karim79
To be even more concise, skip 'map.setZoom(6)' and just use this instead: map.setCenter(point,6);
Chris B