Newer
Older
gpx_web_viewer / js / gpx.js
@GallaFrancesco GallaFrancesco on 28 Dec 2022 896 bytes first
var map = L.map('map');

L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: 'Map data &copy; <a href="http://www.osm.org">OpenStreetMap</a>'
}).addTo(map);

function addGPX(map, gpx, lineColor) {
    new L.GPX(gpx, {
            async: true,
            marker_options: {
                startIconUrl: 'images/pin-icon-start.png',
                endIconUrl: 'images/pin-icon-end.png',
                shadowUrl: 'images/pin-shadow.png'
            },
            polyline_options: {
                color: lineColor,
                opacity: 1,
                weight: 3,
                lineCap: 'round'
            }
    }).on('loaded', function(e) {
        map.fitBounds(e.target.getBounds());
    }).addTo(map);
}

addGPX(map, 'http://localhost:8888/tracks/turin_09122022.gpx', 'red')
addGPX(map, 'http://localhost:8888/tracks/biella_27122022.gpx', 'blue')