hupe13 / extensions-leaflet-map-github

WordPress Plugin Extensions for Leaflet Map - Github Version
GNU General Public License v2.0
13 stars 4 forks source link

tooltip trigged by hover does not automatically control the width of the frame. #7

Closed monkeyotg closed 1 year ago

monkeyotg commented 1 year ago

Thanks for the extension. It does the job very well.

Here is the bug I found. Since the tooltips trigged by hover and click cannot be controlled separately, they can only show the same information. So I decided to make the hover tooltips show the full information, therefor "Note" is included. And in some cases "Note" could be a long-text. And as you can see in the screenshot, the long-text will destroy the frame.

Snipaste_2023-05-08_13-40-40

hupe13 commented 1 year ago

Yes I know that the tooltip is not perfect. But how should I solve this for everyone? One has text, the other an image, ... Do you have an idea? Is it possible for you to use the title option for the markers? There you can write a shorter text.

[leaflet-marker title="Short Info"...]Long Info[/leaflet-marker]
[hover marker=title]
monkeyotg commented 1 year ago

I'm using .geojson. Initially I don't want to show full info in tooltip, like only title or something brief. And in popup full info will be shown. But later I realized "The tooltip content is the same as the popup content.".

both show only Name:

[leaflet-geojson src="/wp-content/uploads/map/Daily_Need.geojson"]{@Name}[/leaflet-geojson]
[hover]

both show everything:

[leaflet-geojson src="/wp-content/uploads/map/Daily_Need.geojson" table-view=1]{@Name}[/leaflet-geojson]
[hover]

both show nothing:

[leaflet-geojson src="/wp-content/uploads/map/Daily_Need.geojson"][/leaflet-geojson]
[hover]

So compared to losing some information in popups, showing full info in tooltips is a better solution.

And I'm a newbie to OSM/Leaflet .... So I don't know, is it also possible that I can name a variant as "Short Info"/Title or something like that, if I use .geojson?

If it would be a pain to handle dynamically, is giving an option to just force a fixed width to the tooltip a viable solution?

hupe13 commented 1 year ago

I searched the internet, this seems to be non-trivial, if not impossible to solve with css. One possibility would be to add the short text as a feature in the geojson file and extend the shortcode hover to use this as a tooltip. Simpler: I create an option for hover for tooltip: hover geojsontooltip="{@Name}" or similar.

monkeyotg commented 1 year ago

Thanks, I will try it today and report back!

hupe13 commented 1 year ago

Did you read my edit? I will change the option geojsontooltip. Until now it was true or false. Later it will have an parameter geojsontooltip="{@Name}".

monkeyotg commented 1 year ago

I have read it. And you haven't pointed out that it's something client-based or some kind of server-based. So to me, a guy who doesn't know how to code, it means 2 possibilities:

  1. it's some kind of server-based. I can try it without updating the plugin.
  2. it's client-based, I have to wait for an update.

No.1 will cost me nothing. Why not give it a try?

hupe13 commented 1 year ago

Das zweite trifft zu.

monkeyotg commented 1 year ago

Danke, dann warte ich darauf.

hupe13 commented 1 year ago

You can test the Github version. Example

monkeyotg commented 1 year ago

Thanks, I'll try it tomorrow.

hupe13 commented 1 year ago

Version 3.4.4 is released.

monkeyotg commented 1 year ago

Version 3.4.4 is released.

I've tried. It works great! Thanks

Snipaste_2023-05-15_19-01-31 Snipaste_2023-05-15_19-01-42