demarches-normaliennes/app/javascript/shared/carto.js

25 lines
518 B
JavaScript
Raw Normal View History

2018-10-03 10:39:35 +02:00
const LON = '2.428462';
const LAT = '46.538192';
const DEFAULT_POSITION = { lon: LON, lat: LAT, zoom: 5 };
import L from 'leaflet';
2018-10-03 10:39:35 +02:00
export { DEFAULT_POSITION, LAT, LON };
const LAYERS = {};
function createLayer(map, layerName) {
const layer = (LAYERS[layerName] = new L.GeoJSON(undefined, {
interactive: false
}));
layer.addTo(map);
return layer;
}
function removeLayer(map, layerName) {
const layer = LAYERS[layerName];
if (layer) {
delete LAYERS[layerName];
map.removeLayer(layer);
}
}