mapserver/public/js/components/LayerSelector.js
2021-04-12 13:03:10 +02:00

23 lines
504 B
JavaScript

import LayerManager from '../LayerManager.js';
function onchange(e){
const params = m.route.param();
params.layerId = e.target.value;
m.route.set("/map/:layerId/:zoom/:lon/:lat", params);
}
export default {
view: function(){
const layers = LayerManager.layers.map(layer => m(
"option",
{ value: layer.id, selected: layer.id == LayerManager.getCurrentLayer().id },
layer.name
));
return m("select", { class: "form-control", onchange: onchange },layers);
}
};