carto: add initMap method
This commit is contained in:
parent
561f9a8164
commit
e1b068d67c
1 changed files with 13 additions and 0 deletions
|
@ -6,6 +6,19 @@ import L from 'leaflet';
|
||||||
export { DEFAULT_POSITION, LAT, LON };
|
export { DEFAULT_POSITION, LAT, LON };
|
||||||
const LAYERS = {};
|
const LAYERS = {};
|
||||||
|
|
||||||
|
export function initMap(position) {
|
||||||
|
const map = L.map('map', {
|
||||||
|
scrollWheelZoom: false
|
||||||
|
}).setView([position.lat, position.lon], position.zoom);
|
||||||
|
|
||||||
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||||
|
attribution:
|
||||||
|
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||||
|
}).addTo(map);
|
||||||
|
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
export function drawLayer(map, data, style, layerName = 'default') {
|
export function drawLayer(map, data, style, layerName = 'default') {
|
||||||
removeLayer(map, layerName);
|
removeLayer(map, layerName);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue