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

问题描述 投票:0回答:1

我正在尝试使用自定义图块作为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)
   }
ios swift google-maps overlay gmsgroundoverlay
1个回答
0
投票

语法应为

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文档。

© www.soinside.com 2019 - 2024. All rights reserved.