gpt4 book ai didi

ios - Firemonkey:如何从我的应用程序打开 native IOS map ?

转载 作者:行者123 更新时间:2023-11-29 00:36:42 25 4
gpt4 key购买 nike

我需要做的只是打开并发送一个字符串到 IOS 本地映射。该字符串包含地址。

我发现这段代码在 android 上运行良好,但在 IOS 上却无法运行,为什么?

function OpenNavigation(const Q: string; const Coord: TLocationCoord2D): Boolean;
var
CoordString: String;
begin
//Open in Google Maps
{$IFDEF ANDROID}
exit(OpenURL('http://maps.google.com/?q=' + Q));
{$ELSE}

//In iOS, if Google Maps is installed, use it, otherwise, use Apple Maps
//If we have coordinates, use them as the start address
{$IFDEF IOS}
exit(OpenURL('http://maps.apple.com/?daddr=' + Q));
//Get a string of the longitute and latitute seperated by a comma if set
if (Coord.Latitude <> 0.0) or (Coord.Longitude <> 0.0) then
begin
CoordString := Coord.Latitude.ToString + ',' + Coord.Longitude.ToString;
end
else begin
CoordString := '';
end;
if not OpenURL('comgooglemaps://?daddr=' + Q) then
begin
if (0.0 < CoordString.Length) then
begin
exit(OpenURL('http://maps.apple.com/?daddr=' + Q + '&saddr=loc:' + CoordString));
end
else begin
exit(OpenURL('http://maps.apple.com/?daddr=' + Q));
end;
end
else begin
exit(true);
end;
{$ELSE}
//Unsupported platform
exit(false);
{$ENDIF IOS}
{$ENDIF ANDROID}
end;

编辑:我使用的版本是 RadStudio 10.1 Berlin

EDIT²:我将标签“字典”更改为“ map ”两次,但又改回了字典 idk 为什么。

最佳答案

要从另一个 iOS 应用程序打开 map 应用程序,您可以执行以下操作:

UIApplication.sharedApplication().openURL(NSURL(string: "http://maps.apple.com/?address=yourAddressHere")!)

您还可以使用 CLGeocoder 获取 CLLocation 位置

请同时查看此 stack overflow's answer了解更多详情。

关于ios - Firemonkey:如何从我的应用程序打开 native IOS map ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40420526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com