Skip to content Skip to main navigation Skip to footer

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”:

Route Map
Journal Entry

This is a journal entry. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco.

Distance (km)
More Details

The information displayed here can be configured in Waymark > Settings > Meta.

More 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

    //Add to target 

Add the following target element to your page to specify where to display the Export option.

<div id="export-here"></div>