Created
July 17, 2018 16:02
-
-
Save getsudocode/2c3745d4f9988c5af0118c248b31b7dc to your computer and use it in GitHub Desktop.
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> | |
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