1 function MapzenEngine(id, costing) {
5 14, // kStartRight = 2;
7 15, // kDestination = 4;
8 15, // kDestinationRight = 5;
9 15, // kDestinationLeft = 6;
12 2, // kSlightRight = 9;
14 4, // kSharpRight = 11;
15 5, // kUturnRight = 12;
16 5, // kUturnLeft = 13;
17 6, // kSharpLeft = 14;
19 8, // kSlightLeft = 16;
20 1, // kRampStraight = 17;
21 2, // kRampRight = 18;
23 2, // kExitRight = 20;
25 1, // kStayStraight = 22;
26 2, // kStayRight = 23;
29 11, // kRoundaboutEnter = 26;
30 12, // kRoundaboutExit = 27;
31 18, // kFerryEnter = 28;
37 creditline: "<a href='https://mapzen.com/projects/valhalla' target='_blank'>Mapzen</a>",
40 getRoute: function (points, callback) {
42 url: document.location.protocol + "//valhalla.mapzen.com/route",
44 api_key: OSM.MAPZEN_VALHALLA_KEY,
45 json: JSON.stringify({
46 locations: points.map(function (p) { return { lat: p.lat, lon: p.lng }; }),
50 language: I18n.currentLocale()
55 success: function (data) {
58 if (trip.status === 0) {
64 trip.legs.forEach(function (leg) {
65 var legLine = L.PolylineUtil.decode(leg.shape, {
69 line = line.concat(legLine);
71 leg.maneuvers.forEach(function (manoeuvre) {
72 var point = legLine[manoeuvre.begin_shape_index];
75 { lat: point[0], lng: point[1] },
76 MZ_INSTR_MAP[manoeuvre.type],
77 manoeuvre.instruction,
78 manoeuvre.length * 1000,
83 distance = distance + leg.summary.length;
84 time = time + leg.summary.time;
90 distance: distance * 1000,
105 if (OSM.MAPZEN_VALHALLA_KEY) {
106 OSM.Directions.addEngine(new MapzenEngine("mapzen_car", "auto"), true);
107 OSM.Directions.addEngine(new MapzenEngine("mapzen_bicycle", "bicycle"), true);
108 OSM.Directions.addEngine(new MapzenEngine("mapzen_foot", "pedestrian"), true);