carto: add initMap method

This commit is contained in:
Paul Chavard 2018-10-13 10:33:56 +02:00
parent 561f9a8164
commit e1b068d67c

View file

@ -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:
'&copy; <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);