wegue-oss / wegue

Template and components for webmapping applications with OpenLayers and Vue.js
BSD 2-Clause "Simplified" License
97 stars 42 forks source link

Global feature hover options #366

Closed fschmenger closed 5 months ago

fschmenger commented 7 months ago

This draft adds a top level option mapHover to app.conf, to provide application wide defaults for feature hover customization. The following properties are supported (quoted from the doc):

Property Meaning Example
delay Timespan in milliseconds, by which displaying the tooltip is deferred after the mouse pointer rests. Defaults to 150. "delay": 150
hideOnMousemove Hide the tooltip when the mouse cursor is moved. Defaults to false. "hideOnMousemove": false
hoverOverlay ID of a custom map overlay to use as a default display when a feature of the layer is hovered. Declaration of the hoverOverlay property on a mapLayer level takes precedence. For more information on how to implement a map overlay see the reusable components section. Defaults to Wegue's default tooltip wgu-hover-tooltip "hoverOverlay": "my-custom-overlay"

Example:

"mapHover":
    {
      "delay": 150,
      "hideOnMousemove": false,
      "hoverOverlay": "my-custom-overlay"
    }

Additionally, some problems related to dangling tooltips have been fixed when the mouse cursor leaves the map canvas (efacbde3d8a6a2c04c5ae466232f235c4ac37ef7).

fschmenger commented 7 months ago

Hi guys. This is a first draft. Some topics to think about:

We now have 3 spots to configure feature hover tooltip behavior: 1. (Optional) App-wide defaults, 2. settings at mapLayer scope and 3. (optional) properties to configure the MapOverlay when doing a custom implementation. Is this OK or could it be generally confusing? To explain the 3 config levels and my motivation.

Most of the new property names have been ad-hoc choices. Any suggestions for renamings are welcome. E.g. should it be something like mouseRestDurationinstead of delay, or something like featureHover or just hover instead of mapHover?

Let me know what you think.

fschmenger commented 6 months ago

Hi @sronveaux, thanks for the review and the valuable feedback. I will go through the points you listed above.

Regarding hideOnMousemove: This could be a property on the layer in addition to the global setting. So the global setting would be just a default as well. However this probably would require a different name on the layer level.

Anyway, since this isn`t urgent, we can wait until @chrismayer is back, so he can have a word about it too.