Grqhf
Grqhf

Reputation: 21

Starting point always invalid (681) (Skobbler Android API)

I am trying to generate a route using the Skobbler Android SDK and I cannot seem to pass a valid starting point.

It is always returning the error code 681, despite trying numerous different latitude longitude pairs.

    SKRouteSettings route = new SKRouteSettings();

    route.setStartCoordinate(new SKCoordinate(51.510537, -0.183426));        
    route.setDestinationCoordinate(new SKCoordinate(51.510943, -0.151020));

    route.setNoOfRoutes(1);
    route.setRouteMode(SKRouteSettings.SKROUTE_CAR_FASTEST);
    route.setRouteExposed(true);
    SKRouteManager.getInstance().setRouteListener(this);
    SKRouteManager.getInstance().calculateRoute(route);

Then on completion of route calculation:

if (statusMessage != SKRouteListener.ROUTE_SUCCESS) {
            runOnUiThread(new Runnable() {

                @Override
                public void run() {
                    Toast.makeText(DisplayMessageActivity.this, "Route calculation failed: " + errorNo, Toast.LENGTH_SHORT).show();
                }
            });
            return;
        }

The starting and end points are situated in London. I am using a modified demo project.

Thank you.

Upvotes: 2

Views: 186

Answers (1)

Ando
Ando

Reputation: 11409

Due to historical reasons the Android SKCoordinate constructor expects a (longitude, latitude) pair - instead of the more common (lat, long) pair.

So replacing your code with:

route.setStartCoordinate(new SKCoordinate(-0.183426,51.510537));
route.setDestinationCoordinate(new SKCoordinate( -0.151020,51.510943));

will fix the issue.

Upvotes: 2

Related Questions