GPS coordinates
GPS coordinates
Hi all !
Is it possible to get GPS coordinates by address ?
Is it possible to get GPS coordinates by address ?
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: GPS coordinates
https://stackoverflow.com/questions/113 ... oordinates
Code: Select all
<script type="text/javascript">
var dir1 = "5th ave, new york";
var google_url = "http://maps.googleapis.com/maps/api/geocode/json?address=";
var sensor = "&sensor=false";
var resultado;
function myFunction(){
$.getJSON(
google_url+dir1+sensor,
function(result){
$( "body" ).append( "Latitude: " + JSON.stringify(result.results[0].geometry.bounds.northeast.lat) )
$( "body" ).append( "Longitude: " + JSON.stringify(result.results[0].geometry.bounds.northeast.lng) )
});
}
Re: GPS coordinates
Thanks it is excellent! But how to make it on a FWH 18.06 ?!
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Re: GPS coordinates
Code: Select all
#include "FiveWin.ch"
function Main()
local cGoogleURL := "http://maps.googleapis.com/maps/api/geocode/json?address="
local cAddress := "5th ave, new york"
local cSensor := "&sensor=false"
local cKey := "&key=" + MY_API_KEY
MsgInfo( WebPageContents( cGoogleURL + cAddress + cSensor + cKey ) )
return nil
https://developers.google.com/maps/docu ... sdk/signup
- Silvio.Falconi
- Posts: 4956
- Joined: Thu Oct 18, 2012 7:17 pm
Re: GPS coordinates
run ok
but Now how obtainthe Lat e long from that message ?
but Now how obtainthe Lat e long from that message ?
I use : FiveWin for Harbour August 2020 (Revision) - Harbour 3.2.0dev (r1712141320) - Bcc7.30 - xMate ver. 1.15.3 - PellesC
Re: GPS coordinates
if you want you can try Nominatim with its Web API.
For example
For example
Code: Select all
#include <fivewin.ch>
function Main()
local cGoogleURL := "https://nominatim.openstreetmap.org/search?format=json&q="
local cAddress := "5th ave, new york"
local aReturn, i, cTxt := ""
aReturn := hb_jsonDecode( WebPageContents( cGoogleURL + cAddress) )
if !empty(aReturn)
for i:=1 to len(aReturn)
cTxt += aReturn[i,"display_name"] + e"\r\n"
cTxt += aReturn[i,"lat"]+" "+aReturn[i,"lon"] + e"\r\n" + e"\r\n"
next
else
cTxt:="not found"
endif
MsgInfo(cTxt)
return nil
Re: GPS coordinates
Hello Antonino,
when I try your sample I get only a number as aReturn.
CAn you help us, please.
Best regards,
Otto
when I try your sample I get only a number as aReturn.
CAn you help us, please.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
Re: GPS coordinates
Otto:
This is correct:
Regards
This is correct:
Code: Select all
#include "FiveWin.ch"
function Main()
local cGoogleURL := "https://nominatim.openstreetmap.org/search?format=json&q="
local cAddress := "5th ave, new york"
local aReturn, i, cTxt := ""
// aReturn := hb_jsonDecode( WebPageContents( cGoogleURL + cAddress) ) // *** Change this ***
aReturn := WebPageContents( cGoogleURL + cAddress)
hb_jsondecode( aReturn, @aReturn )
if !empty(aReturn)
for i:=1 to len(aReturn)
cTxt += aReturn[i,"display_name"] + e"\r\n"
cTxt += aReturn[i,"lat"]+" "+aReturn[i,"lon"] + e"\r\n" + e"\r\n"
next
else
cTxt:="not found"
endif
MsgInfo(cTxt)
return nil
Saludos,
Carlos Gallego
*** FWH-20.07, xHarbour 1.2.3 Build 20190603, Borland C++7.30, PellesC ***
Carlos Gallego
*** FWH-20.07, xHarbour 1.2.3 Build 20190603, Borland C++7.30, PellesC ***
Re: GPS coordinates
Hello Antonino, hello Carlos,
Thank you so much. All working.
Best regards,
Otto
Thank you so much. All working.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
********************************************************************
Re: GPS coordinates
I am not sure, but the different syntax of hb_jsondecode is relative the Harbour and XHarbour implementations.
You can do the get on browser and use some tools like JSON formatter to see that there are a lot of other information.
You can do the get on browser and use some tools like JSON formatter to see that there are a lot of other information.