View Full Version : Android: Target flag on starting position after route calculation

11.11.2014, 22:04
Dear Skobbler Team!

When I open a map, I put a target flag on coordinate position the user was searching. When I now calculate a route from the current GPS position to the target, the flag moves instantly to the GPS position. Now my question, how can I control this flag? Why is it moving?

Kind regards and thanks for your advice!

12.11.2014, 10:56
Hi Lexos,

Could you please add a code snippet for the part where you have added the flag?

12.11.2014, 20:02
Hi Adela_Silvia!

Thanks for your support. What I do is the following. I set a target flag before the user triggers the route calculation with the following code:

selectionPosition = new SKCoordinate();

targetAnnotation = new SKAnnotation();
targetAnnotation.setAnnotationType(SKAnnotation.SK _ANNOTATION_TYPE_DESTINATION_FLAG);

mapView.addAnnotation(targetAnnotation, SKAnimationSettings.ANIMATION_NONE);

mapView.centerMapOnPositionSmooth(selectionPositio n, 500);

After I am starting this calculation.

// get a route object and populate it with the desired properties
SKRouteSettings route = new SKRouteSettings();
// set start and destination points
SKCoordinate currentCoordinate = new SKCoordinate();

SKPosition currentPosition = mapView.getCurrentGPSPosition(false);

currentCoordinate.setLatitude(currentPosition.getL atitude());
currentCoordinate.setLongitude(currentPosition.get Longitude());

// set the number of routes to be calculated
// set the route mode
route.setRouteMode(SKRouteSettings.SKROUTE_CAR_FAS TEST);
// set whether the route should be shown on the map after it's computed
// set the route listener to be notified of route calculation
// event
SKRouteManager.getInstance().setRouteListener(this );
// pass the route to the calculation routine
SKRouteManager.getInstance().calculateRoute(route) ;

the route is drawn to the map view and the flag is located on the current GPS position, which means on the starting point of the navigation.

Any ideas?

Kind regards, Alex!

24.11.2014, 10:28
Hi Alex,

It seems you didn't set the annotationID : targetAnnotation.setUniqueID(uniqueID);
If you will set the annotation id everything should work properly.

Please let us know if there any other issues.