瓷磚我使用的偉大工程的緩存局部區塊擁有的MKMapView在iOS應用程序。可以縮放,移動等...的MapView與折線或註釋丟失的變焦
但是,當我添加註釋或多段線時,它仍然很好,直到縮放達到某個縮放級別,然後註釋和多義線下的塊不會出現,但所有其他人都很好。
Zoomed in one two many levels.
如果我刪除註釋/線,地圖縮放正確的和註釋/線將一直在該地區的偉大工程。
任何想法?
我這降低到最小的測試用例。這個運行良好,直到你放大,然後折線下的任何瓷磚消失。縮小並重新出現。
import Foundation
import UIKit
import MapKit
class MyController: UIViewController, MKMapViewDelegate {
@IBOutlet weak var mapView: MKMapView!
var overlay:MKTileOverlay = MKTileOverlay(URLTemplate: "https://services.arcgisonline.com/ArcGIS/rest/services/USA_Topo_Maps/MapServer/tile/{z}/{y}/{x}.jpg");
override func viewDidLoad() {
mapView.delegate = self
mapView.showsUserLocation = true;
overlay.maximumZ = 15;
overlay.minimumZ = 12;
overlay.canReplaceMapContent = true
mapView.addOverlay(overlay)
var points: [CLLocationCoordinate2D] = [CLLocationCoordinate2D]()
points.append(CLLocationCoordinate2D(latitude: 40.7608, longitude: -111.8910));
points.append(CLLocationCoordinate2D(latitude: 40.8894, longitude: -111.8808));
var polyline = MKPolyline(coordinates: &points, count: points.count)
mapView.addOverlay(polyline)
let region = MKCoordinateRegion(center: points[0], span: MKCoordinateSpan(latitudeDelta: 0.05, longitudeDelta: 0.05))
mapView.setRegion(region, animated: false)
}
func mapView(mapView: MKMapView!, rendererForOverlay overlay: MKOverlay!) -> MKOverlayRenderer! {
if overlay is MKPolyline {
var polylineRenderer = MKPolylineRenderer(overlay: overlay)
polylineRenderer.strokeColor = UIColor.blueColor()
polylineRenderer.lineWidth = 5
return polylineRenderer
} else if (overlay is MKTileOverlay) {
let renderr = MKTileOverlayRenderer(overlay: overlay)
return renderr
}
return nil
}
}