3
3
<l-map class =" map" v-if =" show" :class =" stac.type" @ready =" init" :options =" mapOptions" >
4
4
<l-control-fullscreen :key =" `fullscreen${ix}`" :options =" fullscreenOptions" />
5
5
<l-control-zoom :key =" `zoom${ix}`" v-bind =" zoomControlTexts" position =" topleft" />
6
- <l-control-layers v-if = " showLayerControl " position =" bottomleft" ref =" layerControl" />
6
+ <l-control-layers position =" bottomleft" ref =" layerControl" />
7
7
<component
8
8
v-for =" basemap of basemaps" :is =" basemap.is" :key =" basemap.key"
9
9
ref =" basemaps" layerType =" base" v-bind =" basemap"
10
10
/>
11
- <l-tile-layer v-for =" xyz of xyzLinks" ref =" overlays " :key =" xyz.url" layerType =" overlay" v-bind =" xyz" />
12
- <LWMSTileLayer v-for =" wms of wmsLinks" ref =" overlays " :key =" wms.url" layerType =" overlay" v-bind =" wms" />
11
+ <l-tile-layer v-for =" xyz of xyzLinks" ref =" xyzOverlays " :key =" xyz.url" layerType =" overlay" v-bind =" xyz" />
12
+ <LWMSTileLayer v-for =" wms of wmsLinks" ref =" wmsOverlays " :key =" wms.url" layerType =" overlay" v-bind =" wms" />
13
13
<l-geo-json v-if =" geojson" ref =" geojson" :geojson =" geojson" :options =" {onEachFeature: showPopup}" :optionsStyle =" {color: secondaryColor, weight: secondaryWeight}" />
14
14
</l-map >
15
15
<b-popover
@@ -137,9 +137,6 @@ export default {
137
137
return map;
138
138
}).filter (map => Utils .isObject (map));
139
139
},
140
- showLayerControl () {
141
- return this .xyzLinks .length > 0 || this .wmsLinks .length > 0 || this .basemaps .length > 1 ;
142
- },
143
140
xyzLinks () {
144
141
const links = this .getWebMapLinks (' xyz' );
145
142
return links .map (link => ({
@@ -163,13 +160,14 @@ export default {
163
160
styles = link[' wms:styles' ][i];
164
161
}
165
162
const name = [link .title , layers].filter (x => Boolean (x)).join (' - ' );
163
+ const transparent = Utils .hasText (link[' wms:transparent' ]) ? link[' wms:transparent' ].toLowerCase () === " true" : true ;
166
164
const props = {
167
165
baseUrl: link .href ,
168
166
name,
169
167
attribution: link .attribution || this .stac .getMetadata (' attribution' ),
170
168
version: ' 1.3.0' ,
171
169
layers,
172
- transparent: String (link[ ' wms:transparent ' ] || false ) ,
170
+ transparent,
173
171
styles
174
172
};
175
173
if (typeof link[' type' ] === ' string' && link[' type' ].startsWith (' image/' )) {
@@ -192,9 +190,6 @@ export default {
192
190
if (newVal) {
193
191
this .$nextTick (() => this .geojsonToFront ());
194
192
}
195
- },
196
- showLayerControl () {
197
- this .updateLayerControl ();
198
193
}
199
194
},
200
195
created () {
@@ -243,13 +238,16 @@ export default {
243
238
return links;
244
239
},
245
240
updateLayerControl () {
246
- if (this .showLayerControl ) {
247
- const basemaps = Array .isArray (this .$refs .basemaps ) ? this .$refs .basemaps : [];
248
- const xyzOverlays = Array .isArray (this .$refs .xyzOverlays ) ? this .$refs .xyzOverlays : [];
249
- const wmsOverlays = Array .isArray (this .$refs .wmsOverlays ) ? this .$refs .wmsOverlays : [];
250
- const layers = basemaps .concat (xyzOverlays).concat (wmsOverlays);
251
- layers .forEach (layer => this .$refs .layerControl .addLayer (layer));
252
- }
241
+ const basemaps = Array .isArray (this .$refs .basemaps ) ? this .$refs .basemaps : [];
242
+ basemaps .forEach (layer => this .$refs .layerControl .mapObject .addBaseLayer (layer, layer .name ));
243
+
244
+ const xyzOverlays = Array .isArray (this .$refs .xyzOverlays ) ? this .$refs .xyzOverlays : [];
245
+ const wmsOverlays = Array .isArray (this .$refs .wmsOverlays ) ? this .$refs .wmsOverlays : [];
246
+ const geojsonOverlays = Array .isArray (this .$refs .geojson ) ? this .$refs .geojson : [];
247
+ xyzOverlays
248
+ .concat (wmsOverlays)
249
+ .concat (geojsonOverlays)
250
+ .forEach (layer => this .$refs .layerControl .mapObject .addOverlay (layer, layer .name ));
253
251
},
254
252
viewChanged (event ) {
255
253
if (this .popover ) {
@@ -262,6 +260,7 @@ export default {
262
260
let hadLayer = false ;
263
261
if (this .stacLayer ) {
264
262
this .map .removeLayer (this .stacLayer );
263
+ this .$refs .layerControl .mapObject .removeLayer (this .stacLayer );
265
264
this .stacLayer = null ;
266
265
hadLayer = true ;
267
266
}
@@ -275,6 +274,8 @@ export default {
275
274
return ;
276
275
}
277
276
277
+ let isLinkOrAsset = this .stacLayerData && (' href' in this .stacLayerData );
278
+
278
279
let getDefaultOptions = (customOptions = {}) => Object .assign ({
279
280
baseUrl: this .stac .getAbsoluteUrl (),
280
281
resolution: this .geoTiffResolution ,
@@ -284,8 +285,10 @@ export default {
284
285
displayGeoTiffByDefault: this .displayGeoTiffByDefault
285
286
}, customOptions);
286
287
287
- let options = getDefaultOptions ();
288
- if (this .stacLayerData && ' href' in this .stacLayerData ) {
288
+ let options = getDefaultOptions ({
289
+ displayOverview: ! isLinkOrAsset
290
+ });
291
+ if (isLinkOrAsset) {
289
292
if (this .stac .isItem ()) {
290
293
options .bbox = this .stac ? .bbox ;
291
294
}
@@ -326,6 +329,8 @@ export default {
326
329
this .addMapClickEvent (this .stacLayer );
327
330
this .stacLayer .on (" fallback" , event => this .$emit (' dataChanged' , event .stac ));
328
331
this .stacLayer .addTo (this .map );
332
+ const title = this .stac .type === ' Feature' ? ` stacItem` : ` stac${ this .stac .type } ` ;
333
+ this .$refs .layerControl .mapObject .addOverlay (this .stacLayer , this .$tc (title));
329
334
if (! this .fitBoundsOnce || ! hadLayer) {
330
335
this .fitBounds (this .stacLayer , this .selectBounds );
331
336
}
@@ -342,6 +347,7 @@ export default {
342
347
this .itemPreviewsLayer = await stacLayer (this .stacLayerData , itemPreviewOptions);
343
348
this .addMapClickEvent (this .itemPreviewsLayer );
344
349
this .itemPreviewsLayer .addTo (this .map );
350
+ this .$refs .layerControl .mapObject .addOverlay (this .itemPreviewsLayer , this .$tc (' stacItem' , this .stacLayerData .features .length ));
345
351
this .itemPreviewsLayer .bringToFront ();
346
352
if (! this .stacLayer ) {
347
353
this .fitBounds (this .itemPreviewsLayer );
@@ -392,6 +398,7 @@ export default {
392
398
})
393
399
.then (layer => {
394
400
layer .addTo (this .map );
401
+ this .$refs .layerControl .mapObject .addOverlay (layer, layer .name || link .title );
395
402
// Bring GeoJSON to front to allow opening the popups
396
403
this .geojsonToFront ();
397
404
})
0 commit comments