visualize-admin / visualization-tool

The tool for visualizing Swiss Open Government Data. Project ownership: Federal Office for the Environment FOEN
https://visualize.admin.ch
BSD 3-Clause "New" or "Revised" License
32 stars 3 forks source link

Draw order may prevent tooltip in map chart #479

Closed AFoletti closed 2 years ago

AFoletti commented 2 years ago

Describe the bug When drawing a map, it can be that a feature is completely covered by a bigger one. You may be able to see the smaller feature thanks to transparency, but the hover only returns the tooltip for the larger feature. I guess (from my past map.geo.admin.ch visualization development work) that this is a problem of feature draw order, where the smaller feature is drawn first and then covered by the larger one. Actually, it looks like the draw order is at the moment random, since I have seen the very same map work well with the smaller feature drawn last (thus on top).

To Reproduce Steps to reproduce the behavior:

  1. Go to this map
  2. Find in Wallis the two superimposed points
  3. Hover over those points to check the toolitp
  4. See error... you only get the tooltip for the bigger feature if it's drawn on top

Expected behavior Smaller features are always drawn last (thus on top) and their tooltip is available

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

Additional context Most probably you just need a sorting

AFoletti commented 2 years ago

Fixed the link to visualize map.

ptbrowne commented 2 years ago

Hi Ambroggio, thanks for the report. I am not sure that a solution relying on the order of the point would be good. We would have edge cases where two points have the same radii and have approximately the same position, and then it would still be a problem to hover over one of them. I think a more scalable solution would be to support clustering https://visgl.github.io/react-map-gl/examples/clusters or heatmaps https://visgl.github.io/react-map-gl/examples/heatmap This is not something that we will tackle now, but I keep it in mind, what is your opinion ?

AFoletti commented 2 years ago

Hello @ptbrowne, and thanks for your message and your proposal. Clustering and heatmaps would be very nice additions but they cover in my opinion two additional use cases, since one may want to have the real points on the map from the start. Everyone however wishes for usable tooltips, which are at the moment randomly not possible because of draw order. This would be even more important for actual overlapping surfaces (as opposed to points as in my example) where the smaller ones really need to be drawn on top. You could maybe even activate the tooltip for every feature you hover over and not only the top one, but this may result in confusion and an order fix remains in my opinion a better solution.

ptbrowne commented 2 years ago

Thanks @AFoletti , I think it was a good fix actually 👍 It is now deployed in test.

AFoletti commented 2 years ago

Wonderful, many thanks!