Skip to content

Dynamic popups? #266

@tiptronic

Description

@tiptronic

I just found this nifty plugin (thx for that) and it works pretty good.
However, there's one thing I could not figure out how to do (even with lots of googling):

When clicking a marker, I want to fill the popup with some current data (which changes every minute or so = dynamically).

e.g. that's a snippet of my shortcode:

[leaflet-map zoom=14 lat=53.01 lng=10.57 height="600" detect-retina fitbounds zoomcontrol]
[leaflet-scale]
[leaflet-marker alt="11069736267" id="11069736267" lat=53.0860892 lng=10.604267 title="HGZ"]HGZ[/leaflet-marker]

All attributes (except alt) are thrown away in the shortcode, so it seems there's no way to pass an identifier for my data (or even more data) using custom attributes, but the alt attribute (which works, but is somewhat moot).

Later on, I'm going to bind the popup like so:

WPLeafletMapPlugin.markers.forEach(l => l.bindPopup(doBindMyPopup));

Is there a way to do that using leaflet-map (or using the elsewhere available extensions to leaflet-map?).

If it is not possible, that's ok, because that works as shown above - although it's not ideal, because I have to keep the referenced data around...

Any hint appreciated!

Thx
PS: I'm not a PHP-guy, so I'd like to avoid hacking on WP. EXCEPT there's a much better way to go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions