Skip to content

Instantly share code, notes, and snippets.

@bunnyhawk
Last active November 7, 2015 18:32
Show Gist options
  • Save bunnyhawk/126fb1508e71088f1be1 to your computer and use it in GitHub Desktop.
Save bunnyhawk/126fb1508e71088f1be1 to your computer and use it in GitHub Desktop.
An async Google Map module example
// Google Script on page:
// <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=googleMap.init"
// async defer></script>
var googleMap = (function(){
var myLatLng = {lat: 47.550987, lng: -122.277863},
map,
marker;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: myLatLng,
zoom: 13
});
marker = new google.maps.Marker({
position: myLatLng,
map: map
});
}
return {
init: function() {
return initMap();
}
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment