RouteClass

This class creates a customisable routing component comprising two search boxes for start and end points of the route with search suggestion lists and a mode button for setting the routing mode - walk, drive or public transport Not all modes are available in all territories and walk mode is unavailable for routes of greater than 50km. Insert into your application as a component:

Example

  route: {
       control: nokia.mh5.components.Route({
           listeners: {
               beforeroute: function(results) {
                   log("Route: beforeroute received");
               },
               clear: function(results) {
                   log("Route: clear received");
               },
               success: function(results) {
                   log("Route: success received");
               },
               error: function() {
                   log("Route: error received");
               }
           }
           cssClass: myRoutingStyles
      })
   }      

If you want to use the routing component independently from the rest of the framework, don't forget to include your appId and appCode

Example

 var myRoute = nokia.mh5.components.Route({
           listeners: {
               success: function(results) {
                  ...
               }
           }
           parameters: {
               appId: "zq55GGLOm2YioJe4pzVU",
               appCode: "MH5Examples"
           }
 });      

Inheritance hierarchy

nokia.mh5.Class
  nokia.mh5.ui.Control
    nokia.mh5.ui.Container
        nokia.mh5.components.Route

Constructor Detail

Creates a new instance of route component with given properties. Every property is optional and every property can be overwritten, see example in class definition.

new nokia.mh5.components.Route(props, parentContainer);

Constructor Parameters

Type Name Description
Object props properties for the Route component
Object props.routeAdapter custom route adapter (for switching to a different routing service)
Object props.from start of the route
Number props.from.latitude start's latitude
Number props.from.longitude start's longitude
String props.from.name start's name
Object props.to route's destination
Number props.to.latitude destination's latitude
Number props.to.longitude destination's longitude
String props.to.name destination's name
Object props.parameters hash containg route's parameters which are passed to route adapter
Object props.listeners hash of listeners for events fired by route component
Function props.listeners.beforeroute function called before route is calculated. Event parameter passed to the function contains data property, which contains the start, destination and current parameters.
Function props.listeners.clear function called when route is cleared
Function props.listeners.success function called after successful route calculation. Event parameter passed to the function contains data property, which contains the shape, maneuvers and bounding box of calculated route.
Function props.listeners.error function called after error occurs during route calculation. Event parameter passed to the function contains data property, which contains the error message.
nokia.mh5.ui.Container parentContainer parent container of the route component

Methods    Hide Inherited

publicinherited remove(name) Removes a specified a control from the container, if it can be found.
publicinherited add(control, name) Adds a control with the specified name to the container and adds the "parent" property set to the container to it.
publicinherited getContentRoot() Returns the real DOM node of the control without scroll wrapper (if present).
publicinherited getRootOwnerByClass(Class) Retrieves the instance that owns the root node of the specified Class. Used to retrieve creator of the component inside bound events.
publicinherited insertBefore(control, name, referenceControlName) Inserts a control with a specified name to the container before the control with the specified name and adds the "parent" property set to the container to it.
publicinherited prepareBindings() Calls prepareBindings on children controls (if available) and itself.
publicinherited prepareDidChangeNotifications() Calls prepareDidChangeNotifications on children controls (if available) and itself.
public route() Obtain a route based on from and to points in the route model Calls the success method of build function with the route points as parameters

Properties    Hide Inherited

publicinherited Boolean dontBind makes sure, that the bindings in the container are initialized after the build function of all children is called.
public Object from current start point, can be used for setting and getting the start point. Setting requires presence of mandatory properties: latitude and longitude.
public Object inputs contains the From and To fields.
public Object mode contains the toggle to change map mode
public Object parameters current parameters, can be used for setting and getting current parameters. Setting requires presence of mandatory property: mode. Possible values are: "walk", "drive" and "pt".
public nokia.mh5.adapters.Route routeAdapter adapter tied to the Nokia routing service
public Object to current destination, can be used for setting and getting the destination. Setting requires presence of mandatory properties: latitude and longitude.

Events

nokia.mh5.components.Route has no events.

Callbacks

nokia.mh5.components.Route has no callbacks.

Classes

nokia.mh5.components.Route has no classes.

Constants

nokia.mh5.components.Route has no constants.

Interfaces

nokia.mh5.components.Route has no interfaces.

See also