Coder Social home page Coder Social logo

kamelche / leaflet-elevation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from raruto/leaflet-elevation

0.0 0.0 0.0 5.11 MB

Leaflet plugin that allows to add elevation profiles using d3js

License: GNU General Public License v3.0

CSS 11.01% JavaScript 85.45% HTML 3.54%

leaflet-elevation's Introduction

leaflet-elevation.js

NPM version License

A Leaflet plugin that allows to add elevation profiles using d3js

Leaflet elevation viewer


For a working example see one of the following demos:


Initially based on the work of Felix “MrMufflon” Bache


How to use

  1. include CSS & JavaScript
    <head>
    ...
    <style> 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; } </style>
    
    <!-- leaflet-ui -->
    <script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
    <script src="https://unpkg.com/[email protected]/dist/leaflet-ui.js"></script>
    
    <!-- leaflet-elevation -->
    <link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation/dist/leaflet-elevation.css" />
    <script src="https://unpkg.com/@raruto/leaflet-elevation/dist/leaflet-elevation.js"></script>
    ...
    </head>
  2. choose the div container used for the slippy map
    <body>
    ...
    <div id="map"></div>
    ...
    </body>
  3. create your first simple “leaflet-elevation” slippy map
    <script>
      // Full list options at "leaflet-elevation.js"
      var elevation_options = {
    
        // Default chart colors: theme lime-theme, magenta-theme, ...
        theme: "lightblue-theme",
    
        // Chart container outside/inside map container
        detached: true,
    
        // if (detached), the elevation chart container
        elevationDiv: "#elevation-div",
    
        // if (!detached) autohide chart profile on chart mouseleave
        autohide: false,
    
        // if (!detached) initial state of chart profile control
        collapsed: false,
    
        // if (!detached) control position on one of map corners
        position: "topright",
    
        // Autoupdate map center on chart mouseover.
        followMarker: true,
    
        // Chart distance/elevation units.
        imperial: false,
    
        // [Lat, Long] vs [Long, Lat] points. (leaflet default: [Lat, Long])
        reverseCoords: false,
    
        // Summary track info style: "line" || "multiline" || false,
        summary: 'multiline',
    
      };
    
      // Instantiate map (leaflet-ui).
      var map = new L.Map('map', { mapTypeId: 'terrain', center: [41.4583, 12.7059], zoom: 5 });
    
      // Instantiate elevation control.
      var controlElevation = L.control.elevation(elevation_options).addTo(map);
    
      // Load track from url (allowed data types: "*.geojson", "*.gpx")
      controlElevation.load("https://raruto.github.io/leaflet-elevation/examples/via-emilia.gpx");
    
    </script>

Related: Leaflet-UI presets, QGIS Integration


Compatibile with: Leaflet 1.x compatible! leaflet-gpx 1.5 compatibile! d3.js v5 compatibile!


Contributors: MrMufflon, HostedDinner, ADoroszlai, Raruto

leaflet-elevation's People

Contributors

raruto avatar fgebhart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.