我正在尝试在平铺图像(下面的代码)顶部显示带有 kml 叠加层的平铺图像,并且收到以下错误:
'NSInvalidArgumentException',原因:'-[MKPolyline tilesInMapRect:zoomScale:]:无法识别的选择器发送到实例
是否有人对我是否正确接近多个叠加层或为什么会出现此错误有任何建议?
提前致谢!
(void)viewDidLoad
{
[super viewDidLoad];
// Initialize the map overlay with tiles in the app's bundle.
NSString *tileDirectory = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Tiles"];
MapOverlay *overlay1 = [[MapOverlay alloc] initWithDirectory:tileDirectory];
// Locate the path to the route.kml file in the application's bundle
// and parse it with the KMLParser.
NSString *path = [[NSBundle mainBundle] pathForResource:@"route" ofType:@"kml"];
NSURL *url = [NSURL fileURLWithPath:path];
kmlParser = [[KMLParser alloc] initWithURL:url];
[kmlParser parseKML];
// Add all of the MKOverlay objects parsed from the KML file to the map.
NSArray *overlay2 = [kmlParser overlays];
[map addOverlay:overlay1];
[map addOverlays:overlay2];
// Set the starting location.
CLLocationCoordinate2D startingLocation;
startingLocation.latitude = 0.00;
startingLocation.longitude =-0.00;
map.region = MKCoordinateRegionMakeWithDistance(startingLocation, 4600, 4600);
[map setCenterCoordinate:startingLocation];
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay1
{
MapOverlayView *view = [[MapOverlayView alloc] initWithOverlay:overlay1];
view.overlayAlpha = 1.0;
return view;
}
- (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay2:(id <MKOverlay>)overlay2
{
return [kmlParser viewForOverlay:overlay2];
}
@end