Plugin Author
tinuzz
(@tinuzz)
Hi,
Yes, it is possible, but you have to code it yourself in JavaScript.
After the map and the track have been initialized, you can get to the track object via the global Trackserver object:
Trackserver.mydata.<div_id>[<track_id>].track
So, for example on a page with one map that has track id 99 on it, the track object would be:
Trackserver.mydata.tsmap_1[99].track
Once you have this object, you can do stuff with it. See the Leaflet manual for more information, for example:
http://leafletjs.com/reference-1.0.0.html#evented
You can add an ‘onClick’ handler like this:
Trackserver.mydata.tsmap_1[99].track.on('click', function() { alert("hallo"); });
I hope this helps.
Cheers,
Martijn.
Yes, very helpfull. Thank you.
Plugin Author
tinuzz
(@tinuzz)
Great, glad I could help!
Martijn.
Hi Martijn
Once again thank you for your response. I was a bit quick ending our conversation. I haven’t got any experience with javascript. I falsly thought that I could use the “object” and the “onClick handler” directly on my page. Not so.
I have tried installing a plugin allowing me to write code on specific pages – the plugin is not working. (Scripts n Styles).
I don’t want to take your time – if possible – can you give me a link to a plugin or the code needed to get your brilliant map to be clickable.
If I can clikc on a track at get it to open a new page or a popup – it would be so great.
Best wishes
Henrik
Plugin Author
tinuzz
(@tinuzz)
Hi Henrik,
I’m not sure what to tell you. I have been using ‘Per Post Scripts & Styles’ (https://wordpress.org/plugins/per-post-scripts-and-styles/) for this, but I see now that it hasn’t been updated in 5 years. It does however work with the latest WP.
An alternative option, which is a bit more complicated, it to create a special plugin or a child theme for this, so you can just write your JS in a dedicated file.
I’m sorry I can’t really help you any further than this. If you have questions regarding Trackserver directly, please let me know.
Best regards,
Martijn.