无法使用iOS Swift在Google地图上加载自定义图块

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法使用iOS Swift在Google地图上加载自定义图块相关的知识,希望对你有一定的参考价值。

我正在尝试使用自定义图块作为Google地图的叠加层。“https://tile.example.com/hot/z / x / y .png”我使用了“ GMSTileURLConstructor”,但无法在移动应用程序上加载地图。我似乎无法在网上找到任何东西。预先感谢。

我使用了以下几行。

class ViewController: UIViewController, GMSMapViewDelegate

    let urls: GMSTileURLConstructor = z,x,y in
       let url = "https://tile.example.com/hot/z/x/y.png"
       print(url)
       return URL(string: url)
   
答案

语法应为

let urls: GMSTileURLConstructor = z,x,y in
   let url = "https://tile.example.com/hot\(z)_\(x)_\(y).png"
   print(url)
   return URL(string: url)

根据Add a Tile Layer文档。

以上是关于无法使用iOS Swift在Google地图上加载自定义图块的主要内容,如果未能解决你的问题,请参考以下文章