Skip to content

Commit

Permalink
Default the MapOverlay visibility to true for clarity and make sure i…
Browse files Browse the repository at this point in the history
…t's initially rendered. Added some comments.
  • Loading branch information
fschmenger committed Dec 16, 2021
1 parent 3695691 commit 377a3b2
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/components/modulecore/MapOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
inheritAttrs: false,
props: {
overlayId: { type: String, required: true },
visible: { type: Boolean, required: false, default: false },
visible: { type: Boolean, required: false, default: true },
offset: { type: Array, required: false, default: undefined },
positioning: { type: String, required: false, default: 'top-left' },
coordinates: { type: Array, required: false, default: undefined },
Expand Down Expand Up @@ -48,6 +48,18 @@
});
},
methods: {
/**
* This function is executed, after the map is bound (see mixins/Mapable).
* Create the overlay if visible.
*/
onMapBound () {
if (this.show) {
this.createOlOverlay();
}
},
/**
* Creates the OpenLayers overlay control and adds it to the map.
*/
createOlOverlay () {
if (!this.olOverlay) {
var overlayContainer = this.$refs.overlayContainer;
Expand All @@ -65,6 +77,9 @@
this.map.addOverlay(this.olOverlay);
}
},
/**
* Destroys the OpenLayers overlay control and removes it from the map.
*/
destroyOlOverlay () {
if (this.olOverlay) {
this.map.removeOverlay(this.olOverlay);
Expand All @@ -73,13 +88,19 @@
}
},
watch: {
/**
* Create / destroy the OpenLayers overlay control when the visibility toggles.
*/
show () {
if (this.show) {
this.createOlOverlay();
} else {
this.destroyOlOverlay();
}
},
/**
* Update the position of the OpenLayers overlay control.
*/
position () {
if (this.olOverlay) {
this.olOverlay.setPosition(this.position);
Expand Down
1 change: 1 addition & 0 deletions src/components/ol/HoverTooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<template>
<wgu-map-overlay
overlayId="wgu-hover-tooltip"
:visible=false
autoPan
:autoPanDuration="250"
positioning="top-center"
Expand Down

0 comments on commit 377a3b2

Please sign in to comment.