Last active
December 24, 2015 20:03
-
-
Save ZachMoreno/6e891b6c7487380b69d6 to your computer and use it in GitHub Desktop.
Wrapper function to create a Google Map with a single marker, including optional click event handler
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
function newMap(lat, long, zoom, domID, clickHandler) { | |
var latLong = new google.maps.LatLng(lat,long), | |
options = { | |
center: { | |
lat : lat, | |
lng : long | |
}, | |
// set base map | |
mapTypeId: google.maps.MapTypeId.TERRAIN, | |
// set base map custom styles | |
styles: mapStyles, | |
zoom: zoom, | |
scrollwheel: false, | |
mapTypeControl: false, | |
streetViewControl: false | |
}, | |
map = new google.maps.Map(document.getElementById(domID), options); | |
var marker = new google.maps.Marker({ | |
position : latLong, | |
map : map, | |
icon : 'http://maps.google.com/mapfiles/ms/icons/blue.png', | |
title : '' | |
}); | |
if(clickHandler) { | |
google.maps.event.addListener(marker, 'click', (function(marker) { | |
return (function() { | |
clickHandler(); | |
})(); | |
})); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment