各位读者好。
今天我分享一下,如何从BC客户端中设备获取地理位置信息。
这次我们要使用 codeunit 7568 Geolocation.
Codeunit 7568 Geolocation: 提供从客户端设备获取地理位置信息的功能。

让我们看一个简单的例子。

源代码:
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;
}
首先,您必须允许 Business Central 访问有关设备地理位置的数据。

PS:您可以点击浏览器上的位置图标来管理位置的权限。

然后你可以得到你的设备的纬度和经度。

PS:
1. 关于Geolocation Module的详情:
https://github.com/microsoft/ALAppExtensions/tree/master/Modules/System/Geolocation
2. 如果您想了解如何在 Business Central 中使用在线地图,希望以下内容对您有所帮助:
How to use online maps (Bing maps and Google maps)
以上
ZHU
コメント