Zoom and fit bounds Google maps V3


/ Published in: JavaScript
Save to your folder(s)

Center the map on an array of latlng values


Copy this code and paste it in your HTML
  1. var latlngbounds = new google.maps.LatLngBounds();
  2. for ( var i=0; i<route.length; i++ ){
  3. latlngbounds.extend(route[i]);
  4. }
  5. map.setCenter( latlngbounds.getCenter(), map.fitBounds(latlngbounds));

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.