Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I show multiple tracks in separate layers in one map? #2

Closed
monora opened this issue Mar 30, 2023 · 1 comment
Closed

How do I show multiple tracks in separate layers in one map? #2

monora opened this issue Mar 30, 2023 · 1 comment

Comments

@monora
Copy link

monora commented Mar 30, 2023

In your blog post Danfengshan I see two tracks, which are shown and can be downloaded separetly. How does your input GPX file look like to produce this result?

I tried one file with two tracks, but they are shown in the same layer. How can I accomplish to load each in a separate layer?

This is my test file.

<gpx version="1.1">
  <metadata>
    <name>My Hiking Trip</name>
  </metadata>
  <trk>
    <name>Track 1</name>
    <trkseg>
      <trkpt lat="51.5072" lon="-0.1276"></trkpt>
      <trkpt lat="51.5067" lon="-0.1272"></trkpt>
    </trkseg>
  </trk>
  <trk>
    <name>Track 2</name>
    <trkseg>
      <trkpt lat="51.5080" lon="-0.1276"></trkpt>
      <trkpt lat="51.5100" lon="-0.1276"></trkpt>
    </trkseg>
  </trk>
</gpx>

I checked the code for layer creation in gpx.html:

  // Create map and layers
  var map = L.map(mapid, { fullscreenControl: true, scrollWheelZoom: false });
  {{ $layers := site.Params.gpx.layers }}

But did not find out, how the site.params.gpx.layers array is initialized.

@monora
Copy link
Author

monora commented Apr 1, 2023

After further investigation, I found the solution: The different tracks must be in different gpx files and specified in the hugo markdown like so:

 {{< gpx "track-1.gpx" "track-2.gpx">}}

An example in your README could be helpful for others. I would prefer a solution, where the user would only need one gpx file with several tracks. But this would be a different implementation breaking the current behaviour.

@monora monora closed this as completed Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant