Google Maps Api v3 - set map position in runtime

Viewed 38693

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.

4 Answers
  1. Define the place where to position
  2. Pass that to map.setCenter()
var map;

function initMap() {

    var container = document.getElementById('map');
    var options = {
        zoom: 18,
        gestureHandling: 'cooperative',
        mapTypeId: google.maps.MapTypeId.ROADMAP
    }

    map = new google.maps.Map(container, options);

    var myPlace = { lat: 23.7266, lng: 90.4216 };
    map.setCenter(myPlace);
}
Related