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

标签 ios dictionary firemonkey

我需要做的只是打开并发送一个字符串到 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/

相关文章:

objective-c - presentModalViewController 不显示顶部栏

python - 将 GroupBy 对象 (groupby().size) 转换为字典

python - python 模块的数据描述符

delphi - 如何使用 LiveBindings 在 TStringGrid 中显示超过 200 行?

delphi - XE3 视觉 LiveBindings : bidirectional connection between TSpinBox and TTrackBar (FireMonkey)

ios - UIImageView 层不会变换多次

ios - mvvmcross ios 方法绑定(bind) (RIO)

ios - 文档目录中保存的文件名有空格字符

javascript - 如何使用 For 循环生成字典数组

android - 如何获取内置传感器的名称、制造商和序列号