leaflet-gpx icon indicating copy to clipboard operation
leaflet-gpx copied to clipboard

First style information is used for all segments

Open cyclingcat opened this issue 3 years ago • 1 comments

Hi there,

first of all thank you for this excellent Leaflet plugin. Exactly what I need for visualising my Garmin GPX tracks on a OSM-based map and straightforward to use. :+1:

I'm currently fiddling around with the various possibilities this plugin offers, including the possibility to process GPX style information. According to your documentation the <extensions> tag is a child of the <trkseg> tag. It generally works this way, however, if there is more than one <trkseg> element and I put different stylings into each of the segments, the style of the first <trkseg> is applied to the whole track. The <extensions> elements of the other sections seem to be ignored although I have set gpx_options: {joinTrackSegments: false} when creating the GPX object.

If I delete the whole <extensions> element inside the first <trkseg> element, the next <extensions> inside a <trkseg> element will be applied to the whole track. It seems as if always the first <extensions> element found in the GPX file gets applied to the track no matter of the surrounding <trkseg> element.

Is this a bug?

The cycling cat

cyclingcat avatar Jul 01 '21 06:07 cyclingcat

Okay, it was partly my fault. I accidentally used a very similar looking colour for the second <trkseg> (I should definitely buy new glasses! :laughing:) If each <trkseg> contains its own <extensions> element, it works as described. However, if the first <trkseg> doesn't contain an <extensions> element while the second does, the latter one gets applied to the first <trkseg> as well. One would expect that the default values (i. e. a blue line) would be applied for a segment without style information.

The cycling cat

cyclingcat avatar Jul 01 '21 07:07 cyclingcat