Discussion Board

Results 1 to 6 of 6

Threaded View

  1. #1
    Registered User
    Join Date
    May 2012

    Question How obtain the length of a route?

    Hello, how can i get the length of a route?

    I have been looking at this basic code of a route from a to b:
    // Get the DOM node to which we will append the map
    var mapContainer = document.getElementById("mapContainer");
    // Create a map inside the map container DOM node
    var map = new nokia.maps.map.Display(mapContainer, {
    		// Initial center and zoom level of the map
    		center: [52.51, 13.4],
    		zoomLevel: 7,
    		// We add the behavior component to allow panning / zooming of the map
    		components:[new nokia.maps.map.component.Behavior()]
    	router = new nokia.maps.routing.Manager(); // create a route manager;
    // The function onRouteCalculated  will be called when a route was calculated
    var onRouteCalculated = function (observedRouter, key, value) {
    		if (value == "finished") {
    			var routes = observedRouter.getRoutes();
    			//create the default map representation of a route
    			var mapRoute = new nokia.maps.routing.component.RouteResultSet(routes[0]).container;
    			//Zoom to the bounding box of the route
    			map.zoomTo(mapRoute.getBoundingBox(), false, "default");
    		} else if (value == "failed") {
    			alert("The routing request failed.");
    /* We create on observer on router's "state" property so the above created
     * onRouteCalculated we be called once the route is calculated
    router.addObserver("state", onRouteCalculated);
    // Create waypoints
    var waypoints = new nokia.maps.routing.WaypointParameterList();
    waypoints.addCoordinate(new nokia.maps.geo.Coordinate(52.51652540955727, 13.380154923889933));
    waypoints.addCoordinate(new nokia.maps.geo.Coordinate(52.52114106145058, 13.40921934080231));
    /* Properties such as type, transportModes, options, trafficMode can be
     * specified as second parameter in performing the routing request.
     * See for the mode options the "nokia.maps.routing.Mode" section in the developer's guide
    var modes = [{
    	type: "shortest", 
    	transportModes: ["car"],
    	options: "avoidTollroad",
    	trafficMode: "default"
    // Calculate the route (and call onRouteCalculated afterwards)
    router.calculateRoute(waypoints, modes);
    i found this example for Maps API for JavaME:


    but i could not do it work for javascript api, im gonna wait for your answer!
    Last edited by jasfox; 2013-01-28 at 09:04.

Similar Threads

  1. How to obtain a route between locations
    By m00zg in forum [Archived] MH5: Nokia Maps Framework for mobile HTML5
    Replies: 1
    Last Post: 2012-07-07, 10:22
  2. Replies: 3
    Last Post: 2009-09-16, 16:08
  3. route and record route on 3rd edition
    By jcaradec in forum Symbian Networking & Messaging (Closed)
    Replies: 3
    Last Post: 2007-04-16, 19:07
  4. Record-Route and Route at SIP
    By mhappenhofer in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2005-11-30, 10:22
  5. Replies: 0
    Last Post: 1970-01-01, 01:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts