NOOOB Trying to use mapkit overlay

My IOS map isn't rendering the NOAA tiles on top of it. Can someone give my a clue what is wrong? Here is my viewcontroler. It's just a standard mapkit viewer. Anyways, it is not working and is just giving me a standard satellite map when I run this code. Does anyone know what I am doing wrong? Thanks for any help you can give me.

Have a great rest of your weekend.

import UIKit
import MapKit

class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate {
@IBOutlet weak var mapView: MKMapView!
//Linking MapView

override func viewDidLoad() {
    super.viewDidLoad()
    self.mapView.delegate = self

    self.mapView.mapType = MKMapType.satellite

    let centre = CLLocationCoordinate2D(latitude: 39.2189, longitude: -76.0690)

   let span = MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05)

   let region = MKCoordinateRegion(center: centre, span: span)
   self.mapView.setRegion(region, animated: false)
   self.mapView.regionThatFits(region)



   let template = "https://tileservice.charts.noaa.gov/tiles/50000_1/{z}/{x}/{y}.png"

   let carte_indice = MKTileOverlay(urlTemplate:template)


   carte_indice.isGeometryFlipped = true

   carte_indice.canReplaceMapContent = false


   self.mapView.addOverlay(carte_indice)
}
override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

func mapView(
    mapView: MKMapView!, rendererFor overlay: MKOverlay!) -> MKOverlayRenderer!
{

if overlay is MKTileOverlay{
    var renderer = MKTileOverlayRenderer(overlay:overlay)
    renderer.alpha = 0.8
    return renderer
}
    return nil
}

}

MapKit is very specific to Apple platforms, so you might have more luck asking over in Apple Developer Forums. Make sure to tag your post with MapKit so that interested folks see it.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

Terms of Service

Privacy Policy

Cookie Policy