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

243
Visualizações
How to get longitude and latitude data from an array inside object and display them as google map link on output

How can I get the coordinates and display them as a Google Maps link on the output? I couldn't figure it out and any advice would be much helpful. Thank you. API data content is linked as a pic on below. [`

function searchCity(city) {
    //var r=JSON.parse(xhr.responseText);
    document.getElementById("searchvalues").innerHTML = "Search by City" + "<br>";
    //structure table
    var output = "<tr><th> Location </th><th> City </th><th> Phone </th><th> Vaccine Type </th><th> Map Link</th></tr>";
    var searchid;
    var map = obj.point{coordinates:[]};;
    for (var i = 0; i < r.length; i++) {
        var obj = r[i];
        searchid = obj.city.toUpperCase(); 
        if (searchid.startsWith(city.toUpperCase())) {
            output += "<tr><td>";
            output += obj.location;
            output += "</td><td>";
            output += obj.city;
            output += "</td><td>";
            output += obj.phone;
            output += "</td><td>";
            output += obj.vaccinetype;
            output += "</td><td>";
            output += <a href='https:www.google.com/maps/search/?api=1&query=' + map + ' target=_blank'> Click here to see map </a>;
            output += "</td></tr>";            
            
        }
    }
    document.getElementById("searchresults").innerHTML = output;
}

`]1

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

0

obj.point.coordinates try it

it is an array

var map = obj.point{coordinates:[]};; always don't change, you can set coordinates to link same as :

let coordinate = obj.point.coordinates.reverse().toString();
output += <a href='https:www.google.com/maps/search/?api=1&query=' + coordinate + ' target=_blank'> Click here to see map </a>;

It same as :

function searchCity(city) {
//var r=JSON.parse(xhr.responseText);
document.getElementById("searchvalues").innerHTML = "Search by City" + "<br>";
//structure table
var output = "<tr><th> Location </th><th> City </th><th> Phone </th><th> Vaccine Type </th><th> Map Link</th></tr>";
var searchid;
for (var i = 0; i < r.length; i++) {
    var obj = r[i];
    searchid = obj.city.toUpperCase(); 
    if (searchid.startsWith(city.toUpperCase())) {
        output += "<tr><td>";
        output += obj.location;
        output += "</td><td>";
        output += obj.city;
        output += "</td><td>";
        output += obj.phone;
        output += "</td><td>";
        output += obj.vaccinetype;
        output += "</td><td>";
        let coordinate = obj.point.coordinates.reverse().toString();
        output += <a href='https:www.google.com/maps/search/?api=1&query=' + coordinate + ' target=_blank'> Click here to see map </a>;
        output += "</td></tr>";            
        
    }
}
document.getElementById("searchresults").innerHTML = output;
}
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