Page 1 of 2
Geocoding issue
Posted: Wed Feb 17, 2021 5:52 pm
by PaulDouBret
Hi,
I am a LiveCode amateur and I have a problem that seems to have appeared recently.
A few weeks ago, everything was smooth and OK, but now, I don’t get any answer to my geocoding code line.
Using my
usual Google geocoding line (I have the proper API key),
https://maps...., returns
empty when called from my Livecode app.
It returns the
right answer (in JSON format) when called directly from the browser (Safari).
I then tried to use a different geocoding system (thinking that Google was too professional for me) and I used Nominatim.
Same problem: the result/return is empty while I have the same good result when the very same
https://nominatim.... line is inserted directly into the browser.
Using two different geocoding systems that produce the same result makes me think that it could be a LiveCode problem/misuse. But I can’t figure it out.
Could you help?
PaulDouBret
Re: Geocoding issue
Posted: Thu Feb 18, 2021 9:22 am
by glenn9
Hi,
Not sure if its of any help to know, but I've just tested both my google and bing maps APIs within LC and they both seem to be working as expected.
Regards,
Glenn
Re: Geocoding issue
Posted: Thu Feb 18, 2021 10:10 am
by liveme
PaulDouBret wrote: ↑Wed Feb 17, 2021 5:52 pm
But I can’t figure it out. Could you help? PaulDouBret
Hi @Paul, I have an account at OSM, if you wish to share some code I can run test on my side but just for OSM.
Just as you wish !

Terii
PM / Telegram
Re: Geocoding issue
Posted: Thu Feb 18, 2021 1:23 pm
by simon.schvartzman
Hi Paul, where are you running your App? On the desktop or in Mobile? May be it would be worth to check if the same happens on both environments.
Also (you probably have done this but just in case) I'd suggest you to somehow "capture" the API request issued by your LC App and try it exactly as it is in the browser and see what happens...may be there is some spurius character somehow introduced on the request...
What kind of geocoding request are you issuing? By coordinates? By POI? If by coordinates are you using exactly the same coordinates in your call from Safari as from your LC App?
Hope some of the above helps to find out what is going on
Regards
Re: Geocoding issue
Posted: Thu Feb 18, 2021 4:28 pm
by PaulDouBret
Hi guys,
Thanks for your interest in my problem!
To try to answer all questions:
I am running my App on a Mac, only.
The code I am using is:
put "https://maps(dot)google(dot)apis(dot)com/maps/api/geocode/json?address=1+Place+du+Capitole+31000+Toulouse+France&sensor=false&key=my_Key" into loriginalrequest
put URL loriginalrequest into lrawcoordinates
I put here "(dot)" instead of "." since this forum security don't let me insert the original line (if you can tell me how to bypass that security issue, thanks!!!)
Of course
my_Key is a valid Google API key. I can give it to you if needed.
lrawcoordinates is supposed to be a JSON format file that I then analyze to get coordinates (location=)
It is empty form LC, and correct from Safari...
I copied what my app produces as
loriginalrequest (debug mode/variables) and pasted it in Safari as it is. That gives me a good result.
I suppose that is what Simon means by "capture".
Terii, is the above code good enough for you to test on OSM?
Glenn, thanks. I am sure I do something wrong... but what.
Above all... it used to work perfectly done moth ago. What has changed!?
Cheers
Paul
Re: Geocoding issue
Posted: Thu Feb 18, 2021 6:14 pm
by liveme
Hmm, month ago ! Are you the only one to use it or did you share the app (..and that same key) with many other users too ? If i remember from long ago... there is/was a (quite large) limitation in the number of times (per month) Google would allow one to run requests ? Not a problem if your the only user...worth checking this limitation if you can just in case you havent done any code change by accident...and google hasn't done some rules updates on their side purposely

.
(One reason i wouldnt share a personal key on a forum I think

).
* Just taking a snaphot picture of code lines is worth when short like yours)
... We ll give an eyes at it, i m on Linux.
Re: Geocoding issue
Posted: Thu Feb 18, 2021 7:20 pm
by PaulDouBret
Yes, good idea, and yes I am aware of the limitations imposed by Google.
The App is used only by a small Volunteer Association (helping teaching sick children) and, thanks god, there are not so many "Customers" in our area.
The number of requests is a few per month, very far from the Google limit!
Nope, the code did not change. In fact that App works fine (or fine enough) and I have to modify the code only 2 or 3 times per year. I know it's marvelous, isn't it !!!
Maybe I am missing an external, or something like this. But why now and not before...?
Regards
Paul
PS: I upgraded my LC to the latest version, just in case. But no, still no change.
PS2: Do you think Safari could be at stake? Do you think I could try to declare Firefox as my default browser, just for a trial?
PS3: Thanks for th tip on taking a snapshot picture
Re: Geocoding issue
Posted: Thu Feb 18, 2021 7:33 pm
by liveme
No problem, I do run compatibility access test on at least 2 Browser, Brave is my main and Firefox is my "most compatible" for sometimes, - YES - things work well on FF...and pose some problems still in BRAVE.
I keep Chrome at hand too and even had Opera installed just for testing purpose.
So, yes, I would install some other browsers to test the same page and avoid searching problems where they are none !
could be simple as this... Browser version issues.

Re: Geocoding issue
Posted: Thu Feb 18, 2021 8:29 pm
by simon.schvartzman
Paul I've tested your API request (obviously with my key) and it returned the expected JSON, my environment is:
macOS Mojave 10.14.6
LC 9.6.1
any difference with yours?
Code: Select all
put "https://maps.googleapis.com/maps/api/geocode/json?address=1+Place+du+Capitole+31000+Toulouse+France&sensor=false&key=XXXX" into theURL
put URL theURL into theResult
{
"results" : [
{
"address_components" : [
{
"long_name" : "1",
"short_name" : "1",
"types" : [ "street_number" ]
},
{
"long_name" : "Place du Capitole",
"short_name" : "Place du Capitole",
"types" : [ "route" ]
},
{
"long_name" : "Toulouse",
"short_name" : "Toulouse",
"types" : [ "locality", "political" ]
},
{
"long_name" : "Haute-Garonne",
"short_name" : "Haute-Garonne",
"types" : [ "administrative_area_level_2", "political" ]
},
{
"long_name" : "Occitanie",
"short_name" : "Occitanie",
"types" : [ "administrative_area_level_1", "political" ]
},
{
"long_name" : "France",
"short_name" : "FR",
"types" : [ "country", "political" ]
},
{
"long_name" : "31000",
"short_name" : "31000",
"types" : [ "postal_code" ]
}
],
"formatted_address" : "1 Place du Capitole, 31000 Toulouse, France",
"geometry" : {
"bounds" : {
"northeast" : {
"lat" : 43.6038975,
"lng" : 1.4442977
},
"southwest" : {
"lat" : 43.6037239,
"lng" : 1.4438412
}
},
"location" : {
"lat" : 43.6038238,
"lng" : 1.4442056
},
"location_type" : "ROOFTOP",
"viewport" : {
"northeast" : {
"lat" : 43.60515968029149,
"lng" : 1.445418430291502
},
"southwest" : {
"lat" : 43.6024617197085,
"lng" : 1.442720469708498
}
}
},
"place_id" : "ChIJocPH7Z28rhIRfUhMt9N8Ny8",
"types" : [ "premise" ]
}
],
"status" : "OK"
}
Re: Geocoding issue
Posted: Thu Feb 18, 2021 11:40 pm
by PaulDouBret
Simon,
Yes, the JSON is as expected and is what I used to get. And what I get when running directly with Safari.
I am using macOS BigSur 11 2 1 and LC 9 6 1
liveme, I will try Firefox but I will be away from my Mac for a couple of days. So I'll resume posting the results next Monday.
Thanks to y'all and have a good weekend
Paul
Re: Geocoding issue
Posted: Fri Feb 19, 2021 10:20 am
by PaulDouBret
Hi guys
I managed to have some time on my Mac...
Changing the default browser to Firefox does not improve the App response.
So I created a new App, with just a few lines, just to test the geocoding part of the code and I discovered a few things:
the put URL command takes between 7 and 10 s to execute (!!!)
while the launch URL command is instantaneous (and display the good result in the browser)
removing the "//" in the http line (as indicated in LC help) makes the put URL command response instantaneous but there is still no result !
The code is:
on mouseUp
put "Start: " & the seconds into field "Timing"
put field "Address" into laddress
-- formatting the address
replace "," with "+" in laddress
replace " " with "+" in laddress
replace "é" with "e" in lAddress
replace "ê" with "e" in lAddress
replace "è" with "e" in lAddress
replace "ç" with "c" in lAddress
replace "à" with "a" in lAddress
replace return with "+" in laddress
replace "++" with "+" in laddress
-- geocoding
put "https://maps[dot]googleapis[dot]com/maps/api/geocode/json?address=" & laddress & "+France&sensor=false&key=my_Key" into loriginalrequest
put return & "Step 1: " & the seconds after field "Timing"
put URL loriginalrequest into field "Result"
put return & "Step 2: " & the seconds after field "Timing"
replace "//" with "" in loriginalrequest
put URL loriginalrequest into field "Result"
put return & "Step 3: " & the seconds after field "Timing"
launch URL loriginalrequest
put return & "Step 4: " & the seconds after field "Timing"
end mouseUp
My "Timing" field shows:
Start: 1613725641
Step 1: 1613725641
Step 2: 1613725648
Step 3: 1613725649
Step 4: 1613725649
and my "Result" field is still empty...
I am puzzled
Regards
Paul
Re: Geocoding issue
Posted: Fri Feb 19, 2021 12:16 pm
by bogs
Just to throw some soup on your experiment, look into '
load url' in the lessons.
Re: Geocoding issue
Posted: Fri Feb 19, 2021 1:23 pm
by Thierry
Hi Paul,
Code: Select all
on mouseUp
-- .....
put "https://maps......" into loriginalrequest
put return & "Step 1: " & the seconds after field "Timing"
put URL loriginalrequest into field "Result"
put return & "Step 2: " & the seconds after field "Timing"
replace "//" with "" in loriginalrequest
put URL loriginalrequest into field "Result"
put return & "Step 3: " & the seconds after field "Timing"
launch URL loriginalrequest
put return & "Step 4: " & the seconds after field "Timing"
end mouseUp
Just wandering if this would help you to see better your results?
Change your 2 lines:
put URL loriginalrequest
into field "Result"
with:
put URL loriginalrequest
&cr&cr after field "Result"
otherwise, you'll miss the 1st result, except if you're using the debugger.
Does that make sense?
Thierry
Re: Geocoding issue
Posted: Fri Feb 19, 2021 1:50 pm
by PaulDouBret
Hi bogs and Thierry
Yes I am using the debugger, so I go step by step.
And the second call for "put URL..." was just for timing. When I remove these lines... no progress.
I tried the
load command as
bogs suggested. No difference. It looks like the URL does not respond...or respond empty.
I am getting very upset
By the way, when using the
load command, the
pURLStatus is empty too... no "cached", "dowloaded" or other message as we could expect. Just empty
Any other idea?
Best regards to y'all
Paul
Re: Geocoding issue
Posted: Fri Feb 19, 2021 2:08 pm
by bogs
PaulDouBret wrote: ↑Fri Feb 19, 2021 1:50 pm
I am getting very upset
Well don't do that, or you'll start making mistakes (least it seems I do when I get frustrated heh).
I've never seen something Thierry posted not work, did you try his solution ?
Alternately, try a different (translate as simpler) address. If that works, it may be something as simple as an issue in the address your using.