Why MKTileOverlay repeats same tile over and over for openstreet map in ios, swift4

百般思念 提交于 2019-12-06 09:26:19

问题


I'm using OpenStreet map to with our own map server with iOS. for iOS I couldn't find any third party library (free or paid) which can use with our open StreetMap server. then I decided to go with MKMapView using MKTileOverlay like below :

added a MapKit outlet to my storyboard. made a outlet connection and set delegates to self using storyboard and then here is my viewdidload method.

let urltemplate = "http://tile.openstreetmap.org/17/94621/62995.png"
let overlay = MKTileOverlay(urlTemplate: urltemplate)
overlay.canReplaceMapContent = true
mapView.add(overlay)

then the output is like below :

Any idea of what is going on. when I scroll to right of left I can only see this image. please help me with this.


回答1:


Because that's exactly what you specified in your URL template.

Instead of

http://tile.openstreetmap.org/17/94621/62995.png

use

http://tile.openstreetmap.org/{z}/{x}/{y}.png



来源:https://stackoverflow.com/questions/51347044/why-mktileoverlay-repeats-same-tile-over-and-over-for-openstreet-map-in-ios-swi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!