Is there any known bug to the SKRoutingService not zooming to route after calculating it?
My case scenario is next: I have a list of venues in one view controller. When the user clicks on any of them, another ViewController will open and on them, new instance of SKMapView will be created using this code:
-(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];
}
Thing is, first time I open up a venue screen, route is calculated and zoomed to perfectly.
But once I go back, select another venue and get to the ViewController where another new map should be initialised and zoomed to the route location, it doesn't happen. What happens is: - Map is initialised - Route is calculated - Map Annotations are placed perfectly
But it is zoomed out to showing a planet earth...so completely zoomed out, even though I set
[[SKRoutingService sharedInstance] zoomToRouteWithInsets:UIEdgeInsetsZero];
And I checked, the code is reachable after route calculation, but it simply doesn't zoom?
Any solution to this?
It's a bug: call zoomToRouteWithInsets
twice
See details at Skobbler map not zooming with zoomToRouteWithInsets