Last active
October 7, 2015 03:28
-
-
Save wholypantalones/3098400 to your computer and use it in GitHub Desktop.
Google Maps Zoom To Fit All Markers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // create an array of coordinates to zoom on | |
| var latlng = [{ | |
| name: "South West Marker", | |
| latlng: new google.maps.LatLng(swLat, swLng) | |
| }, { | |
| name: "North East Marker", | |
| latlng: new google.maps.LatLng(neLat, neLng) | |
| }]; | |
| var latlngbounds = new google.maps.LatLngBounds(); | |
| for (var i = 0; i < latlng.length; i++) { | |
| latlngbounds.extend(latlng[i].latlng); | |
| } | |
| // zoom on coordinates | |
| map.fitBounds(latlngbounds); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment