Raruto / leaflet-elevation

Leaflet plugin that allows to add elevation profiles using d3js
GNU General Public License v3.0
254 stars 82 forks source link

Add support for geojson tracks in `L.GpxGroup` library #228

Closed Raruto closed 1 year ago

Raruto commented 1 year ago

Close: https://github.com/Raruto/leaflet-elevation/issues/225


How to use

Ref: https://github.com/Raruto/leaflet-elevation/issues/225#issuecomment-1341141730

let tracks = [
  // a string pointing to a gpx file (URL)
  "tracks/20131006.gpx",
  "tracks/20131110.gpx",

  // a geojson object track (feature collection)
  {
    "type": "FeatureCollection",
    "features": [{
      "type": "Feature",
      "geometry": {
        "type": "MultiLineString",
        "coordinates": [
          [
            [
              18.8793834,
              47.5757454,
              336.399
            ],
            [
              18.879521,
              47.5757001,
              336.243
            ],
            [
              18.879616,
              47.575628,
              336.476
            ],
            [
              18.8798517,
              47.5755253,
              338.85
            ],
            [
              18.8801746,
              47.5753281,
              337.622
            ],
            [
              18.8803667,
              47.5751841,
              335.793
            ],
            [
              18.8806468,
              47.5750652,
              334.178
            ]
          ]
        ]
      },
      "properties": {
        "name": "2013/10/06 - Bronz-barlang, Karády-lak, festékföld égető kemencék",
        "number": 1
      }
    }]
  },

  // another geojson object track (feature collection)
  {
    "type": "FeatureCollection",
    "features": [{
      "type": "Feature",
      "geometry": {
        "type": "MultiLineString",
        "coordinates": [
          [
            [
              18.8793834,
              47.5757454,
              336.399
            ],
            [
              18.879521,
              47.5757001,
              336.243
            ],
            [
              18.879616,
              47.575628,
              336.476
            ],
            [
              18.8798517,
              47.5755253,
              338.85
            ],
            [
              18.8801746,
              47.5753281,
              337.622
            ],
            [
              18.8803667,
              47.5751841,
              335.793
            ],
            [
              18.8806468,
              47.5750652,
              334.178
            ]
          ]
        ]
      },
      "properties": {
        "name": "2013/10/06 - Bronz-barlang, Karády-lak, festékföld égető kemencék",
        "number": 1
      }
    }]
  }

];

routes = L.gpxGroup(tracks, gpxGroupOpts });