Automatic centering of Google maps on points : <p>I have this code:</p>

<pre><code>&lt;script src="https://maps.googleapis.com/maps/api/js?sensor=false"&gt;&lt;/script&gt;

&lt;style&gt;
#map_canvas {
    border:1px solid transparent;
    height: 400px;
    width: 100%;
}
&lt;/style&gt;

&lt;div class="col-xs-12 col-sm-12 col-md-12 col-lg-6 padding_all_right_4"&gt;
&lt;div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding_all_3"&gt;
   &lt;h2 class="h2"&gt;Atrakcje w okolicy&lt;/h2&gt;
&lt;/div&gt;
&lt;div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding_all_2"&gt;
   &lt;a href ="#" class="obj-1" id="obj-1"&gt;
      &lt;div class="apartament_atrakcje"&gt;Atrakcja 1 pl&lt;/div&gt;
   &lt;/a&gt;
&lt;/div&gt;
&lt;div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding_all_2"&gt;
   &lt;a href ="#" class="obj-2" id="obj-2"&gt;
      &lt;div class="apartament_atrakcje"&gt;Atrakcja 2 PL&lt;/div&gt;
   &lt;/a&gt;
&lt;/div&gt;
&lt;div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding_all_0"&gt;
&lt;div class="apartament_mapa"&gt;
&lt;div id="map_canvas"&gt;&lt;/div&gt;
&lt;script&gt;
   var locations = [
                                               ['Atrakcja 1 pl', 51.73925413, 19.51309225, 1],
                                               ['Atrakcja 2 PL', 53.41475000, 14.60220358, 2],
                                           ];
   var map;
   var markers = [];

   function init(){
       map = new google.maps.Map(document.getElementById('map_canvas'), {
           zoom: 10,
           center: new google.maps.LatLng(-33.92, 151.25),
           mapTypeId: google.maps.MapTypeId.ROADMAP
       });

       var num_markers = locations.length;
       for (var i = 0; i &lt; num_markers; i++) {
           markers[i] = new google.maps.Marker({
               position: {lat:locations[i][1], lng:locations[i][2]},
               map: map,
               html: locations[i][0],
               id: i,
           });

           google.maps.event.addListener(markers[i], 'click', function(){
               var infowindow = new google.maps.InfoWindow({
                   id: this.id,
                   content:this.html,
                   position:this.getPosition()
               });
               google.maps.event.addListenerOnce(infowindow, 'closeclick', function(){
                   markers[this.id].setVisible(true);
               });
               this.setVisible(false);
               infowindow.open(map);
           });
       }
   }

   init();

&lt;/script&gt;
</code></pre>

<p>The script displays 2 points on the google map.
I have a problem with centering the map on these points. Currently, I enter the coordinates of the centering of the map in the page code, however points on the map are added from the CMS and must center automatically :(</p>

<p>Does anyone know how to do it?</p>
