Disable existing layers if selecting via URL
This probably breaks existing links that assume a basemap, but…meh! Otherwise there's no way to disable my location layer nor the basemap, both of which are on by default. Requested-By: Eric Villnow <eric@vill.now>
This commit is contained in:
parent
1ea90a0f69
commit
ca8aa335e5
1 changed files with 4 additions and 0 deletions
4
main.js
4
main.js
|
|
@ -132,6 +132,10 @@ for (let category of layerCategories) {
|
||||||
const urlParams = qs.parse(window.location.search, { ignoreQueryPrefix: true });
|
const urlParams = qs.parse(window.location.search, { ignoreQueryPrefix: true });
|
||||||
const urlLayers = ('layer' in urlParams) ? (typeof urlParams.layer === 'string' ? [urlParams.layer] : urlParams.layer) : [];
|
const urlLayers = ('layer' in urlParams) ? (typeof urlParams.layer === 'string' ? [urlParams.layer] : urlParams.layer) : [];
|
||||||
|
|
||||||
|
if (urlLayers.length > 0) {
|
||||||
|
// Disable default-enabled layers if we're selecting layers via query params
|
||||||
|
layerCategories.forEach(c => c.layers.forEach(l => l.enabled = false));
|
||||||
|
}
|
||||||
for (let category of layerCategories) {
|
for (let category of layerCategories) {
|
||||||
for (let layer of category.layers) {
|
for (let layer of category.layers) {
|
||||||
if (urlLayers.includes(layer.name)) {
|
if (urlLayers.includes(layer.name)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue