Skip to content

Instantly share code, notes, and snippets.

@getsudocode
Created July 17, 2018 16:02
Show Gist options
  • Save getsudocode/2c3745d4f9988c5af0118c248b31b7dc to your computer and use it in GitHub Desktop.
Save getsudocode/2c3745d4f9988c5af0118c248b31b7dc to your computer and use it in GitHub Desktop.
<script>
let map;
// define global array to store markers added
let markersArray = [];
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
// define function to add marker at given lat & lng
function addMarker(latLng) {
let marker = new google.maps.Marker({
map: map,
position: latLng,
draggable: true
});
//store the marker object drawn on map in global array
markersArray.push(marker);
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment