-
-
Save AbdulKabia/20d33e0459c751f4a74ac2fcc7c210c1 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
init(lat, lng) { | |
let mapEl = document.createElement('div'); | |
mapEl.id = 'map'; | |
document.body.appendChild(mapEl); | |
// http://leafletjs.com/reference-1.3.0.html#map | |
let map = (this.map = leaflet.map(mapEl, this.options)); | |
leaflet.tileLayer(tileUrl, { attribution }).addTo(map); | |
map.setView([lat, lng], defaultZoomLevel); | |
// http://leafletjs.com/reference-1.3.0.html#map-event | |
let onMapChange = () => this.emit('update', map.getBounds()); | |
map.on('viewreset', onMapChange); | |
map.on('moveend', onMapChange); | |
// Show a marker at our current location | |
this.currentLocationMarker = leaflet | |
.marker([lat, lng], { | |
title: 'Current Location', | |
icon: svgMarker.location | |
}) | |
.addTo(map); | |
log.info(`Map initialized with centre lat=${lat}, lng=${lng}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment