Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Api v3 - set map position in runtime

How can I change position of the map, from where it is pointing now, to ie. 45.00,19.00, but in a runtime, now when map is initialized?

my application have to "jump" from some coordinates to other, so that's why I need this ability.

like image 985
user198003 Avatar asked Oct 27 '10 06:10

user198003


People also ask

How do I change the position on Google Maps?

Change your home or work addressOpen Google Maps and make sure you're signed in. In the search box, type Home or Work . Next to the address you want to change, click Edit. Type in a new address, then click Save.

How do I center a Google map?

Please go to your map and drag and drop your map to the position you wish. You can also zoom in your map a little bit with mouse wheel or zoom cotrols on the bottom right corner of the map. Please remember to save your map after any changes. Hope that helps.


2 Answers

ok, here it is:

MyMap.map.setCenter(new google.maps.LatLng( 45, 19 ) );
like image 117
user198003 Avatar answered Oct 29 '22 07:10

user198003


Create that Map object, save it to a variable (i.e. map) and then use map.panTo(). See the reference of Map

like image 34
Martin Thurau Avatar answered Oct 29 '22 06:10

Martin Thurau