94 online 3 members  + Join RP Base  +
FreeScript

leaflet-elevation

by Raruto  ·  version 2026.11.14  ·  updated 2 days ago

No reviews yet

Downloads
0
Reviews
0
Size
214 KB
Code check
Checked
Licence
GPL-3.0
Released
Nov 2026

A Leaflet plugin that allows to add elevation profiles using native SVG and Canvas elements

leaflet-elevation
leaflet-elevation.js
A Leaflet plugin that allows to add elevation profiles using native SVG and Canvas elements.

Examples
Topic, Demos

Data sources, GPX, GeoJSON, KML, TCX, file upload, textarea
Multiple tracks, GeoJSON tracks, GPX tracks, hover to toggle, click to toggle
Profiles, Slope, speed, temperature, cadence, heart rate and pace, bathymetry
Appearance, Colors, gradient, summary, chart labels, translations
Layout and controls, Multiple maps, stacked charts, hide map, hide chart, clear button, collapse button
Map interaction, Follow marker, near-track hover, edge scale, GPX waypoints, GeoJSON waypoints
Live data and animation, Live tracking, walking marker

Initially based on the work of Felix “MrMufflon” Bache

How to use
  1. include CSS & JavaScript
    
    ...
     html, body, #map, #elevation-div { height: 100%; width: 100%; padding: 0; margin: 0; } #map { height: 75%; } #elevation-div {	height: 25%; font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; } 

    
    
    

    
    
    
    ...
  1. choose the div container used for the slippy map
    
    ...
    
    ...
  1. create your first simple “leaflet-elevation” slippy map
    
      // Instantiate map (leaflet-ui).
      const map = new L.Map('map', { mapTypeId: 'terrain', center: [41.4583, 12.7059], zoom: 5 });

      // Instantiate elevation control.
      const controlElevation = L.control.elevation({
        theme: "lightblue-theme",       // set chart and track colors.
        detached: true,                 // display the chart outside the map.
        elevationDiv: "#elevation-div", // optional: chart container (if missing, the chart is placed after the map).
      }).addTo(map);

      // Load a URL containing GeoJSON, GPX, KML, or TCX data.
      controlElevation.load("https://raruto.github.io/leaflet-elevation/examples/via-emilia.gpx");

Options
Option, Default, Description

detached, true, Render the chart outside the map.
elevationDiv, "#elevation-div", Selector for the detached chart container; if missing, the chart is placed after the map.
position, "topright", Map corner for the control when detached: false.
collapsed, false, Start with the map-attached chart collapsed.
closeBtn, true, Show the chart toggle button.
autohide, false, Hide the map-attached chart when the pointer leaves it.
autohideMarker, true, Hide the map indicator when it is not in use.
autofitBounds, true, Fit the map to a loaded track.
followMarker, true, Center the map on the chart's current point.
zFollow, false, When numeric, minimum zoom while following the current point; change with setZFollow().
theme, "lightblue-theme", Chart and track theme: "lightblue-theme", "lime-theme", "steelblue-theme", "purple-theme", "yellow-theme", "red-theme", or "magenta-theme". Custom CSS themes are also supported.
`altitud

…