From 42912b5d98a706c0ab129de9144edb10708bfa90 Mon Sep 17 00:00:00 2001 From: Damon Ulmi <63123585+DamonU2@users.noreply.github.com> Date: Mon, 3 Feb 2025 10:12:50 -0800 Subject: [PATCH] feat(names): function added to replace layer names Closes #2724 --- packages/geoview-core/public/css/style.css | 15 - .../templates/demos/demo-esri-renderer.html | 15 + .../demos/demo-osdp-integration.html | 366 ++++++++++-------- .../map-event-processor.ts | 142 ++++--- .../geoview-core/src/geo/map/map-viewer.ts | 23 +- 5 files changed, 341 insertions(+), 220 deletions(-) diff --git a/packages/geoview-core/public/css/style.css b/packages/geoview-core/public/css/style.css index 88adf711717..d46b6e4b99f 100644 --- a/packages/geoview-core/public/css/style.css +++ b/packages/geoview-core/public/css/style.css @@ -254,21 +254,6 @@ table.state { color: #506882; } -textarea { - height: 99999px; - line-height: 21px; - overflow-y: hidden; - padding: 0; - border: 0; - background: #282a3a; - color: #fff; - min-width: 500px; - outline: none; - resize: none; - overflow-x: auto; - white-space: nowrap; -} - @media only screen and (max-width: 767px) { body { padding: 2px; /* Adjust the value as needed */ diff --git a/packages/geoview-core/public/templates/demos/demo-esri-renderer.html b/packages/geoview-core/public/templates/demos/demo-esri-renderer.html index 9528740af52..d710c98623c 100644 --- a/packages/geoview-core/public/templates/demos/demo-esri-renderer.html +++ b/packages/geoview-core/public/templates/demos/demo-esri-renderer.html @@ -22,6 +22,21 @@ #serviceUrlInput { width: 700px; } + + textarea { + height: 99999px; + line-height: 21px; + overflow-y: hidden; + padding: 0; + border: 0; + background: #282a3a; + color: #fff; + min-width: 500px; + outline: none; + resize: none; + overflow-x: auto; + white-space: nowrap; + } diff --git a/packages/geoview-core/public/templates/demos/demo-osdp-integration.html b/packages/geoview-core/public/templates/demos/demo-osdp-integration.html index 7a4c8f50726..2bf9713536c 100644 --- a/packages/geoview-core/public/templates/demos/demo-osdp-integration.html +++ b/packages/geoview-core/public/templates/demos/demo-osdp-integration.html @@ -47,151 +47,187 @@

OSDP Integration

-
- +
+

Changes to map div:

+
+ +
+ Code +
document.getElementById('Map1').remove();
+
+
+ +
+ +
+ Code +
+if (!document.getElementById('Map1')) {
+  const newDiv = document.createElement('div');
+  const id = document.createAttribute('id');
+  id.value = 'Map1';
+  newDiv.setAttributeNode(id);
+  const dataLang = document.createAttribute('data-lang');
+  dataLang.value = lang;
+  newDiv.setAttributeNode(dataLang);
+  document.getElementById('mapSection').appendChild(newDiv);
+}
+          
+
+
+ +
+ + Note: Will not effect the map until reloaded. +
+ Code +
+lang = lang === 'fr' ? 'en' : 'fr';
+const mapDiv = document.getElementById('Map1');
+if (mapDiv) {
+  mapDiv.setAttribute('data-lang', lang);
+            }
+          
+
+
+

-
- - - -
-
-
- - +
+
+
+
+ +
+ +
+ + +
+
+ +
+ Code +
cgpv.api.maps.Map1.layer.addGeoviewLayerByGeoCoreUUID(uuid, customListOfLayerEntries);
+
+
+
-
    -
  • - - Add entered Geocore UUID's to the map with a custom configuration (List of layer entries) -
    - Code -
    -                cgpv.api.maps.Map1.layer.addGeoviewLayerByGeoCoreUUID(uuid, customListOfLayerEntries);
    -            
    -
    -
  • -
+

+ +
+

Current Stored Config:

+
+ +
+ Code +
+return new Promise (resolve => {
+  removeMap('Map1')
+    .then(() => {
+      cgpv.api.createMapFromConfig('Map1', JSON.stringify(mapConfig), 800)
+      .then(() => {
+          resolve();
+        });
+    });
+  });
+
+  function removeMap(map) {
+    return new Promise(resolve => {
+      if (cgpv.api.maps[map]) {
+        cgpv.api.maps[map].remove(false)
+          .then(() => {
+            resolve();
+          });
+      } else {
+        resolve();
+      }
+    });
+  }
+          
+
+
+
+ +
+ + +
+
+ Modes +
true - All names are kept as they appear on the map
+false - All geocore names are set to undefined, to be reapplied by the service
+hybrid - Geocore layer names are kept, style to be reapplied by the service
+          
+
+
+ Code +
mapConfig = cgpv.api.maps.Map1.createMapConfigFromMapState(overrideGeocoreServiceNames);
+
+
+
+
+ +
+ +
+ +
+

Change the layer names in the config:

+

The examples provided below are for the default three layers in the add layers box above. To see this work, click the "Add Layers" button with the default layers, + click "Update With Map State" once the layers are loaded, and then click "Change Names". The names in the config will be updated. +

+

To try it yourself, add any layer to the map, update the config, and then copy the layer name you would like to change. Put it in square brackets in the box below, + followed by a comma, and then the name you would like to replace it with - [name to change, new name]. Note that the order of the names in the pair, and the order of the pairs + do not matter, [Radioactivité de l'air, Radioactivity] and [Radioactivity, Radioactivité de l'air] will function the same - any provided layer name will be replaced with its pair, + so the same call can be used to switch a name and switch it back. +

+ +
+ +
+ Code +
+const pairs = [["Radioactivité de l'air", 'Radioactivity'], ['Périmètre de localisation des stations', 'Perimeter'], ['Carte commémorative du Canada', 'Commemorative Map']];
+cgpv.api.maps.Map1.replaceMapConfigLayerNames(pairs, mapConfig);
+        
+
+
+