I need to display 2 different, non-connected routes using Ovi mapping. But i am unable to get this to work. In google maps i just needed to define a routing object for each route, but this doesn't seem to work in Ovi. Does anyone have any idea how?
For reference, here is the code for one route:
router = new ovi.mapsapi.routing.Manager();
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.");
}
};
router.addObserver("state", onRouteCalculated);
var waypoints = new ovi.mapsapi.routing.WaypointParameterList();
waypoints.addCoordinate(new ovi.mapsapi.geo.Coordinate(x, y))
// coords are ommited, but just a line for every stop point in Lat/Lng format
var modes =
[{
type: "shortest",
transportModes: ["car"],
options: "avoidTollroad",
trafficMode: "default"
}];
router.calculateRoute(waypoints, modes);
Making another ovi.mapsapi.routing.Manager() object and using that for another route does not work. Letting the existing one handle the second route doesn't work either
Additionally i need to display a infobubble on each marker, but i am unable to find in what container they reside
You would be better off using Nokia Maps than Ovi Maps, as Nokia Maps is the 2.0 version of the Ovi Map API. It is possible to retrieve multiple routes through creating multiple managers which then use the same call back - the example below does just that:
In the example, the A and B markers are held in the container called "mapRoute" , the separate routes are held in an array called routesArr[]