【发布时间】:2016-11-04 10:37:18
【问题描述】:
我需要做的只是打开并向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²:我将标签“字典”两次更改为“地图”,但改回字典 idk 为什么。
【问题讨论】:
标签: ios dictionary firemonkey