Swiftpack.co - thepeaklab/GoogleMapsTileOverlay as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by thepeaklab.
thepeaklab/GoogleMapsTileOverlay 0.5.0
GoogleMapsTileOverlay lets you customize Apple Maps MKMapView with the Google Maps StylingWizard
⭐️ 72
🕓 3 years ago
iOS macOS tvOS
.package(url: "https://github.com/thepeaklab/GoogleMapsTileOverlay.git", from: "0.5.0")

GoogleMapsTileOverlay for MapKit

Swift Version PackageManager Cocoapods Platforms License Twitter: @thepeaklab

GoogleMapsTileOverlay lets you customize Apple Maps MKMapView with the Google Maps StylingWizard.

Install

Swift Package Manager

Add this line to your depedencies in Package.swift

.package("https://github.com/thepeaklab/GoogleMapsTileOverlay", from: "0.5.0")

Carthage

To install GoogleMapsTileOverlay with Carthage, setup Carthage for your project as described in the Quick Start.

Then add this line to your Cartfile:

github "thepeaklab/GoogleMapsTileOverlay" ~> 0.4.1

CocoaPods

Install CocoaPods if you haven't already

Add this in your Podfile for your target:

pod 'GoogleMapsTileOverlay', '~> 0.4.1'

And install with:

pod install

Example

You can customize Apple Maps to match the design of your App or Game:

Example Project

Usage

  1. Create MapStyle with the Google Maps StylingWizard and save it to a JSON-File
  2. Add JSON-File to your XCode Project
  3. In your ViewController:
import GoogleMapsTileOverlay

Add custom overlay to your 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)

Add delegate for your 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)
    }

}

Known Issues

  1. Labels in iOS 13 On iOS 13 the labels on the map and the annotations are not visible, even when using the level aboveRoads. This bug is already reported to Apple and will hopefully be solved in future versions of iOS.

Need Help?

Please submit an issue on GitHub.

License

This project is licensed under the terms of the MIT license. See the LICENSE file.

GitHub

link
Stars: 72
Last commit: 3 years ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics