Posts

Post not yet marked as solved
0 Replies
1.4k Views
Hello, In my iOS application I add a custom MKTileOverlay to my MKMapView, on iOS 12 I was able to display the default labels by adding the overlay using the level .aboveRoads. Also the Title and Subtitle of the MKAnnotation was shown on the map. Now on iOS 13 all labels are hidden under the TileOverlay. The only workaround I found was to set the canReplaceMapContent to false on the overlay. Unfortunally this has a ugly effect when loading the TileOverlays, because the original Map is visible below. I have found no changes in the documentation for MKTileOverlays in iOS 13 so I believe this may be a bug.class ViewController: UIViewController { @IBOutlet weak var mapView: MKMapView! override func viewDidLoad() { super.viewDidLoad() mapView.delegate = self addCustomOverlay() let annotation = SampleAnnotation(coordinate: CLLocationCoordinate2D(latitude: 53.141351, longitude: 8.229935), title: "Title", subtitle: "Subtitle") mapView.addAnnotation(annotation) } private func addCustomOverlay() { guard let jsonURL = Bundle.main.url(forResource: "LightBlueGreen", withExtension: "json") else { return } do { let customTileOverlay = try CustomOverlay(jsonURL: jsonURL) customTileOverlay.canReplaceMapContent = true mapView.add(customTileOverlay, level: .aboveRoads) } catch let error { print(error.localizedDescription) } } } extension ViewController: MKMapViewDelegate { func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { if let tileOverlay = overlay as? MKTileOverlay { return MKTileOverlayRenderer(tileOverlay: tileOverlay) } return MKOverlayRenderer(overlay: overlay) } } class SampleAnnotation: NSObject, MKAnnotation { public var coordinate: CLLocationCoordinate2D public var title: String? public var subtitle: String? public init(coordinate: CLLocationCoordinate2D, title: String, subtitle: String) { self.coordinate = coordinate self.title = title self.subtitle = subtitle } }Thank you in advance
Posted
by SandroWe.
Last updated
.