Zoom Google Map V3 API on all markers with JavaScript
Here a
little piece of JavaScript code to zoom in on the Google Maps V3 API on all
markers.
The data array in the example is a custom Javascript Array with Latitude / Longitude properties.
The data array in the example is a custom Javascript Array with Latitude / Longitude properties.
var latlngbounds = new google.maps.LatLngBounds(); for (var i = 0; i < data.length; i++) { var dataPoint = data[i]; latlngbounds.extend(new google.maps.LatLng(dataPoint.Latitude, dataPoint.Longitude)); } map.setCenter(latlngbounds.getCenter()); map.fitBounds(latlngbounds);
Comments