diff --git a/dist/leaflet-routing-machine.js b/dist/leaflet-routing-machine.js new file mode 100644 index 00000000..d1e8f976 --- /dev/null +++ b/dist/leaflet-routing-machine.js @@ -0,0 +1,2866 @@ +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),(f.L||(f.L={})).Routing=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o= 200 && status < 300 || status === 304; + } + + if (cors && !('withCredentials' in x)) { + // IE8-9 + x = new window.XDomainRequest(); + + // Ensure callback is never called synchronously, i.e., before + // x.send() returns (this has been observed in the wild). + // See https://github.com/mapbox/mapbox.js/issues/472 + var original = callback; + callback = function() { + if (sent) { + original.apply(this, arguments); + } else { + var that = this, args = arguments; + setTimeout(function() { + original.apply(that, args); + }, 0); + } + } + } + + function loaded() { + if ( + // XDomainRequest + x.status === undefined || + // modern browsers + isSuccessful(x.status)) callback.call(x, null, x); + else callback.call(x, x, null); + } + + // Both `onreadystatechange` and `onload` can fire. `onreadystatechange` + // has [been supported for longer](http://stackoverflow.com/a/9181508/229001). + if ('onload' in x) { + x.onload = loaded; + } else { + x.onreadystatechange = function readystate() { + if (x.readyState === 4) { + loaded(); + } + }; + } + + // Call the callback with the XMLHttpRequest object as an error and prevent + // it from ever being called again by reassigning it to `noop` + x.onerror = function error(evt) { + // XDomainRequest provides no evt parameter + callback.call(this, evt || true, null); + callback = function() { }; + }; + + // IE9 must have onprogress be set to a unique function. + x.onprogress = function() { }; + + x.ontimeout = function(evt) { + callback.call(this, evt, null); + callback = function() { }; + }; + + x.onabort = function(evt) { + callback.call(this, evt, null); + callback = function() { }; + }; + + // GET is the only supported HTTP Verb by XDomainRequest and is the + // only one supported here. + x.open('GET', url, true); + + // Send the request. Sending data is not supported. + x.send(null); + sent = true; + + return x; +} + +if (typeof module !== 'undefined') module.exports = corslite; + +},{}],2:[function(require,module,exports){ +var polyline = {}; + +// Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) +// +// Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js) +// by [Mark McClure](http://facstaff.unca.edu/mcmcclur/) + +function encode(coordinate, factor) { + coordinate = Math.round(coordinate * factor); + coordinate <<= 1; + if (coordinate < 0) { + coordinate = ~coordinate; + } + var output = ''; + while (coordinate >= 0x20) { + output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63); + coordinate >>= 5; + } + output += String.fromCharCode(coordinate + 63); + return output; +} + +// This is adapted from the implementation in Project-OSRM +// https://github.com/DennisOSRM/Project-OSRM-Web/blob/master/WebContent/routing/OSRM.RoutingGeometry.js +polyline.decode = function(str, precision) { + var index = 0, + lat = 0, + lng = 0, + coordinates = [], + shift = 0, + result = 0, + byte = null, + latitude_change, + longitude_change, + factor = Math.pow(10, precision || 5); + + // Coordinates have variable length when encoded, so just keep + // track of whether we've hit the end of the string. In each + // loop iteration, a single coordinate is decoded. + while (index < str.length) { + + // Reset shift, result, and byte + byte = null; + shift = 0; + result = 0; + + do { + byte = str.charCodeAt(index++) - 63; + result |= (byte & 0x1f) << shift; + shift += 5; + } while (byte >= 0x20); + + latitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1)); + + shift = result = 0; + + do { + byte = str.charCodeAt(index++) - 63; + result |= (byte & 0x1f) << shift; + shift += 5; + } while (byte >= 0x20); + + longitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1)); + + lat += latitude_change; + lng += longitude_change; + + coordinates.push([lat / factor, lng / factor]); + } + + return coordinates; +}; + +polyline.encode = function(coordinates, precision) { + if (!coordinates.length) return ''; + + var factor = Math.pow(10, precision || 5), + output = encode(coordinates[0][0], factor) + encode(coordinates[0][1], factor); + + for (var i = 1; i < coordinates.length; i++) { + var a = coordinates[i], b = coordinates[i - 1]; + output += encode(a[0] - b[0], factor); + output += encode(a[1] - b[1], factor); + } + + return output; +}; + +if (typeof module !== undefined) module.exports = polyline; + +},{}],3:[function(require,module,exports){ +(function() { + 'use strict'; + + L.Routing = L.Routing || {}; + + L.Routing.Autocomplete = L.Class.extend({ + options: { + timeout: 500, + blurTimeout: 100, + noResultsMessage: 'No results found.' + }, + + initialize: function(elem, callback, context, options) { + L.setOptions(this, options); + + this._elem = elem; + this._resultFn = options.resultFn ? L.Util.bind(options.resultFn, options.resultContext) : null; + this._autocomplete = options.autocompleteFn ? L.Util.bind(options.autocompleteFn, options.autocompleteContext) : null; + this._selectFn = L.Util.bind(callback, context); + this._container = L.DomUtil.create('div', 'leaflet-routing-geocoder-result'); + this._resultTable = L.DomUtil.create('table', '', this._container); + + // TODO: looks a bit like a kludge to register same for input and keypress - + // browsers supporting both will get duplicate events; just registering + // input will not catch enter, though. + L.DomEvent.addListener(this._elem, 'input', this._keyPressed, this); + L.DomEvent.addListener(this._elem, 'keypress', this._keyPressed, this); + L.DomEvent.addListener(this._elem, 'keydown', this._keyDown, this); + L.DomEvent.addListener(this._elem, 'blur', function() { + if (this._isOpen) { + this.close(); + } + }, this); + }, + + close: function() { + L.DomUtil.removeClass(this._container, 'leaflet-routing-geocoder-result-open'); + this._isOpen = false; + }, + + _open: function() { + var rect = this._elem.getBoundingClientRect(); + if (!this._container.parentElement) { + // See notes section under https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX + // This abomination is required to support all flavors of IE + var scrollX = (window.pageXOffset !== undefined) ? window.pageXOffset + : (document.documentElement || document.body.parentNode || document.body).scrollLeft; + var scrollY = (window.pageYOffset !== undefined) ? window.pageYOffset + : (document.documentElement || document.body.parentNode || document.body).scrollTop; + this._container.style.left = (rect.left + scrollX) + 'px'; + this._container.style.top = (rect.bottom + scrollY) + 'px'; + this._container.style.width = (rect.right - rect.left) + 'px'; + document.body.appendChild(this._container); + } + + L.DomUtil.addClass(this._container, 'leaflet-routing-geocoder-result-open'); + this._isOpen = true; + }, + + _setResults: function(results) { + var i, + tr, + td, + text; + + delete this._selection; + this._results = results; + + while (this._resultTable.firstChild) { + this._resultTable.removeChild(this._resultTable.firstChild); + } + + for (i = 0; i < results.length; i++) { + tr = L.DomUtil.create('tr', '', this._resultTable); + tr.setAttribute('data-result-index', i); + td = L.DomUtil.create('td', '', tr); + text = document.createTextNode(results[i].name); + td.appendChild(text); + // mousedown + click because: + // http://stackoverflow.com/questions/10652852/jquery-fire-click-before-blur-event + L.DomEvent.addListener(td, 'mousedown', L.DomEvent.preventDefault); + L.DomEvent.addListener(td, 'click', this._createClickListener(results[i])); + } + + if (!i) { + tr = L.DomUtil.create('tr', '', this._resultTable); + td = L.DomUtil.create('td', 'leaflet-routing-geocoder-no-results', tr); + td.innerHTML = this.options.noResultsMessage; + } + + this._open(); + + if (results.length > 0) { + // Select the first entry + this._select(1); + } + }, + + _createClickListener: function(r) { + var resultSelected = this._resultSelected(r); + return L.bind(function() { + this._elem.blur(); + resultSelected(); + }, this); + }, + + _resultSelected: function(r) { + return L.bind(function() { + this.close(); + this._elem.value = r.name; + this._lastCompletedText = r.name; + this._selectFn(r); + }, this); + }, + + _keyPressed: function(e) { + var index; + + if (this._isOpen && e.keyCode === 13 && this._selection) { + index = parseInt(this._selection.getAttribute('data-result-index'), 10); + this._resultSelected(this._results[index])(); + L.DomEvent.preventDefault(e); + return; + } + + if (e.keyCode === 13) { + this._complete(this._resultFn, true); + return; + } + + if (this._autocomplete && document.activeElement === this._elem) { + if (this._timer) { + clearTimeout(this._timer); + } + this._timer = setTimeout(L.Util.bind(function() { this._complete(this._autocomplete); }, this), + this.options.timeout); + return; + } + + this._unselect(); + }, + + _select: function(dir) { + var sel = this._selection; + if (sel) { + L.DomUtil.removeClass(sel.firstChild, 'leaflet-routing-geocoder-selected'); + sel = sel[dir > 0 ? 'nextSibling' : 'previousSibling']; + } + if (!sel) { + sel = this._resultTable[dir > 0 ? 'firstChild' : 'lastChild']; + } + + if (sel) { + L.DomUtil.addClass(sel.firstChild, 'leaflet-routing-geocoder-selected'); + this._selection = sel; + } + }, + + _unselect: function() { + if (this._selection) { + L.DomUtil.removeClass(this._selection.firstChild, 'leaflet-routing-geocoder-selected'); + } + delete this._selection; + }, + + _keyDown: function(e) { + if (this._isOpen) { + switch (e.keyCode) { + // Escape + case 27: + this.close(); + L.DomEvent.preventDefault(e); + return; + // Up + case 38: + this._select(-1); + L.DomEvent.preventDefault(e); + return; + // Down + case 40: + this._select(1); + L.DomEvent.preventDefault(e); + return; + } + } + }, + + _complete: function(completeFn, trySelect) { + var v = this._elem.value; + function completeResults(results) { + this._lastCompletedText = v; + if (trySelect && results.length === 1) { + this._resultSelected(results[0])(); + } else { + this._setResults(results); + } + } + + if (!v) { + return; + } + + if (v !== this._lastCompletedText) { + completeFn(v, completeResults, this); + } else if (trySelect) { + completeResults.call(this, this._results); + } + } + }); +})(); + +},{}],4:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null); + + L.Routing = L.Routing || {}; + L.extend(L.Routing, require('./L.Routing.Itinerary')); + L.extend(L.Routing, require('./L.Routing.Line')); + L.extend(L.Routing, require('./L.Routing.Plan')); + L.extend(L.Routing, require('./L.Routing.OSRMv1')); + L.extend(L.Routing, require('./L.Routing.Mapbox')); + L.extend(L.Routing, require('./L.Routing.ErrorControl')); + + L.Routing.Control = L.Routing.Itinerary.extend({ + options: { + fitSelectedRoutes: 'smart', + routeLine: function(route, options) { return L.Routing.line(route, options); }, + autoRoute: true, + routeWhileDragging: false, + routeDragInterval: 500, + waypointMode: 'connect', + showAlternatives: false, + defaultErrorHandler: function(e) { + console.error('Routing error:', e.error); + } + }, + + initialize: function(options) { + L.Util.setOptions(this, options); + + this._router = this.options.router || new L.Routing.OSRMv1(options); + this._plan = this.options.plan || L.Routing.plan(this.options.waypoints, options); + this._requestCount = 0; + + L.Routing.Itinerary.prototype.initialize.call(this, options); + + this.on('routeselected', this._routeSelected, this); + if (this.options.defaultErrorHandler) { + this.on('routingerror', this.options.defaultErrorHandler); + } + this._plan.on('waypointschanged', this._onWaypointsChanged, this); + if (options.routeWhileDragging) { + this._setupRouteDragging(); + } + + if (this.options.autoRoute) { + this.route(); + } + }, + + onAdd: function(map) { + var container = L.Routing.Itinerary.prototype.onAdd.call(this, map); + + this._map = map; + this._map.addLayer(this._plan); + + this._map.on('zoomend', function() { + if (!this._selectedRoute || + !this._router.requiresMoreDetail) { + return; + } + + var map = this._map; + if (this._router.requiresMoreDetail(this._selectedRoute, + map.getZoom(), map.getBounds())) { + this.route({ + callback: L.bind(function(err, routes) { + var i; + if (!err) { + for (i = 0; i < routes.length; i++) { + this._routes[i].properties = routes[i].properties; + } + this._updateLineCallback(err, routes); + } + + }, this), + simplifyGeometry: false, + geometryOnly: true + }); + } + }, this); + + if (this._plan.options.geocoder) { + container.insertBefore(this._plan.createGeocoders(), container.firstChild); + } + + return container; + }, + + onRemove: function(map) { + if (this._line) { + map.removeLayer(this._line); + } + map.removeLayer(this._plan); + return L.Routing.Itinerary.prototype.onRemove.call(this, map); + }, + + getWaypoints: function() { + return this._plan.getWaypoints(); + }, + + setWaypoints: function(waypoints) { + this._plan.setWaypoints(waypoints); + return this; + }, + + spliceWaypoints: function() { + var removed = this._plan.spliceWaypoints.apply(this._plan, arguments); + return removed; + }, + + getPlan: function() { + return this._plan; + }, + + getRouter: function() { + return this._router; + }, + + _routeSelected: function(e) { + var route = this._selectedRoute = e.route, + alternatives = this.options.showAlternatives && e.alternatives, + fitMode = this.options.fitSelectedRoutes, + fitBounds = + (fitMode === 'smart' && !this._waypointsVisible()) || + (fitMode !== 'smart' && fitMode); + + this._updateLines({route: route, alternatives: alternatives}); + + if (fitBounds) { + this._map.fitBounds(this._line.getBounds()); + } + + if (this.options.waypointMode === 'snap') { + this._plan.off('waypointschanged', this._onWaypointsChanged, this); + this.setWaypoints(route.waypoints); + this._plan.on('waypointschanged', this._onWaypointsChanged, this); + } + }, + + _waypointsVisible: function() { + var wps = this.getWaypoints(), + mapSize, + bounds, + boundsSize, + i, + p; + + try { + mapSize = this._map.getSize(); + + for (i = 0; i < wps.length; i++) { + p = this._map.latLngToLayerPoint(wps[i].latLng); + + if (bounds) { + bounds.extend(p); + } else { + bounds = L.bounds([p]); + } + } + + boundsSize = bounds.getSize(); + return (boundsSize.x > mapSize.x / 5 || + boundsSize.y > mapSize.y / 5) && this._waypointsInViewport(); + + } catch (e) { + return false; + } + }, + + _waypointsInViewport: function() { + var wps = this.getWaypoints(), + mapBounds, + i; + + try { + mapBounds = this._map.getBounds(); + } catch (e) { + return false; + } + + for (i = 0; i < wps.length; i++) { + if (mapBounds.contains(wps[i].latLng)) { + return true; + } + } + + return false; + }, + + _updateLines: function(routes) { + var addWaypoints = this.options.addWaypoints !== undefined ? + this.options.addWaypoints : true; + this._clearLines(); + + // add alternatives first so they lie below the main route + this._alternatives = []; + if (routes.alternatives) routes.alternatives.forEach(function(alt, i) { + this._alternatives[i] = this.options.routeLine(alt, + L.extend({ + isAlternative: true + }, this.options.altLineOptions || this.options.lineOptions)); + this._alternatives[i].addTo(this._map); + this._hookAltEvents(this._alternatives[i]); + }, this); + + this._line = this.options.routeLine(routes.route, + L.extend({ + addWaypoints: addWaypoints, + extendToWaypoints: this.options.waypointMode === 'connect' + }, this.options.lineOptions)); + this._line.addTo(this._map); + this._hookEvents(this._line); + }, + + _hookEvents: function(l) { + l.on('linetouched', function(e) { + this._plan.dragNewWaypoint(e); + }, this); + }, + + _hookAltEvents: function(l) { + l.on('linetouched', function(e) { + var alts = this._routes.slice(); + var selected = alts.splice(e.target._route.routesIndex, 1)[0]; + this.fire('routeselected', {route: selected, alternatives: alts}); + }, this); + }, + + _onWaypointsChanged: function(e) { + if (this.options.autoRoute) { + this.route({}); + } + if (!this._plan.isReady()) { + this._clearLines(); + this._clearAlts(); + } + this.fire('waypointschanged', {waypoints: e.waypoints}); + }, + + _setupRouteDragging: function() { + var timer = 0, + waypoints; + + this._plan.on('waypointdrag', L.bind(function(e) { + waypoints = e.waypoints; + + if (!timer) { + timer = setTimeout(L.bind(function() { + this.route({ + waypoints: waypoints, + geometryOnly: true, + callback: L.bind(this._updateLineCallback, this) + }); + timer = undefined; + }, this), this.options.routeDragInterval); + } + }, this)); + this._plan.on('waypointdragend', function() { + if (timer) { + clearTimeout(timer); + timer = undefined; + } + this.route(); + }, this); + }, + + _updateLineCallback: function(err, routes) { + if (!err) { + routes = routes.slice(); + var selected = routes.splice(this._selectedRoute.routesIndex, 1)[0]; + this._updateLines({route: selected, alternatives: routes }); + } else { + this._clearLines(); + } + }, + + route: function(options) { + var ts = ++this._requestCount, + wps; + + options = options || {}; + + if (this._plan.isReady()) { + if (this.options.useZoomParameter) { + options.z = this._map && this._map.getZoom(); + } + + wps = options && options.waypoints || this._plan.getWaypoints(); + this.fire('routingstart', {waypoints: wps}); + this._router.route(wps, options.callback || function(err, routes) { + // Prevent race among multiple requests, + // by checking the current request's timestamp + // against the last request's; ignore result if + // this isn't the latest request. + if (ts === this._requestCount) { + this._clearLines(); + this._clearAlts(); + if (err) { + this.fire('routingerror', {error: err}); + return; + } + + routes.forEach(function(route, i) { route.routesIndex = i; }); + + if (!options.geometryOnly) { + this.fire('routesfound', {waypoints: wps, routes: routes}); + this.setAlternatives(routes); + } else { + var selectedRoute = routes.splice(0,1)[0]; + this._routeSelected({route: selectedRoute, alternatives: routes}); + } + } + }, this, options); + } + }, + + _clearLines: function() { + if (this._line) { + this._map.removeLayer(this._line); + delete this._line; + } + if (this._alternatives && this._alternatives.length) { + for (var i in this._alternatives) { + this._map.removeLayer(this._alternatives[i]); + } + this._alternatives = []; + } + } + }); + + L.Routing.control = function(options) { + return new L.Routing.Control(options); + }; + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./L.Routing.ErrorControl":5,"./L.Routing.Itinerary":8,"./L.Routing.Line":10,"./L.Routing.Mapbox":12,"./L.Routing.OSRMv1":13,"./L.Routing.Plan":14}],5:[function(require,module,exports){ +(function() { + 'use strict'; + + L.Routing = L.Routing || {}; + + L.Routing.ErrorControl = L.Control.extend({ + options: { + header: 'Routing error', + formatMessage: function(error) { + if (error.status < 0) { + return 'Calculating the route caused an error. Technical description follows:
' +
+						error.message + '
= 1000) { + data = { + value: round(d / 1609.344, sensitivity), + unit: un.miles + }; + } else { + data = { + value: round(yards, sensitivity), + unit: un.yards + }; + } + } else { + v = round(d, sensitivity); + data = { + value: v >= 1000 ? (v / 1000) : v, + unit: v >= 1000 ? un.kilometers : un.meters + }; + } + + if (simpleRounding) { + data.value = data.value.toFixed(-sensitivity); + } + + return L.Util.template(this.options.distanceTemplate, data); + }, + + _round: function(d, sensitivity) { + var s = sensitivity || this.options.roundingSensitivity, + pow10 = Math.pow(10, (Math.floor(d / s) + '').length - 1), + r = Math.floor(d / pow10), + p = (r > 5) ? pow10 : pow10 / 2; + + return Math.round(d / p) * p; + }, + + formatTime: function(t /* Number (seconds) */) { + var un = this.options.unitNames || this._localization.localize('units'); + // More than 30 seconds precision looks ridiculous + t = Math.round(t / 30) * 30; + + if (t > 86400) { + return Math.round(t / 3600) + ' ' + un.hours; + } else if (t > 3600) { + return Math.floor(t / 3600) + ' ' + un.hours + ' ' + + Math.round((t % 3600) / 60) + ' ' + un.minutes; + } else if (t > 300) { + return Math.round(t / 60) + ' ' + un.minutes; + } else if (t > 60) { + return Math.floor(t / 60) + ' ' + un.minutes + + (t % 60 !== 0 ? ' ' + (t % 60) + ' ' + un.seconds : ''); + } else { + return t + ' ' + un.seconds; + } + }, + + formatInstruction: function(instr, i) { + if (instr.text === undefined) { + return this.capitalize(L.Util.template(this._getInstructionTemplate(instr, i), + L.extend({}, instr, { + exitStr: instr.exit ? this._localization.localize('formatOrder')(instr.exit) : '', + dir: this._localization.localize(['directions', instr.direction]), + modifier: this._localization.localize(['directions', instr.modifier]) + }))); + } else { + return instr.text; + } + }, + + getIconName: function(instr, i) { + switch (instr.type) { + case 'Head': + if (i === 0) { + return 'depart'; + } + break; + case 'WaypointReached': + return 'via'; + case 'Roundabout': + return 'enter-roundabout'; + case 'DestinationReached': + return 'arrive'; + } + + switch (instr.modifier) { + case 'Straight': + return 'continue'; + case 'SlightRight': + return 'bear-right'; + case 'Right': + return 'turn-right'; + case 'SharpRight': + return 'sharp-right'; + case 'TurnAround': + case 'Uturn': + return 'u-turn'; + case 'SharpLeft': + return 'sharp-left'; + case 'Left': + return 'turn-left'; + case 'SlightLeft': + return 'bear-left'; + } + }, + + capitalize: function(s) { + return s.charAt(0).toUpperCase() + s.substring(1); + }, + + _getInstructionTemplate: function(instr, i) { + var type = instr.type === 'Straight' ? (i === 0 ? 'Head' : 'Continue') : instr.type, + strings = this._localization.localize(['instructions', type]); + + if (!strings) { + strings = [ + this._localization.localize(['directions', type]), + ' ' + this._localization.localize(['instructions', 'Onto']) + ]; + } + + return strings[0] + (strings.length > 1 && instr.road ? strings[1] : ''); + } + }); + + module.exports = L.Routing; +})(); + + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./L.Routing.Localization":11}],7:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null); + L.Routing = L.Routing || {}; + L.extend(L.Routing, require('./L.Routing.Autocomplete')); + + function selectInputText(input) { + if (input.setSelectionRange) { + // On iOS, select() doesn't work + input.setSelectionRange(0, 9999); + } else { + // On at least IE8, setSeleectionRange doesn't exist + input.select(); + } + } + + L.Routing.GeocoderElement = L.Class.extend({ + includes: L.Mixin.Events, + + options: { + createGeocoder: function(i, nWps, options) { + var container = L.DomUtil.create('div', 'leaflet-routing-geocoder'), + input = L.DomUtil.create('input', '', container), + remove = options.addWaypoints ? L.DomUtil.create('span', 'leaflet-routing-remove-waypoint', container) : undefined; + + input.disabled = !options.addWaypoints; + + return { + container: container, + input: input, + closeButton: remove + }; + }, + geocoderPlaceholder: function(i, numberWaypoints, geocoderElement) { + var l = new L.Routing.Localization(geocoderElement.options.language).localize('ui'); + return i === 0 ? + l.startPlaceholder : + (i < numberWaypoints - 1 ? + L.Util.template(l.viaPlaceholder, {viaNumber: i}) : + l.endPlaceholder); + }, + + geocoderClass: function() { + return ''; + }, + + waypointNameFallback: function(latLng) { + var ns = latLng.lat < 0 ? 'S' : 'N', + ew = latLng.lng < 0 ? 'W' : 'E', + lat = (Math.round(Math.abs(latLng.lat) * 10000) / 10000).toString(), + lng = (Math.round(Math.abs(latLng.lng) * 10000) / 10000).toString(); + return ns + lat + ', ' + ew + lng; + }, + maxGeocoderTolerance: 200, + autocompleteOptions: {}, + language: 'en', + }, + + initialize: function(wp, i, nWps, options) { + L.setOptions(this, options); + + var g = this.options.createGeocoder(i, nWps, this.options), + closeButton = g.closeButton, + geocoderInput = g.input; + geocoderInput.setAttribute('placeholder', this.options.geocoderPlaceholder(i, nWps, this)); + geocoderInput.className = this.options.geocoderClass(i, nWps); + + this._element = g; + this._waypoint = wp; + + this.update(); + // This has to be here, or geocoder's value will not be properly + // initialized. + // TODO: look into why and make _updateWaypointName fix this. + geocoderInput.value = wp.name; + + L.DomEvent.addListener(geocoderInput, 'click', function() { + selectInputText(this); + }, geocoderInput); + + if (closeButton) { + L.DomEvent.addListener(closeButton, 'click', function() { + this.fire('delete', { waypoint: this._waypoint }); + }, this); + } + + new L.Routing.Autocomplete(geocoderInput, function(r) { + geocoderInput.value = r.name; + wp.name = r.name; + wp.latLng = r.center; + this.fire('geocoded', { waypoint: wp, value: r }); + }, this, L.extend({ + resultFn: this.options.geocoder.geocode, + resultContext: this.options.geocoder, + autocompleteFn: this.options.geocoder.suggest, + autocompleteContext: this.options.geocoder + }, this.options.autocompleteOptions)); + }, + + getContainer: function() { + return this._element.container; + }, + + setValue: function(v) { + this._element.input.value = v; + }, + + update: function(force) { + var wp = this._waypoint, + wpCoords; + + wp.name = wp.name || ''; + + if (wp.latLng && (force || !wp.name)) { + wpCoords = this.options.waypointNameFallback(wp.latLng); + if (this.options.geocoder && this.options.geocoder.reverse) { + this.options.geocoder.reverse(wp.latLng, 67108864 /* zoom 18 */, function(rs) { + if (rs.length > 0 && rs[0].center.distanceTo(wp.latLng) < this.options.maxGeocoderTolerance) { + wp.name = rs[0].name; + } else { + wp.name = wpCoords; + } + this._update(); + }, this); + } else { + wp.name = wpCoords; + this._update(); + } + } + }, + + focus: function() { + var input = this._element.input; + input.focus(); + selectInputText(input); + }, + + _update: function() { + var wp = this._waypoint, + value = wp && wp.name ? wp.name : ''; + this.setValue(value); + this.fire('reversegeocoded', {waypoint: wp, value: value}); + } + }); + + L.Routing.geocoderElement = function(wp, i, nWps, plan) { + return new L.Routing.GeocoderElement(wp, i, nWps, plan); + }; + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./L.Routing.Autocomplete":3}],8:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null); + + L.Routing = L.Routing || {}; + L.extend(L.Routing, require('./L.Routing.Formatter')); + L.extend(L.Routing, require('./L.Routing.ItineraryBuilder')); + + L.Routing.Itinerary = L.Control.extend({ + includes: L.Mixin.Events, + + options: { + pointMarkerStyle: { + radius: 5, + color: '#03f', + fillColor: 'white', + opacity: 1, + fillOpacity: 0.7 + }, + summaryTemplate: '

{name}

{distance}, {time}

', + timeTemplate: '{time}', + containerClassName: '', + alternativeClassName: '', + minimizedClassName: '', + itineraryClassName: '', + totalDistanceRoundingSensitivity: -1, + show: true, + collapsible: undefined, + collapseBtn: function(itinerary) { + var collapseBtn = L.DomUtil.create('span', itinerary.options.collapseBtnClass); + L.DomEvent.on(collapseBtn, 'click', itinerary._toggle, itinerary); + itinerary._container.insertBefore(collapseBtn, itinerary._container.firstChild); + }, + collapseBtnClass: 'leaflet-routing-collapse-btn' + }, + + initialize: function(options) { + L.setOptions(this, options); + this._formatter = this.options.formatter || new L.Routing.Formatter(this.options); + this._itineraryBuilder = this.options.itineraryBuilder || new L.Routing.ItineraryBuilder({ + containerClassName: this.options.itineraryClassName + }); + }, + + onAdd: function(map) { + var collapsible = this.options.collapsible; + + collapsible = collapsible || (collapsible === undefined && map.getSize().x <= 640); + + this._container = L.DomUtil.create('div', 'leaflet-routing-container leaflet-bar ' + + (!this.options.show ? 'leaflet-routing-container-hide ' : '') + + (collapsible ? 'leaflet-routing-collapsible ' : '') + + this.options.containerClassName); + this._altContainer = this.createAlternativesContainer(); + this._container.appendChild(this._altContainer); + L.DomEvent.disableClickPropagation(this._container); + L.DomEvent.addListener(this._container, 'mousewheel', function(e) { + L.DomEvent.stopPropagation(e); + }); + + if (collapsible) { + this.options.collapseBtn(this); + } + + return this._container; + }, + + onRemove: function() { + }, + + createAlternativesContainer: function() { + return L.DomUtil.create('div', 'leaflet-routing-alternatives-container'); + }, + + setAlternatives: function(routes) { + var i, + alt, + altDiv; + + this._clearAlts(); + + this._routes = routes; + + for (i = 0; i < this._routes.length; i++) { + alt = this._routes[i]; + altDiv = this._createAlternative(alt, i); + this._altContainer.appendChild(altDiv); + this._altElements.push(altDiv); + } + + this._selectRoute({route: this._routes[0], alternatives: this._routes.slice(1)}); + + return this; + }, + + show: function() { + L.DomUtil.removeClass(this._container, 'leaflet-routing-container-hide'); + }, + + hide: function() { + L.DomUtil.addClass(this._container, 'leaflet-routing-container-hide'); + }, + + _toggle: function() { + var collapsed = L.DomUtil.hasClass(this._container, 'leaflet-routing-container-hide'); + this[collapsed ? 'show' : 'hide'](); + }, + + _createAlternative: function(alt, i) { + var altDiv = L.DomUtil.create('div', 'leaflet-routing-alt ' + + this.options.alternativeClassName + + (i > 0 ? ' leaflet-routing-alt-minimized ' + this.options.minimizedClassName : '')), + template = this.options.summaryTemplate, + data = L.extend({ + name: alt.name, + distance: this._formatter.formatDistance(alt.summary.totalDistance, this.options.totalDistanceRoundingSensitivity), + time: this._formatter.formatTime(alt.summary.totalTime) + }, alt); + altDiv.innerHTML = typeof(template) === 'function' ? template(data) : L.Util.template(template, data); + L.DomEvent.addListener(altDiv, 'click', this._onAltClicked, this); + this.on('routeselected', this._selectAlt, this); + + altDiv.appendChild(this._createItineraryContainer(alt)); + return altDiv; + }, + + _clearAlts: function() { + var el = this._altContainer; + while (el && el.firstChild) { + el.removeChild(el.firstChild); + } + + this._altElements = []; + }, + + _createItineraryContainer: function(r) { + var container = this._itineraryBuilder.createContainer(), + steps = this._itineraryBuilder.createStepsContainer(), + i, + instr, + step, + distance, + text, + icon; + + container.appendChild(steps); + + for (i = 0; i < r.instructions.length; i++) { + instr = r.instructions[i]; + text = this._formatter.formatInstruction(instr, i); + distance = this._formatter.formatDistance(instr.distance); + icon = this._formatter.getIconName(instr, i); + step = this._itineraryBuilder.createStep(text, distance, icon, steps); + + this._addRowListeners(step, r.coordinates[instr.index]); + } + + return container; + }, + + _addRowListeners: function(row, coordinate) { + L.DomEvent.addListener(row, 'mouseover', function() { + this._marker = L.circleMarker(coordinate, + this.options.pointMarkerStyle).addTo(this._map); + }, this); + L.DomEvent.addListener(row, 'mouseout', function() { + if (this._marker) { + this._map.removeLayer(this._marker); + delete this._marker; + } + }, this); + L.DomEvent.addListener(row, 'click', function(e) { + this._map.panTo(coordinate); + L.DomEvent.stopPropagation(e); + }, this); + }, + + _onAltClicked: function(e) { + var altElem = e.target || window.event.srcElement; + while (!L.DomUtil.hasClass(altElem, 'leaflet-routing-alt')) { + altElem = altElem.parentElement; + } + + var j = this._altElements.indexOf(altElem); + var alts = this._routes.slice(); + var route = alts.splice(j, 1)[0]; + + this.fire('routeselected', { + route: route, + alternatives: alts + }); + }, + + _selectAlt: function(e) { + var altElem, + j, + n, + classFn; + + altElem = this._altElements[e.route.routesIndex]; + + if (L.DomUtil.hasClass(altElem, 'leaflet-routing-alt-minimized')) { + for (j = 0; j < this._altElements.length; j++) { + n = this._altElements[j]; + classFn = j === e.route.routesIndex ? 'removeClass' : 'addClass'; + L.DomUtil[classFn](n, 'leaflet-routing-alt-minimized'); + if (this.options.minimizedClassName) { + L.DomUtil[classFn](n, this.options.minimizedClassName); + } + + if (j !== e.route.routesIndex) n.scrollTop = 0; + } + } + + L.DomEvent.stop(e); + }, + + _selectRoute: function(routes) { + if (this._marker) { + this._map.removeLayer(this._marker); + delete this._marker; + } + this.fire('routeselected', routes); + } + }); + + L.Routing.itinerary = function(options) { + return new L.Routing.Itinerary(options); + }; + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./L.Routing.Formatter":6,"./L.Routing.ItineraryBuilder":9}],9:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null); + L.Routing = L.Routing || {}; + + L.Routing.ItineraryBuilder = L.Class.extend({ + options: { + containerClassName: '' + }, + + initialize: function(options) { + L.setOptions(this, options); + }, + + createContainer: function(className) { + var table = L.DomUtil.create('table', className || ''), + colgroup = L.DomUtil.create('colgroup', '', table); + + L.DomUtil.create('col', 'leaflet-routing-instruction-icon', colgroup); + L.DomUtil.create('col', 'leaflet-routing-instruction-text', colgroup); + L.DomUtil.create('col', 'leaflet-routing-instruction-distance', colgroup); + + return table; + }, + + createStepsContainer: function() { + return L.DomUtil.create('tbody', ''); + }, + + createStep: function(text, distance, icon, steps) { + var row = L.DomUtil.create('tr', '', steps), + span, + td; + td = L.DomUtil.create('td', '', row); + span = L.DomUtil.create('span', 'leaflet-routing-icon leaflet-routing-icon-'+icon, td); + td.appendChild(span); + td = L.DomUtil.create('td', '', row); + td.appendChild(document.createTextNode(text)); + td = L.DomUtil.create('td', '', row); + td.appendChild(document.createTextNode(distance)); + return row; + } + }); + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],10:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null); + + L.Routing = L.Routing || {}; + + L.Routing.Line = L.LayerGroup.extend({ + includes: L.Mixin.Events, + + options: { + styles: [ + {color: 'black', opacity: 0.15, weight: 9}, + {color: 'white', opacity: 0.8, weight: 6}, + {color: 'red', opacity: 1, weight: 2} + ], + missingRouteStyles: [ + {color: 'black', opacity: 0.15, weight: 7}, + {color: 'white', opacity: 0.6, weight: 4}, + {color: 'gray', opacity: 0.8, weight: 2, dashArray: '7,12'} + ], + addWaypoints: true, + extendToWaypoints: true, + missingRouteTolerance: 10 + }, + + initialize: function(route, options) { + L.setOptions(this, options); + L.LayerGroup.prototype.initialize.call(this, options); + this._route = route; + + if (this.options.extendToWaypoints) { + this._extendToWaypoints(); + } + + this._addSegment( + route.coordinates, + this.options.styles, + this.options.addWaypoints); + }, + + getBounds: function() { + return L.latLngBounds(this._route.coordinates); + }, + + _findWaypointIndices: function() { + var wps = this._route.inputWaypoints, + indices = [], + i; + for (i = 0; i < wps.length; i++) { + indices.push(this._findClosestRoutePoint(wps[i].latLng)); + } + + return indices; + }, + + _findClosestRoutePoint: function(latlng) { + var minDist = Number.MAX_VALUE, + minIndex, + i, + d; + + for (i = this._route.coordinates.length - 1; i >= 0 ; i--) { + // TODO: maybe do this in pixel space instead? + d = latlng.distanceTo(this._route.coordinates[i]); + if (d < minDist) { + minIndex = i; + minDist = d; + } + } + + return minIndex; + }, + + _extendToWaypoints: function() { + var wps = this._route.inputWaypoints, + wpIndices = this._getWaypointIndices(), + i, + wpLatLng, + routeCoord; + + for (i = 0; i < wps.length; i++) { + wpLatLng = wps[i].latLng; + routeCoord = L.latLng(this._route.coordinates[wpIndices[i]]); + if (wpLatLng.distanceTo(routeCoord) > + this.options.missingRouteTolerance) { + this._addSegment([wpLatLng, routeCoord], + this.options.missingRouteStyles); + } + } + }, + + _addSegment: function(coords, styles, mouselistener) { + var i, + pl; + + for (i = 0; i < styles.length; i++) { + pl = L.polyline(coords, styles[i]); + this.addLayer(pl); + if (mouselistener) { + pl.on('mousedown', this._onLineTouched, this); + } + } + }, + + _findNearestWpBefore: function(i) { + var wpIndices = this._getWaypointIndices(), + j = wpIndices.length - 1; + while (j >= 0 && wpIndices[j] > i) { + j--; + } + + return j; + }, + + _onLineTouched: function(e) { + var afterIndex = this._findNearestWpBefore(this._findClosestRoutePoint(e.latlng)); + this.fire('linetouched', { + afterIndex: afterIndex, + latlng: e.latlng + }); + }, + + _getWaypointIndices: function() { + if (!this._wpIndices) { + this._wpIndices = this._route.waypointIndices || this._findWaypointIndices(); + } + + return this._wpIndices; + } + }); + + L.Routing.line = function(route, options) { + return new L.Routing.Line(route, options); + }; + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],11:[function(require,module,exports){ +(function() { + 'use strict'; + L.Routing = L.Routing || {}; + + L.Routing.Localization = L.Class.extend({ + initialize: function(langs) { + this._langs = L.Util.isArray(langs) ? langs : [langs, 'en']; + + for (var i = 0, l = this._langs.length; i < l; i++) { + if (!L.Routing.Localization[this._langs[i]]) { + throw new Error('No localization for language "' + this._langs[i] + '".'); + } + } + }, + + localize: function(keys) { + var dict, + key, + value; + + keys = L.Util.isArray(keys) ? keys : [keys]; + + for (var i = 0, l = this._langs.length; i < l; i++) { + dict = L.Routing.Localization[this._langs[i]]; + for (var j = 0, nKeys = keys.length; dict && j < nKeys; j++) { + key = keys[j]; + value = dict[key]; + dict = value; + } + + if (value) { + return value; + } + } + } + }); + + L.Routing.Localization = L.extend(L.Routing.Localization, { + 'en': { + directions: { + N: 'north', + NE: 'northeast', + E: 'east', + SE: 'southeast', + S: 'south', + SW: 'southwest', + W: 'west', + NW: 'northwest', + SlightRight: 'slight right', + Right: 'right', + SharpRight: 'sharp right', + SlightLeft: 'slight left', + Left: 'left', + SharpLeft: 'sharp left', + Uturn: 'Turn around' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Head {dir}', ' on {road}'], + 'Continue': + ['Continue {dir}'], + 'TurnAround': + ['Turn around'], + 'WaypointReached': + ['Waypoint reached'], + 'Roundabout': + ['Take the {exitStr} exit in the roundabout', ' onto {road}'], + 'DestinationReached': + ['Destination reached'], + 'Fork': ['At the fork, turn {modifier}', ' onto {road}'], + 'Merge': ['Merge {modifier}', ' onto {road}'], + 'OnRamp': ['Turn {modifier} on the ramp', ' onto {road}'], + 'OffRamp': ['Take the ramp on the {modifier}', ' onto {road}'], + 'EndOfRoad': ['Turn {modifier} at the end of the road', ' onto {road}'], + 'Onto': 'onto {road}' + }, + formatOrder: function(n) { + var i = n % 10 - 1, + suffix = ['st', 'nd', 'rd']; + + return suffix[i] ? n + suffix[i] : n + 'th'; + }, + ui: { + startPlaceholder: 'Start', + viaPlaceholder: 'Via {viaNumber}', + endPlaceholder: 'End' + }, + units: { + meters: 'm', + kilometers: 'km', + yards: 'yd', + miles: 'mi', + hours: 'h', + minutes: 'mín', + seconds: 's' + } + }, + + 'de': { + directions: { + N: 'Norden', + NE: 'Nordosten', + E: 'Osten', + SE: 'Südosten', + S: 'Süden', + SW: 'Südwesten', + W: 'Westen', + NW: 'Nordwesten' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Richtung {dir}', ' auf {road}'], + 'Continue': + ['Geradeaus Richtung {dir}', ' auf {road}'], + 'SlightRight': + ['Leicht rechts abbiegen', ' auf {road}'], + 'Right': + ['Rechts abbiegen', ' auf {road}'], + 'SharpRight': + ['Scharf rechts abbiegen', ' auf {road}'], + 'TurnAround': + ['Wenden'], + 'SharpLeft': + ['Scharf links abbiegen', ' auf {road}'], + 'Left': + ['Links abbiegen', ' auf {road}'], + 'SlightLeft': + ['Leicht links abbiegen', ' auf {road}'], + 'WaypointReached': + ['Zwischenhalt erreicht'], + 'Roundabout': + ['Nehmen Sie die {exitStr} Ausfahrt im Kreisverkehr', ' auf {road}'], + 'DestinationReached': + ['Sie haben ihr Ziel erreicht'], + }, + formatOrder: function(n) { + return n + '.'; + }, + ui: { + startPlaceholder: 'Start', + viaPlaceholder: 'Via {viaNumber}', + endPlaceholder: 'Ziel' + } + }, + + 'sv': { + directions: { + N: 'norr', + NE: 'nordost', + E: 'öst', + SE: 'sydost', + S: 'syd', + SW: 'sydväst', + W: 'väst', + NW: 'nordväst', + SlightRight: 'svagt höger', + Right: 'höger', + SharpRight: 'skarpt höger', + SlightLeft: 'svagt vänster', + Left: 'vänster', + SharpLeft: 'skarpt vänster', + Uturn: 'Vänd' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Åk åt {dir}', ' till {road}'], + 'Continue': + ['Fortsätt {dir}'], + 'SlightRight': + ['Svagt höger', ' till {road}'], + 'Right': + ['Sväng höger', ' till {road}'], + 'SharpRight': + ['Skarpt höger', ' till {road}'], + 'TurnAround': + ['Vänd'], + 'SharpLeft': + ['Skarpt vänster', ' till {road}'], + 'Left': + ['Sväng vänster', ' till {road}'], + 'SlightLeft': + ['Svagt vänster', ' till {road}'], + 'WaypointReached': + ['Viapunkt nådd'], + 'Roundabout': + ['Tag {exitStr} avfarten i rondellen', ' till {road}'], + 'DestinationReached': + ['Framme vid resans mål'], + 'Fork': ['Tag av {modifier}', ' till {road}'], + 'Merge': ['Anslut {modifier} ', ' till {road}'], + 'OnRamp': ['Tag påfarten {modifier}', ' till {road}'], + 'OffRamp': ['Tag avfarten {modifier}', ' till {road}'], + 'EndOfRoad': ['Sväng {modifier} vid vägens slut', ' till {road}'], + 'Onto': 'till {road}' + }, + formatOrder: function(n) { + return ['första', 'andra', 'tredje', 'fjärde', 'femte', + 'sjätte', 'sjunde', 'åttonde', 'nionde', 'tionde' + /* Can't possibly be more than ten exits, can there? */][n - 1]; + }, + ui: { + startPlaceholder: 'Från', + viaPlaceholder: 'Via {viaNumber}', + endPlaceholder: 'Till' + } + }, + + 'sp': { + directions: { + N: 'norte', + NE: 'noreste', + E: 'este', + SE: 'sureste', + S: 'sur', + SW: 'suroeste', + W: 'oeste', + NW: 'noroeste' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Derecho {dir}', ' sobre {road}'], + 'Continue': + ['Continuar {dir}', ' en {road}'], + 'SlightRight': + ['Leve giro a la derecha', ' sobre {road}'], + 'Right': + ['Derecha', ' sobre {road}'], + 'SharpRight': + ['Giro pronunciado a la derecha', ' sobre {road}'], + 'TurnAround': + ['Dar vuelta'], + 'SharpLeft': + ['Giro pronunciado a la izquierda', ' sobre {road}'], + 'Left': + ['Izquierda', ' en {road}'], + 'SlightLeft': + ['Leve giro a la izquierda', ' en {road}'], + 'WaypointReached': + ['Llegó a un punto del camino'], + 'Roundabout': + ['Tomar {exitStr} salida en la rotonda', ' en {road}'], + 'DestinationReached': + ['Llegada a destino'], + }, + formatOrder: function(n) { + return n + 'º'; + }, + ui: { + startPlaceholder: 'Inicio', + viaPlaceholder: 'Via {viaNumber}', + endPlaceholder: 'Destino' + } + }, + 'nl': { + directions: { + N: 'noordelijke', + NE: 'noordoostelijke', + E: 'oostelijke', + SE: 'zuidoostelijke', + S: 'zuidelijke', + SW: 'zuidewestelijke', + W: 'westelijke', + NW: 'noordwestelijke' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Vertrek in {dir} richting', ' de {road} op'], + 'Continue': + ['Ga in {dir} richting', ' de {road} op'], + 'SlightRight': + ['Volg de weg naar rechts', ' de {road} op'], + 'Right': + ['Ga rechtsaf', ' de {road} op'], + 'SharpRight': + ['Ga scherpe bocht naar rechts', ' de {road} op'], + 'TurnAround': + ['Keer om'], + 'SharpLeft': + ['Ga scherpe bocht naar links', ' de {road} op'], + 'Left': + ['Ga linksaf', ' de {road} op'], + 'SlightLeft': + ['Volg de weg naar links', ' de {road} op'], + 'WaypointReached': + ['Aangekomen bij tussenpunt'], + 'Roundabout': + ['Neem de {exitStr} afslag op de rotonde', ' de {road} op'], + 'DestinationReached': + ['Aangekomen op eindpunt'], + }, + formatOrder: function(n) { + if (n === 1 || n >= 20) { + return n + 'ste'; + } else { + return n + 'de'; + } + }, + ui: { + startPlaceholder: 'Vertrekpunt', + viaPlaceholder: 'Via {viaNumber}', + endPlaceholder: 'Bestemming' + } + }, + 'fr': { + directions: { + N: 'nord', + NE: 'nord-est', + E: 'est', + SE: 'sud-est', + S: 'sud', + SW: 'sud-ouest', + W: 'ouest', + NW: 'nord-ouest' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Tout droit au {dir}', ' sur {road}'], + 'Continue': + ['Continuer au {dir}', ' sur {road}'], + 'SlightRight': + ['Légèrement à droite', ' sur {road}'], + 'Right': + ['A droite', ' sur {road}'], + 'SharpRight': + ['Complètement à droite', ' sur {road}'], + 'TurnAround': + ['Faire demi-tour'], + 'SharpLeft': + ['Complètement à gauche', ' sur {road}'], + 'Left': + ['A gauche', ' sur {road}'], + 'SlightLeft': + ['Légèrement à gauche', ' sur {road}'], + 'WaypointReached': + ['Point d\'étape atteint'], + 'Roundabout': + ['Au rond-point, prenez la {exitStr} sortie', ' sur {road}'], + 'DestinationReached': + ['Destination atteinte'], + }, + formatOrder: function(n) { + return n + 'º'; + }, + ui: { + startPlaceholder: 'Départ', + viaPlaceholder: 'Intermédiaire {viaNumber}', + endPlaceholder: 'Arrivée' + } + }, + 'it': { + directions: { + N: 'nord', + NE: 'nord-est', + E: 'est', + SE: 'sud-est', + S: 'sud', + SW: 'sud-ovest', + W: 'ovest', + NW: 'nord-ovest' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Dritto verso {dir}', ' su {road}'], + 'Continue': + ['Continuare verso {dir}', ' su {road}'], + 'SlightRight': + ['Mantenere la destra', ' su {road}'], + 'Right': + ['A destra', ' su {road}'], + 'SharpRight': + ['Strettamente a destra', ' su {road}'], + 'TurnAround': + ['Fare inversione di marcia'], + 'SharpLeft': + ['Strettamente a sinistra', ' su {road}'], + 'Left': + ['A sinistra', ' sur {road}'], + 'SlightLeft': + ['Mantenere la sinistra', ' su {road}'], + 'WaypointReached': + ['Punto di passaggio raggiunto'], + 'Roundabout': + ['Alla rotonda, prendere la {exitStr} uscita'], + 'DestinationReached': + ['Destinazione raggiunta'], + }, + formatOrder: function(n) { + return n + 'º'; + }, + ui: { + startPlaceholder: 'Partenza', + viaPlaceholder: 'Intermedia {viaNumber}', + endPlaceholder: 'Destinazione' + } + }, + 'pt': { + directions: { + N: 'norte', + NE: 'nordeste', + E: 'leste', + SE: 'sudeste', + S: 'sul', + SW: 'sudoeste', + W: 'oeste', + NW: 'noroeste' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Siga {dir}', ' na {road}'], + 'Continue': + ['Continue {dir}', ' na {road}'], + 'SlightRight': + ['Curva ligeira a direita', ' na {road}'], + 'Right': + ['Curva a direita', ' na {road}'], + 'SharpRight': + ['Curva fechada a direita', ' na {road}'], + 'TurnAround': + ['Retorne'], + 'SharpLeft': + ['Curva fechada a esquerda', ' na {road}'], + 'Left': + ['Curva a esquerda', ' na {road}'], + 'SlightLeft': + ['Curva ligueira a esquerda', ' na {road}'], + 'WaypointReached': + ['Ponto de interesse atingido'], + 'Roundabout': + ['Pegue a {exitStr} saída na rotatória', ' na {road}'], + 'DestinationReached': + ['Destino atingido'], + }, + formatOrder: function(n) { + return n + 'º'; + }, + ui: { + startPlaceholder: 'Origem', + viaPlaceholder: 'Intermédio {viaNumber}', + endPlaceholder: 'Destino' + } + }, + 'sk': { + directions: { + N: 'sever', + NE: 'serverovýchod', + E: 'východ', + SE: 'juhovýchod', + S: 'juh', + SW: 'juhozápad', + W: 'západ', + NW: 'serverozápad' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Mierte na {dir}', ' na {road}'], + 'Continue': + ['Pokračujte na {dir}', ' na {road}'], + 'SlightRight': + ['Mierne doprava', ' na {road}'], + 'Right': + ['Doprava', ' na {road}'], + 'SharpRight': + ['Prudko doprava', ' na {road}'], + 'TurnAround': + ['Otočte sa'], + 'SharpLeft': + ['Prudko doľava', ' na {road}'], + 'Left': + ['Doľava', ' na {road}'], + 'SlightLeft': + ['Mierne doľava', ' na {road}'], + 'WaypointReached': + ['Ste v prejazdovom bode.'], + 'Roundabout': + ['Odbočte na {exitStr} výjazde', ' na {road}'], + 'DestinationReached': + ['Prišli ste do cieľa.'], + }, + formatOrder: function(n) { + var i = n % 10 - 1, + suffix = ['.', '.', '.']; + + return suffix[i] ? n + suffix[i] : n + '.'; + }, + ui: { + startPlaceholder: 'Začiatok', + viaPlaceholder: 'Cez {viaNumber}', + endPlaceholder: 'Koniec' + } + }, + 'el': { + directions: { + N: 'βόρεια', + NE: 'βορειοανατολικά', + E: 'ανατολικά', + SE: 'νοτιοανατολικά', + S: 'νότια', + SW: 'νοτιοδυτικά', + W: 'δυτικά', + NW: 'βορειοδυτικά' + }, + instructions: { + // instruction, postfix if the road is named + 'Head': + ['Κατευθυνθείτε {dir}', ' στην {road}'], + 'Continue': + ['Συνεχίστε {dir}', ' στην {road}'], + 'SlightRight': + ['Ελαφρώς δεξιά', ' στην {road}'], + 'Right': + ['Δεξιά', ' στην {road}'], + 'SharpRight': + ['Απότομη δεξιά στροφή', ' στην {road}'], + 'TurnAround': + ['Κάντε αναστροφή'], + 'SharpLeft': + ['Απότομη αριστερή στροφή', ' στην {road}'], + 'Left': + ['Αριστερά', ' στην {road}'], + 'SlightLeft': + ['Ελαφρώς αριστερά', ' στην {road}'], + 'WaypointReached': + ['Φτάσατε στο σημείο αναφοράς'], + 'Roundabout': + ['Ακολουθήστε την {exitStr} έξοδο στο κυκλικό κόμβο', ' στην {road}'], + 'DestinationReached': + ['Φτάσατε στον προορισμό σας'], + }, + formatOrder: function(n) { + return n + 'º'; + }, + ui: { + startPlaceholder: 'Αφετηρία', + viaPlaceholder: 'μέσω {viaNumber}', + endPlaceholder: 'Προορισμός' + } + } + }); + + module.exports = L.Routing; +})(); + +},{}],12:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null); + + L.Routing = L.Routing || {}; + L.extend(L.Routing, require('./L.Routing.OSRMv1')); + + /** + * Works against OSRM's new API in version 5.0; this has + * the API version v1. + */ + L.Routing.Mapbox = L.Routing.OSRMv1.extend({ + options: { + serviceUrl: 'https://api.mapbox.com/directions/v5', + profile: 'mapbox/driving', + useHints: false + }, + + initialize: function(accessToken, options) { + L.Routing.OSRMv1.prototype.initialize.call(this, options); + this.options.requestParameters = this.options.requestParameters || {}; + /* jshint camelcase: false */ + this.options.requestParameters.access_token = accessToken; + /* jshint camelcase: true */ + } + }); + + L.Routing.mapbox = function(accessToken, options) { + return new L.Routing.Mapbox(accessToken, options); + }; + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./L.Routing.OSRMv1":13}],13:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null), + corslite = require('corslite'), + polyline = require('polyline'); + + // Ignore camelcase naming for this file, since OSRM's API uses + // underscores. + /* jshint camelcase: false */ + + L.Routing = L.Routing || {}; + L.extend(L.Routing, require('./L.Routing.Waypoint')); + + /** + * Works against OSRM's new API in version 5.0; this has + * the API version v1. + */ + L.Routing.OSRMv1 = L.Class.extend({ + options: { + serviceUrl: 'https://router.project-osrm.org/route/v1', + profile: 'driving', + timeout: 30 * 1000, + routingOptions: { + alternatives: true, + steps: true + }, + polylinePrecision: 5, + useHints: true + }, + + initialize: function(options) { + L.Util.setOptions(this, options); + this._hints = { + locations: {} + }; + }, + + route: function(waypoints, callback, context, options) { + var timedOut = false, + wps = [], + url, + timer, + wp, + i; + + options = L.extend({}, this.options.routingOptions, options); + url = this.buildRouteUrl(waypoints, options); + if (this.options.requestParameters) { + url += L.Util.getParamString(this.options.requestParameters, url); + } + + timer = setTimeout(function() { + timedOut = true; + callback.call(context || callback, { + status: -1, + message: 'OSRM request timed out.' + }); + }, this.options.timeout); + + // Create a copy of the waypoints, since they + // might otherwise be asynchronously modified while + // the request is being processed. + for (i = 0; i < waypoints.length; i++) { + wp = waypoints[i]; + wps.push(new L.Routing.Waypoint(wp.latLng, wp.name, wp.options)); + } + + corslite(url, L.bind(function(err, resp) { + var data, + errorMessage, + statusCode; + + clearTimeout(timer); + if (!timedOut) { + errorMessage = 'HTTP request failed: ' + err; + statusCode = -1; + + if (!err) { + try { + data = JSON.parse(resp.responseText); + try { + return this._routeDone(data, wps, options, callback, context); + } catch (ex) { + statusCode = -3; + errorMessage = ex.toString(); + } + } catch (ex) { + statusCode = -2; + errorMessage = 'Error parsing OSRM response: ' + ex.toString(); + } + } + + callback.call(context || callback, { + status: statusCode, + message: errorMessage + }); + } + }, this)); + + return this; + }, + + requiresMoreDetail: function(route, zoom, bounds) { + if (!route.properties.isSimplified) { + return false; + } + + var waypoints = route.inputWaypoints, + i; + for (i = 0; i < waypoints.length; ++i) { + if (!bounds.contains(waypoints[i].latLng)) { + return true; + } + } + + return false; + }, + + _routeDone: function(response, inputWaypoints, options, callback, context) { + var alts = [], + actualWaypoints, + i, + route; + + context = context || callback; + if (response.code !== 'Ok') { + callback.call(context, { + status: response.code + }); + return; + } + + actualWaypoints = this._toWaypoints(inputWaypoints, response.waypoints); + + for (i = 0; i < response.routes.length; i++) { + route = this._convertRoute(response.routes[i]); + route.inputWaypoints = inputWaypoints; + route.waypoints = actualWaypoints; + route.properties = {isSimplified: !options || !options.geometryOnly || options.simplifyGeometry}; + alts.push(route); + } + + this._saveHintData(response.waypoints, inputWaypoints); + + callback.call(context, null, alts); + }, + + _convertRoute: function(responseRoute) { + var result = { + name: '', + coordinates: [], + instructions: [], + summary: { + totalDistance: responseRoute.distance, + totalTime: responseRoute.duration + } + }, + legNames = [], + index = 0, + legCount = responseRoute.legs.length, + hasSteps = responseRoute.legs[0].steps.length > 0, + i, + j, + leg, + step, + geometry, + type, + modifier; + + for (i = 0; i < legCount; i++) { + leg = responseRoute.legs[i]; + legNames.push(leg.summary && leg.summary.charAt(0).toUpperCase() + leg.summary.substring(1)); + for (j = 0; j < leg.steps.length; j++) { + step = leg.steps[j]; + geometry = this._decodePolyline(step.geometry); + result.coordinates.push.apply(result.coordinates, geometry); + type = this._maneuverToInstructionType(step.maneuver, i === legCount - 1); + modifier = this._maneuverToModifier(step.maneuver); + + if (type) { + result.instructions.push({ + type: type, + distance: step.distance, + time: step.duration, + road: step.name, + direction: this._bearingToDirection(step.maneuver.bearing_after), + exit: step.maneuver.exit, + index: index, + mode: step.mode, + modifier: modifier + }); + } + + index += geometry.length; + } + } + + result.name = legNames.join(', '); + if (!hasSteps) { + result.coordinates = this._decodePolyline(responseRoute.geometry); + } + + return result; + }, + + _bearingToDirection: function(bearing) { + var oct = Math.round(bearing / 45) % 8; + return ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'][oct]; + }, + + _maneuverToInstructionType: function(maneuver, lastLeg) { + switch (maneuver.type) { + case 'new name': + return 'Continue'; + case 'depart': + return 'Head'; + case 'arrive': + return lastLeg ? 'DestinationReached' : 'WaypointReached'; + case 'roundabout': + case 'rotary': + return 'Roundabout'; + case 'merge': + case 'fork': + case 'on ramp': + case 'off ramp': + case 'end of road': + return this._camelCase(maneuver.type); + // These are all reduced to the same instruction in the current model + //case 'turn': + //case 'ramp': // deprecated in v5.1 + default: + return this._camelCase(maneuver.modifier); + } + }, + + _maneuverToModifier: function(maneuver) { + var modifier = maneuver.modifier; + + switch (maneuver.type) { + case 'merge': + case 'fork': + case 'on ramp': + case 'off ramp': + case 'end of road': + modifier = this._leftOrRight(modifier); + } + + return modifier && this._camelCase(modifier); + }, + + _camelCase: function(s) { + var words = s.split(' '), + result = ''; + for (var i = 0, l = words.length; i < l; i++) { + result += words[i].charAt(0).toUpperCase() + words[i].substring(1); + } + + return result; + }, + + _leftOrRight: function(d) { + return d.indexOf('left') >= 0 ? 'Left' : 'Right'; + }, + + _decodePolyline: function(routeGeometry) { + var cs = polyline.decode(routeGeometry, this.options.polylinePrecision), + result = new Array(cs.length), + i; + for (i = cs.length - 1; i >= 0; i--) { + result[i] = L.latLng(cs[i]); + } + + return result; + }, + + _toWaypoints: function(inputWaypoints, vias) { + var wps = [], + i; + for (i = 0; i < vias.length; i++) { + wps.push(L.Routing.waypoint(L.latLng(vias[i].location), + inputWaypoints[i].name, + inputWaypoints[i].options)); + } + + return wps; + }, + + buildRouteUrl: function(waypoints, options) { + var locs = [], + hints = [], + wp, + latLng, + computeInstructions, + computeAlternative = true; + + for (var i = 0; i < waypoints.length; i++) { + wp = waypoints[i]; + latLng = wp.latLng; + locs.push(latLng.lng + ',' + latLng.lat); + hints.push(this._hints.locations[this._locationKey(latLng)] || ''); + } + + computeInstructions = + !(options && options.geometryOnly); + + return this.options.serviceUrl + '/' + this.options.profile + '/' + + locs.join(';') + '?' + + (options.geometryOnly ? (options.simplifyGeometry ? '' : 'overview=full') : 'overview=false') + + '&alternatives=' + computeAlternative.toString() + + '&steps=' + computeInstructions.toString() + + (this.options.useHints ? '&hints=' + hints.join(';') : '') + + (options.allowUTurns ? '&continue_straight=' + !options.allowUTurns : ''); + }, + + _locationKey: function(location) { + return location.lat + ',' + location.lng; + }, + + _saveHintData: function(actualWaypoints, waypoints) { + var loc; + this._hints = { + locations: {} + }; + for (var i = actualWaypoints.length - 1; i >= 0; i--) { + loc = waypoints[i].latLng; + this._hints.locations[this._locationKey(loc)] = actualWaypoints[i].hint; + } + }, + }); + + L.Routing.osrmv1 = function(options) { + return new L.Routing.OSRMv1(options); + }; + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./L.Routing.Waypoint":15,"corslite":1,"polyline":2}],14:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null); + L.Routing = L.Routing || {}; + L.extend(L.Routing, require('./L.Routing.GeocoderElement')); + L.extend(L.Routing, require('./L.Routing.Waypoint')); + + L.Routing.Plan = L.Class.extend({ + includes: L.Mixin.Events, + + options: { + dragStyles: [ + {color: 'black', opacity: 0.15, weight: 9}, + {color: 'white', opacity: 0.8, weight: 6}, + {color: 'red', opacity: 1, weight: 2, dashArray: '7,12'} + ], + draggableWaypoints: true, + routeWhileDragging: false, + addWaypoints: true, + reverseWaypoints: false, + addButtonClassName: '', + language: 'en', + createGeocoderElement: L.Routing.geocoderElement, + createMarker: function(i, wp) { + var options = { + draggable: this.draggableWaypoints + }, + marker = L.marker(wp.latLng, options); + + return marker; + }, + geocodersClassName: '' + }, + + initialize: function(waypoints, options) { + L.Util.setOptions(this, options); + this._waypoints = []; + this.setWaypoints(waypoints); + }, + + isReady: function() { + var i; + for (i = 0; i < this._waypoints.length; i++) { + if (!this._waypoints[i].latLng) { + return false; + } + } + + return true; + }, + + getWaypoints: function() { + var i, + wps = []; + + for (i = 0; i < this._waypoints.length; i++) { + wps.push(this._waypoints[i]); + } + + return wps; + }, + + setWaypoints: function(waypoints) { + var args = [0, this._waypoints.length].concat(waypoints); + this.spliceWaypoints.apply(this, args); + return this; + }, + + spliceWaypoints: function() { + var args = [arguments[0], arguments[1]], + i; + + for (i = 2; i < arguments.length; i++) { + args.push(arguments[i] && arguments[i].hasOwnProperty('latLng') ? arguments[i] : L.Routing.waypoint(arguments[i])); + } + + [].splice.apply(this._waypoints, args); + + // Make sure there's always at least two waypoints + while (this._waypoints.length < 2) { + this.spliceWaypoints(this._waypoints.length, 0, null); + } + + this._updateMarkers(); + this._fireChanged.apply(this, args); + }, + + onAdd: function(map) { + this._map = map; + this._updateMarkers(); + }, + + onRemove: function() { + var i; + this._removeMarkers(); + + if (this._newWp) { + for (i = 0; i < this._newWp.lines.length; i++) { + this._map.removeLayer(this._newWp.lines[i]); + } + } + + delete this._map; + }, + + createGeocoders: function() { + var container = L.DomUtil.create('div', 'leaflet-routing-geocoders ' + this.options.geocodersClassName), + waypoints = this._waypoints, + addWpBtn, + reverseBtn; + + this._geocoderContainer = container; + this._geocoderElems = []; + + + if (this.options.addWaypoints) { + addWpBtn = L.DomUtil.create('button', 'leaflet-routing-add-waypoint ' + this.options.addButtonClassName, container); + addWpBtn.setAttribute('type', 'button'); + L.DomEvent.addListener(addWpBtn, 'click', function() { + this.spliceWaypoints(waypoints.length, 0, null); + }, this); + } + + if (this.options.reverseWaypoints) { + reverseBtn = L.DomUtil.create('button', 'leaflet-routing-reverse-waypoints', container); + reverseBtn.setAttribute('type', 'button'); + L.DomEvent.addListener(reverseBtn, 'click', function() { + this._waypoints.reverse(); + this.setWaypoints(this._waypoints); + }, this); + } + + this._updateGeocoders(); + this.on('waypointsspliced', this._updateGeocoders); + + return container; + }, + + _createGeocoder: function(i) { + var geocoder = this.options.createGeocoderElement(this._waypoints[i], i, this._waypoints.length, this.options); + geocoder + .on('delete', function() { + if (i > 0 || this._waypoints.length > 2) { + this.spliceWaypoints(i, 1); + } else { + this.spliceWaypoints(i, 1, new L.Routing.Waypoint()); + } + }, this) + .on('geocoded', function(e) { + this._updateMarkers(); + this._fireChanged(); + this._focusGeocoder(i + 1); + this.fire('waypointgeocoded', { + waypointIndex: i, + waypoint: e.waypoint + }); + }, this) + .on('reversegeocoded', function(e) { + this.fire('waypointgeocoded', { + waypointIndex: i, + waypoint: e.waypoint + }); + }, this); + + return geocoder; + }, + + _updateGeocoders: function() { + var elems = [], + i, + geocoderElem; + + for (i = 0; i < this._geocoderElems.length; i++) { + this._geocoderContainer.removeChild(this._geocoderElems[i].getContainer()); + } + + for (i = this._waypoints.length - 1; i >= 0; i--) { + geocoderElem = this._createGeocoder(i); + this._geocoderContainer.insertBefore(geocoderElem.getContainer(), this._geocoderContainer.firstChild); + elems.push(geocoderElem); + } + + this._geocoderElems = elems.reverse(); + }, + + _removeMarkers: function() { + var i; + if (this._markers) { + for (i = 0; i < this._markers.length; i++) { + if (this._markers[i]) { + this._map.removeLayer(this._markers[i]); + } + } + } + this._markers = []; + }, + + _updateMarkers: function() { + var i, + m; + + if (!this._map) { + return; + } + + this._removeMarkers(); + + for (i = 0; i < this._waypoints.length; i++) { + if (this._waypoints[i].latLng) { + m = this.options.createMarker(i, this._waypoints[i], this._waypoints.length); + if (m) { + m.addTo(this._map); + if (this.options.draggableWaypoints) { + this._hookWaypointEvents(m, i); + } + } + } else { + m = null; + } + this._markers.push(m); + } + }, + + _fireChanged: function() { + this.fire('waypointschanged', {waypoints: this.getWaypoints()}); + + if (arguments.length >= 2) { + this.fire('waypointsspliced', { + index: Array.prototype.shift.call(arguments), + nRemoved: Array.prototype.shift.call(arguments), + added: arguments + }); + } + }, + + _hookWaypointEvents: function(m, i, trackMouseMove) { + var eventLatLng = function(e) { + return trackMouseMove ? e.latlng : e.target.getLatLng(); + }, + dragStart = L.bind(function(e) { + this.fire('waypointdragstart', {index: i, latlng: eventLatLng(e)}); + }, this), + drag = L.bind(function(e) { + this._waypoints[i].latLng = eventLatLng(e); + this.fire('waypointdrag', {index: i, latlng: eventLatLng(e)}); + }, this), + dragEnd = L.bind(function(e) { + this._waypoints[i].latLng = eventLatLng(e); + this._waypoints[i].name = ''; + if (this._geocoderElems) { + this._geocoderElems[i].update(true); + } + this.fire('waypointdragend', {index: i, latlng: eventLatLng(e)}); + this._fireChanged(); + }, this), + mouseMove, + mouseUp; + + if (trackMouseMove) { + mouseMove = L.bind(function(e) { + this._markers[i].setLatLng(e.latlng); + drag(e); + }, this); + mouseUp = L.bind(function(e) { + this._map.dragging.enable(); + this._map.off('mouseup', mouseUp); + this._map.off('mousemove', mouseMove); + dragEnd(e); + }, this); + this._map.dragging.disable(); + this._map.on('mousemove', mouseMove); + this._map.on('mouseup', mouseUp); + dragStart({latlng: this._waypoints[i].latLng}); + } else { + m.on('dragstart', dragStart); + m.on('drag', drag); + m.on('dragend', dragEnd); + } + }, + + dragNewWaypoint: function(e) { + var newWpIndex = e.afterIndex + 1; + if (this.options.routeWhileDragging) { + this.spliceWaypoints(newWpIndex, 0, e.latlng); + this._hookWaypointEvents(this._markers[newWpIndex], newWpIndex, true); + } else { + this._dragNewWaypoint(newWpIndex, e.latlng); + } + }, + + _dragNewWaypoint: function(newWpIndex, initialLatLng) { + var wp = new L.Routing.Waypoint(initialLatLng), + prevWp = this._waypoints[newWpIndex - 1], + nextWp = this._waypoints[newWpIndex], + marker = this.options.createMarker(newWpIndex, wp, this._waypoints.length + 1), + lines = [], + mouseMove = L.bind(function(e) { + var i; + if (marker) { + marker.setLatLng(e.latlng); + } + for (i = 0; i < lines.length; i++) { + lines[i].spliceLatLngs(1, 1, e.latlng); + } + }, this), + mouseUp = L.bind(function(e) { + var i; + if (marker) { + this._map.removeLayer(marker); + } + for (i = 0; i < lines.length; i++) { + this._map.removeLayer(lines[i]); + } + this._map.off('mousemove', mouseMove); + this._map.off('mouseup', mouseUp); + this.spliceWaypoints(newWpIndex, 0, e.latlng); + }, this), + i; + + if (marker) { + marker.addTo(this._map); + } + + for (i = 0; i < this.options.dragStyles.length; i++) { + lines.push(L.polyline([prevWp.latLng, initialLatLng, nextWp.latLng], + this.options.dragStyles[i]).addTo(this._map)); + } + + this._map.on('mousemove', mouseMove); + this._map.on('mouseup', mouseUp); + }, + + _focusGeocoder: function(i) { + if (this._geocoderElems[i]) { + this._geocoderElems[i].focus(); + } else { + document.activeElement.blur(); + } + } + }); + + L.Routing.plan = function(waypoints, options) { + return new L.Routing.Plan(waypoints, options); + }; + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{"./L.Routing.GeocoderElement":7,"./L.Routing.Waypoint":15}],15:[function(require,module,exports){ +(function (global){ +(function() { + 'use strict'; + + var L = (typeof window !== "undefined" ? window.L : typeof global !== "undefined" ? global.L : null); + L.Routing = L.Routing || {}; + + L.Routing.Waypoint = L.Class.extend({ + options: { + allowUTurn: false, + }, + initialize: function(latLng, name, options) { + L.Util.setOptions(this, options); + this.latLng = L.latLng(latLng); + this.name = name; + } + }); + + L.Routing.waypoint = function(latLng, name, options) { + return new L.Routing.Waypoint(latLng, name, options); + }; + + module.exports = L.Routing; +})(); + +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}]},{},[4])(4) +}); \ No newline at end of file diff --git a/dist/leaflet-routing-machine.min.js b/dist/leaflet-routing-machine.min.js new file mode 100644 index 00000000..36b53905 --- /dev/null +++ b/dist/leaflet-routing-machine.min.js @@ -0,0 +1,4 @@ +/*! leaflet-routing-machine - v3.1.1 - 2016-09-02 */ + +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),(b.L||(b.L={})).Routing=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g=200&&300>a||304===a}function e(){void 0===h.status||d(h.status)?b.call(h,null,h):b.call(h,h,null)}var f=!1;if("undefined"==typeof window.XMLHttpRequest)return b(Error("Browser not supported"));if("undefined"==typeof c){var g=a.match(/^\s*https?:\/\/[^\/]*/);c=g&&g[0]!==location.protocol+"//"+location.domain+(location.port?":"+location.port:"")}var h=new window.XMLHttpRequest;if(c&&!("withCredentials"in h)){h=new window.XDomainRequest;var i=b;b=function(){if(f)i.apply(this,arguments);else{var a=this,b=arguments;setTimeout(function(){i.apply(a,b)},0)}}}return"onload"in h?h.onload=e:h.onreadystatechange=function(){4===h.readyState&&e()},h.onerror=function(a){b.call(this,a||!0,null),b=function(){}},h.onprogress=function(){},h.ontimeout=function(a){b.call(this,a,null),b=function(){}},h.onabort=function(a){b.call(this,a,null),b=function(){}},h.open("GET",a,!0),h.send(null),f=!0,h}"undefined"!=typeof b&&(b.exports=c)},{}],2:[function(a,b){function c(a,b){a=Math.round(a*b),a<<=1,0>a&&(a=~a);for(var c="";a>=32;)c+=String.fromCharCode((32|31&a)+63),a>>=5;return c+=String.fromCharCode(a+63)}var d={};d.decode=function(a,b){for(var c,d,e=0,f=0,g=0,h=[],i=0,j=0,k=null,l=Math.pow(10,b||5);e=32);c=1&j?~(j>>1):j>>1,i=j=0;do k=a.charCodeAt(e++)-63,j|=(31&k)<=32);d=1&j?~(j>>1):j>>1,f+=c,g+=d,h.push([f/l,g/l])}return h},d.encode=function(a,b){if(!a.length)return"";for(var d=Math.pow(10,b||5),e=c(a[0][0],d)+c(a[0][1],d),f=1;f0&&this._select(1)},_createClickListener:function(a){var b=this._resultSelected(a);return L.bind(function(){this._elem.blur(),b()},this)},_resultSelected:function(a){return L.bind(function(){this.close(),this._elem.value=a.name,this._lastCompletedText=a.name,this._selectFn(a)},this)},_keyPressed:function(a){var b;return this._isOpen&&13===a.keyCode&&this._selection?(b=parseInt(this._selection.getAttribute("data-result-index"),10),this._resultSelected(this._results[b])(),void L.DomEvent.preventDefault(a)):13===a.keyCode?void this._complete(this._resultFn,!0):this._autocomplete&&document.activeElement===this._elem?(this._timer&&clearTimeout(this._timer),void(this._timer=setTimeout(L.Util.bind(function(){this._complete(this._autocomplete)},this),this.options.timeout))):void this._unselect()},_select:function(a){var b=this._selection;b&&(L.DomUtil.removeClass(b.firstChild,"leaflet-routing-geocoder-selected"),b=b[a>0?"nextSibling":"previousSibling"]),b||(b=this._resultTable[a>0?"firstChild":"lastChild"]),b&&(L.DomUtil.addClass(b.firstChild,"leaflet-routing-geocoder-selected"),this._selection=b)},_unselect:function(){this._selection&&L.DomUtil.removeClass(this._selection.firstChild,"leaflet-routing-geocoder-selected"),delete this._selection},_keyDown:function(a){if(this._isOpen)switch(a.keyCode){case 27:return this.close(),void L.DomEvent.preventDefault(a);case 38:return this._select(-1),void L.DomEvent.preventDefault(a);case 40:return this._select(1),void L.DomEvent.preventDefault(a)}},_complete:function(a,b){function c(a){this._lastCompletedText=d,b&&1===a.length?this._resultSelected(a[0])():this._setResults(a)}var d=this._elem.value;d&&(d!==this._lastCompletedText?a(d,c,this):b&&c.call(this,this._results))}})}()},{}],4:[function(a,b){(function(c){!function(){"use strict";var d="undefined"!=typeof window?window.L:"undefined"!=typeof c?c.L:null;d.Routing=d.Routing||{},d.extend(d.Routing,a("./L.Routing.Itinerary")),d.extend(d.Routing,a("./L.Routing.Line")),d.extend(d.Routing,a("./L.Routing.Plan")),d.extend(d.Routing,a("./L.Routing.OSRMv1")),d.extend(d.Routing,a("./L.Routing.Mapbox")),d.extend(d.Routing,a("./L.Routing.ErrorControl")),d.Routing.Control=d.Routing.Itinerary.extend({options:{fitSelectedRoutes:"smart",routeLine:function(a,b){return d.Routing.line(a,b)},autoRoute:!0,routeWhileDragging:!1,routeDragInterval:500,waypointMode:"connect",showAlternatives:!1,defaultErrorHandler:function(a){console.error("Routing error:",a.error)}},initialize:function(a){d.Util.setOptions(this,a),this._router=this.options.router||new d.Routing.OSRMv1(a),this._plan=this.options.plan||d.Routing.plan(this.options.waypoints,a),this._requestCount=0,d.Routing.Itinerary.prototype.initialize.call(this,a),this.on("routeselected",this._routeSelected,this),this.options.defaultErrorHandler&&this.on("routingerror",this.options.defaultErrorHandler),this._plan.on("waypointschanged",this._onWaypointsChanged,this),a.routeWhileDragging&&this._setupRouteDragging(),this.options.autoRoute&&this.route()},onAdd:function(a){var b=d.Routing.Itinerary.prototype.onAdd.call(this,a);return this._map=a,this._map.addLayer(this._plan),this._map.on("zoomend",function(){if(this._selectedRoute&&this._router.requiresMoreDetail){var a=this._map;this._router.requiresMoreDetail(this._selectedRoute,a.getZoom(),a.getBounds())&&this.route({callback:d.bind(function(a,b){var c;if(!a){for(c=0;ca.x/5||c.y>a.y/5)&&this._waypointsInViewport()}catch(h){return!1}},_waypointsInViewport:function(){var a,b,c=this.getWaypoints();try{a=this._map.getBounds()}catch(d){return!1}for(b=0;b
"+a.message+"
=b,i=h?function(a){return a}:d.bind(this._round,this);return"imperial"===this.options.units?(e=a/.9144,f=e>=1e3?{value:i(a/1609.344,b),unit:g.miles}:{value:i(e,b),unit:g.yards}):(c=i(a,b),f={value:c>=1e3?c/1e3:c,unit:c>=1e3?g.kilometers:g.meters}),h&&(f.value=f.value.toFixed(-b)),d.Util.template(this.options.distanceTemplate,f)},_round:function(a,b){var c=b||this.options.roundingSensitivity,d=Math.pow(10,(Math.floor(a/c)+"").length-1),e=Math.floor(a/d),f=e>5?d:d/2;return Math.round(a/f)*f},formatTime:function(a){var b=this.options.unitNames||this._localization.localize("units");return a=30*Math.round(a/30),a>86400?Math.round(a/3600)+" "+b.hours:a>3600?Math.floor(a/3600)+" "+b.hours+" "+Math.round(a%3600/60)+" "+b.minutes:a>300?Math.round(a/60)+" "+b.minutes:a>60?Math.floor(a/60)+" "+b.minutes+(a%60!==0?" "+a%60+" "+b.seconds:""):a+" "+b.seconds},formatInstruction:function(a,b){return void 0===a.text?this.capitalize(d.Util.template(this._getInstructionTemplate(a,b),d.extend({},a,{exitStr:a.exit?this._localization.localize("formatOrder")(a.exit):"",dir:this._localization.localize(["directions",a.direction]),modifier:this._localization.localize(["directions",a.modifier])}))):a.text},getIconName:function(a,b){switch(a.type){case"Head":if(0===b)return"depart";break;case"WaypointReached":return"via";case"Roundabout":return"enter-roundabout";case"DestinationReached":return"arrive"}switch(a.modifier){case"Straight":return"continue";case"SlightRight":return"bear-right";case"Right":return"turn-right";case"SharpRight":return"sharp-right";case"TurnAround":case"Uturn":return"u-turn";case"SharpLeft":return"sharp-left";case"Left":return"turn-left";case"SlightLeft":return"bear-left"}},capitalize:function(a){return a.charAt(0).toUpperCase()+a.substring(1)},_getInstructionTemplate:function(a,b){var c="Straight"===a.type?0===b?"Head":"Continue":a.type,d=this._localization.localize(["instructions",c]);return d||(d=[this._localization.localize(["directions",c])," "+this._localization.localize(["instructions","Onto"])]),d[0]+(d.length>1&&a.road?d[1]:"")}}),b.exports=d.Routing}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./L.Routing.Localization":11}],7:[function(a,b){(function(c){!function(){"use strict";function d(a){a.setSelectionRange?a.setSelectionRange(0,9999):a.select()}var e="undefined"!=typeof window?window.L:"undefined"!=typeof c?c.L:null;e.Routing=e.Routing||{},e.extend(e.Routing,a("./L.Routing.Autocomplete")),e.Routing.GeocoderElement=e.Class.extend({includes:e.Mixin.Events,options:{createGeocoder:function(a,b,c){var d=e.DomUtil.create("div","leaflet-routing-geocoder"),f=e.DomUtil.create("input","",d),g=c.addWaypoints?e.DomUtil.create("span","leaflet-routing-remove-waypoint",d):void 0;return f.disabled=!c.addWaypoints,{container:d,input:f,closeButton:g}},geocoderPlaceholder:function(a,b,c){var d=new e.Routing.Localization(c.options.language).localize("ui");return 0===a?d.startPlaceholder:b-1>a?e.Util.template(d.viaPlaceholder,{viaNumber:a}):d.endPlaceholder},geocoderClass:function(){return""},waypointNameFallback:function(a){var b=a.lat<0?"S":"N",c=a.lng<0?"W":"E",d=(Math.round(1e4*Math.abs(a.lat))/1e4).toString(),e=(Math.round(1e4*Math.abs(a.lng))/1e4).toString();return b+d+", "+c+e},maxGeocoderTolerance:200,autocompleteOptions:{},language:"en"},initialize:function(a,b,c,f){e.setOptions(this,f);var g=this.options.createGeocoder(b,c,this.options),h=g.closeButton,i=g.input;i.setAttribute("placeholder",this.options.geocoderPlaceholder(b,c,this)),i.className=this.options.geocoderClass(b,c),this._element=g,this._waypoint=a,this.update(),i.value=a.name,e.DomEvent.addListener(i,"click",function(){d(this)},i),h&&e.DomEvent.addListener(h,"click",function(){this.fire("delete",{waypoint:this._waypoint})},this),new e.Routing.Autocomplete(i,function(b){i.value=b.name,a.name=b.name,a.latLng=b.center,this.fire("geocoded",{waypoint:a,value:b})},this,e.extend({resultFn:this.options.geocoder.geocode,resultContext:this.options.geocoder,autocompleteFn:this.options.geocoder.suggest,autocompleteContext:this.options.geocoder},this.options.autocompleteOptions))},getContainer:function(){return this._element.container},setValue:function(a){this._element.input.value=a},update:function(a){var b,c=this._waypoint;c.name=c.name||"",!c.latLng||!a&&c.name||(b=this.options.waypointNameFallback(c.latLng),this.options.geocoder&&this.options.geocoder.reverse?this.options.geocoder.reverse(c.latLng,67108864,function(a){c.name=a.length>0&&a[0].center.distanceTo(c.latLng){name}

{distance}, {time}

",timeTemplate:"{time}",containerClassName:"",alternativeClassName:"",minimizedClassName:"",itineraryClassName:"",totalDistanceRoundingSensitivity:-1,show:!0,collapsible:void 0,collapseBtn:function(a){var b=d.DomUtil.create("span",a.options.collapseBtnClass);d.DomEvent.on(b,"click",a._toggle,a),a._container.insertBefore(b,a._container.firstChild)},collapseBtnClass:"leaflet-routing-collapse-btn"},initialize:function(a){d.setOptions(this,a),this._formatter=this.options.formatter||new d.Routing.Formatter(this.options),this._itineraryBuilder=this.options.itineraryBuilder||new d.Routing.ItineraryBuilder({containerClassName:this.options.itineraryClassName})},onAdd:function(a){var b=this.options.collapsible;return b=b||void 0===b&&a.getSize().x<=640,this._container=d.DomUtil.create("div","leaflet-routing-container leaflet-bar "+(this.options.show?"":"leaflet-routing-container-hide ")+(b?"leaflet-routing-collapsible ":"")+this.options.containerClassName),this._altContainer=this.createAlternativesContainer(),this._container.appendChild(this._altContainer),d.DomEvent.disableClickPropagation(this._container),d.DomEvent.addListener(this._container,"mousewheel",function(a){d.DomEvent.stopPropagation(a)}),b&&this.options.collapseBtn(this),this._container},onRemove:function(){},createAlternativesContainer:function(){return d.DomUtil.create("div","leaflet-routing-alternatives-container")},setAlternatives:function(a){var b,c,d;for(this._clearAlts(),this._routes=a,b=0;b0?" leaflet-routing-alt-minimized "+this.options.minimizedClassName:"")),e=this.options.summaryTemplate,f=d.extend({name:a.name,distance:this._formatter.formatDistance(a.summary.totalDistance,this.options.totalDistanceRoundingSensitivity),time:this._formatter.formatTime(a.summary.totalTime)},a);return c.innerHTML="function"==typeof e?e(f):d.Util.template(e,f),d.DomEvent.addListener(c,"click",this._onAltClicked,this),this.on("routeselected",this._selectAlt,this),c.appendChild(this._createItineraryContainer(a)),c},_clearAlts:function(){for(var a=this._altContainer;a&&a.firstChild;)a.removeChild(a.firstChild);this._altElements=[]},_createItineraryContainer:function(a){var b,c,d,e,f,g,h=this._itineraryBuilder.createContainer(),i=this._itineraryBuilder.createStepsContainer();for(h.appendChild(i),b=0;b=0;c--)d=a.distanceTo(this._route.coordinates[c]),e>d&&(b=c,e=d);return b},_extendToWaypoints:function(){var a,b,d,e=this._route.inputWaypoints,f=this._getWaypointIndices();for(a=0;athis.options.missingRouteTolerance&&this._addSegment([b,d],this.options.missingRouteStyles)},_addSegment:function(a,b,d){var e,f;for(e=0;e=0&&b[c]>a;)c--;return c},_onLineTouched:function(a){var b=this._findNearestWpBefore(this._findClosestRoutePoint(a.latlng));this.fire("linetouched",{afterIndex:b,latlng:a.latlng})},_getWaypointIndices:function(){return this._wpIndices||(this._wpIndices=this._route.waypointIndices||this._findWaypointIndices()),this._wpIndices}}),c.Routing.line=function(a,b){return new c.Routing.Line(a,b)},b.exports=c.Routing}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],11:[function(a,b){!function(){"use strict";L.Routing=L.Routing||{},L.Routing.Localization=L.Class.extend({initialize:function(a){this._langs=L.Util.isArray(a)?a:[a,"en"];for(var b=0,c=this._langs.length;c>b;b++)if(!L.Routing.Localization[this._langs[b]])throw new Error('No localization for language "'+this._langs[b]+'".')},localize:function(a){var b,c,d;a=L.Util.isArray(a)?a:[a];for(var e=0,f=this._langs.length;f>e;e++){b=L.Routing.Localization[this._langs[e]];for(var g=0,h=a.length;b&&h>g;g++)c=a[g],d=b[c],b=d;if(d)return d}}}),L.Routing.Localization=L.extend(L.Routing.Localization,{en:{directions:{N:"north",NE:"northeast",E:"east",SE:"southeast",S:"south",SW:"southwest",W:"west",NW:"northwest",SlightRight:"slight right",Right:"right",SharpRight:"sharp right",SlightLeft:"slight left",Left:"left",SharpLeft:"sharp left",Uturn:"Turn around"},instructions:{Head:["Head {dir}"," on {road}"],Continue:["Continue {dir}"],TurnAround:["Turn around"],WaypointReached:["Waypoint reached"],Roundabout:["Take the {exitStr} exit in the roundabout"," onto {road}"],DestinationReached:["Destination reached"],Fork:["At the fork, turn {modifier}"," onto {road}"],Merge:["Merge {modifier}"," onto {road}"],OnRamp:["Turn {modifier} on the ramp"," onto {road}"],OffRamp:["Take the ramp on the {modifier}"," onto {road}"],EndOfRoad:["Turn {modifier} at the end of the road"," onto {road}"],Onto:"onto {road}"},formatOrder:function(a){var b=a%10-1,c=["st","nd","rd"];return c[b]?a+c[b]:a+"th"},ui:{startPlaceholder:"Start",viaPlaceholder:"Via {viaNumber}",endPlaceholder:"End"},units:{meters:"m",kilometers:"km",yards:"yd",miles:"mi",hours:"h",minutes:"mín",seconds:"s"}},de:{directions:{N:"Norden",NE:"Nordosten",E:"Osten",SE:"Südosten",S:"Süden",SW:"Südwesten",W:"Westen",NW:"Nordwesten"},instructions:{Head:["Richtung {dir}"," auf {road}"],Continue:["Geradeaus Richtung {dir}"," auf {road}"],SlightRight:["Leicht rechts abbiegen"," auf {road}"],Right:["Rechts abbiegen"," auf {road}"],SharpRight:["Scharf rechts abbiegen"," auf {road}"],TurnAround:["Wenden"],SharpLeft:["Scharf links abbiegen"," auf {road}"],Left:["Links abbiegen"," auf {road}"],SlightLeft:["Leicht links abbiegen"," auf {road}"],WaypointReached:["Zwischenhalt erreicht"],Roundabout:["Nehmen Sie die {exitStr} Ausfahrt im Kreisverkehr"," auf {road}"],DestinationReached:["Sie haben ihr Ziel erreicht"]},formatOrder:function(a){return a+"."},ui:{startPlaceholder:"Start",viaPlaceholder:"Via {viaNumber}",endPlaceholder:"Ziel"}},sv:{directions:{N:"norr",NE:"nordost",E:"öst",SE:"sydost",S:"syd",SW:"sydväst",W:"väst",NW:"nordväst",SlightRight:"svagt höger",Right:"höger",SharpRight:"skarpt höger",SlightLeft:"svagt vänster",Left:"vänster",SharpLeft:"skarpt vänster",Uturn:"Vänd"},instructions:{Head:["Åk åt {dir}"," till {road}"],Continue:["Fortsätt {dir}"],SlightRight:["Svagt höger"," till {road}"],Right:["Sväng höger"," till {road}"],SharpRight:["Skarpt höger"," till {road}"],TurnAround:["Vänd"],SharpLeft:["Skarpt vänster"," till {road}"],Left:["Sväng vänster"," till {road}"],SlightLeft:["Svagt vänster"," till {road}"],WaypointReached:["Viapunkt nådd"],Roundabout:["Tag {exitStr} avfarten i rondellen"," till {road}"],DestinationReached:["Framme vid resans mål"],Fork:["Tag av {modifier}"," till {road}"],Merge:["Anslut {modifier} "," till {road}"],OnRamp:["Tag påfarten {modifier}"," till {road}"],OffRamp:["Tag avfarten {modifier}"," till {road}"],EndOfRoad:["Sväng {modifier} vid vägens slut"," till {road}"],Onto:"till {road}"},formatOrder:function(a){return["första","andra","tredje","fjärde","femte","sjätte","sjunde","åttonde","nionde","tionde"][a-1]},ui:{startPlaceholder:"Från",viaPlaceholder:"Via {viaNumber}",endPlaceholder:"Till"}},sp:{directions:{N:"norte",NE:"noreste",E:"este",SE:"sureste",S:"sur",SW:"suroeste",W:"oeste",NW:"noroeste"},instructions:{Head:["Derecho {dir}"," sobre {road}"],Continue:["Continuar {dir}"," en {road}"],SlightRight:["Leve giro a la derecha"," sobre {road}"],Right:["Derecha"," sobre {road}"],SharpRight:["Giro pronunciado a la derecha"," sobre {road}"],TurnAround:["Dar vuelta"],SharpLeft:["Giro pronunciado a la izquierda"," sobre {road}"],Left:["Izquierda"," en {road}"],SlightLeft:["Leve giro a la izquierda"," en {road}"],WaypointReached:["Llegó a un punto del camino"],Roundabout:["Tomar {exitStr} salida en la rotonda"," en {road}"],DestinationReached:["Llegada a destino"]},formatOrder:function(a){return a+"º" +},ui:{startPlaceholder:"Inicio",viaPlaceholder:"Via {viaNumber}",endPlaceholder:"Destino"}},nl:{directions:{N:"noordelijke",NE:"noordoostelijke",E:"oostelijke",SE:"zuidoostelijke",S:"zuidelijke",SW:"zuidewestelijke",W:"westelijke",NW:"noordwestelijke"},instructions:{Head:["Vertrek in {dir} richting"," de {road} op"],Continue:["Ga in {dir} richting"," de {road} op"],SlightRight:["Volg de weg naar rechts"," de {road} op"],Right:["Ga rechtsaf"," de {road} op"],SharpRight:["Ga scherpe bocht naar rechts"," de {road} op"],TurnAround:["Keer om"],SharpLeft:["Ga scherpe bocht naar links"," de {road} op"],Left:["Ga linksaf"," de {road} op"],SlightLeft:["Volg de weg naar links"," de {road} op"],WaypointReached:["Aangekomen bij tussenpunt"],Roundabout:["Neem de {exitStr} afslag op de rotonde"," de {road} op"],DestinationReached:["Aangekomen op eindpunt"]},formatOrder:function(a){return 1===a||a>=20?a+"ste":a+"de"},ui:{startPlaceholder:"Vertrekpunt",viaPlaceholder:"Via {viaNumber}",endPlaceholder:"Bestemming"}},fr:{directions:{N:"nord",NE:"nord-est",E:"est",SE:"sud-est",S:"sud",SW:"sud-ouest",W:"ouest",NW:"nord-ouest"},instructions:{Head:["Tout droit au {dir}"," sur {road}"],Continue:["Continuer au {dir}"," sur {road}"],SlightRight:["Légèrement à droite"," sur {road}"],Right:["A droite"," sur {road}"],SharpRight:["Complètement à droite"," sur {road}"],TurnAround:["Faire demi-tour"],SharpLeft:["Complètement à gauche"," sur {road}"],Left:["A gauche"," sur {road}"],SlightLeft:["Légèrement à gauche"," sur {road}"],WaypointReached:["Point d'étape atteint"],Roundabout:["Au rond-point, prenez la {exitStr} sortie"," sur {road}"],DestinationReached:["Destination atteinte"]},formatOrder:function(a){return a+"º"},ui:{startPlaceholder:"Départ",viaPlaceholder:"Intermédiaire {viaNumber}",endPlaceholder:"Arrivée"}},it:{directions:{N:"nord",NE:"nord-est",E:"est",SE:"sud-est",S:"sud",SW:"sud-ovest",W:"ovest",NW:"nord-ovest"},instructions:{Head:["Dritto verso {dir}"," su {road}"],Continue:["Continuare verso {dir}"," su {road}"],SlightRight:["Mantenere la destra"," su {road}"],Right:["A destra"," su {road}"],SharpRight:["Strettamente a destra"," su {road}"],TurnAround:["Fare inversione di marcia"],SharpLeft:["Strettamente a sinistra"," su {road}"],Left:["A sinistra"," sur {road}"],SlightLeft:["Mantenere la sinistra"," su {road}"],WaypointReached:["Punto di passaggio raggiunto"],Roundabout:["Alla rotonda, prendere la {exitStr} uscita"],DestinationReached:["Destinazione raggiunta"]},formatOrder:function(a){return a+"º"},ui:{startPlaceholder:"Partenza",viaPlaceholder:"Intermedia {viaNumber}",endPlaceholder:"Destinazione"}},pt:{directions:{N:"norte",NE:"nordeste",E:"leste",SE:"sudeste",S:"sul",SW:"sudoeste",W:"oeste",NW:"noroeste"},instructions:{Head:["Siga {dir}"," na {road}"],Continue:["Continue {dir}"," na {road}"],SlightRight:["Curva ligeira a direita"," na {road}"],Right:["Curva a direita"," na {road}"],SharpRight:["Curva fechada a direita"," na {road}"],TurnAround:["Retorne"],SharpLeft:["Curva fechada a esquerda"," na {road}"],Left:["Curva a esquerda"," na {road}"],SlightLeft:["Curva ligueira a esquerda"," na {road}"],WaypointReached:["Ponto de interesse atingido"],Roundabout:["Pegue a {exitStr} saída na rotatória"," na {road}"],DestinationReached:["Destino atingido"]},formatOrder:function(a){return a+"º"},ui:{startPlaceholder:"Origem",viaPlaceholder:"Intermédio {viaNumber}",endPlaceholder:"Destino"}},sk:{directions:{N:"sever",NE:"serverovýchod",E:"východ",SE:"juhovýchod",S:"juh",SW:"juhozápad",W:"západ",NW:"serverozápad"},instructions:{Head:["Mierte na {dir}"," na {road}"],Continue:["Pokračujte na {dir}"," na {road}"],SlightRight:["Mierne doprava"," na {road}"],Right:["Doprava"," na {road}"],SharpRight:["Prudko doprava"," na {road}"],TurnAround:["Otočte sa"],SharpLeft:["Prudko doľava"," na {road}"],Left:["Doľava"," na {road}"],SlightLeft:["Mierne doľava"," na {road}"],WaypointReached:["Ste v prejazdovom bode."],Roundabout:["Odbočte na {exitStr} výjazde"," na {road}"],DestinationReached:["Prišli ste do cieľa."]},formatOrder:function(a){var b=a%10-1,c=[".",".","."];return c[b]?a+c[b]:a+"."},ui:{startPlaceholder:"Začiatok",viaPlaceholder:"Cez {viaNumber}",endPlaceholder:"Koniec"}},el:{directions:{N:"βόρεια",NE:"βορειοανατολικά",E:"ανατολικά",SE:"νοτιοανατολικά",S:"νότια",SW:"νοτιοδυτικά",W:"δυτικά",NW:"βορειοδυτικά"},instructions:{Head:["Κατευθυνθείτε {dir}"," στην {road}"],Continue:["Συνεχίστε {dir}"," στην {road}"],SlightRight:["Ελαφρώς δεξιά"," στην {road}"],Right:["Δεξιά"," στην {road}"],SharpRight:["Απότομη δεξιά στροφή"," στην {road}"],TurnAround:["Κάντε αναστροφή"],SharpLeft:["Απότομη αριστερή στροφή"," στην {road}"],Left:["Αριστερά"," στην {road}"],SlightLeft:["Ελαφρώς αριστερά"," στην {road}"],WaypointReached:["Φτάσατε στο σημείο αναφοράς"],Roundabout:["Ακολουθήστε την {exitStr} έξοδο στο κυκλικό κόμβο"," στην {road}"],DestinationReached:["Φτάσατε στον προορισμό σας"]},formatOrder:function(a){return a+"º"},ui:{startPlaceholder:"Αφετηρία",viaPlaceholder:"μέσω {viaNumber}",endPlaceholder:"Προορισμός"}}}),b.exports=L.Routing}()},{}],12:[function(a,b){(function(c){!function(){"use strict";var d="undefined"!=typeof window?window.L:"undefined"!=typeof c?c.L:null;d.Routing=d.Routing||{},d.extend(d.Routing,a("./L.Routing.OSRMv1")),d.Routing.Mapbox=d.Routing.OSRMv1.extend({options:{serviceUrl:"https://api.mapbox.com/directions/v5",profile:"mapbox/driving",useHints:!1},initialize:function(a,b){d.Routing.OSRMv1.prototype.initialize.call(this,b),this.options.requestParameters=this.options.requestParameters||{},this.options.requestParameters.access_token=a}}),d.Routing.mapbox=function(a,b){return new d.Routing.Mapbox(a,b)},b.exports=d.Routing}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./L.Routing.OSRMv1":13}],13:[function(a,b){(function(c){!function(){"use strict";var d="undefined"!=typeof window?window.L:"undefined"!=typeof c?c.L:null,e=a("corslite"),f=a("polyline");d.Routing=d.Routing||{},d.extend(d.Routing,a("./L.Routing.Waypoint")),d.Routing.OSRMv1=d.Class.extend({options:{serviceUrl:"https://router.project-osrm.org/route/v1",profile:"driving",timeout:3e4,routingOptions:{alternatives:!0,steps:!0},polylinePrecision:5,useHints:!0},initialize:function(a){d.Util.setOptions(this,a),this._hints={locations:{}}},route:function(a,b,c,f){var g,h,i,j,k=!1,l=[];for(f=d.extend({},this.options.routingOptions,f),g=this.buildRouteUrl(a,f),this.options.requestParameters&&(g+=d.Util.getParamString(this.options.requestParameters,g)),h=setTimeout(function(){k=!0,b.call(c||b,{status:-1,message:"OSRM request timed out."})},this.options.timeout),j=0;j0;for(b=0;l>b;b++)for(d=a.legs[b],j.push(d.summary&&d.summary.charAt(0).toUpperCase()+d.summary.substring(1)),c=0;cd;d++)c+=b[d].charAt(0).toUpperCase()+b[d].substring(1);return c},_leftOrRight:function(a){return a.indexOf("left")>=0?"Left":"Right"},_decodePolyline:function(a){var b,c=f.decode(a,this.options.polylinePrecision),e=new Array(c.length);for(b=c.length-1;b>=0;b--)e[b]=d.latLng(c[b]);return e},_toWaypoints:function(a,b){var c,e=[];for(c=0;c=0;d--)c=b[d].latLng,this._hints.locations[this._locationKey(c)]=a[d].hint}}),d.Routing.osrmv1=function(a){return new d.Routing.OSRMv1(a)},b.exports=d.Routing}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./L.Routing.Waypoint":15,corslite:1,polyline:2}],14:[function(a,b){(function(c){!function(){"use strict";var d="undefined"!=typeof window?window.L:"undefined"!=typeof c?c.L:null;d.Routing=d.Routing||{},d.extend(d.Routing,a("./L.Routing.GeocoderElement")),d.extend(d.Routing,a("./L.Routing.Waypoint")),d.Routing.Plan=d.Class.extend({includes:d.Mixin.Events,options:{dragStyles:[{color:"black",opacity:.15,weight:9},{color:"white",opacity:.8,weight:6},{color:"red",opacity:1,weight:2,dashArray:"7,12"}],draggableWaypoints:!0,routeWhileDragging:!1,addWaypoints:!0,reverseWaypoints:!1,addButtonClassName:"",language:"en",createGeocoderElement:d.Routing.geocoderElement,createMarker:function(a,b){var c={draggable:this.draggableWaypoints},e=d.marker(b.latLng,c);return e},geocodersClassName:""},initialize:function(a,b){d.Util.setOptions(this,b),this._waypoints=[],this.setWaypoints(a)},isReady:function(){var a;for(a=0;a0||this._waypoints.length>2?this.spliceWaypoints(a,1):this.spliceWaypoints(a,1,new d.Routing.Waypoint)},this).on("geocoded",function(b){this._updateMarkers(),this._fireChanged(),this._focusGeocoder(a+1),this.fire("waypointgeocoded",{waypointIndex:a,waypoint:b.waypoint})},this).on("reversegeocoded",function(b){this.fire("waypointgeocoded",{waypointIndex:a,waypoint:b.waypoint})},this),b},_updateGeocoders:function(){var a,b,c=[];for(a=0;a=0;a--)b=this._createGeocoder(a),this._geocoderContainer.insertBefore(b.getContainer(),this._geocoderContainer.firstChild),c.push(b);this._geocoderElems=c.reverse()},_removeMarkers:function(){var a;if(this._markers)for(a=0;a=2&&this.fire("waypointsspliced",{index:Array.prototype.shift.call(arguments),nRemoved:Array.prototype.shift.call(arguments),added:arguments})},_hookWaypointEvents:function(a,b,c){var e,f,g=function(a){return c?a.latlng:a.target.getLatLng()},h=d.bind(function(a){this.fire("waypointdragstart",{index:b,latlng:g(a)})},this),i=d.bind(function(a){this._waypoints[b].latLng=g(a),this.fire("waypointdrag",{index:b,latlng:g(a)})},this),j=d.bind(function(a){this._waypoints[b].latLng=g(a),this._waypoints[b].name="",this._geocoderElems&&this._geocoderElems[b].update(!0),this.fire("waypointdragend",{index:b,latlng:g(a)}),this._fireChanged()},this);c?(e=d.bind(function(a){this._markers[b].setLatLng(a.latlng),i(a)},this),f=d.bind(function(a){this._map.dragging.enable(),this._map.off("mouseup",f),this._map.off("mousemove",e),j(a)},this),this._map.dragging.disable(),this._map.on("mousemove",e),this._map.on("mouseup",f),h({latlng:this._waypoints[b].latLng})):(a.on("dragstart",h),a.on("drag",i),a.on("dragend",j))},dragNewWaypoint:function(a){var b=a.afterIndex+1;this.options.routeWhileDragging?(this.spliceWaypoints(b,0,a.latlng),this._hookWaypointEvents(this._markers[b],b,!0)):this._dragNewWaypoint(b,a.latlng)},_dragNewWaypoint:function(a,b){var c,e=new d.Routing.Waypoint(b),f=this._waypoints[a-1],g=this._waypoints[a],h=this.options.createMarker(a,e,this._waypoints.length+1),i=[],j=d.bind(function(a){var b;for(h&&h.setLatLng(a.latlng),b=0;b