Title: Leaflet Plugin: Leaflet.Elevation (height profile)
Last modified: November 2, 2017

---

# Leaflet Plugin: Leaflet.Elevation (height profile)

 *  [sinhex](https://wordpress.org/support/users/sinhex/)
 * (@sinhex)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/leaflet-plugin-leaflet-elevation-height-profile/)
 * Hello,
 * i want to hack into the Trackservers Leaflet Libraries the Leaflet.Elevation 
   Plugin:
    [https://github.com/MrMufflon/Leaflet.Elevation](https://github.com/MrMufflon/Leaflet.Elevation)
   you can see working static html test here, this is how it looks: [https://dev.peterscheerer.de/playground/leaflet/02/example_gpx.html](https://dev.peterscheerer.de/playground/leaflet/02/example_gpx.html)
 * The main problem i have: i don’t know how to hook in the current Track(s) from
   the Trackservers Database so the leaflet.elevation code can read it.
 * The Plugin itself is working, i loaded into trackserver.php:
 *     ```
       				wp_enqueue_script( 'leaflet-gpx', TRACKSERVER_JSLIB . 'leaflet-gpx/gpx.js', array(), false, true );
       				wp_enqueue_script( 'leaflet-elevation', TRACKSERVER_JSLIB . 'leaflet-elevation-0.0.4/leaflet.elevation-0.0.4.min.js', array(), false, true );
       				wp_enqueue_style( 'leaflet-elevation', TRACKSERVER_JSLIB . 'leaflet-elevation-0.0.4/leaflet.elevation-0.0.4.css' );
       				wp_enqueue_script( 'd3', TRACKSERVER_JSLIB . 'd3/d3.v3.min.js', array(), false, true );
       ```
   
 * and i put this code into trackserver.js
 *     ```
                       var el = L.control.elevation({
                               theme: "steelblue-theme",
                               width: 400,
                               collapsed: true,
                        });
   
                        el.addTo(map);  
   
   
               		var g=new L.GPX("./test.gpx", {async: true});
   
   
                        g.on("addline",function(e){
       	                   el.addData(e.line);
                        });
       ```
   
 * what i want to do is now to change the hardcoded “./test.gpx” url into the current
   Track from Trackserver.
 * Any Ideas? Thanks pete
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fleaflet-plugin-leaflet-elevation-height-profile%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [kabouton](https://wordpress.org/support/users/kabouton/)
 * (@kabouton)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/leaflet-plugin-leaflet-elevation-height-profile/#post-9645431)
 * Sinhex
    Thats the same plugin I use. Please keep us posted how you do it. Thanks
 *  Plugin Author [tinuzz](https://wordpress.org/support/users/tinuzz/)
 * (@tinuzz)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/leaflet-plugin-leaflet-elevation-height-profile/#post-9646752)
 * Hi,
 * When Trackserver gets tracks from the database, it only uses the coordinates,
   not the timestamps or the elevation, because there wasn’t really any useful way
   to present them. The tracks are served in a format called ‘polyline’, that doesn’t
   have room for other data than coordinates.
 * If you want to create an altitude graph, a different format is needed. At one
   point, Trackserver supported GeoJSON, but that was never really used, and at 
   current, it doesn’t work.
 * See [https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L96](https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L96)
 * At the very least, you’d have to expand the function ‘send_as_geojson’ ([https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L3310](https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L3310))
   to include elevation data and maybe also the timestamps.
 * But that function isn;t called anywhere in the code, because at some point the
   whole interaction between te client en the server has been redesigned and GeoJSON
   fell off the map, so to speak.
 * You would have to change the function ‘send_alltracks’ ([https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L3343](https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L3343))
   to send GeoJSON instead of Polyline, and then there may be some work needed on
   the JavaScript side as well.
 * So, in short: this is going to be quite some work. I’m afraid it’s not something
   I can dedicate a lot of time to, but I’m open to pull requests on Github.
 * Please let me know if you have any more questions!
 * Cheers,
    Martijn.
 *  Plugin Author [tinuzz](https://wordpress.org/support/users/tinuzz/)
 * (@tinuzz)
 * [8 years, 7 months ago](https://wordpress.org/support/topic/leaflet-plugin-leaflet-elevation-height-profile/#post-9646771)
 * Hm, I forgot about something. See that as the Elevation plugin also supports 
   GPX files, your best bet may be the GPX support in Trackserver.
 * Trackserver can send GPX files with multiple tracks inside, except this functionality
   is only implemented in the [tslink] shortcode and is currently not suitable for
   consumption in other ways. But that could be a lot easier to implement than GeoJSON
   support.
 * [https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L1772](https://github.com/tinuzz/wp-plugin-trackserver/blob/master/trackserver.php#L1772)
 * I think I can do something in that respect. I am preparing a new Trackserver 
   release, it should be here before the end of the year with a lot of new features.
   I will have a look and see if I can improve the support for different formats
   a little.
 * Cheers,
    Martijn.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Leaflet Plugin: Leaflet.Elevation (height profile)’ is closed to new 
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/trackserver.svg)
 * [Trackserver](https://wordpress.org/plugins/trackserver/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/trackserver/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/trackserver/)
 * [Active Topics](https://wordpress.org/support/plugin/trackserver/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/trackserver/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/trackserver/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [tinuzz](https://wordpress.org/support/users/tinuzz/)
 * Last activity: [8 years, 7 months ago](https://wordpress.org/support/topic/leaflet-plugin-leaflet-elevation-height-profile/#post-9646771)
 * Status: not resolved