Cloning the Export Feature
Display Multiple Instances of the Export/Download Feature.
By default the Export option (download the current Map in GPX, KML or GeoJSON format) is displayed in the Shortcode Header (clicking “More Details”) when embedding as well as on the Map Details page.
The following code uses the Waymark Callback Function to clone the Export option and adds copies of it to our page.
Like this…
The Export option is still accessible by clicking “Details”:
…another Export option gets added here too!
To achieve this, we pass the name of a JavaScript function to the Shortcode like this:
Waymark map_id="1647" loaded_callback="waymark_download"
Once defined on your page (accessible in the global scope), the following code will create the copies:
//Our callback function
function waymark_download(Waymark) {
//Get the container
const shortcodes = jQuery('.waymark-shortcode');
shortcodes.each(function() {
const shortcode = jQuery(this);
const exportContainer = jQuery('.waymark-meta-export_data', shortcode);
//Add after the Map
shortcode.after(exportContainer.clone());
//Add to target
jQuery('#export-here').append(exportContainer.clone())
});
}
Add the following target element to your page to specify where to display the Export option.
<div id="export-here"></div>