Categories
JavaScript

Disable mouse wheel zoom on Google Maps

Mouse wheel zoom can be disabled by adding scrollwheel: false to map options object.

Categories
JavaScript

Zoom To Fit All Markers on Google Maps

Zoom Google Maps to fit all markers on your map.

var latLngArr = [new google.maps.LatLng(52.537,-2.061), new google.maps.LatLng(52.564,-2.017)],
    bounds = new google.maps.LatLngBounds(),
    idx = 0,
    count = latLngArr.length;

for ( ; idx < count; idx++) {
  bounds.extend (latLngArr[idx]);
}

map.fitBounds(bounds);