How to use fitBounds of GMaps.js
bounds, dictionary, gmaps.js, google-maps
Solution
I didn't find the solution obvious, but, here is an example that works with v0.4.11:
var latlngs = [{lat:"39.158542", lng:"-84.423903"}, {lat:"39.4339357", lng:"-84.9850474"}];
var bounds = [];
for (var i in latlngs) {
var latlng = new google.maps.LatLng(latlngs[i].lat, latlngs[i].lng);
bounds.push(latlng);
map.addMarker({
lat: latlngs[i].lat,
lng: latlngs[i].lng
});
}
map.fitLatLngBounds(bounds);
Problem
I am using GMaps.js and I have several points to show, I need to show all and set the zoom to the point, I was watching the documentation and requests an array of google.maps.LatLng type. I have the following code ``` for (x in geo){ var item = new google.maps.LatLng(geo[x]["latitud"], geo[x]["longitud"]); arrayBound.push(item); } map = new GMaps({ div: '#divMapa', lat: latWS, lng: lngWS, zoom: 13 }); map.fitBounds(arrayBound); ```