<p></p>
<p dir="auto">For discussion:</p>
<p dir="auto">I had a quick look, if we can offer this feature with very little effort. It seems <a href="https://github.com/mpetazzoni/leaflet-gpx">https://github.com/mpetazzoni/leaflet-gpx</a> could good be a good starting point. It offers gpx parsing/rendering out of the box.</p>
<p dir="auto">I haven't tested if this works with zip files. If in doubt we could show some error message, or simply a start point like we do today. Private traces are also visible (like on the example screenshots below), as long as the user is logged on.</p>
<p dir="auto"><a href="https://github.com/user-attachments/assets/9beb3c6d-1512-46d4-a411-32ac50a19f74">image.png (view on web)</a></p>
<p dir="auto">Click on "View Map"</p>
<p dir="auto">GPX trace is shown on map, including start and end point.</p>
<p dir="auto"><a href="https://github.com/user-attachments/assets/a8a36621-4f1e-4a9c-86bf-447d1b23e614">image.png (view on web)</a></p>
<p dir="auto">Based on a bit of prototyping:</p>
<pre class="notranslate"><code class="notranslate">diff --git a/app/assets/javascripts/embed.js.erb b/app/assets/javascripts/embed.js.erb
index 9a0ec07d3..159a67fc7 100644
--- a/app/assets/javascripts/embed.js.erb
+++ b/app/assets/javascripts/embed.js.erb
@@ -2,6 +2,7 @@
//= depend_on settings.local.yml
//= require leaflet/dist/leaflet-src
//= require leaflet.osm
+//= require leaflet-gpx
//= require i18n
//= require i18n/embed
@@ -51,6 +52,19 @@ window.onload = function () {
new L.OSM.HOT().addTo(map);
}
+ if (args.trace && /^\d+$/.test(args.trace)) {
+ var url = `/trace/${args.trace}/data.xml`;
+ new L.GPX(url, {
+ async: true,
+ markers: {
+ startIcon: <%= asset_path('leaflet-gpx/pin-icon-start.png').to_json %>,
+ endIcon: <%= asset_path('leaflet-gpx/pin-icon-end.png').to_json %>,
+ }
+ }).on('loaded', function(e) {
+ map.fitBounds(e.target.getBounds());
+ }).addTo(map);
+ }
+
if (args.marker) {
L.marker(args.marker.split(','), {icon: L.icon({
iconUrl: <%= asset_path('leaflet/dist/images/marker-icon.png').to_json %>,
diff --git a/app/views/traces/_trace.html.erb b/app/views/traces/_trace.html.erb
index f60eea7f1..0fa021161 100644
--- a/app/views/traces/_trace.html.erb
+++ b/app/views/traces/_trace.html.erb
@@ -49,7 +49,7 @@
<nav class="secondary-actions">
<ul>
<li>
- <%= link_to t(".view_map"), root_path(:mlat => trace.latitude, :mlon => trace.longitude, :anchor => "map=14/#
{trace.latitude}/#{trace.longitude}") %>
+ <%= link_to t(".view_map"), export_embed_path(:trace => trace.id) %>
</li>
<li>
<%= link_to t(".edit_map"), edit_path(:gpx => trace.id) %>
diff --git a/package.json b/package.json
index 7d19be0d2..27d8acf67 100644
--- a/package.json
+++ b/package.json
@@ -6,6 +6,7 @@
"js-cookie": "^3.0.0",
"leaflet": "^1.8.0",
"leaflet.locatecontrol": "^0.81.0",
+ "leaflet-gpx": "^2.0.0",
"osm-community-index": "^5.2.0",
"qs": "^6.9.4"
},
</code></pre>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/issues/387#issuecomment-2261498632">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLMDDIAGWVQHVU7LGLLZPFJYJAVCNFSM6AAAAABLZJGS26VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRRGQ4TQNRTGI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLM2KJIPNTQ4SARP2IDZPFJYJA5CNFSM6AAAAABLZJGS26WGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTUGZO5QQ.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/issues/387/2261498632</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/issues/387#issuecomment-2261498632",
"url": "https://github.com/openstreetmap/openstreetmap-website/issues/387#issuecomment-2261498632",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>