Skip to content

Commit

Permalink
feat(initialView): empty layerIds array defaults to all layers
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonU2 committed Jul 18, 2024
1 parent e4a8e73 commit 2718c1d
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"map": {
"interaction": "dynamic",
"viewSettings": {
"initialView": {
"layerIds": []
},
"projection": 3978
},
"basemapOptions": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ <h4 id="HLYR1">1. Many ESRI Dynamic Layers with legend settings in the config</h
'map': {
'interaction': 'dynamic',
'viewSettings': {
'initialView': {
'layerIds': []
},
'projection': 3857
},
'basemapOptions': {
Expand Down
3 changes: 3 additions & 0 deletions packages/geoview-core/public/templates/layers/geocore.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ <h4 id="HLYR1">1. Many GeoCore Layers</h4>
'map': {
'interaction': 'dynamic',
'viewSettings': {
'initialView': {
'layerIds': []
},
'projection': 3978
},
'basemapOptions': {
Expand Down
3 changes: 1 addition & 2 deletions packages/geoview-core/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1562,11 +1562,10 @@
},
"layerIds": {
"type": "array",
"minItems": 1,
"items": {
"type": "string"
},
"description": "Geoview layer ID(s) or layer path(s) of layer(s) to use as initial map focus."
"description": "Geoview layer ID(s) or layer path(s) of layer(s) to use as initial map focus. If empty, will use all layers."
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,8 @@
}
},
"layerIds": {
"description": "ID(s) of layer(s) to use as initial map focus.",
"description": "Geoview layer ID(s) or layer path(s) of layer(s) to use as initial map focus. If empty, will use all layers.",
"type": "array",
"minItems": 1,
"items": {
"type": "string"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export type TypeMapViewSettings = {
* Option to set initial view by extent.
* Called with [minX, minY, maxX, maxY] extent coordinates. */
extent?: Extent;
/** Geoview layer ID(s) or layer path(s) of layer(s) to use as initial map focus. */
/** Geoview layer ID(s) or layer path(s) of layer(s) to use as initial map focus. If empty, will use all layers. */
layerIds?: string[];
};

Expand Down
7 changes: 6 additions & 1 deletion packages/geoview-core/src/geo/map/map-viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,12 @@ export class MapViewer {

// Zoom to extents of layers selected in config, if provided.
if (this.mapFeaturesConfig.map.viewSettings.initialView?.layerIds) {
let layerExtents = this.layer.getExtentOfMultipleLayers(this.mapFeaturesConfig.map.viewSettings.initialView.layerIds);
// If the layerIds array is empty, use all layers
const layerIdsToZoomTo = this.mapFeaturesConfig.map.viewSettings.initialView.layerIds.length
? this.mapFeaturesConfig.map.viewSettings.initialView.layerIds
: this.layer.getGeoviewLayerIds();

let layerExtents = this.layer.getExtentOfMultipleLayers(layerIdsToZoomTo);

// If extents have infinity, use default instead
if (layerExtents.includes(Infinity))
Expand Down

0 comments on commit 2718c1d

Please sign in to comment.