From Clomosy Docs
procedure GetCurrentLocation;
In mobile applications, a function is used to obtain the current location of the device. This function typically uses GPS or network-based location services to return the device's geographical coordinates (latitude and longitude).
Test this feature on mobile devices.
There are two methods to enable access to location data:
The recommended method is the second method.
1) In the application, before accessing the user's location data, the device's location data is obtained using GetCurrentLocation.
Clomosy.GetCurrentLocation;
2) In the web development environment, navigate to the Management and then click on Params. On the page that opens, the Location setting must be enabled.
Then, to obtain the latitude and longitude data, the LocationValue property should be used. The LocationValue property returns a string in the format of Latitude|Longitude.
In the example, the second method is used to access location data. However, the GetCurrentLocation feature is still mentioned in the comment. Then, the retrieved latitude and longitude information is parsed and displayed on the screen.
Example
var
form1:TCLForm;
btn1 : TclButton;
Latitude,Longitude : String;
void onBtnClick;
{
ShowMessage(Clomosy.LocationValue); //// Accesses locationList Data => Latitude|Longitude
Latitude=clGetStringTo(Clomosy.LocationValue,'|')
Longitude=clGetStringAfter(Clomosy.LocationValue,'|')
ShowMessage('Latitude value: '+Latitude);
ShowMessage('Longitude value: '+Longitude);
}
{
form1 = TCLForm.Create(Self);
//Clomosy.GetCurrentLocation;
btn1 = form1.AddNewButton(form1,'btn1','Get location data');
btn1.Width = 150;
form1.AddNewEvent(btn1,tbeOnClick,'onBtnClick');
form1.Run;
}
Each device produces different results.
Output:
38,0019703075353|32,5078080237408
Latitude valu: 38,0019703075353
Longitude value: 32,5078080237408