Skip to content

Commit c282552

Browse files
jreyesramotl
authored andcommitted
Overlay image can now be refreshed with the dashboard
1 parent 3a7dc70 commit c282552

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,12 @@ Optionally, you can show an image over the base map (but below the data points).
287287

288288
Show/hide the overlay.
289289

290+
**Auto reload overlay**
291+
292+
By default, the overlay image is fetched once, on page load, and never updated. If the overlay image is updated regularly (say, the overlay is generated on another application and then served on a fixed URL), it may be desirable to fetch the image when the dashboard is refreshed. This switch enables it.
293+
294+
If the overlay image is fixed (e. g., an orthomosaic of the area, taken with a drone), leave this option disabled, as it would cause an additional request on each dashboard reload.
295+
290296
**Overlay URL**
291297

292298
The URL where the image is available. Please notice that only URLs can be used (no local files!)

src/partials/editor.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ <h5>Custom image overlay</h5>
554554
<gf-form-switch class="gf-form" label="Enable" label-class="width-10" checked="ctrl.panel.enableOverlay"
555555
on-change="ctrl.refreshOverlay()">
556556
</gf-form-switch>
557+
<gf-form-switch class="gf-form" ng-show="ctrl.panel.enableOverlay == true"
558+
label="Auto reload overlay" tooltip="Enable to update the image whenever the dashboard is refreshed"
559+
label-class="width-10" checked="ctrl.panel.enableReloadOverlay">
560+
</gf-form-switch>
557561
<div class="gf-form" ng-show="ctrl.panel.enableOverlay == true">
558562
<label class="gf-form-label width-10">Overlay URL</label>
559563
<input type="url" class="input-small gf-form-input width-10" ng-model="ctrl.panel.overlayUrl"

src/worldmap_ctrl.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const panelDefaults = {
6363
overlayOpacity: 0.5,
6464
overlayRangeLatitude: '0,10',
6565
overlayRangeLongitude: '0,20',
66+
enableReloadOverlay: false,
6667
clickthroughUrl: '',
6768
clickthroughOptions: {
6869
windowName: null,
@@ -271,6 +272,10 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
271272
) {
272273
this.loadLocationData(true);
273274
}
275+
276+
if (this.panel.enableOverlay && this.panel.enableReloadOverlay) {
277+
this.refreshOverlay();
278+
}
274279
}
275280

276281
onDataSnapshotLoad(snapshotData) {
@@ -550,8 +555,11 @@ export default class WorldmapCtrl extends MetricsPanelCtrl {
550555
}
551556

552557
refreshOverlay() {
553-
this.map.overlay.remove();
554-
this.map.overlay = null;
558+
if (this.map) {
559+
this.map.overlay?.remove();
560+
this.map.overlay = null;
561+
}
562+
555563
this.render();
556564
}
557565

0 commit comments

Comments
 (0)