NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: Poul Jensen on September 10, 2019, 06:35:14 AM

Title: Read clients lat/lon
Post by: Poul Jensen on September 10, 2019, 06:35:14 AM
Hi,

Can I read a clients lat/lon from his browser like Google does ?

Realise this probably needs javascript of which I know very little :-)

https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_geolocation

I guess I would place this somewhere in my login-procedure, but how do I get the lat lon from the javascript function and plug it into my sessionvariable ?

Cheers
/Poul
Title: Re: Read clients lat/lon
Post by: Matthew51 on September 10, 2019, 12:58:36 PM
I've use hidden fields to get values out of javascript when users log in. You just need to add a hidden field and a bit of code to the end of your javascript function:

document.[form name]_frm.[field equate].value = [javascript variable]

You can also use the NetTalk Javascript funtion SetSessionValue([value name], [javascript value]); and then read it in clarion using p_web.gsv([value name])

NetTalk also has location features built in though I haven't used it. You need to call p_web.GetLocation() at the start of the page, and then if the user accepts the data should be available in the following session variables on subsequent requests: _Longitude_, _Latitude_, _Altitude_, _Accuracy_, _AltitudeAccuracy_, _Heading_, _Speed_, _LocationUnixTime_, _LocationDate_=, _LocationTime_, _LocationError_.
Title: Re: Read clients lat/lon
Post by: Bruce on September 10, 2019, 07:31:21 PM
This is the right answer;

>> NetTalk also has location features built in.
>> You need to call p_web.GetLocation() at the start of the page,

<<  and then if the user accepts the data should be available in the following session variables on subsequent requests: _Longitude_, _Latitude_, _Altitude_, _Accuracy_, _AltitudeAccuracy_, _Heading_, _Speed_, _LocationUnixTime_, _LocationDate_=, _LocationTime_, _LocationError_.

Cheers
Bruce
Title: Re: Read clients lat/lon
Post by: Poul Jensen on September 10, 2019, 09:23:38 PM
Matthew & Bruce,

Thanks - just what I need.

Works great.

Cheers
/Poul