GoogleMapsTileOverlay 0.4.1

GoogleMapsTileOverlay 0.4.1

Sandro Wehrhahn 维护。



  • 巅峰实验室

针对 MapKit 的 GoogleMapsTileOverlay

Swift Version PackageManager Cocoapods Platforms License Twitter: @thepeaklab

GoogleMapsTileOverlay 允许您使用 Google Maps StylingWizard 自定义 Apple Maps MKMapView

安装

Carthage

要使用 Carthage 安装 GoogleMapsTileOverlay,按照 快速入门 中的说明设置 Carthage 项目。

然后在 Cartfile 中添加此行

github "thepeaklab/GoogleMapsTileOverlay" ~> 0.4.1

CocoaPods

如果您尚未安装 CocoaPods,请先安装它

在您的 target 的 Podfile 中添加此行

pod 'GoogleMapsTileOverlay', '~> 0.4.1'

然后执行安装

pod install

示例

您可以自定义 Apple Maps,以适台您的 App 或游孑的设计

示例项目

用法

  1. 使用 Google Maps StylingWizard 创建 MapStyle 并将其保存到 JSON 文件
  2. 将 JSON 文件添加到您的 XCode 项目中
  3. 在您的 ViewController 中
import GoogleMapsTileOverlay

将自定义覆盖层添加到您的 MKMapView

guard let jsonURL = Bundle.main.url(forResource: "MapStyle", withExtension: "json") else { return }

let tileOverlay = try? GoogleMapsTileOverlay(jsonURL: jsonURL)
tileOverlay.canReplaceMapContent = true
mapView.addOverlay(tileOverlay, level: .aboveRoads)

为您的 MKMapView 添加代理

mapView.delegate = self
extension YourViewController: MKMapViewDelegate {

    func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer {
        if let tileOverlay = overlay as? MKTileOverlay {
            return MKTileOverlayRenderer(tileOverlay: tileOverlay)
        }
        return MKOverlayRenderer(overlay: overlay)
    }

}

已知问题

  1. iOS 13 的标签 在 iOS 13 中,即使是使用了 aboveRoads 级别,地图上的标签和注释也无法显示。此错误已经在 Apple 处进行了报告,并有望在未来版本的 iOS 中得到解决。

需要帮助?

在 GitHub 上提交一个問題

许可证

本项目采用MIT许可证条款进行授权。请参阅LICENSE文件。