Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift MKTileOverlay-添加捆绑瓷砖_Swift_Mapkit_Mktileoverlay - Fatal编程技术网

Swift MKTileOverlay-添加捆绑瓷砖

Swift MKTileOverlay-添加捆绑瓷砖,swift,mapkit,mktileoverlay,Swift,Mapkit,Mktileoverlay,添加带有平铺贴图的覆盖应该很容易。我有个大问题。他们没有表现出来 我有一个文件夹baymap中的Bayeux中心的15、16和17缩放图块。 我将文件夹滑入项目中 这是密码 import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate, CLLocationManagerDelegate { @IBOutlet weak var mapView: MKMapVi

添加带有平铺贴图的覆盖应该很容易。我有个大问题。他们没有表现出来

我有一个文件夹baymap中的Bayeux中心的15、16和17缩放图块。 我将文件夹滑入项目中

这是密码

  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.Standard

      //Map centre
      let centre = CLLocationCoordinate2D(latitude: 49.275,
        longitude: -0.7028)

      //Declare span of map
      let span = MKCoordinateSpan(latitudeDelta: 0.01,
        longitudeDelta: 0.01)

      //Set region of the map
      let region = MKCoordinateRegion(center: centre, span: span)
      self.mapView.setRegion(region, animated: false)
      self.mapView.regionThatFits(region)



      //Get the URL template to the map tiles
      let baseURL = NSBundle.mainBundle().bundleURL.absoluteString

      let urlTemplate = baseURL.stringByAppendingString("baymap/{z}/{x}/{y}.png/")
      print(urlTemplate)

      let carte_indice = MKTileOverlay(URLTemplate:urlTemplate)


      carte_indice.geometryFlipped = 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!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer!
{
  print("call overlay")
  if overlay is MKTileOverlay
  {
print("is MKTileoverlay")
    var renderer = MKTileOverlayRenderer(overlay:overlay)

    renderer.alpha = 0.8

    return renderer
  }
  return nil
}
}
我对问题进行了编辑,添加了打印“呼叫覆盖”和“is MKTileoverlay”。 它们都在控制台中打印

巴约的苹果地图显示得很好,但没有覆盖

在控制台中,我收到了几十个类似这样的错误,这些错误都是指不在捆绑包中的磁贴

:加载URL时出错file:///Users/colinmcgarry/Library/Developer/CoreSimulator/Devices/5A9A20A4-9C3F-4A65-8823-9721463FF985/data/Containers/Bundle/Application/D2C87A46-E848-4C0D-9B05-30E731EC037F/TileOverlaystack.app/baymap/17/65283/86214.png/: Error Domain=NSURERRORDOMAIN Code=-1100“在此服务器上找不到请求的URL。”

谁能看出我做错了什么。在Swift中是否有一个很好的捆绑瓷砖覆盖教程

谢谢

找到了解决方案。 carte_indice.geometryFlipped=真

应该是假的

取决于磁贴系统。

找到了解决方案。 carte_indice.geometryFlipped=真

应该是假的

取决于瓷砖系统