Created
May 26, 2019 09:15
-
-
Save barikoi/42eccd0953450b77f97eb99f05503dbe 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
function initMap() { | |
const defaultLatLng = new google.maps.LatLng(23.7624286, 90.378406); | |
// Google map options | |
let mapOptions = { | |
zoom: 12, | |
center: defaultLatLng | |
} | |
const map = new google.maps.Map(document.getElementById("map"), mapOptions) | |
let marker = new google.maps.Marker({ | |
position: defaultLatLng, | |
}) | |
// Add marker to the map | |
marker.setMap() | |
Bkoi.onSelect(function () { | |
// get selected data from dropdown list | |
let selectedPlace = Bkoi.getSelectedData() | |
let selectedPlaceMarker = new google.maps.LatLng(selectedPlace.latitude, selectedPlace.longitude) | |
// Update marker position | |
marker.setPosition(selectedPlaceMarker) | |
map.zoom = 15 | |
// Update map center | |
map.panTo(selectedPlaceMarker) | |
// Add marker to the map | |
marker.setMap(map) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment