From 87069e98d8a8d95acbf56e45d4d11356b3214f8a Mon Sep 17 00:00:00 2001 From: tariqksoliman Date: Wed, 27 Mar 2024 17:11:21 -0700 Subject: [PATCH] Info.go --- config/js/config.js | 1 + docs/pages/Configure/Layers/Vector/Vector.md | 4 +++- src/essence/Ancillary/Description.js | 16 ++++++++++++++++ src/essence/Ancillary/Search.js | 3 ++- src/external/Leaflet/leaflet.hotline.js | 6 +++++- 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/config/js/config.js b/config/js/config.js index 7dbf76ca..433f2153 100644 --- a/config/js/config.js +++ b/config/js/config.js @@ -3002,6 +3002,7 @@ function layerPopulateVariable(modalId, layerType) { which: "last", icon: "material design icon", value: "Prop: {prop}", + go: false, }, ]; currentLayerVars.markerIcon = currentLayerVars.markerIcon || { diff --git a/docs/pages/Configure/Layers/Vector/Vector.md b/docs/pages/Configure/Layers/Vector/Vector.md index 428cc5cd..60a25038 100644 --- a/docs/pages/Configure/Layers/Vector/Vector.md +++ b/docs/pages/Configure/Layers/Vector/Vector.md @@ -149,7 +149,8 @@ Example: { "which": "last", "icon": "material design icon", - "value": "Prop: {prop}" + "value": "Prop: {prop}", + "go": false } ], "layerAttachments": { @@ -272,6 +273,7 @@ Example: - `which`: This only supports the value `last` at this point. - `icon`: Any [Material Design Icon](http://materialdesignicons.com/) name - `value`: A name to display. All `{prop}`s will be replaced by their corresponding `features[which].properties[prop]` value. + - `go`: Boolean that, if true, pans and zooms to the feature of `which` on intial load. The zoom used is Map Scale Zoom or the current zoom. Only the first feature with info.go is gone to. - `layerAttachments`: Attachments that may apply to the entire layer. - `labels`: Place a label beside each feature. Also applies to `coordinateAttachments.marker` features. - `initialVisibility`: Whether the label sublayer is initially on. Users can toggle sublayers on and off in the layer settings in the LayersTool. diff --git a/src/essence/Ancillary/Description.js b/src/essence/Ancillary/Description.js index 40425ef7..a124b1cd 100644 --- a/src/essence/Ancillary/Description.js +++ b/src/essence/Ancillary/Description.js @@ -14,6 +14,7 @@ const Description = { descPoint: null, tippyDesc: null, L_: null, + _infoAlreadyGone: false, init: function (mission, site, Map_, L_) { this.L_ = L_ this.Map_ = Map_ @@ -140,6 +141,20 @@ const Description = { l.variables.info[i].icon + " mdi-18px'>" newInfo += '
' + infoText + '
' + + // Go initially + if (Description._infoAlreadyGone == false) { + if (l.variables.info[i].go == true) { + if (lat != null && lng != null) { + Description.Map_.map.setView( + [lat, lng], + Description.Map_.mapScaleZoom || + Description.Map_.map.getZoom() + ) + } + Description._infoAlreadyGone = true + } + } } if (newInfo.length > 0) infos.push(newInfo) } @@ -166,6 +181,7 @@ const Description = { ) } }) + Description._infoAlreadyGone = true }, updatePoint: function (activeLayer) { if ( diff --git a/src/essence/Ancillary/Search.js b/src/essence/Ancillary/Search.js index 4389f665..b1acaeec 100644 --- a/src/essence/Ancillary/Search.js +++ b/src/essence/Ancillary/Search.js @@ -470,7 +470,8 @@ function getSearchFieldStringForFeature(name, props) { str += Math.round(F_.getIn(props, sf[i][1])) break case 'rmunder': - str += F_.getIn(props, sf[i][1]).replace('_', ' ') + if (F_.getIn(props, sf[i][1])) + str += F_.getIn(props, sf[i][1]).replace('_', ' ') break } if (i != sf.length - 1) str += ' ' diff --git a/src/external/Leaflet/leaflet.hotline.js b/src/external/Leaflet/leaflet.hotline.js index 0bb1598b..56f00cee 100644 --- a/src/external/Leaflet/leaflet.hotline.js +++ b/src/external/Leaflet/leaflet.hotline.js @@ -64,7 +64,11 @@ canvas.width = 1 canvas.height = 256 for (var i in palette) { - gradient.addColorStop(i, palette[i]) + try { + gradient.addColorStop(i, palette[i]) + } catch (err) { + console.warn(`Hotline gradient - Bad color: ${palette[i]}`) + } } ctx.fillStyle = gradient ctx.fillRect(0, 0, 1, 256)