Created
August 25, 2015 06:43
-
-
Save bencooling/52e35ac7a36dc0669c93 to your computer and use it in GitHub Desktop.
api | google maps simple
This file contains 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
# API: Google maps | |
## Simple map | |
<div id="map" class="map"></div> | |
## Geolocation map | |
Map centered by address, not latlng | |
<div id="address" class="map"></div> | |
## |
This file contains 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
function initAddress(){ | |
var geocoder = new google.maps.Geocoder(); | |
var address = '1 Moonan Street Maryland, NSW'; | |
geocoder.geocode( { 'address': address}, function(results, status) { | |
if (status == google.maps.GeocoderStatus.OK) { | |
var map = new google.maps.Map(document.getElementById('address'), { | |
center: results[0].geometry.location, | |
zoom: 18 | |
}); | |
} | |
}); | |
} | |
google.maps.event.addDomListener(window, 'load', initAddress); | |
function initMap() { | |
var map = new google.maps.Map(document.getElementById('map'), { | |
center: {lat: -34.397, lng: 150.644}, | |
zoom: 8 | |
}); | |
} | |
google.maps.event.addDomListener(window, 'load', initMap); | |
This file contains 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
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> |
This file contains 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
.map { | |
width: 400px; | |
height: 200px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment