Created
March 18, 2019 08:40
-
-
Save barikoi/72aa7f242130c678da1a33cf254c8ede to your computer and use it in GitHub Desktop.
Initializing map and marker
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
const defaultMarker = [23.7104, 90.40744] | |
let map = L.map('map') | |
map.setView(defaultMarker, 13) | |
//Set up the OSM layer | |
L.tileLayer( | |
'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | |
maxZoom: 18 | |
}).addTo(map) | |
L.marker(defaultMarker).addTo(map) | |
Bkoi.onSelect(function() { | |
// get selected data from dropdown list | |
let selectedPlace = Bkoi.getSelectedData() | |
// center of the map | |
let center = [selectedPlace.latitude, selectedPlace.longitude] | |
// Update the map | |
map.setView(center, 18) | |
L.marker(center).addTo(map).bindPopup(selectedPlace.Address) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment