Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

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
Master II
Master II

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