SKRoutingService在计算之后是否有任何已知错误未放大到路由?
我的案例场景是下一个:我在一个视图控制器中有一个场地列表。 当用户点击其中任何一个时,另一个ViewController将打开并在其上,将使用以下代码创建SKMapView的新实例:
-(void)initMap
{
_map = [[SKMapView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _mapView.frame.size.height)];
//UIView* userInteractionBlocker = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, _mapView.frame.size.height)];
//[_mapView addSubview:userInteractionBlocker];
_map.settings.rotationEnabled = YES;
_map.settings.displayMode = SKMapDisplayMode2D;
_map.mapScaleView.hidden = YES;
//[map centerOnCurrentPosition];
//[map animateToZoomLevel:25.0];
[SKRoutingService sharedInstance].mapView = _map;
[SKRoutingService sharedInstance].routingDelegate = self;
SKRouteSettings* route = [[SKRouteSettings alloc]init];
route.startCoordinate=CLLocationCoordinate2DMake([Constants shared].selectedExit.lat, [Constants shared].selectedExit.lon);
route.destinationCoordinate=CLLocationCoordinate2DMake([Constants shared].selectedVenue.lat, [Constants shared].selectedVenue.lon);
UIImage *venuePin;
switch (_venue.primary_category) {
case 626:
venuePin = [UIImage imageNamed:@"pinGasBlack"];
break;
case 623:
venuePin = [UIImage imageNamed:@"pinHotelBlack"];
break;
case 593:
venuePin = [UIImage imageNamed:@"pinFoodYellow"];
break;
}
SKAnnotation* exit = [self createPinWithImage:[UIImage imageNamed:@"pinExitYellow"] atCoordinates:CLLocationCoordinate2DMake([Constants shared].selectedExit.lat, [Constants shared].selectedExit.lon) withIdentifier:@"pinExit" identifier:0];
SKAnnotation* venue = [self createPinWithImage:venuePin atCoordinates:CLLocationCoordinate2DMake([Constants shared].selectedVenue.lat, [Constants shared].selectedVenue.lon) withIdentifier:@"pinVenue" identifier:1];
[_map addAnnotation:exit withAnimationSettings:nil];
[_map addAnnotation:venue withAnimationSettings:nil];
[_mapView addSubview:_map];
[[SKRoutingService sharedInstance] calculateRoute:route];
}
- (void)routingService:(SKRoutingService *)routingService didFinishRouteCalculationWithInfo:(SKRouteInformation*)routeInformation{
[[SKRoutingService sharedInstance] zoomToRouteWithInsets:UIEdgeInsetsZero];
}
事情是,我第一次打开场地屏幕,计算路线并完美地缩放。
但是一旦我回去,选择另一个场地并进入ViewController,其中应该初始化另一个新地图并缩放到路线位置,它不会发生。 会发生什么: - 地图已初始化 - 计算路线 - 地图注释完美放置
但它缩小到显示行星地球......所以完全缩小,即使我设置
[[SKRoutingService sharedInstance] zoomToRouteWithInsets:UIEdgeInsetsZero];
我检查过,路由计算后代码是可以访问的,但它根本不会缩放?
对此有任何解决方案吗?
答案 0 :(得分:1)
这是一个错误:两次致电zoomToRouteWithInsets