2

I am trying to get the Points(coordinates) traveled on the Route while navigating. SKnavigationState does not provide any latlon coordinates on ongoing navigation to the route.

How do I get the coordinates of the user's position on the route while navigation is taking place?

Ranjana Dangol
  • 1,319
  • 2
  • 13
  • 24

1 Answers1

1

There are a number of ways of doing this:


    private void startNavigation() 
    { 
        //..... navigation settings 
        if (configuration.getNavigationType() == SKNavigationSettings.SKNavigationType.REAL) { 
            navigationSettings.setNavigationType(SKNavigationSettings.SKNavigationType.REAL); 
            Date date = new Date(); 
            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss"); 
            final File navigationLogsFolder =  new File(Environment.getExternalStorageDirectory() + File.separator + "LogFileName" + File.separator); 
            if (!navigationLogsFolder.exists()) { 
                navigationLogsFolder.mkdirs(); 
            } 
            final String fileName = navigationLogsFolder.getAbsolutePath() + "/" + dateFormat.format(date); 
            SKPositionLoggingManager.getInstance().startLoggingPositions(fileName, SKPositionLoggingManager.SPositionLoggingType.SK_POSITION_LOGGING_TYPE_LOG); 
        } 
        navigationManager.startNavigation(navigationSettings); 
    } 
When you want to stop the logging process please call SKPositionLoggingManager().stopLoggingPositions()
  • when receiving a location update (or any other time) you can ask & log the currently known position via the getCurrentGPSPosition API ( via the matched paremeter you can ask either for the real position or the "matched on road" position)
Ando
  • 11,199
  • 2
  • 30
  • 46
  • Hey Ando, Is there any way that I could match the last position of the user on the route after restarting the navigation on the same route? – Ranjana Dangol Jul 22 '16 at 09:03
  • There is no API that would allow you to ask for the "matched" position of a real position - you can try to feel via reportLocation the last known position to the SDK and then ask it back via getCurrentGPSPosition but it might not work as the "matched" position is established by also taking into account historical positions (for better determining the candidate streets) – Ando Jul 22 '16 at 09:59
  • This is a different question :) . The answer is yes, see the addViaPoint API: http://developer.skobbler.com/docs/android/3.0.0/com/skobbler/ngx/routing/SKRouteManager.html#addViaPoint(com.skobbler.ngx.routing.SKViaPoint,%20int) – Ando Jul 22 '16 at 13:59
  • I tried adding viapoints on navigationstart but i could only add one viapoint to the route. – Ranjana Dangol Jul 25 '16 at 06:38