Click and Hover
Every annotation layer reports taps and the mouse on its features:
onClick: the user tapped or clicked a feature.onEnter: a mouse or stylus moved onto a feature, or from one feature of the layer onto another.onLeave: the mouse or stylus left the feature thatonEnterreported.
Hover effect
Keep the hovered feature in the state and draw it again in a second, more opaque layer:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | |
Details
- Each
LayerFeatureEventholds the feature'sindexin the layer's list, itsgeometry, and where the pointer is aspointandscreenPoint. - Of features of several layers, a tap goes to the topmost layer, and of its
points to the nearest. A tap next to a small feature still hits it.
MapLibreMap.onClickis called as well. onEnterandonLeaveare tracked per layer: moving from a feature of one layer onto an overlapping feature of a layer above enters the second without leaving the first.- Touches don't hover, so
onEnterandonLeaveare only called for mice and styluses. UseonClickon touch screens.