Zoom to Markers in Google Maps API

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

Borrowed from Jerome Paradis: http://blog.jeromeparadis.com

Copy this code and paste it in your HTML
  1. function fitMap( map, points ) {
  2. var bounds = new GLatLngBounds();
  3. for (var i=0; i< points.length; i++) {
  4. bounds.extend(points[i]);
  5. }
  6. map.setZoom(map.getBoundsZoomLevel(bounds));
  7. map.setCenter(bounds.getCenter());
  8. }

URL: http://blog.jeromeparadis.com/archive/2007/02/08/1468.aspx

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.