Search code examples
skmaps

NavigationManager's startNavigation() has blank map


I'm trying to use turn by turn navigation using SKNavigationManager's startNavigation(navigationSettings). Interestingly it works flawless in 'Simulation' mode but when I switch to 'Real' mode there is no map on the screen. It's just that the map is not drawn on screen, but the rest like annotations and other stuff are populated and working fine.

I've used SKToolsNavigatoinManager and it works fine, but I don't want to use it as it has a lot of UI interfaces which are not useful for my application.

Any help is appreciated.

Here is the settings and the navigationManager code I'm using

SKNavigationSettings navigationSettings = new SKNavigationSettings();
SKNavigationManager navigationManager = SKNavigationManager.getInstance();
navigationSettings.setNavigationType(SKNavigationSettings.SKNavigationType.REAL);
navigationSettings.setNavigationMode(SKNavigationSettings.SKNavigationMode.PEDESTRIAN);
navigationManager.setMapView(navMapView);
navigationManager.startNavigation(navigationSettings);

If i don't use the navigationManager.setMapView(navMapView); I get a different view.

1. This is how the screen looks like after I start navigation
2. This is how the screen looks like before navigation


Solution

  • The map is drawn to the screen its just centered at the point [0,0] which is in the middle of the Atlantic ocean therefore the screen is blue. To have the camera follow the current location you must do the following 2 steps:

    1. Set follow positions to true on your SKMapView object: navMapView.getMapSettings().setFollowPositions(true);

    2. Create a SKCurrentPositionProvider and set the SKCurrentPositionListener

      SKCurrentPositionProvider positionProvider = new SKCurrentPositionProvider(activity);
      positionProvider.setCurrentPositionListener(new SKCurrentPositionListener(){
      
          @Override
          public void onCurrentPositionUpdate(SKPosition currentPosition) {
              SKPositionerManager.getInstance().reportNewGPSPosition(currentPosition);
      
          }
      
      });
      positionProvider.requestLocationUpdates(true, true, false);