I'm quite new to iOS development and am facing an issue using MapKit.
I am trying to create a simple application to overlay a raster image to a map created with mapkit.
Here is the code for my tabViewcontroller:
import UIKit
import MapKit
class J_1_TabViewController: UIViewController,MKMapViewDelegate {
@IBOutlet weak var CarteMapView: MKMapView!
override func viewDidLoad() {
super.viewDidLoad()
// Localisation centre de Clermont-Ferrand pour centrer la carte
let location = CLLocationCoordinate2D(
latitude: 45.774792,
longitude: 3.091641
)
let span = MKCoordinateSpanMake(0.1, 0.1) // declaration du niveau d'affichage en X et Y en °
let region = MKCoordinateRegion(center: location, span: span) //declaration de la zone de la carte
self.CarteMapView.setRegion(region, animated: true)
//var template = "http://tile.openstreetmap.org/{z}/{x}/{y}.png" //declaration de l'adresse pour les tuiles
var template = "http://81.255.152.141/galineau/carteNO2/{z}/{x}/{y}.png"
let carte_indice = MKTileOverlay(URLTemplate:template)
self.CarteMapView.addOverlay(carte_indice)
}
And the code for my rendererForOverlay
func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! {
if overlay is MKTileOverlay {
var carte_Renderer = MKTileOverlayRenderer(overlay: overlay)
carte_Renderer.alpha = 0.9
return carte_Renderer
}
return nil
}
In my example, if I am using OpenStreetMap link, my overlay is ok but if I am using my own tiles, It is not working anymore. I have generated my tiles using gdal and when I try to visualize them on safari, it seems ok. Here is the link to visualize my tiles: MyMap
I can't understand why they are not showing in my app?