jQuery-gMap
jQuery-gMap copied to clipboard
Zoom to fit (all markers)
Is there an option to set the zoom level to auto, so it shows all markers (let's say in a city)?
I extended the code with this implementation:
// Zoom it fit markers
$(this).bind('gMap.zoomToFitMarkers', function () {
if (overlays && overlays.length > 0) {
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < overlays.length; i++) {
bounds.extend(overlays[i].getPosition());
}
$gmap.fitBounds(bounds);
}
});
You also need to add this to the case at the top:
case 'zoomToFitMarkers':
return $(this).trigger('gMap.zoomToFitMarkers');
Tried to clone so I could submit a pull request, but gitHub for Windows keeps failing to clone.
I can't understand how to use it