fmo91 / MapKitGoogleStyler

Customize iOS MapKit using Google JSON styles
MIT License
132 stars 41 forks source link

MapKitGoogleStyler no longer working #10

Open ajaymerchia opened 5 years ago

ajaymerchia commented 5 years ago

Can anyone confirm that this library is no longer functioning -- perhaps Apple restricted usage of tileOverlays for this purpose.

I call the following in viewDidLoad

//  LayoutManager is a custom library that I wrote, it successfully places the MapView onscreen
        mapView = MKMapView(frame: LayoutManager.between(elementAbove: roundName, elementBelow: selectTeamButton, width: view.frame.width, topPadding: 2 * .MARGINAL_PADDING, bottomPadding: .PADDING))
        mapView.delegate = self
        mapView.showsUserLocation = true
        mapView.setUserTrackingMode(.follow, animated: true)
        view.addSubview(mapView)
        restyleMap()

Where restyleMap contains

guard let overlayFileURLString = Bundle.main.path(forResource: "overlay", ofType: "json") else {
            return
        }
        let overlayFileURL = URL(fileURLWithPath: overlayFileURLString)
        debugPrint(overlayFileURL)
        // After that, you can create the tile overlay using MapKitGoogleStyler
        guard let tileOverlay = try? MapKitGoogleStyler.buildOverlay(with: overlayFileURL) else {
            return
        }
        // And finally add it to your MKMapView
        mapView.delegate = self
        mapView.addOverlay(tileOverlay, level: .aboveLabels)
        debugPrint(mapView.overlays)

I can confirm that the overlay is added to the map, but the dark style JSON doesn't load. I put a breakpoint inside the func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer function, but the function isn't getting called.

Any thoughts on why this might be happening? Is the renderer returned without the necessary attributes to make the map load it?

JohLud commented 5 years ago

Yes you're right same problem here.

3vangelos commented 5 years ago

Hey @fmo91, thanks for this lib, I am actually also facing this problem right now. Any plans on releasing a new version any time soon?

LinusGeffarth commented 4 years ago

Works fine for me in iOS 13.4.