adds gpx rte tag to maps

This commit is contained in:
Christian Beutel
2024-05-05 12:31:08 +02:00
parent 844d5771e8
commit 930feda4d6
7 changed files with 15 additions and 14 deletions

View File

@@ -79,7 +79,7 @@
weight: 5,
},
gpx_options: {
parseElements: ["track"] as any,
parseElements: ["track", "route"] as any,
},
marker_options: {
startIcon: L.AwesomeMarkers.icon({
@@ -93,7 +93,7 @@
shadowUrl: "",
},
})
.on("loaded", function (e) {
.on("loaded", function (e) {
map.fitBounds(e.target.getBounds());
})
.addTo(map);

View File

@@ -79,7 +79,7 @@
"language": "Taal",
"latitude": "Breedtegraad",
"license": "Licentie",
"list": "{n, plural, =1 {lijst} other {lijsten}}",
"list": "{n, plural, =1 {Lijst} other {Lijsten}}",
"location": "Locatie",
"login": "Inloggen",
"logout": "Uitloggen",
@@ -135,7 +135,7 @@
"stop-drawing": "",
"summit-book": "Bergtopboek",
"text": "Tekst",
"trail": "{n, plural, =1 {wandelroute} other {wandelroutes}}",
"trail": "{n, plural, =1 {Wandelroute} other {Wandelroutes}}",
"trails-for-you": "Wandelroutes voor jou",
"units": "Eenheden",
"upload-file": "Bestand uploaden",

View File

@@ -28,15 +28,17 @@ export async function gpx2trail(gpxString: string) {
const totals = gpx.getTotals()
const points = gpx.trk?.at(0)?.trkseg?.at(0)?.trkpt
const startPoint = points?.at(0);
const trackPoints = gpx.trk?.at(0)?.trkseg?.at(0)?.trkpt
const routePoints = gpx.rte?.at(0)?.rtept;
const startPoint = trackPoints?.at(0) ?? routePoints?.at(0);
if (startPoint) {
trail.lat = startPoint.$.lat
trail.lon = startPoint.$.lon
}
}
const startTime = points?.at(0)?.time;
const endTime = points?.at((points?.length ?? 1) - 1)?.time
const startTime = trackPoints?.at(0)?.time;
const endTime = trackPoints?.at((trackPoints?.length ?? 1) - 1)?.time
if (startTime && endTime && !trail.date) {
trail.date = startTime.toISOString()

View File

@@ -17,7 +17,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
__TOGEOJSON: '/vendor/leaflet-elevation/libs/togeojson.umd.js',
__LGEOMUTIL: '/vendor/leaflet-elevation/libs/leaflet.geometryutil.js',
__LALMOSTOVER: '/vendor/leaflet-elevation/libs/leaflet.almostover.js',
__LHOTLINE: '/vendor/leaflet-elevation/libs/leaflet-hotline.min.js',
__LHOTLINE: '/vendor/leaflet-elevation/libs/leaflet-hotline.js',
__LDISTANCEM: '/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js',
__LEDGESCALE: '/vendor/leaflet-elevation/libs/leaflet-edgescale.min.js',
__LCHART: '/vendor/leaflet-elevation/src/components/chart.js',
@@ -452,7 +452,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
.then(() => {
layer.eachLayer((trkseg) => {
if (trkseg.feature.geometry.type != "Point") {
let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2] * (this.options.altitudeFactor || 1)) });
let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], (coords[2] * (this.options.altitudeFactor || 1)) || 0) });
let line = L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, {
renderer: L.Hotline.renderer(),
min: isFinite(this.track_info[prop + '_min']) ? this.track_info[prop + '_min'] : 0,

View File

@@ -77,7 +77,7 @@
weight: 5,
},
gpx_options: {
parseElements: ["track"],
parseElements: ["track", "route"],
},
marker_options: {
startIcon: L.AwesomeMarkers.icon({

View File

@@ -211,7 +211,7 @@
weight: 5,
},
gpx_options: {
parseElements: ["track"],
parseElements: ["track", "route"],
},
marker_options: {
startIcon: L.AwesomeMarkers.icon({

View File

@@ -243,7 +243,6 @@ https://github.com/iosphere/Leaflet.hotline/
for (i = 0, dataLength = this._data.length; i < dataLength; i++) {
path = this._data[i];
for (j = 1, pathLength = path.length; j < pathLength; j++) {
pointStart = path[j - 1];
pointEnd = path[j];