Created
September 26, 2020 15:56
-
-
Save anjalbinayak/7bf0545986796b8ae79cd02a0f90360a to your computer and use it in GitHub Desktop.
This gist is used in medium article
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
let mapMarker = null; | |
let map; | |
map = new google.maps.Map(document.getElementById("map"), { | |
center: { lat: 28.3949, lng: 84.1240 }, // :nepal: | |
zoom: 6, | |
}); | |
map.addListener('click',function (e){ | |
let marker = new google.maps.Marker({ | |
position: {lat: e.latLng.lat(), lng: e.latLng.lng() }, | |
map: map, //map object | |
title: 'Dynamic Marker,click on map to change marker location' | |
}); | |
if (mapMarker) mapMarker.setMap(null); | |
mapMarker = marker; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment