Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
Cómo encontrar long y lat desde la URL del mapa y luego hacerlo más dinámico al pasar long y lat como param

Soy nuevo en vue js y estoy atascado con la URL del mapa de Google incrustado. Tengo google y busqué mucho pero no obtengo lo que quiero. Tengo esta URL, por ejemplo: "https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d20041.58914746939!2d17.008093249999998!3d51.10479505!2m3!1f0!2f0!3f0 !3m2!1i1024!2i768!4f13.1!5e0!3m2!1spl!2spl!4v1644570663221!5m2!1spl!2spl"; y desde esta url estoy tratando de obtener la latitud y la longitud, para poder hacerlos más dinámicos y no solo codificarlos. ¡Cualquier ayuda será muy apreciada!

Hasta ahora probé esto a continuación, quiero pasar long y lat como param o como variable (+ lat + long...):

 computed: { src() { const url = "https://www.google.com/maps/embed?pb="; const params = new URLSearchParams({ center: `${20041.58914746939},${17.008093249999998}`, zoom: 15, size: "300x300", maptype: "terrain", }); return `${url}?${params}`; }, },
 // also tried with this example ( nothing seems to work): computed: { src() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition((position) => { console.log(position.coords.latitude, position.coords.longitude); const url = "https://www.google.com/maps/embed?pb="; const myLatlng = `${position.coords.latitude} , ${position.coords.longitude}`; const params = new URLSearchParams({ center: myLatlng, zoom: 15, size: "600x300", maptype: "terrain", }); console.log("params", params); console.log("mylatlong", myLatlng); return `${url}?${params}`; }); } }, },

y luego usar como accesorios en Iframe:

 <template> <iframe :src="src" class="map" /> </template>

ingrese la descripción de la imagen aquí

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si el formato de URL es siempre el mismo, tal vez pueda usar RegExp así:

 const url = 'https://www.google.com/maps/embed?pb=!1m14!1m12!1m3!1d20041.58914746939!2d17.008093249999998!3d51.10479505!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!5e0!3m2!1spl!2spl!4v1644570663221!5m2!1spl!2spl'; const matchLat = url.match(/!2d.*!3d/g)[0].match(/d.*!/g)[0]; const matchLon = url.match(/!3d.*!2m/g)[0].match(/d.*!/g)[0]; const lat = matchLat.substr(1, matchLat.length - 2); const lon = matchLon.substr(1, matchLon.length - 2); console.log('Lat: ', lat); console.log('Lon: ', lon);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!