Since I am suffering from a GAFA allergy and for reasons of data protection (GRDP-Regulations), I try to implement a Leaflet Maps plugin -hidden link) - to bridge, until You offer a suitable alternative. My choice fell on this plugin because it is very simple and markers can be set using shortcodes. And so I hope to make them dynamic with the help of your tools.
I have registered the shortcodes in your settings and it is possible to display a map in a single content template and set a dynamic marker with a code like this:
For the Map:
[leaflet-map address = "[types field = 'zipcode' format = 'FIELD_VALUE'] [/ types] [types field = 'place name'] [/ types]" zoom = "10"]
For the Marker:
[leaflet-marker address = "[types field = 'street'] [/ types], [types field = 'place name'] [/ types]" svg = "1" background = "# 654" iconClass = "dashicons dashicons- marker "color =" white "]
So far so good.
What I have failed so far is to run the marker shortcode in a view item loop. What I want to achieve, of course, is to dynamically generate the markers that belong to a View and show them together on the map. Like that
We are aware of certain demand from clients to provide an alternative to Google or Azure maps; it is under consideration, but is not being currently worked on, so I can't say with any confidence if and when it will.
As we don't support leaflet maps, there is not much I can do to help, I'm afraid.
It's not obvious to my why it would work with a single marker on a map in a content template, but not for multiple markers output by a View.
If each post in your View query has one address field, the looping over the posts and outputting the address is effectively the same as displaying a single address in a content template.
Maybe your leaflet-marker shortcode needs an ID or similar to uniquely identify them.
If in a content template you add multiple leaflet-marker shortcodes with different addresses do they work?
That's just a thought, as I say we don't support it I'm afraid.
Hello Nigel,
Thank you for your kind answer. Yes, multiple markers work well in a content template.
When the markers go through the loop, a Jave Script error is displayed: Uncaught SyntaxError: Invalid or unexpected token.
I have copy-paced the appropriate part from the Chrome Inspector (See the attached file). Reference is made to line 314, respectively (and each corresponding line of the ongoing loop)
I do not know if this information is illuminating. Anyway, the output shows that the markers go through the loop.
Maybe more of a problem where Leaflet Maps Plugin Maker can help?
I took a quick look and tried the same, installing the Leaflet Map plugin and trying to output a map with multiple markers in a View, but came across the same JS errors (which look as if they arise because of HTML encoding of the JS that the plugin inserts with the marker shortcode).
I'm sorry I don't have any advice about fixing that, it is not something we support. (If it was a very popular plugin we could look at identifying the cause, but it is not.)