Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
Export GPX route from leaflet map

I'm trying to find a way of producing a GPX string from a Leaflet map so I can then save it into my DB. I am using Leaflet Routing Machine to create the route and then display it on an embedded map. So far, I found many ways to import a GPX to Leaflet but I cannot figure out a way to do the opposite.

So far, my (simplified) code to display the map and generate the route is as it follows:

    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.2.0/dist/leaflet.css" />
    <link rel="stylesheet" href="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.css" />
    <script src="https://unpkg.com/leaflet@1.2.0/dist/leaflet.js"></script>
    <script src="https://unpkg.com/leaflet-routing-machine@latest/dist/leaflet-routing-machine.js"></script>
    
    <link rel="stylesheet" href="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.css" />
    <script src="https://unpkg.com/leaflet-control-geocoder/dist/Control.Geocoder.js"></script>




<div id="map" class="map"></div>
        



<style>
        .map {
            position: absolute;
            width: 50%;
            height: 50%;
            justify-content: right;         
        }
</style>



<script>
            var map = L.map('map').
            setView([40.416729,-3.703339], 5);
                
            L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
                attribution: '© OpenStreetMap contributors'
            }).addTo(map);
            
            L.Routing.control({
                routeWhileDragging: true,
                geocoder: L.Control.Geocoder.nominatim()    
            }).addTo(map);
        
</script> 

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I created recently the small Leaflet Plugin L.ConvertCoords, which allows you to import (parse) and export (convert) layers in different Formats:

var gpxString = L.ConvertCoords.GPX.convert(layer);

In the back I use the library toGPX

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda