Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Talk:HERE Maps API - How to calculate a route between two points

From Wiki
Jump to: navigation, search

Collandres - Re: How to calculate a route between two points

Hello, I'm trying to calculate a route between two (or more) points by using the address of the cities I want to add to the itinerary. After the initialization of the search.Managers I made a "SEARCH3.maxResults=1;" in order to have just one point per search so the itinerary may be found. I'm having a lot of troubles with the waypoints.addLocation and waypoints.addPlace functions, my code is :

                                               var SEARCH1 = new;

var SEARCH2 = new; SEARCH1.maxResults=1; SEARCH2.maxResults=1; adr1 = "Paris"; adr2 = "Dijon"; SEARCH1.placeSearch("\'"+adr1+"\'"); SEARCH2.placeSearch("\'"+adr2+"\'");

var router = new ovi.mapsapi.routing.Manager(); //create waypoints var waypoints = new ovi.mapsapi.routing.WaypointParameterList(); waypoints.addPlace(SEARCH1.places[0]); waypoints.addPlace(SEARCH2.places[0]); var modes = [{ type: "shortest", transportModes: ["car"], options: "avoidTollroad", trafficMode: "default" }];

var onRouteCalculated = function(observedRouter, key, value){ if (value == "finished") { var routes = observedRouter.getRoutes(); var mapRoute = new ovi.mapsapi.routing.component.RouteResultSet(routes[0]).container; map.objects.add(mapRoute); map.zoomTo(mapRoute.getBoundingBox(), false, "default"); } else if (value == "failed") { alert("The routing request failed."); } };

//add the observer function to the router\'s "state" property router.addObserver("state", onRouteCalculated);

//calculate the route (and call onRouteCalculated afterwards) router.calculateRoute(waypoints, modes);

In this case I would like a route from Paris to Dijon as you can see, a little help would be very usefull! Thanks,


collandres 15:24, 27 June 2011 (EEST)

Avnee.nathani - Article rename

I've updated the article to Nokia Maps Javascript API v2.0 - updated/ added new code, added screenshot, removed broken links, rebranded to 'Nokia Maps', etc. The article needs to be renamed to Nokia Maps API - How to...


avnee.nathani 12:34, 31 December 2011 (EET)