I use the following code to set markers on my map:
var latLngs = []
$.each(locations.markers, function(i, m){
var myLatLng = new google.maps.LatLng(m.latitude, m.longitude);
latLngs[i] = myLatLng
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
shadow: shadow,
icon: image,
shape: shape,
title: m.city,
zIndex: i
});
})
the markers show up on my map. now i would like to center & zoom the map on these markers. How can i accomplish that? I have tried:
map.fitBounds(getBoundsForLatLngs(latLngs));
the console.log of latLngs gives out:
[(46.793182, 7.146903) { b=46.793182, more...}, (46.8077779, 7.1709386) { b=46.8077779, more...}]
But it seams not work and i get no error in the console. What i am doing wrong?