Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

167
Vistas
Save lat and lng on leaflet map click event

I am new to leaflet and js and I am looking for a way to get the latitude and longitude from a leaflet map on a click event and pass it into an HTML text input.

I tried to use

map.on('click', function(e) {
 var latitude = e.latlng.lat; 
 var longitude = e.latlng.lng;     
 var latt = document.getElementById("idfromHTML").innerHTML(latitude);
});

to save them on a variable, yet I cant seem to pass them in an HTML tag. Any help would be appreciated.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you have an <input> you need to add a value:

document.getElementById("idfromHTML").value = latitude;

if you have a other html element you need to change the innerHTML:

document.getElementById("idfromHTML").innerHTML = latitude;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda