How to recompute Route in Sygic





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















my issue is simple I compute a primary route and I added it to Sygic MapView. I defined the startWay point and also the the end point. It works perfectly. But when I try to change to the alternative route when I started the navigation It can't recalculate perfectly the new route. I Used the



 func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {


to detect changes in my position and compute the route every time but I think is not the best choice:



func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {
if (mapRoute != nil){
mapView.remove(mapRoute)
computeRoute(from: startPointMP, to: endPointMP)
}
}

func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
SYGeoCoordinate) {
let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
let routingOptions = SYRoutingOptions()
routingOptions.transportMode = .unknown// For other options see SYTransportMode
routingOptions.routingType = .economic// For other options see SYRoutingType
routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
}


func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
SYNavigation.shared().start(with: route)
// You might want to put it also on the map
mapRoute = SYMapRoute(route: route!, type: .primary)
markerEnd = SYMapMarker(coordinate: endPointMP!, image: UIImage(named: "Arrive")!)
mapView.add(mapRoute)
mapView.add(markerEnd)
mapView.add(markerStart)
mapView.cameraMovementMode = .free
}









share|improve this question























  • Why are you trying to compute route after every position change? After you start navigation, the route progress is computed and modified automatically. If it changes because you decided to go different way, then you will get call from SYRoutingDelegate func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). After that it makes sense to replace old route with new one. Or is there any other reason you would want to do it the way you described?

    – anonym
    Nov 26 '18 at 16:21













  • if I understand you, when I go away from my route, I should recompute the new route when func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). and the new route will those passed in the argument of this method delegate or should I recalculate the route ???

    – Walid Sassi
    Nov 27 '18 at 20:17













  • Yep, that is correct. The route will be automatically recomputed when you go different way than you was supposed to and new route will be passed as an argument in that method. So you don't need to compute new route again.

    – anonym
    Nov 27 '18 at 23:24











  • ok, it's work fine

    – Walid Sassi
    Nov 28 '18 at 14:20


















0















my issue is simple I compute a primary route and I added it to Sygic MapView. I defined the startWay point and also the the end point. It works perfectly. But when I try to change to the alternative route when I started the navigation It can't recalculate perfectly the new route. I Used the



 func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {


to detect changes in my position and compute the route every time but I think is not the best choice:



func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {
if (mapRoute != nil){
mapView.remove(mapRoute)
computeRoute(from: startPointMP, to: endPointMP)
}
}

func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
SYGeoCoordinate) {
let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
let routingOptions = SYRoutingOptions()
routingOptions.transportMode = .unknown// For other options see SYTransportMode
routingOptions.routingType = .economic// For other options see SYRoutingType
routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
}


func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
SYNavigation.shared().start(with: route)
// You might want to put it also on the map
mapRoute = SYMapRoute(route: route!, type: .primary)
markerEnd = SYMapMarker(coordinate: endPointMP!, image: UIImage(named: "Arrive")!)
mapView.add(mapRoute)
mapView.add(markerEnd)
mapView.add(markerStart)
mapView.cameraMovementMode = .free
}









share|improve this question























  • Why are you trying to compute route after every position change? After you start navigation, the route progress is computed and modified automatically. If it changes because you decided to go different way, then you will get call from SYRoutingDelegate func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). After that it makes sense to replace old route with new one. Or is there any other reason you would want to do it the way you described?

    – anonym
    Nov 26 '18 at 16:21













  • if I understand you, when I go away from my route, I should recompute the new route when func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). and the new route will those passed in the argument of this method delegate or should I recalculate the route ???

    – Walid Sassi
    Nov 27 '18 at 20:17













  • Yep, that is correct. The route will be automatically recomputed when you go different way than you was supposed to and new route will be passed as an argument in that method. So you don't need to compute new route again.

    – anonym
    Nov 27 '18 at 23:24











  • ok, it's work fine

    – Walid Sassi
    Nov 28 '18 at 14:20














0












0








0








my issue is simple I compute a primary route and I added it to Sygic MapView. I defined the startWay point and also the the end point. It works perfectly. But when I try to change to the alternative route when I started the navigation It can't recalculate perfectly the new route. I Used the



 func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {


to detect changes in my position and compute the route every time but I think is not the best choice:



func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {
if (mapRoute != nil){
mapView.remove(mapRoute)
computeRoute(from: startPointMP, to: endPointMP)
}
}

func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
SYGeoCoordinate) {
let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
let routingOptions = SYRoutingOptions()
routingOptions.transportMode = .unknown// For other options see SYTransportMode
routingOptions.routingType = .economic// For other options see SYRoutingType
routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
}


func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
SYNavigation.shared().start(with: route)
// You might want to put it also on the map
mapRoute = SYMapRoute(route: route!, type: .primary)
markerEnd = SYMapMarker(coordinate: endPointMP!, image: UIImage(named: "Arrive")!)
mapView.add(mapRoute)
mapView.add(markerEnd)
mapView.add(markerStart)
mapView.cameraMovementMode = .free
}









share|improve this question














my issue is simple I compute a primary route and I added it to Sygic MapView. I defined the startWay point and also the the end point. It works perfectly. But when I try to change to the alternative route when I started the navigation It can't recalculate perfectly the new route. I Used the



 func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {


to detect changes in my position and compute the route every time but I think is not the best choice:



func navigation(_ navigation: SYNavigation, didUpdate positionInfo: SYPositionInfo?) {
if (mapRoute != nil){
mapView.remove(mapRoute)
computeRoute(from: startPointMP, to: endPointMP)
}
}

func computeRoute(from fromCoordinate: SYGeoCoordinate, to toCoordinate:
SYGeoCoordinate) {
let startWaypoint = SYWaypoint(position: fromCoordinate, type: .start, name: "Begin")
let endWaypoint = SYWaypoint(position: toCoordinate, type: .end, name: "End")
let routingOptions = SYRoutingOptions()
routingOptions.transportMode = .unknown// For other options see SYTransportMode
routingOptions.routingType = .economic// For other options see SYRoutingType
routing.computeRoute(startWaypoint, to: endWaypoint, via: nil, with: routingOptions)
}


func routing(_ routing: SYRouting, didComputePrimaryRoute route: SYRoute?) {
SYNavigation.shared().start(with: route)
// You might want to put it also on the map
mapRoute = SYMapRoute(route: route!, type: .primary)
markerEnd = SYMapMarker(coordinate: endPointMP!, image: UIImage(named: "Arrive")!)
mapView.add(mapRoute)
mapView.add(markerEnd)
mapView.add(markerStart)
mapView.cameraMovementMode = .free
}






swift sygic sygic-mobile-sdk sygic-maps






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 '18 at 7:27









Walid SassiWalid Sassi

409




409













  • Why are you trying to compute route after every position change? After you start navigation, the route progress is computed and modified automatically. If it changes because you decided to go different way, then you will get call from SYRoutingDelegate func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). After that it makes sense to replace old route with new one. Or is there any other reason you would want to do it the way you described?

    – anonym
    Nov 26 '18 at 16:21













  • if I understand you, when I go away from my route, I should recompute the new route when func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). and the new route will those passed in the argument of this method delegate or should I recalculate the route ???

    – Walid Sassi
    Nov 27 '18 at 20:17













  • Yep, that is correct. The route will be automatically recomputed when you go different way than you was supposed to and new route will be passed as an argument in that method. So you don't need to compute new route again.

    – anonym
    Nov 27 '18 at 23:24











  • ok, it's work fine

    – Walid Sassi
    Nov 28 '18 at 14:20



















  • Why are you trying to compute route after every position change? After you start navigation, the route progress is computed and modified automatically. If it changes because you decided to go different way, then you will get call from SYRoutingDelegate func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). After that it makes sense to replace old route with new one. Or is there any other reason you would want to do it the way you described?

    – anonym
    Nov 26 '18 at 16:21













  • if I understand you, when I go away from my route, I should recompute the new route when func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). and the new route will those passed in the argument of this method delegate or should I recalculate the route ???

    – Walid Sassi
    Nov 27 '18 at 20:17













  • Yep, that is correct. The route will be automatically recomputed when you go different way than you was supposed to and new route will be passed as an argument in that method. So you don't need to compute new route again.

    – anonym
    Nov 27 '18 at 23:24











  • ok, it's work fine

    – Walid Sassi
    Nov 28 '18 at 14:20

















Why are you trying to compute route after every position change? After you start navigation, the route progress is computed and modified automatically. If it changes because you decided to go different way, then you will get call from SYRoutingDelegate func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). After that it makes sense to replace old route with new one. Or is there any other reason you would want to do it the way you described?

– anonym
Nov 26 '18 at 16:21







Why are you trying to compute route after every position change? After you start navigation, the route progress is computed and modified automatically. If it changes because you decided to go different way, then you will get call from SYRoutingDelegate func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). After that it makes sense to replace old route with new one. Or is there any other reason you would want to do it the way you described?

– anonym
Nov 26 '18 at 16:21















if I understand you, when I go away from my route, I should recompute the new route when func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). and the new route will those passed in the argument of this method delegate or should I recalculate the route ???

– Walid Sassi
Nov 27 '18 at 20:17







if I understand you, when I go away from my route, I should recompute the new route when func routing(_ routing: SYRouting, didFinishRouteRecompute route: SYRoute). and the new route will those passed in the argument of this method delegate or should I recalculate the route ???

– Walid Sassi
Nov 27 '18 at 20:17















Yep, that is correct. The route will be automatically recomputed when you go different way than you was supposed to and new route will be passed as an argument in that method. So you don't need to compute new route again.

– anonym
Nov 27 '18 at 23:24





Yep, that is correct. The route will be automatically recomputed when you go different way than you was supposed to and new route will be passed as an argument in that method. So you don't need to compute new route again.

– anonym
Nov 27 '18 at 23:24













ok, it's work fine

– Walid Sassi
Nov 28 '18 at 14:20





ok, it's work fine

– Walid Sassi
Nov 28 '18 at 14:20












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53425833%2fhow-to-recompute-route-in-sygic%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53425833%2fhow-to-recompute-route-in-sygic%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?