Hi, Readers.
Today I would like to share another mini tip of Business Central, how to get geographical location information from the client device.
This time we will use codeunit 7568 Geolocation.
Codeunit 7568 Geolocation: Provides functionality for getting geographical location information from the client device.
Let’s see a simple example.
Source Code:
pageextension 50100 CustomerListExt extends "Customer List"
{
trigger OnOpenPage();
var
Geolocation: Codeunit Geolocation;
Latitude: Decimal;
Longitude: Decimal;
Msg: Label 'Latitude is %1.\Longitude is %2.';
begin
Geolocation.SetHighAccuracy(true);
if Geolocation.RequestGeolocation() then begin
Geolocation.GetGeolocation(Latitude, Longitude);
Message(Msg, Format(Latitude), Format(Longitude));
end;
end;
}
First, you must allow Business Central to access data about the geographical location of the device.
PS: You can click the Location icon on the browser to manage the Location permission.
Then you can get the latitude and longitude of your device.
PS:
1. More details for Geolocation Module:
2. If you want to know how to use online maps in Business Central, hope the following can help you.
How to use online maps (Bing maps and Google maps)
END
Hope this will help.
Thanks for reading.
ZHU
コメント