Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2020: Join us May 11 - 14, 2020 in Phoenix, AZ. Register early and save $400. Learn More
Highlighted
hencovanee
Contributor II

Get geolocation (latitude and longitude) using Google API

Hi all,

I have an issue when getting the latitude and longitude for a city. The problem is as follows: roci

Lets say I have 10 cities. I run the script below. The first time I get a result for 8 cities, the next time for 7, then for 5 or 8, but never the full 10. The result is totally random. So, the first time city A can be found, the next time the result is empty. What am I doing wrong?

Script:

Location:
LOAD 
        City
      , Country
FROM [Dimensions QVD\LocationTmp.qvd] (qvd)
;

Let noRows = NoOfRows('Location')-1;

for i=0 to $(noRows)
    let b = peek('City',$(i),'Location');
    let c = peek('Country',$(i),'Location');
     
GeocodeResponse:
LOAD
'$(b)'                                    as LocationKey,
([result/geometry/location/lat])          as Latitude,
([result/geometry/location/lng])          as Longitude
FROM [http://maps.googleapis.com/maps/api/geocode/xml?address=$(b)+$(c)&sensor=false] (XmlSimple, Table is [GeocodeResponse]);
sleep 500;
next i;

1 Reply
Frank_Hartmann
Honored Contributor II

Re: Get geolocation (latitude and longitude) using Google API

I guess its because you dont have an API Key.

You can register here:

https://console.developers.google.com/projectselector/apis/credentials?pli=1&supportedpurview=projec...

hope this helps