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

188
Vistas
Google Maps loadGeoJSON getGeometry.get() latlng disappear

Working through this tutorial from Google: https://developers.google.com/codelabs/maps-platform/google-maps-simple-store-locator

Github code here: https://github.com/googlecodelabs/google-maps-simple-store-locator

file: app.js functions: initMap(), calculateDistances();

My specific issue is that the latlng properties get lost somewhere. The map loads and all the map points load. However when I use the search/autocomplete the map.data is passed as parameter through this function (line 218)

const rankedStores = await calculateDistances(map.data, originLocation);

and is parsed with this function (line 234)

async function calculateDistances(data, origin) {
   const stores = [];
   const destinations = []
  // Build parallel arrays for the store IDs and destinations
  data.forEach((store) => {
     const storeNum = store.getProperty('storeid');
     const storeLoc = store.getGeometry().get();
     console.log(storeLoc);
     stores.push(storeNum);
     destinations.push(storeLoc);
});

in the console.log no geometries appear. the objects and respective latlng properties are there just not the actual coordinates. when I view the storeNum in console. they display as they should. I have verified the coordinates exist in jSON and they map points prove that the map.data.loadGeoJSON is working correctly. I am just going crazy trying to find where the coordinates went and how to ensure they get passed to the calculateDistances function. Any help is appreciated.

Screenshot A: screenshot A console.log(store.storeLoc)

Screenshot B:

screenshot B console.log(store.toUrlValue(6))

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

0

To retrieve the coordinates from a google.maps.LatLng object (which is what is returned by store.getGeometry().get()), use the .lat() function for latitude, the .lng() function for longitude, or the .toUrlValue() function for a comma separated string containing both.

async function calculateDistances(data, origin) {
   const stores = [];
   const destinations = []
  // Build parallel arrays for the store IDs and destinations
  data.forEach((store) => {
     const storeNum = store.getProperty('storeid');
     const storeLoc = store.getGeometry().get();
     console.log(storeLoc.toUrlValue(6));
     stores.push(storeNum);
     destinations.push(storeLoc);
});
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