mapserver/public/js/components/LayerSelector.js

25 lines
617 B
JavaScript
Raw Normal View History

2019-09-18 12:53:58 +03:00
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(){
// Display layer selector only if there is choice
if (LayerManager.layers.length <= 1)
return null;
2019-09-18 12:53:58 +03:00
const layers = LayerManager.layers.map(layer => m(
"option",
{ value: layer.id, selected: layer.id == LayerManager.getCurrentLayer().id },
layer.name
2019-09-19 08:33:14 +03:00
));
2019-09-18 12:53:58 +03:00
return m("select", { class: "form-control", onchange: onchange },layers);
}
};