wrld.js

L.Wrld.map.routes

Methods

map.routes.getRoute(viaPoints, onLoadHandler)

var _onRoutesLoaded = function(routes) {
    // ... use the returned route options
};

var _onRoutesError = function(err) {
    console.log(err);
};

// Get routes between the two provided points
map.routes.getRoute(
    [
        [-2.9786788,56.4602727, 2], // start point (indoors on 2nd level)
        [-2.9783117,56.4600344], // end point (outside)
    ],
    _onRoutesLoaded,
    _onRoutesError
);

Get route options between the supplied indoor and/or outdoor points asynchronously, returning the results to the provided callback.

Argument Type Description
viaPoints [lon, lat, <level>] An array of [lon, lat] pairs specifying the coordinates the route should pass through, in the order they should be visited. A level can optionally be specified to indicate an indoor waypoint. This level parameter should match the level index of the indoor map floor that contains the waypoint.
onLoadHandler callback A callback taking an array of returned routes, as arrays of [lon, lat]. This is only called if no errors occurred.
onErrorHandler callback An optional callback taking some error JSON. This is only called if no routes could be acquired.
v0.1.1335