ios - Add MKTileOverlay on map in swift -


during execute image repeated throughout map. specify uiimage in place of urltemplate?

i have add overlay image in particular location. precisely @ current position.

thank you

this code:

import uikit import mapkit   class viewcontroller: uiviewcontroller, mkmapviewdelegate, cllocationmanagerdelegate {      @iboutlet weak var mapview: mkmapview!      let locationmanager = cllocationmanager()      var latitude: cllocationdegrees = 0.0     var longitude: cllocationdegrees = 0.0      var cnt: int = 0       override func viewdidload() {         super.viewdidload()          self.mapview.delegate = self          self.mapview.maptype = mkmaptype.satellite          //map centre         let centre = cllocationcoordinate2d(latitude: 40.8325769,             longitude: 14.318884400000002)          //declare span of map         let span = mkcoordinatespan(latitudedelta: 0.05,             longitudedelta: 0.05)          //set region of map         let region = mkcoordinateregion(center: centre, span: span)         self.mapview.setregion(region, animated: false)         self.mapview.regionthatfits(region)            var template = "http://tile.openstreetmap.org/0/0/0.png"          let carte_indice = mktileoverlay(urltemplate:template)           carte_indice.geometryflipped = true          carte_indice.canreplacemapcontent = false           self.mapview.addoverlay(carte_indice)        }        override func didreceivememorywarning() {         super.didreceivememorywarning()         // dispose of resources can recreated.     }      func mapview(mapview: mkmapview!, rendererforoverlay overlay: mkoverlay!) -> mkoverlayrenderer!     {              if overlay mktileoverlay             {                 var renderer = mktileoverlayrenderer(overlay:overlay)                  renderer.alpha = 0.8                  return renderer             }             return nil     }  } 

i think template url must be:

var template = "http://tile.openstreetmap.org/{z}/{x}/{y}.png" 

regards.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -