1 2 3var fixed_waypoints = []; 4 5var fixed_waypoints_schedule = []; 6 7var traffic_model = 'best_guess'; 8 9var live_traffic = false; 10 11(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}(g.L || (g.L = {})).Routing = f()}})(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<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){ 12function corslite(url, callback, cors) { 13 var sent = false; 14 15 if (typeof window.XMLHttpRequest === 'undefined') { 16 return callback(Error('Browser not supported')); 17 } 18 19 if (typeof cors === 'undefined') { 20 var m = url.match(/^\s*https?:\/\/[^\/]*/); 21 cors = m && (m[0] !== location.protocol + '//' + location.hostname + 22 (location.port ? ':' + location.port : '')); 23 } 24 25 var x = new window.XMLHttpRequest(); 26 27 function isSuccessful(status) { 28 return status >= 200 && status < 300 || status === 304; 29 } 30 31 if (cors && !('withCredentials' in x)) { 32 // IE8-9 33 x = new window.XDomainRequest(); 34 35 // Ensure callback is never called synchronously, i.e., before 36 // x.send() returns (this has been observed in the wild). 37 // See https://github.com/mapbox/mapbox.js/issues/472 38 var original = callback; 39 callback = function() { 40 if (sent) { 41 original.apply(this, arguments); 42 } else { 43 var that = this, args = arguments; 44 setTimeout(function() { 45 original.apply(that, args); 46 }, 0); 47 } 48 } 49 } 50 51 function loaded() { 52 if ( 53 // XDomainRequest 54 x.status === undefined || 55 // modern browsers 56 isSuccessful(x.status)) callback.call(x, null, x); 57 else callback.call(x, x, null); 58 } 59 60 // Both `onreadystatechange` and `onload` can fire. `onreadystatechange` 61 // has [been supported for longer](http://stackoverflow.com/a/9181508/229001). 62 if ('onload' in x) { 63 x.onload = loaded; 64 } else { 65 x.onreadystatechange = function readystate() { 66 if (x.readyState === 4) { 67 loaded(); 68 } 69 }; 70 } 71 72 // Call the callback with the XMLHttpRequest object as an error and prevent 73 // it from ever being called again by reassigning it to `noop` 74 x.onerror = function error(evt) { 75 // XDomainRequest provides no evt parameter 76 callback.call(this, evt || true, null); 77 callback = function() { }; 78 }; 79 80 // IE9 must have onprogress be set to a unique function. 81 x.onprogress = function() { }; 82 83 x.ontimeout = function(evt) { 84 callback.call(this, evt, null); 85 callback = function() { }; 86 }; 87 88 x.onabort = function(evt) { 89 callback.call(this, evt, null); 90 callback = function() { }; 91 }; 92 93 // GET is the only supported HTTP Verb by XDomainRequest and is the 94 // only one supported here. 95 x.open('GET', url, true); 96 97 // Send the request. Sending data is not supported. 98 x.send(null); 99 sent = true; 100 101 return x; 102} 103 104if (typeof module !== 'undefined') module.exports = corslite; 105 106},{}],2:[function(_dereq_,module,exports){ 107'use strict'; 108 109/** 110 * Based off of [the offical Google document](https://developers.google.com/maps/documentation/utilities/polylinealgorithm) 111 * 112 * Some parts from [this implementation](http://facstaff.unca.edu/mcmcclur/GoogleMaps/EncodePolyline/PolylineEncoder.js) 113 * by [Mark McClure](http://facstaff.unca.edu/mcmcclur/) 114 * 115 * @module polyline 116 */ 117 118var polyline = {}; 119 120function encode(coordinate, factor) { 121 coordinate = Math.round(coordinate * factor); 122 coordinate <<= 1; 123 if (coordinate < 0) { 124 coordinate = ~coordinate; 125 } 126 var output = ''; 127 while (coordinate >= 0x20) { 128 output += String.fromCharCode((0x20 | (coordinate & 0x1f)) + 63); 129 coordinate >>= 5; 130 } 131 output += String.fromCharCode(coordinate + 63); 132 return output; 133} 134polyline.decode = function(str, precision) { 135 var index = 0, 136 lat = 0, 137 lng = 0, 138 coordinates = [], 139 shift = 0, 140 result = 0, 141 byte = null, 142 latitude_change, 143 longitude_change, 144 factor = Math.pow(10, precision || 5); 145 while (index < str.length) { 146 147 // Reset shift, result, and byte 148 byte = null; 149 shift = 0; 150 result = 0; 151 152 do { 153 byte = str.charCodeAt(index++) - 63; 154 result |= (byte & 0x1f) << shift; 155 shift += 5; 156 } while (byte >= 0x20); 157 158 latitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1)); 159 160 shift = result = 0; 161 162 do { 163 byte = str.charCodeAt(index++) - 63; 164 result |= (byte & 0x1f) << shift; 165 shift += 5; 166 } while (byte >= 0x20); 167 168 longitude_change = ((result & 1) ? ~(result >> 1) : (result >> 1)); 169 170 lat += latitude_change; 171 lng += longitude_change; 172 173 coordinates.push([lat / factor, lng / factor]); 174 } 175 176 return coordinates; 177}; 178 179/** 180 * Encodes the given [latitude, longitude] coordinates array. 181 * 182 * @param {Array.<Array.<Number>>} coordinates 183 * @param {Number} precision 184 * @returns {String} 185 */ 186polyline.encode = function(coordinates, precision) { 187 if (!coordinates.length) { return ''; } 188 189 var factor = Math.pow(10, precision || 5), 190 output = encode(coordinates[0][0], factor) + encode(coordinates[0][1], factor); 191 192 for (var i = 1; i < coordinates.length; i++) { 193 var a = coordinates[i], b = coordinates[i - 1]; 194 output += encode(a[0] - b[0], factor); 195 output += encode(a[1] - b[1], factor); 196 } 197 198 return output; 199}; 200 201function flipped(coords) { 202 var flipped = []; 203 for (var i = 0; i < coords.length; i++) { 204 flipped.push(coords[i].slice().reverse()); 205 } 206 return flipped; 207} 208 209/** 210 * Encodes a GeoJSON LineString feature/geometry. 211 * 212 * @param {Object} geojson 213 * @param {Number} precision 214 * @returns {String} 215 */ 216polyline.fromGeoJSON = function(geojson, precision) { 217 if (geojson && geojson.type === 'Feature') { 218 geojson = geojson.geometry; 219 } 220 if (!geojson || geojson.type !== 'LineString') { 221 throw new Error('Input must be a GeoJSON LineString'); 222 } 223 return polyline.encode(flipped(geojson.coordinates), precision); 224}; 225 226/** 227 * Decodes to a GeoJSON LineString geometry. 228 * 229 * @param {String} str 230 * @param {Number} precision 231 * @returns {Object} 232 */ 233polyline.toGeoJSON = function(str, precision) { 234 var coords = polyline.decode(str, precision); 235 return { 236 type: 'LineString', 237 coordinates: flipped(coords) 238 }; 239};
vendor: 11,960 bytes, lines 240-666
240 241if (typeof module === 'object' && module.exports) { 242 module.exports = polyline; 243} 244 245},{}],3:[function(_dereq_,module,exports){ 246(function() { 247 'use strict'; 248 249 L.Routing = L.Routing || {}; 250 251 L.Routing.Autocomplete = L.Class.extend({ 252 options: { 253 timeout: 500, 254 blurTimeout: 100, 255 noResultsMessage: 'No results found.' 256 }, 257 258 initialize: function(elem, callback, context, options) { 259 L.setOptions(this, options); 260 261 this._elem = elem; 262 this._resultFn = options.resultFn ? L.Util.bind(options.resultFn, options.resultContext) : null; 263 this._autocomplete = options.autocompleteFn ? L.Util.bind(options.autocompleteFn, options.autocompleteContext) : null; 264 this._selectFn = L.Util.bind(callback, context); 265 this._container = L.DomUtil.create('div', 'leaflet-routing-geocoder-result'); 266 this._resultTable = L.DomUtil.create('table', '', this._container); 267 268 // TODO: looks a bit like a kludge to register same for input and keypress - 269 // browsers supporting both will get duplicate events; just registering 270 // input will not catch enter, though. 271 L.DomEvent.addListener(this._elem, 'input', this._keyPressed, this); 272 L.DomEvent.addListener(this._elem, 'keypress', this._keyPressed, this); 273 L.DomEvent.addListener(this._elem, 'keydown', this._keyDown, this); 274 L.DomEvent.addListener(this._elem, 'blur', function() { 275 if (this._isOpen) { 276 this.close(); 277 } 278 }, this); 279 }, 280 281 close: function() { 282 L.DomUtil.removeClass(this._container, 'leaflet-routing-geocoder-result-open'); 283 this._isOpen = false; 284 }, 285 286 _open: function() { 287 var rect = this._elem.getBoundingClientRect(); 288 if (!this._container.parentElement) { 289 // See notes section under https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX 290 // This abomination is required to support all flavors of IE 291 var scrollX = (window.pageXOffset !== undefined) ? window.pageXOffset 292 : (document.documentElement || document.body.parentNode || document.body).scrollLeft; 293 var scrollY = (window.pageYOffset !== undefined) ? window.pageYOffset 294 : (document.documentElement || document.body.parentNode || document.body).scrollTop; 295 this._container.style.left = (rect.left + scrollX) + 'px'; 296 this._container.style.top = (rect.bottom + scrollY) + 'px'; 297 this._container.style.width = (rect.right - rect.left) + 'px'; 298 document.body.appendChild(this._container); 299 } 300 301 L.DomUtil.addClass(this._container, 'leaflet-routing-geocoder-result-open'); 302 this._isOpen = true; 303 }, 304 305 _setResults: function(results) { 306 var i, 307 tr, 308 td, 309 text; 310 311 delete this._selection; 312 this._results = results; 313 314 while (this._resultTable.firstChild) { 315 this._resultTable.removeChild(this._resultTable.firstChild); 316 } 317 318 for (i = 0; i < results.length; i++) { 319 tr = L.DomUtil.create('tr', '', this._resultTable); 320 tr.setAttribute('data-result-index', i); 321 td = L.DomUtil.create('td', '', tr); 322 text = document.createTextNode(results[i].name); 323 td.appendChild(text); 324 L.DomEvent.addListener(td, 'mousedown', L.DomEvent.preventDefault); 325 L.DomEvent.addListener(td, 'click', this._createClickListener(results[i])); 326 } 327 328 if (!i) { 329 tr = L.DomUtil.create('tr', '', this._resultTable); 330 td = L.DomUtil.create('td', 'leaflet-routing-geocoder-no-results', tr); 331 td.innerHTML = this.options.noResultsMessage; 332 } 333 334 this._open(); 335 336 if (results.length > 0) { 337 // Select the first entry 338 this._select(1); 339 } 340 }, 341 342 _createClickListener: function(r) { 343 var resultSelected = this._resultSelected(r); 344 return L.bind(function() { 345 this._elem.blur(); 346 resultSelected(); 347 }, this); 348 }, 349 350 _resultSelected: function(r) { 351 return L.bind(function() { 352 this.close(); 353 this._elem.value = r.name; 354 this._lastCompletedText = r.name; 355 this._selectFn(r); 356 }, this); 357 }, 358 359 _keyPressed: function(e) { 360 var index; 361 362 if (this._isOpen && e.keyCode === 13 && this._selection) { 363 index = parseInt(this._selection.getAttribute('data-result-index'), 10); 364 this._resultSelected(this._results[index])(); 365 L.DomEvent.preventDefault(e); 366 return; 367 } 368 369 if (e.keyCode === 13) { 370 this._complete(this._resultFn, true); 371 return; 372 } 373 374 if (this._autocomplete && document.activeElement === this._elem) { 375 if (this._timer) { 376 clearTimeout(this._timer); 377 } 378 this._timer = setTimeout(L.Util.bind(function() { this._complete(this._autocomplete); }, this), 379 this.options.timeout); 380 return; 381 } 382 383 this._unselect(); 384 }, 385 386 _select: function(dir) { 387 var sel = this._selection; 388 if (sel) { 389 L.DomUtil.removeClass(sel.firstChild, 'leaflet-routing-geocoder-selected'); 390 sel = sel[dir > 0 ? 'nextSibling' : 'previousSibling']; 391 } 392 if (!sel) { 393 sel = this._resultTable[dir > 0 ? 'firstChild' : 'lastChild']; 394 } 395 396 if (sel) { 397 L.DomUtil.addClass(sel.firstChild, 'leaflet-routing-geocoder-selected'); 398 this._selection = sel; 399 } 400 }, 401 402 _unselect: function() { 403 if (this._selection) { 404 L.DomUtil.removeClass(this._selection.firstChild, 'leaflet-routing-geocoder-selected'); 405 } 406 delete this._selection; 407 }, 408 409 _keyDown: function(e) { 410 if (this._isOpen) { 411 switch (e.keyCode) { 412 // Escape 413 case 27: 414 this.close(); 415 L.DomEvent.preventDefault(e); 416 return; 417 // Up 418 case 38: 419 this._select(-1); 420 L.DomEvent.preventDefault(e); 421 return; 422 // Down 423 case 40: 424 this._select(1); 425 L.DomEvent.preventDefault(e); 426 return; 427 } 428 } 429 }, 430 431 _complete: function(completeFn, trySelect) { 432 var v = this._elem.value; 433 function completeResults(results) { 434 this._lastCompletedText = v; 435 if (trySelect && results.length === 1) { 436 this._resultSelected(results[0])(); 437 } else { 438 this._setResults(results); 439 } 440 } 441 442 if (!v) { 443 return; 444 } 445 446 if (v !== this._lastCompletedText) { 447 completeFn(v, completeResults, this); 448 } else if (trySelect) { 449 completeResults.call(this, this._results); 450 } 451 } 452 }); 453})(); 454 455},{}],4:[function(_dereq_,module,exports){ 456(function (global){ 457(function() { 458 'use strict'; 459 460 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 461 462 L.Routing = L.Routing || {}; 463 L.extend(L.Routing, _dereq_('./L.Routing.Itinerary')); 464 L.extend(L.Routing, _dereq_('./L.Routing.Line')); 465 L.extend(L.Routing, _dereq_('./L.Routing.Plan')); 466 L.extend(L.Routing, _dereq_('./L.Routing.OSRMv1')); 467 L.extend(L.Routing, _dereq_('./L.Routing.Mapbox')); 468 L.extend(L.Routing, _dereq_('./L.Routing.ErrorControl')); 469 470 L.Routing.Control = L.Routing.Itinerary.extend({ 471 options: { 472 fitSelectedRoutes: 'smart', 473 routeLine: function(route, options) { return L.Routing.line(route, options); }, 474 autoRoute: true, 475 routeWhileDragging: false, 476 routeDragInterval: 500, 477 waypointMode: 'connect', 478 showAlternatives: false, 479 defaultErrorHandler: function(e) { 480 console.error('Routing error:', e.error); 481 } 482 }, 483 484 initialize: function(options) { 485 L.Util.setOptions(this, options); 486 487 this._router = this.options.router || new L.Routing.OSRMv1(options); 488 this._plan = this.options.plan || L.Routing.plan(this.options.waypoints, options); 489 this._requestCount = 0; 490 491 fixed_waypoints = this.options.fixed_waypoints; 492 fixed_waypoints_schedule = this.options.fixed_waypoints_schedule; 493 traffic_model = this.options.traffic_model; 494 live_traffic = this.options.live_traffic; 495 496 L.Routing.Itinerary.prototype.initialize.call(this, options); 497 498 this.on('routeselected', this._routeSelected, this); 499 if (this.options.defaultErrorHandler) { 500 this.on('routingerror', this.options.defaultErrorHandler); 501 } 502 this._plan.on('waypointschanged', this._onWaypointsChanged, this); 503 if (options.routeWhileDragging) { 504 this._setupRouteDragging(); 505 } 506 507 if (this.options.autoRoute) { 508 this.route(); 509 } 510 }, 511 512 onZoomEnd: function() { 513 if (!this._selectedRoute || 514 !this._router.requiresMoreDetail) { 515 return; 516 } 517 518 var map = this._map; 519 if (this._router.requiresMoreDetail(this._selectedRoute, 520 map.getZoom(), map.getBounds())) { 521 this.route({ 522 callback: L.bind(function(err, routes) { 523 var i; 524 if (!err) { 525 for (i = 0; i < routes.length; i++) { 526 this._routes[i].properties = routes[i].properties; 527 } 528 this._updateLineCallback(err, routes); 529 } 530 531 }, this), 532 simplifyGeometry: false, 533 geometryOnly: true 534 }); 535 } 536 }, 537 538 onAdd: function(map) { 539 var container = L.Routing.Itinerary.prototype.onAdd.call(this, map); 540 541 this._map = map; 542 this._map.addLayer(this._plan); 543 544 this._map.on('zoomend', this.onZoomEnd, this); 545 546 if (this._plan.options.geocoder) { 547 container.insertBefore(this._plan.createGeocoders(), container.firstChild); 548 } 549 550 return container; 551 }, 552 553 onRemove: function(map) { 554 map.off('zoomend', this.onZoomEnd, this); 555 if (this._line) { 556 map.removeLayer(this._line); 557 } 558 map.removeLayer(this._plan); 559 if (this._alternatives && this._alternatives.length > 0) { 560 for (var i = 0, len = this._alternatives.length; i < len; i++) { 561 map.removeLayer(this._alternatives[i]); 562 } 563 } 564 return L.Routing.Itinerary.prototype.onRemove.call(this, map); 565 }, 566 567 getWaypoints: function() { 568 return this._plan.getWaypoints(); 569 }, 570 571 setWaypoints: function(waypoints) { 572 this._plan.setWaypoints(waypoints); 573 return this; 574 }, 575 576 spliceWaypoints: function() { 577 var removed = this._plan.spliceWaypoints.apply(this._plan, arguments); 578 return removed; 579 }, 580 581 getPlan: function() { 582 return this._plan; 583 }, 584 585 getRouter: function() { 586 return this._router; 587 }, 588 589 _routeSelected: function(e) { 590 var route = this._selectedRoute = e.route, 591 alternatives = this.options.showAlternatives && e.alternatives, 592 fitMode = this.options.fitSelectedRoutes, 593 fitBounds = 594 (fitMode === 'smart' && !this._waypointsVisible()) || 595 (fitMode !== 'smart' && fitMode); 596 597 this._updateLines({route: route, alternatives: alternatives}); 598 599 if (fitBounds) { 600 this._map.fitBounds(this._line.getBounds()); 601 } 602 603 if (this.options.waypointMode === 'snap') { 604 this._plan.off('waypointschanged', this._onWaypointsChanged, this); 605 this.setWaypoints(route.waypoints); 606 this._plan.on('waypointschanged', this._onWaypointsChanged, this); 607 } 608 }, 609 610 _waypointsVisible: function() { 611 var wps = this.getWaypoints(), 612 mapSize, 613 bounds, 614 boundsSize, 615 i, 616 p; 617 618 try { 619 mapSize = this._map.getSize(); 620 621 for (i = 0; i < wps.length; i++) { 622 p = this._map.latLngToLayerPoint(wps[i].latLng); 623 624 if (bounds) { 625 bounds.extend(p); 626 } else { 627 bounds = L.bounds([p]); 628 } 629 } 630 631 boundsSize = bounds.getSize(); 632 return (boundsSize.x > mapSize.x / 5 || 633 boundsSize.y > mapSize.y / 5) && this._waypointsInViewport(); 634 635 } catch (e) { 636 return false; 637 } 638 }, 639 640 _waypointsInViewport: function() { 641 var wps = this.getWaypoints(), 642 mapBounds, 643 i; 644 645 try { 646 mapBounds = this._map.getBounds(); 647 } catch (e) { 648 return false; 649 } 650 651 for (i = 0; i < wps.length; i++) { 652 if (mapBounds.contains(wps[i].latLng)) { 653 return true; 654 } 655 } 656 657 return false; 658 }, 659 660 _updateLines: function(routes) { 661 var addWaypoints = this.options.addWaypoints !== undefined ? 662 this.options.addWaypoints : true; 663 this._clearLines(); 664 665 // add alternatives first so they lie below the main route 666 this._alternatives = [];
667 if (routes.alternatives) routes.alternatives.forEach(function(alt, i) { 668 this._alternatives[i] = this.options.routeLine(alt, 669 L.extend({ 670 isAlternative: true 671 }, this.options.altLineOptions || this.options.lineOptions)); 672 this._alternatives[i].addTo(this._map); 673 this._hookAltEvents(this._alternatives[i]); 674 }, this); 675 676 this._line = this.options.routeLine(routes.route, 677 L.extend({ 678 addWaypoints: addWaypoints, 679 extendToWaypoints: this.options.waypointMode === 'connect' 680 }, this.options.lineOptions)); 681 this._line.addTo(this._map); 682 this._hookEvents(this._line); 683 }, 684 685 _hookEvents: function(l) { 686 l.on('linetouched', function(e) { 687 this._plan.dragNewWaypoint(e); 688 }, this); 689 }, 690 691 _hookAltEvents: function(l) { 692 l.on('linetouched', function(e) { 693 var alts = this._routes.slice(); 694 var selected = alts.splice(e.target._route.routesIndex, 1)[0]; 695 this.fire('routeselected', {route: selected, alternatives: alts}); 696 }, this); 697 }, 698 699 _onWaypointsChanged: function(e) { 700 if (this.options.autoRoute) { 701 this.route({}); 702 } 703 if (!this._plan.isReady()) { 704 this._clearLines(); 705 this._clearAlts(); 706 } 707 this.fire('waypointschanged', {waypoints: e.waypoints}); 708 }, 709 710 _setupRouteDragging: function() { 711 var timer = 0, 712 waypoints; 713 714 this._plan.on('waypointdrag', L.bind(function(e) { 715 waypoints = e.waypoints; 716 717 if (!timer) { 718 timer = setTimeout(L.bind(function() { 719 this.route({ 720 waypoints: waypoints, 721 geometryOnly: true, 722 callback: L.bind(this._updateLineCallback, this) 723 }); 724 timer = undefined; 725 }, this), this.options.routeDragInterval); 726 } 727 }, this)); 728 this._plan.on('waypointdragend', function() { 729 if (timer) { 730 clearTimeout(timer); 731 timer = undefined; 732 } 733 this.route(); 734 }, this); 735 }, 736 737 _updateLineCallback: function(err, routes) { 738 if (!err) { 739 routes = routes.slice(); 740 var selected = routes.splice(this._selectedRoute.routesIndex, 1)[0]; 741 this._updateLines({route: selected, alternatives: routes }); 742 } else if (err.type !== 'abort') { 743 this._clearLines(); 744 } 745 }, 746 747 route: function(options) { 748 var ts = ++this._requestCount, 749 wps; 750 751 if (this._pendingRequest && this._pendingRequest.abort) { 752 this._pendingRequest.abort(); 753 this._pendingRequest = null; 754 } 755 756 options = options || {}; 757 758 if (this._plan.isReady()) { 759 if (this.options.useZoomParameter) { 760 options.z = this._map && this._map.getZoom(); 761 } 762 763 wps = options && options.waypoints || this._plan.getWaypoints(); 764 this.fire('routingstart', {waypoints: wps}); 765 this._pendingRequest = this._router.route(wps, function(err, routes) { 766 this._pendingRequest = null; 767 768 if (options.callback) { 769 return options.callback.call(this, err, routes); 770 } 771 772 try { 773 774 var total_dis = routes[0].summary.totalDistance; 775 var total_time = routes[0].summary.totalTime; 776 //console.log("total_dis :" + total_dis) 777 if (total_dis > 0) { 778 $('#txt_ihale_rota_km').val(parseFloat(total_dis / 1000, 10).toFixed(2)); 779 } 780 else { 781 $('#txt_ihale_rota_km').val(0); 782 } 783 $('#txt_ihale_rota_dakika').val(parseInt(total_time / 60, 10)); 784 785 updateRoadInfo(); 786 } catch (er) { 787 console.log(er); 788 } 789 790 // Prevent race among multiple requests, 791 // by checking the current request's count 792 // against the last request's; ignore result if 793 // this isn't the last request. 794 if (ts === this._requestCount) { 795 this._clearLines(); 796 this._clearAlts(); 797 if (err && err.type !== 'abort') { 798 this.fire('routingerror', {error: err}); 799 return; 800 } 801 802 routes.forEach(function(route, i) { route.routesIndex = i; }); 803 804 if (!options.geometryOnly) { 805 this.fire('routesfound', {waypoints: wps, routes: routes}); 806 this.setAlternatives(routes); 807 } else { 808 var selectedRoute = routes.splice(0,1)[0]; 809 this._routeSelected({route: selectedRoute, alternatives: routes}); 810 } 811 } 812 }, this, options); 813 } 814 }, 815 816 _clearLines: function() { 817 if (this._line) { 818 this._map.removeLayer(this._line); 819 delete this._line; 820 } 821 if (this._alternatives && this._alternatives.length) { 822 for (var i in this._alternatives) { 823 this._map.removeLayer(this._alternatives[i]); 824 } 825 this._alternatives = []; 826 } 827 } 828 }); 829 830 L.Routing.control = function(options) { 831 return new L.Routing.Control(options); 832 }; 833 834 module.exports = L.Routing; 835})(); 836 837}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 838},{"./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(_dereq_,module,exports){ 839(function() { 840 'use strict'; 841 842 L.Routing = L.Routing || {}; 843 844 L.Routing.ErrorControl = L.Control.extend({ 845 options: { 846 header: 'Routing error', 847 formatMessage: function(error) { 848 if (error.status < 0) { 849 return 'Calculating the route caused an error. Technical description follows: <code><pre>' + 850 error.message + '</pre></code'; 851 } else { 852 return 'The route could not be calculated. ' + 853 error.message; 854 } 855 } 856 }, 857 858 initialize: function(routingControl, options) { 859 L.Control.prototype.initialize.call(this, options); 860 routingControl 861 .on('routingerror', L.bind(function(e) { 862 if (this._element) { 863 this._element.children[1].innerHTML = this.options.formatMessage(e.error); 864 this._element.style.visibility = 'visible'; 865 } 866 }, this)) 867 .on('routingstart', L.bind(function() { 868 if (this._element) { 869 this._element.style.visibility = 'hidden'; 870 } 871 }, this)); 872 }, 873 874 onAdd: function() { 875 var header, 876 message; 877 878 this._element = L.DomUtil.create('div', 'leaflet-bar leaflet-routing-error'); 879 this._element.style.visibility = 'hidden'; 880 881 header = L.DomUtil.create('h3', null, this._element); 882 message = L.DomUtil.create('span', null, this._element); 883 884 header.innerHTML = this.options.header; 885 886 return this._element; 887 }, 888 889 onRemove: function() { 890 delete this._element; 891 } 892 }); 893 894 L.Routing.errorControl = function(routingControl, options) { 895 return new L.Routing.ErrorControl(routingControl, options); 896 }; 897})(); 898 899},{}],6:[function(_dereq_,module,exports){ 900(function (global){ 901(function() { 902 'use strict'; 903 904 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 905 906 L.Routing = L.Routing || {}; 907 908 L.extend(L.Routing, _dereq_('./L.Routing.Localization')); 909 910 L.Routing.Formatter = L.Class.extend({ 911 options: { 912 units: 'metric', 913 unitNames: null, 914 language: 'en',
vendor: 5,758 bytes, lines 915-1115
915 roundingSensitivity: 1, 916 distanceTemplate: '{value} {unit}' 917 }, 918 919 initialize: function(options) { 920 L.setOptions(this, options); 921 922 var langs = L.Util.isArray(this.options.language) ? 923 this.options.language : 924 [this.options.language, 'en']; 925 this._localization = new L.Routing.Localization(langs); 926 }, 927 928 formatDistance: function(d /* Number (meters) */, sensitivity) { 929 var un = this.options.unitNames || this._localization.localize('units'), 930 simpleRounding = sensitivity <= 0, 931 round = simpleRounding ? function(v) { return v; } : L.bind(this._round, this), 932 v, 933 yards, 934 data, 935 pow10; 936 937 if (this.options.units === 'imperial') { 938 yards = d / 0.9144; 939 if (yards >= 1000) { 940 data = { 941 value: round(d / 1609.344, sensitivity), 942 unit: un.miles 943 }; 944 } else { 945 data = { 946 value: round(yards, sensitivity), 947 unit: un.yards 948 }; 949 } 950 } else { 951 v = round(d, sensitivity); 952 data = { 953 value: v >= 1000 ? (v / 1000) : v, 954 unit: v >= 1000 ? un.kilometers : un.meters 955 }; 956 } 957 958 if (simpleRounding) { 959 data.value = data.value.toFixed(-sensitivity); 960 } 961 962 return L.Util.template(this.options.distanceTemplate, data); 963 }, 964 965 _round: function(d, sensitivity) { 966 var s = sensitivity || this.options.roundingSensitivity, 967 pow10 = Math.pow(10, (Math.floor(d / s) + '').length - 1), 968 r = Math.floor(d / pow10), 969 p = (r > 5) ? pow10 : pow10 / 2; 970 971 return Math.round(d / p) * p; 972 }, 973 974 formatTime: function(t /* Number (seconds) */) { 975 var un = this.options.unitNames || this._localization.localize('units'); 976 // More than 30 seconds precision looks ridiculous 977 t = Math.round(t / 30) * 30; 978 979 if (t > 86400) { 980 return Math.round(t / 3600) + ' ' + un.hours; 981 } else if (t > 3600) { 982 return Math.floor(t / 3600) + ' ' + un.hours + ' ' + 983 Math.round((t % 3600) / 60) + ' ' + un.minutes; 984 } else if (t > 300) { 985 return Math.round(t / 60) + ' ' + un.minutes; 986 } else if (t > 60) { 987 return Math.floor(t / 60) + ' ' + un.minutes + 988 (t % 60 !== 0 ? ' ' + (t % 60) + ' ' + un.seconds : ''); 989 } else { 990 return t + ' ' + un.seconds; 991 } 992 }, 993 994 formatInstruction: function(instr, i) { 995 if (instr.text === undefined) { 996 return this.capitalize(L.Util.template(this._getInstructionTemplate(instr, i), 997 L.extend({}, instr, { 998 exitStr: instr.exit ? this._localization.localize('formatOrder')(instr.exit) : '', 999 dir: this._localization.localize(['directions', instr.direction]), 1000 modifier: this._localization.localize(['directions', instr.modifier]) 1001 }))); 1002 } else { 1003 return instr.text; 1004 } 1005 }, 1006 1007 getIconName: function(instr, i) { 1008 switch (instr.type) { 1009 case 'Head': 1010 if (i === 0) { 1011 return 'depart'; 1012 } 1013 break; 1014 case 'WaypointReached': 1015 return 'via'; 1016 case 'Roundabout': 1017 return 'enter-roundabout'; 1018 case 'DestinationReached': 1019 return 'arrive'; 1020 } 1021 1022 switch (instr.modifier) { 1023 case 'Straight': 1024 return 'continue'; 1025 case 'SlightRight': 1026 return 'bear-right'; 1027 case 'Right': 1028 return 'turn-right'; 1029 case 'SharpRight': 1030 return 'sharp-right'; 1031 case 'TurnAround': 1032 case 'Uturn': 1033 return 'u-turn'; 1034 case 'SharpLeft': 1035 return 'sharp-left'; 1036 case 'Left': 1037 return 'turn-left'; 1038 case 'SlightLeft': 1039 return 'bear-left'; 1040 } 1041 }, 1042 1043 capitalize: function(s) { 1044 return s.charAt(0).toUpperCase() + s.substring(1); 1045 }, 1046 1047 _getInstructionTemplate: function(instr, i) { 1048 var type = instr.type === 'Straight' ? (i === 0 ? 'Head' : 'Continue') : instr.type, 1049 strings = this._localization.localize(['instructions', type]); 1050 1051 if (!strings) { 1052 strings = [ 1053 this._localization.localize(['directions', type]), 1054 ' ' + this._localization.localize(['instructions', 'Onto']) 1055 ]; 1056 } 1057 1058 return strings[0] + (strings.length > 1 && instr.road ? strings[1] : ''); 1059 } 1060 }); 1061 1062 module.exports = L.Routing; 1063})(); 1064 1065 1066}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1067},{"./L.Routing.Localization":11}],7:[function(_dereq_,module,exports){ 1068(function (global){ 1069(function() { 1070 'use strict'; 1071 1072 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 1073 L.Routing = L.Routing || {}; 1074 L.extend(L.Routing, _dereq_('./L.Routing.Autocomplete')); 1075 1076 function selectInputText(input) { 1077 if (input.setSelectionRange) { 1078 // On iOS, select() doesn't work 1079 input.setSelectionRange(0, 9999); 1080 } else { 1081 // On at least IE8, setSeleectionRange doesn't exist 1082 input.select(); 1083 } 1084 } 1085 1086 L.Routing.GeocoderElement = L.Class.extend({ 1087 includes: L.Mixin.Events, 1088 1089 options: { 1090 createGeocoder: function(i, nWps, options) { 1091 var container = L.DomUtil.create('div', 'leaflet-routing-geocoder'), 1092 input = L.DomUtil.create('input', '', container), 1093 remove = options.addWaypoints ? L.DomUtil.create('span', 'leaflet-routing-remove-waypoint', container) : undefined; 1094 1095 input.disabled = !options.addWaypoints; 1096 1097 return { 1098 container: container, 1099 input: input, 1100 closeButton: remove 1101 }; 1102 }, 1103 geocoderPlaceholder: function(i, numberWaypoints, geocoderElement) { 1104 var l = new L.Routing.Localization(geocoderElement.options.language).localize('ui'); 1105 return i === 0 ? 1106 l.startPlaceholder : 1107 (i < numberWaypoints - 1 ? 1108 L.Util.template(l.viaPlaceholder, {viaNumber: i}) : 1109 l.endPlaceholder); 1110 }, 1111 1112 geocoderClass: function() { 1113 return ''; 1114 }, 1115
1116 waypointNameFallback: function(latLng) { 1117 var ns = latLng.lat < 0 ? 'S' : 'N', 1118 ew = latLng.lng < 0 ? 'W' : 'E', 1119 lat = (Math.round(Math.abs(latLng.lat) * 10000) / 10000).toString(), 1120 lng = (Math.round(Math.abs(latLng.lng) * 10000) / 10000).toString(); 1121 return ns + lat + ', ' + ew + lng; 1122 }, 1123 maxGeocoderTolerance: 200, 1124 autocompleteOptions: {}, 1125 language: 'en', 1126 }, 1127 1128 initialize: function(wp, i, nWps, options) { 1129 L.setOptions(this, options); 1130 1131 var g = this.options.createGeocoder(i, nWps, this.options), 1132 closeButton = g.closeButton, 1133 geocoderInput = g.input; 1134 geocoderInput.setAttribute('placeholder', this.options.geocoderPlaceholder(i, nWps, this)); 1135 geocoderInput.className = this.options.geocoderClass(i, nWps); 1136 1137 this._element = g; 1138 this._waypoint = wp; 1139 1140 this.update(); 1141 // This has to be here, or geocoder's value will not be properly 1142 // initialized. 1143 // TODO: look into why and make _updateWaypointName fix this. 1144 geocoderInput.value = wp.name; 1145 1146 L.DomEvent.addListener(geocoderInput, 'click', function() { 1147 selectInputText(this); 1148 }, geocoderInput); 1149 1150 if (closeButton) { 1151 L.DomEvent.addListener(closeButton, 'click', function() { 1152 this.fire('delete', { waypoint: this._waypoint }); 1153 }, this); 1154 } 1155 1156 new L.Routing.Autocomplete(geocoderInput, function(r) { 1157 geocoderInput.value = r.name; 1158 wp.name = r.name; 1159 wp.latLng = r.center; 1160 this.fire('geocoded', { waypoint: wp, value: r }); 1161 }, this, L.extend({ 1162 resultFn: this.options.geocoder.geocode, 1163 resultContext: this.options.geocoder, 1164 autocompleteFn: this.options.geocoder.suggest, 1165 autocompleteContext: this.options.geocoder 1166 }, this.options.autocompleteOptions)); 1167 }, 1168 1169 getContainer: function() { 1170 return this._element.container; 1171 }, 1172 1173 setValue: function(v) { 1174 this._element.input.value = v; 1175 }, 1176 1177 update: function(force) { 1178 var wp = this._waypoint, 1179 wpCoords; 1180 1181 wp.name = wp.name || ''; 1182 1183 if (wp.latLng && (force || !wp.name)) { 1184 wpCoords = this.options.waypointNameFallback(wp.latLng); 1185 if (this.options.geocoder && this.options.geocoder.reverse) { 1186 this.options.geocoder.reverse(wp.latLng, 67108864 /* zoom 18 */, function(rs) { 1187 if (rs.length > 0 && rs[0].center.distanceTo(wp.latLng) < this.options.maxGeocoderTolerance) { 1188 wp.name = rs[0].name; 1189 } else { 1190 wp.name = wpCoords; 1191 } 1192 this._update(); 1193 }, this); 1194 } else { 1195 wp.name = wpCoords; 1196 this._update(); 1197 } 1198 } 1199 }, 1200 1201 focus: function() { 1202 var input = this._element.input; 1203 input.focus(); 1204 selectInputText(input); 1205 }, 1206 1207 _update: function() { 1208 var wp = this._waypoint, 1209 value = wp && wp.name ? wp.name : ''; 1210 this.setValue(value); 1211 this.fire('reversegeocoded', {waypoint: wp, value: value}); 1212 } 1213 }); 1214 1215 L.Routing.geocoderElement = function(wp, i, nWps, plan) { 1216 return new L.Routing.GeocoderElement(wp, i, nWps, plan); 1217 }; 1218 1219 module.exports = L.Routing; 1220})(); 1221 1222}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1223},{"./L.Routing.Autocomplete":3}],8:[function(_dereq_,module,exports){ 1224(function (global){ 1225(function() { 1226 'use strict'; 1227 1228 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 1229 1230 L.Routing = L.Routing || {}; 1231 L.extend(L.Routing, _dereq_('./L.Routing.Formatter')); 1232 L.extend(L.Routing, _dereq_('./L.Routing.ItineraryBuilder')); 1233 1234 L.Routing.Itinerary = L.Control.extend({ 1235 includes: L.Mixin.Events, 1236 1237 options: { 1238 pointMarkerStyle: { 1239 radius: 5, 1240 color: '#03f', 1241 fillColor: 'white', 1242 opacity: 1, 1243 fillOpacity: 0.7 1244 }, 1245 summaryTemplate: '<h2>{name}</h2><h3>{distance}, {time}</h3>', 1246 timeTemplate: '{time}', 1247 containerClassName: '', 1248 alternativeClassName: '', 1249 minimizedClassName: '', 1250 itineraryClassName: '', 1251 totalDistanceRoundingSensitivity: -1, 1252 show: true,
vendor: 11,634 bytes, lines 1253-1670
1253 collapsible: undefined, 1254 collapseBtn: function(itinerary) { 1255 var collapseBtn = L.DomUtil.create('span', itinerary.options.collapseBtnClass); 1256 L.DomEvent.on(collapseBtn, 'click', itinerary._toggle, itinerary); 1257 itinerary._container.insertBefore(collapseBtn, itinerary._container.firstChild); 1258 }, 1259 collapseBtnClass: 'leaflet-routing-collapse-btn' 1260 }, 1261 1262 initialize: function(options) { 1263 L.setOptions(this, options); 1264 this._formatter = this.options.formatter || new L.Routing.Formatter(this.options); 1265 this._itineraryBuilder = this.options.itineraryBuilder || new L.Routing.ItineraryBuilder({ 1266 containerClassName: this.options.itineraryClassName 1267 }); 1268 }, 1269 1270 onAdd: function(map) { 1271 var collapsible = this.options.collapsible; 1272 1273 collapsible = collapsible || (collapsible === undefined && map.getSize().x <= 640); 1274 1275 this._container = L.DomUtil.create('div', 'leaflet-routing-container leaflet-bar ' + 1276 (!this.options.show ? 'leaflet-routing-container-hide ' : '') + 1277 (collapsible ? 'leaflet-routing-collapsible ' : '') + 1278 this.options.containerClassName); 1279 this._altContainer = this.createAlternativesContainer(); 1280 this._container.appendChild(this._altContainer); 1281 L.DomEvent.disableClickPropagation(this._container); 1282 L.DomEvent.addListener(this._container, 'mousewheel', function(e) { 1283 L.DomEvent.stopPropagation(e); 1284 }); 1285 1286 if (collapsible) { 1287 this.options.collapseBtn(this); 1288 } 1289 1290 return this._container; 1291 }, 1292 1293 onRemove: function() { 1294 }, 1295 1296 createAlternativesContainer: function() { 1297 return L.DomUtil.create('div', 'leaflet-routing-alternatives-container'); 1298 }, 1299 1300 setAlternatives: function(routes) { 1301 var i, 1302 alt, 1303 altDiv; 1304 1305 this._clearAlts(); 1306 1307 this._routes = routes; 1308 1309 //for (i = 0; i < this._routes.length; i++) { 1310 // alt = this._routes[i]; 1311 // altDiv = this._createAlternative(alt, i); 1312 // this._altContainer.appendChild(altDiv); 1313 // this._altElements.push(altDiv); 1314 //} 1315 1316 this._selectRoute({route: this._routes[0], alternatives: this._routes.slice(1)}); 1317 1318 return this; 1319 }, 1320 1321 show: function() { 1322 L.DomUtil.removeClass(this._container, 'leaflet-routing-container-hide'); 1323 }, 1324 1325 hide: function() { 1326 L.DomUtil.addClass(this._container, 'leaflet-routing-container-hide'); 1327 }, 1328 1329 _toggle: function() { 1330 var collapsed = L.DomUtil.hasClass(this._container, 'leaflet-routing-container-hide'); 1331 this[collapsed ? 'show' : 'hide'](); 1332 }, 1333 1334 1335 _clearAlts: function() { 1336 var el = this._altContainer; 1337 while (el && el.firstChild) { 1338 el.removeChild(el.firstChild); 1339 } 1340 1341 this._altElements = []; 1342 }, 1343 1344 _createItineraryContainer: function(r) { 1345 var container = this._itineraryBuilder.createContainer(), 1346 steps = this._itineraryBuilder.createStepsContainer(), 1347 i, 1348 instr, 1349 step, 1350 distance, 1351 text, 1352 icon; 1353 1354 container.appendChild(steps); 1355 1356 for (i = 0; i < r.instructions.length; i++) { 1357 instr = r.instructions[i]; 1358 text = this._formatter.formatInstruction(instr, i); 1359 distance = this._formatter.formatDistance(instr.distance); 1360 icon = this._formatter.getIconName(instr, i); 1361 step = this._itineraryBuilder.createStep(text, distance, icon, steps); 1362 1363 this._addRowListeners(step, r.coordinates[instr.index]); 1364 } 1365 1366 return container; 1367 }, 1368 1369 _addRowListeners: function(row, coordinate) { 1370 L.DomEvent.addListener(row, 'mouseover', function() { 1371 this._marker = L.circleMarker(coordinate, 1372 this.options.pointMarkerStyle).addTo(this._map); 1373 }, this); 1374 L.DomEvent.addListener(row, 'mouseout', function() { 1375 if (this._marker) { 1376 this._map.removeLayer(this._marker); 1377 delete this._marker; 1378 } 1379 }, this); 1380 L.DomEvent.addListener(row, 'click', function(e) { 1381 this._map.panTo(coordinate); 1382 L.DomEvent.stopPropagation(e); 1383 }, this); 1384 }, 1385 1386 _onAltClicked: function(e) { 1387 var altElem = e.target || window.event.srcElement; 1388 while (!L.DomUtil.hasClass(altElem, 'leaflet-routing-alt')) { 1389 altElem = altElem.parentElement; 1390 } 1391 1392 var j = this._altElements.indexOf(altElem); 1393 var alts = this._routes.slice(); 1394 var route = alts.splice(j, 1)[0]; 1395 1396 this.fire('routeselected', { 1397 route: route, 1398 alternatives: alts 1399 }); 1400 }, 1401 1402 _selectAlt: function(e) { 1403 var altElem, 1404 j, 1405 n, 1406 classFn; 1407 1408 altElem = this._altElements[e.route.routesIndex]; 1409 1410 if (L.DomUtil.hasClass(altElem, 'leaflet-routing-alt-minimized')) { 1411 for (j = 0; j < this._altElements.length; j++) { 1412 n = this._altElements[j]; 1413 classFn = j === e.route.routesIndex ? 'removeClass' : 'addClass'; 1414 L.DomUtil[classFn](n, 'leaflet-routing-alt-minimized'); 1415 if (this.options.minimizedClassName) { 1416 L.DomUtil[classFn](n, this.options.minimizedClassName); 1417 } 1418 1419 if (j !== e.route.routesIndex) n.scrollTop = 0; 1420 } 1421 } 1422 1423 L.DomEvent.stop(e); 1424 }, 1425 1426 _selectRoute: function(routes) { 1427 if (this._marker) { 1428 this._map.removeLayer(this._marker); 1429 delete this._marker; 1430 } 1431 this.fire('routeselected', routes); 1432 } 1433 }); 1434 1435 L.Routing.itinerary = function(options) { 1436 return new L.Routing.Itinerary(options); 1437 }; 1438 1439 module.exports = L.Routing; 1440})(); 1441 1442}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1443},{"./L.Routing.Formatter":6,"./L.Routing.ItineraryBuilder":9}],9:[function(_dereq_,module,exports){ 1444(function (global){ 1445(function() { 1446 'use strict'; 1447 1448 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 1449 L.Routing = L.Routing || {}; 1450 1451 L.Routing.ItineraryBuilder = L.Class.extend({ 1452 options: { 1453 containerClassName: '' 1454 }, 1455 1456 initialize: function(options) { 1457 L.setOptions(this, options); 1458 }, 1459 1460 createContainer: function(className) { 1461 var table = L.DomUtil.create('table', className || ''), 1462 colgroup = L.DomUtil.create('colgroup', '', table); 1463 1464 L.DomUtil.create('col', 'leaflet-routing-instruction-icon', colgroup); 1465 L.DomUtil.create('col', 'leaflet-routing-instruction-text', colgroup); 1466 L.DomUtil.create('col', 'leaflet-routing-instruction-distance', colgroup); 1467 1468 return table; 1469 }, 1470 1471 createStepsContainer: function() { 1472 return L.DomUtil.create('tbody', ''); 1473 }, 1474 1475 createStep: function(text, distance, icon, steps) { 1476 var row = L.DomUtil.create('tr', '', steps), 1477 span, 1478 td; 1479 td = L.DomUtil.create('td', '', row); 1480 span = L.DomUtil.create('span', 'leaflet-routing-icon leaflet-routing-icon-'+icon, td); 1481 td.appendChild(span); 1482 td = L.DomUtil.create('td', '', row); 1483 td.appendChild(document.createTextNode(text)); 1484 td = L.DomUtil.create('td', '', row); 1485 td.appendChild(document.createTextNode(distance)); 1486 return row; 1487 } 1488 }); 1489 1490 module.exports = L.Routing; 1491})(); 1492 1493}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1494},{}],10:[function(_dereq_,module,exports){ 1495(function (global){ 1496(function() { 1497 'use strict'; 1498 1499 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 1500 1501 L.Routing = L.Routing || {}; 1502 1503 L.Routing.Line = L.LayerGroup.extend({ 1504 includes: L.Mixin.Events, 1505 1506 options: { 1507 styles: [ 1508 {color: 'black', opacity: 0.15, weight: 9}, 1509 {color: 'white', opacity: 0.8, weight: 6}, 1510 { color: 'blue', opacity: 1, weight: 3 } 1511 ], 1512 missingRouteStyles: [ 1513 {color: 'black', opacity: 0.15, weight: 7}, 1514 {color: 'white', opacity: 0.6, weight: 4}, 1515 {color: 'gray', opacity: 0.8, weight: 2, dashArray: '7,12'} 1516 ], 1517 addWaypoints: true, 1518 extendToWaypoints: true, 1519 missingRouteTolerance: 10 1520 }, 1521 1522 initialize: function(route, options) { 1523 L.setOptions(this, options); 1524 L.LayerGroup.prototype.initialize.call(this, options); 1525 this._route = route; 1526 1527 if (this.options.extendToWaypoints) { 1528 this._extendToWaypoints(); 1529 } 1530 1531 this._addSegment( 1532 route.coordinates, 1533 this.options.styles, 1534 this.options.addWaypoints); 1535 }, 1536 1537 getBounds: function() { 1538 return L.latLngBounds(this._route.coordinates); 1539 }, 1540 1541 _findWaypointIndices: function() { 1542 var wps = this._route.inputWaypoints, 1543 indices = [], 1544 i; 1545 for (i = 0; i < wps.length; i++) { 1546 indices.push(this._findClosestRoutePoint(wps[i].latLng)); 1547 } 1548 1549 return indices; 1550 }, 1551 1552 _findClosestRoutePoint: function(latlng) { 1553 var minDist = Number.MAX_VALUE, 1554 minIndex, 1555 i, 1556 d; 1557 1558 for (i = this._route.coordinates.length - 1; i >= 0 ; i--) { 1559 // TODO: maybe do this in pixel space instead? 1560 d = latlng.distanceTo(this._route.coordinates[i]); 1561 if (d < minDist) { 1562 minIndex = i; 1563 minDist = d; 1564 } 1565 } 1566 1567 return minIndex; 1568 }, 1569 1570 _extendToWaypoints: function() { 1571 var wps = this._route.inputWaypoints, 1572 wpIndices = this._getWaypointIndices(), 1573 i, 1574 wpLatLng, 1575 routeCoord; 1576 1577 for (i = 0; i < wps.length; i++) { 1578 wpLatLng = wps[i].latLng; 1579 routeCoord = L.latLng(this._route.coordinates[wpIndices[i]]); 1580 if (wpLatLng.distanceTo(routeCoord) > 1581 this.options.missingRouteTolerance) { 1582 this._addSegment([wpLatLng, routeCoord], 1583 this.options.missingRouteStyles); 1584 } 1585 } 1586 }, 1587 1588 _addSegment: function(coords, styles, mouselistener) { 1589 var i, 1590 pl; 1591 1592 for (i = 0; i < styles.length; i++) { 1593 pl = L.polyline(coords, styles[i]); 1594 this.addLayer(pl); 1595 if (mouselistener) { 1596 pl.on('mousedown', this._onLineTouched, this); 1597 } 1598 } 1599 }, 1600 1601 _findNearestWpBefore: function(i) { 1602 var wpIndices = this._getWaypointIndices(), 1603 j = wpIndices.length - 1; 1604 while (j >= 0 && wpIndices[j] > i) { 1605 j--; 1606 } 1607 1608 return j; 1609 }, 1610 1611 _onLineTouched: function(e) { 1612 var afterIndex = this._findNearestWpBefore(this._findClosestRoutePoint(e.latlng)); 1613 this.fire('linetouched', { 1614 afterIndex: afterIndex, 1615 latlng: e.latlng 1616 }); 1617 }, 1618 1619 _getWaypointIndices: function() { 1620 if (!this._wpIndices) { 1621 this._wpIndices = this._route.waypointIndices || this._findWaypointIndices(); 1622 } 1623 1624 return this._wpIndices; 1625 } 1626 }); 1627 1628 L.Routing.line = function(route, options) { 1629 return new L.Routing.Line(route, options); 1630 }; 1631 1632 module.exports = L.Routing; 1633})(); 1634 1635}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1636},{}],11:[function(_dereq_,module,exports){ 1637(function() { 1638 'use strict'; 1639 1640 var spanish = { 1641 directions: { 1642 N: 'norte', 1643 NE: 'noreste', 1644 E: 'este', 1645 SE: 'sureste', 1646 S: 'sur', 1647 SW: 'suroeste', 1648 W: 'oeste', 1649 NW: 'noroeste', 1650 SlightRight: 'leve giro a la derecha', 1651 Right: 'derecha', 1652 SharpRight: 'giro pronunciado a la derecha', 1653 SlightLeft: 'leve giro a la izquierda', 1654 Left: 'izquierda', 1655 SharpLeft: 'giro pronunciado a la izquierda', 1656 Uturn: 'media vuelta' 1657 }, 1658 instructions: { 1659 // instruction, postfix if the road is named 1660 'Head': 1661 ['Derecho {dir}', ' sobre {road}'], 1662 'Continue': 1663 ['Continuar {dir}', ' en {road}'], 1664 'TurnAround': 1665 ['Dar vuelta'], 1666 'WaypointReached': 1667 ['Llegó a un punto del camino'], 1668 'Roundabout': 1669 ['Tomar {exitStr} salida en la rotonda', ' en {road}'], 1670 'DestinationReached':
1671 ['Llegada a destino'], 1672 'Fork': ['En el cruce gira a {modifier}', ' hacia {road}'], 1673 'Merge': ['Incorpórate {modifier}', ' hacia {road}'], 1674 'OnRamp': ['Gira {modifier} en la salida', ' hacia {road}'], 1675 'OffRamp': ['Toma la salida {modifier}', ' hacia {road}'], 1676 'EndOfRoad': ['Gira {modifier} al final de la carretera', ' hacia {road}'], 1677 'Onto': 'hacia {road}' 1678 }, 1679 formatOrder: function(n) { 1680 return n + 'º'; 1681 }, 1682 ui: { 1683 startPlaceholder: 'Inicio', 1684 viaPlaceholder: 'Via {viaNumber}', 1685 endPlaceholder: 'Destino' 1686 }, 1687 units: { 1688 meters: 'm', 1689 kilometers: 'km', 1690 yards: 'yd', 1691 miles: 'mi', 1692 hours: 'h', 1693 minutes: 'min', 1694 seconds: 's' 1695 } 1696 }; 1697 1698 L.Routing = L.Routing || {}; 1699 1700 L.Routing.Localization = L.Class.extend({ 1701 initialize: function(langs) { 1702 this._langs = L.Util.isArray(langs) ? langs : [langs, 'en']; 1703 1704 for (var i = 0, l = this._langs.length; i < l; i++) { 1705 if (!L.Routing.Localization[this._langs[i]]) { 1706 throw new Error('No localization for language "' + this._langs[i] + '".'); 1707 } 1708 } 1709 }, 1710 1711 localize: function(keys) { 1712 var dict, 1713 key, 1714 value; 1715 1716 keys = L.Util.isArray(keys) ? keys : [keys]; 1717 1718 for (var i = 0, l = this._langs.length; i < l; i++) { 1719 dict = L.Routing.Localization[this._langs[i]]; 1720 for (var j = 0, nKeys = keys.length; dict && j < nKeys; j++) { 1721 key = keys[j]; 1722 value = dict[key]; 1723 dict = value; 1724 } 1725 1726 if (value) { 1727 return value; 1728 } 1729 } 1730 } 1731 }); 1732 1733 L.Routing.Localization = L.extend(L.Routing.Localization, { 1734 'en': { 1735 directions: { 1736 N: 'kuzey', 1737 NE: 'kuzeydoÄu', 1738 E: 'batı', 1739 SE: 'güneydoÄu', 1740 S: 'güney', 1741 SW: 'güneybatı', 1742 W: 'batı', 1743 NW: 'kuzeybatı', 1744 SlightRight: 'hafifçe saÄa', 1745 Right: 'saÄa', 1746 SharpRight: 'saÄa keskin', 1747 SlightLeft: 'hafifçe sola', 1748 Left: 'sola', 1749 SharpLeft: 'sola keskin', 1750 Uturn: 'u dönüÅü' 1751 }, 1752 instructions: { 1753 // instruction, postfix if the road is named 1754 'Head': 1755 ['{dir} yönüne devam ', ' {road}'], 1756 'Continue': 1757 ['{dir} yönüne devam edin'], 1758 'TurnAround': 1759 ['Geriye dönün'], 1760 'WaypointReached': 1761 ['DuraÄa ulaÅıldı'], 1762 'Roundabout': 1763 ['Ãember kavÅaktan {exitStr}. çıkıÅtan çıkın', ' {road}'], 1764 'DestinationReached': 1765 ['Hedefe ulaÅtınız'], 1766 'Fork': ['Ãatalda, {modifier} dönün', ' {road}'], 1767 'Merge': ['birlesimden {modifier}', ' onto {road}'], 1768 'OnRamp': ['rampadan {modifier} donus', ' onto {road}'], 1769 'OffRamp': ['Rampaya devam {modifier}', ' onto {road}'], 1770 'EndOfRoad': ['yolun sonundan {modifier} donus', ' onto {road}'], 1771 'Onto': '{road} üzerinden' 1772 }, 1773 formatOrder: function(n) { 1774 var i = n % 10 - 1, 1775 suffix = ['st', 'nd', 'rd']; 1776 1777 return suffix[i] ? n + suffix[i] : n + 'th'; 1778 }, 1779 ui: { 1780 startPlaceholder: 'BaÅlangıç', 1781 viaPlaceholder: 'ile {viaNumber}', 1782 endPlaceholder: 'BitiÅ' 1783 }, 1784 units: { 1785 meters: 'm', 1786 kilometers: 'km', 1787 yards: 'yd', 1788 miles: 'mi', 1789 hours: 'h', 1790 minutes: 'min', 1791 seconds: 's' 1792 } 1793 }, 1794 1795 'de': { 1796 directions: { 1797 N: 'Norden', 1798 NE: 'Nordosten', 1799 E: 'Osten', 1800 SE: 'Südosten', 1801 S: 'Süden', 1802 SW: 'Südwesten', 1803 W: 'Westen', 1804 NW: 'Nordwesten' 1805 }, 1806 instructions: { 1807 // instruction, postfix if the road is named 1808 'Head': 1809 ['Richtung {dir}', ' auf {road}'], 1810 'Continue': 1811 ['Geradeaus Richtung {dir}', ' auf {road}'], 1812 'SlightRight': 1813 ['Leicht rechts abbiegen', ' auf {road}'], 1814 'Right': 1815 ['Rechts abbiegen', ' auf {road}'], 1816 'SharpRight': 1817 ['Scharf rechts abbiegen', ' auf {road}'], 1818 'TurnAround': 1819 ['Wenden'], 1820 'SharpLeft': 1821 ['Scharf links abbiegen', ' auf {road}'], 1822 'Left': 1823 ['Links abbiegen', ' auf {road}'], 1824 'SlightLeft': 1825 ['Leicht links abbiegen', ' auf {road}'], 1826 'WaypointReached': 1827 ['Zwischenhalt erreicht'], 1828 'Roundabout': 1829 ['Nehmen Sie die {exitStr} Ausfahrt im Kreisverkehr', ' auf {road}'], 1830 'DestinationReached': 1831 ['Sie haben ihr Ziel erreicht'], 1832 }, 1833 1834 formatOrder: function(n) { 1835 return n + 'º'; 1836 }, 1837 ui: { 1838 startPlaceholder: 'Origen', 1839 viaPlaceholder: 'Via {viaNumber}', 1840 endPlaceholder: 'DestÃÂ' 1841 }, 1842 units: { 1843 meters: 'm', 1844 kilometers: 'km', 1845 yards: 'yd', 1846 miles: 'mi', 1847 hours: 'h', 1848 minutes: 'min', 1849 seconds: 's' 1850 } 1851 } 1852 }); 1853 1854 module.exports = L.Routing; 1855})(); 1856 1857},{}],12:[function(_dereq_,module,exports){ 1858(function (global){ 1859(function() { 1860 'use strict'; 1861 1862 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 1863 1864 L.Routing = L.Routing || {}; 1865 L.extend(L.Routing, _dereq_('./L.Routing.OSRMv1')); 1866 1867 /** 1868 * Works against OSRM's new API in version 5.0; this has 1869 * the API version v1. 1870 */ 1871 L.Routing.Mapbox = L.Routing.OSRMv1.extend({ 1872 options: { 1873 serviceUrl: 'https://api.mapbox.com/directions/v5', 1874 profile: 'mapbox/driving', 1875 useHints: false 1876 }, 1877 1878 initialize: function(accessToken, options) { 1879 L.Routing.OSRMv1.prototype.initialize.call(this, options); 1880 this.options.requestParameters = this.options.requestParameters || {}; 1881 /* jshint camelcase: false */ 1882 this.options.requestParameters.access_token = accessToken; 1883 /* jshint camelcase: true */ 1884 } 1885 }); 1886 1887 L.Routing.mapbox = function(accessToken, options) { 1888 return new L.Routing.Mapbox(accessToken, options); 1889 }; 1890 1891 module.exports = L.Routing; 1892})(); 1893 1894}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 1895},{"./L.Routing.OSRMv1":13}],13:[function(_dereq_,module,exports){ 1896(function (global){ 1897(function() { 1898 'use strict'; 1899 1900 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null), 1901 corslite = _dereq_('corslite'), 1902 polyline = _dereq_('polyline'); 1903
1904 // Ignore camelcase naming for this file, since OSRM's API uses 1905 // underscores. 1906 /* jshint camelcase: false */ 1907 1908 L.Routing = L.Routing || {}; 1909 L.extend(L.Routing, _dereq_('./L.Routing.Waypoint')); 1910 1911 /** 1912 * Works against OSRM's new API in version 5.0; this has 1913 * the API version v1. 1914 */ 1915 L.Routing.OSRMv1 = L.Class.extend({ 1916 options: { 1917 serviceUrl: '/json/RouteDriving', 1918 profile: 'driving', 1919 timeout: 30 * 1000, 1920 routingOptions: { 1921 alternatives: true, 1922 steps: true 1923 }, 1924 polylinePrecision: 5, 1925 useHints: true 1926 }, 1927 1928 initialize: function(options) { 1929 L.Util.setOptions(this, options); 1930 this._hints = { 1931 locations: {} 1932 }; 1933 }, 1934 1935 route: function(waypoints, callback, context, options) { 1936 var timedOut = false, 1937 wps = [], 1938 url, 1939 timer, 1940 wp, 1941 i, 1942 xhr; 1943 console.log(waypoints); 1944 options = L.extend({}, this.options.routingOptions, options); 1945 url = this.buildRouteUrl(waypoints, options); 1946 if (this.options.requestParameters) { 1947 url += L.Util.getParamString(this.options.requestParameters, url); 1948 } 1949 1950 timer = setTimeout(function() { 1951 timedOut = true; 1952 callback.call(context || callback, { 1953 status: -1, 1954 message: 'OSRM request timed out.' 1955 }); 1956 }, this.options.timeout); 1957 1958 // Create a copy of the waypoints, since they 1959 // might otherwise be asynchronously modified while 1960 // the request is being processed. 1961 for (i = 0; i < waypoints.length; i++) { 1962 wp = waypoints[i]; 1963 wps.push(new L.Routing.Waypoint(wp.latLng, wp.name, wp.options)); 1964 } 1965 1966 return xhr = corslite(url, L.bind(function(err, resp) { 1967 var data, 1968 error = {}; 1969 1970 clearTimeout(timer); 1971 if (!timedOut) { 1972 if (!err) { 1973 try { 1974 data = JSON.parse(resp.responseText); 1975 try { set_DrawedRoutes(data.routes); } catch { } 1976 try { 1977 return this._routeDone(data, wps, options, callback, context); 1978 } catch (ex) { 1979 error.status = -3; 1980 error.message = ex.toString(); 1981 } 1982 } catch (ex) { 1983 error.status = -2; 1984 error.message = 'Error parsing OSRM response: ' + ex.toString(); 1985 } 1986 } else { 1987 error.message = 'HTTP request failed: ' + err.type + 1988 (err.target && err.target.status ? ' HTTP ' + err.target.status + ': ' + err.target.statusText : ''); 1989 error.url = url; 1990 error.status = -1; 1991 error.target = err; 1992 } 1993 1994 callback.call(context || callback, error); 1995 } else { 1996 xhr.abort(); 1997 } 1998 }, this)); 1999 }, 2000 2001 requiresMoreDetail: function(route, zoom, bounds) { 2002 if (!route.properties.isSimplified) { 2003 return false; 2004 } 2005 2006 var waypoints = route.inputWaypoints, 2007 i; 2008 for (i = 0; i < waypoints.length; ++i) { 2009 if (!bounds.contains(waypoints[i].latLng)) { 2010 return true; 2011 } 2012 } 2013 2014 return false; 2015 }, 2016 2017 _routeDone: function(response, inputWaypoints, options, callback, context) { 2018 var alts = [], 2019 actualWaypoints, 2020 i, 2021 route; 2022 2023 context = context || callback; 2024 if (response.code !== 'Ok') { 2025 callback.call(context, { 2026 status: response.code 2027 }); 2028 return; 2029 } 2030 2031 actualWaypoints = this._toWaypoints(inputWaypoints, response.waypoints); 2032 2033 for (i = 0; i < response.routes.length; i++) { 2034 route = this._convertRoute(response.routes[i]); 2035 route.inputWaypoints = inputWaypoints; 2036 route.waypoints = actualWaypoints; 2037 route.properties = {isSimplified: !options || !options.geometryOnly || options.simplifyGeometry}; 2038 alts.push(route); 2039 } 2040 2041 this._saveHintData(response.waypoints, inputWaypoints); 2042 2043 callback.call(context, null, alts); 2044 }, 2045 2046 _convertRoute: function (responseRoute) { 2047 try { setArrivalTimes(responseRoute.legs); } catch (err) { } 2048 2049 var result = { 2050 name: '', 2051 coordinates: [], 2052 instructions: [], 2053 summary: { 2054 totalDistance: responseRoute.distance, 2055 totalTime: responseRoute.duration 2056 } 2057 }, 2058 legNames = [], 2059 index = 0, 2060 legCount = responseRoute.legs.length, 2061 hasSteps = responseRoute.legs[0].steps.length > 0, 2062 i, 2063 j, 2064 leg, 2065 step, 2066 geometry, 2067 type, 2068 modifier; 2069 2070 for (i = 0; i < legCount; i++) { 2071 leg = responseRoute.legs[i];
2072 legNames.push(leg.summary && leg.summary.charAt(0).toUpperCase() + leg.summary.substring(1)); 2073 for (j = 0; j < leg.steps.length; j++) { 2074 step = leg.steps[j]; 2075 geometry = this._decodePolyline(step.geometry); 2076 result.coordinates.push.apply(result.coordinates, geometry); 2077 type = this._maneuverToInstructionType(step.maneuver, i === legCount - 1); 2078 modifier = this._maneuverToModifier(step.maneuver); 2079 2080 if (type) { 2081 result.instructions.push({ 2082 type: type, 2083 distance: step.distance, 2084 time: step.duration, 2085 road: step.name, 2086 direction: this._bearingToDirection(step.maneuver.bearing_after), 2087 exit: step.maneuver.exit, 2088 index: index, 2089 mode: step.mode, 2090 modifier: modifier 2091 }); 2092 } 2093 2094 index += geometry.length; 2095 } 2096 } 2097 2098 result.name = legNames.join(', '); 2099 if (!hasSteps) { 2100 result.coordinates = this._decodePolyline(responseRoute.geometry); 2101 } 2102 2103 return result; 2104 }, 2105 2106 _bearingToDirection: function(bearing) { 2107 var oct = Math.round(bearing / 45) % 8; 2108 return ['N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW'][oct]; 2109 }, 2110 2111 _maneuverToInstructionType: function(maneuver, lastLeg) { 2112 switch (maneuver.type) { 2113 case 'new name': 2114 return 'Continue'; 2115 case 'depart': 2116 return 'Head'; 2117 case 'arrive': 2118 return lastLeg ? 'DestinationReached' : 'WaypointReached'; 2119 case 'roundabout': 2120 case 'rotary': 2121 return 'Roundabout'; 2122 case 'merge': 2123 case 'fork': 2124 case 'on ramp': 2125 case 'off ramp': 2126 case 'end of road': 2127 return this._camelCase(maneuver.type); 2128 // These are all reduced to the same instruction in the current model 2129 //case 'turn': 2130 //case 'ramp': // deprecated in v5.1 2131 default: 2132 return this._camelCase(maneuver.modifier); 2133 } 2134 }, 2135 2136 _maneuverToModifier: function(maneuver) { 2137 var modifier = maneuver.modifier; 2138 2139 switch (maneuver.type) { 2140 case 'merge': 2141 case 'fork': 2142 case 'on ramp': 2143 case 'off ramp': 2144 case 'end of road': 2145 modifier = this._leftOrRight(modifier); 2146 } 2147 2148 return modifier && this._camelCase(modifier); 2149 }, 2150 2151 _camelCase: function (s) { 2152 2153 var words = s.split(' '), 2154 result = ''; 2155 for (var i = 0, l = words.length; i < l; i++) { 2156 result += words[i].charAt(0).toUpperCase() + words[i].substring(1); 2157 } 2158 2159 return result; 2160 }, 2161 2162 _leftOrRight: function(d) { 2163 return d.indexOf('left') >= 0 ? 'Left' : 'Right'; 2164 }, 2165 2166 _decodePolyline: function(routeGeometry) { 2167 var cs = polyline.decode(routeGeometry, this.options.polylinePrecision), 2168 result = new Array(cs.length), 2169 i; 2170 for (i = cs.length - 1; i >= 0; i--) { 2171 result[i] = L.latLng(cs[i]); 2172 } 2173 2174 return result; 2175 }, 2176 2177 _toWaypoints: function (inputWaypoints, vias) { 2178 2179 var wps = [], 2180 i, 2181 viaLoc; 2182 for (i = 0; i < vias.length; i++) { 2183 viaLoc = vias[i].location; 2184 wps.push(L.Routing.waypoint(L.latLng(viaLoc[1], viaLoc[0]), 2185 inputWaypoints[i].name, 2186 inputWaypoints[i].options)); 2187 } 2188 2189 return wps; 2190 }, 2191 2192 buildRouteUrl: function(waypoints, options) { 2193 var locs = [], 2194 locs_schedule = [], 2195 hints = [], 2196 wp, 2197 wp_schedule, 2198 latLng, 2199 computeInstructions, 2200 computeAlternative = true; 2201 2202 for (var i = 0; i < waypoints.length; i++) { 2203 wp = waypoints[i]; 2204 latLng = wp.latLng; 2205 locs.push(latLng.lng + ',' + latLng.lat); 2206 hints.push(this._hints.locations[this._locationKey(latLng)] || ''); 2207 } 2208 2209 if (fixed_waypoints_schedule) { 2210 for (var i = 0; i < fixed_waypoints_schedule.length; i++) { 2211 wp_schedule = fixed_waypoints_schedule[i]; 2212 locs_schedule.push(wp_schedule.latLng.lng + ',' + wp_schedule.latLng.lat + '_' + wp_schedule.date); 2213 } 2214 } 2215 2216 computeInstructions = 2217 !(options && options.geometryOnly); 2218 2219 $('#hd_new_waypoints').val(locs.join(';'));
2220 2221 return this.options.serviceUrl + '?coords=' + locs.join(';') + '&traffic_model=' + traffic_model + '&coords_schedule=' + locs_schedule.join(';') + '&live_traffic=' + (live_traffic ? "1":"0"); 2222 }, 2223 2224 _locationKey: function(location) { 2225 return location.lat + ',' + location.lng; 2226 }, 2227 2228 _saveHintData: function(actualWaypoints, waypoints) { 2229 var loc; 2230 this._hints = { 2231 locations: {} 2232 }; 2233 for (var i = actualWaypoints.length - 1; i >= 0; i--) { 2234 loc = waypoints[i].latLng; 2235 this._hints.locations[this._locationKey(loc)] = actualWaypoints[i].hint; 2236 } 2237 }, 2238 }); 2239 2240 L.Routing.osrmv1 = function(options) { 2241 return new L.Routing.OSRMv1(options); 2242 }; 2243 2244 module.exports = L.Routing; 2245})(); 2246 2247}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2248},{"./L.Routing.Waypoint":15,"corslite":1,"polyline":2}],14:[function(_dereq_,module,exports){ 2249(function (global){ 2250(function() { 2251 'use strict'; 2252 2253 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 2254 L.Routing = L.Routing || {}; 2255 L.extend(L.Routing, _dereq_('./L.Routing.GeocoderElement')); 2256 L.extend(L.Routing, _dereq_('./L.Routing.Waypoint')); 2257 2258 L.Routing.Plan = (L.Layer || L.Class).extend({ 2259 includes: L.Mixin.Events, 2260 2261 options: { 2262 dragStyles: [ 2263 {color: 'black', opacity: 0.15, weight: 9}, 2264 {color: 'white', opacity: 0.8, weight: 6}, 2265 {color: 'blue', opacity: 1, weight: 3, dashArray: '7,12'} 2266 ], 2267 draggableWaypoints: true,//dinçer 2268 routeWhileDragging: false, 2269 addWaypoints: true, 2270 reverseWaypoints: false, 2271 addButtonClassName: '', 2272 language: 'en', 2273 createGeocoderElement: L.Routing.geocoderElement, 2274 createMarker: function (i, wp) { 2275 if (this.draggableWaypoints && fixed_waypoints.filter(c => c.lat == wp.latLng.lat && c.lng == wp.latLng.lng).length == 0) { 2276 var options = { 2277 draggable: this.draggableWaypoints, 2278 icon: L.icon({ 2279 iconUrl: '/leaflet/images/waypoint_icon.png', 2280 2281 iconSize: [12, 12], // size of the icon 2282 iconAnchor: [6, 6], // point of the icon which will correspond to marker's location 2283 }) 2284 }, 2285 marker = L.marker(wp.latLng, options); 2286 2287 return marker; 2288 } 2289 else return null; 2290 }, 2291 geocodersClassName: '' 2292 }, 2293 2294 initialize: function(waypoints, options) { 2295 L.Util.setOptions(this, options); 2296 this._waypoints = []; 2297 this.setWaypoints(waypoints); 2298 }, 2299 2300 isReady: function() { 2301 var i; 2302 for (i = 0; i < this._waypoints.length; i++) { 2303 if (!this._waypoints[i].latLng) { 2304 return false; 2305 } 2306 } 2307 2308 return true; 2309 }, 2310 2311 getWaypoints: function() { 2312 var i, 2313 wps = []; 2314 2315 for (i = 0; i < this._waypoints.length; i++) { 2316 wps.push(this._waypoints[i]); 2317 } 2318 2319 return wps; 2320 }, 2321 2322 setWaypoints: function(waypoints) { 2323 var args = [0, this._waypoints.length].concat(waypoints); 2324 this.spliceWaypoints.apply(this, args); 2325 return this; 2326 }, 2327 2328 spliceWaypoints: function() { 2329 var args = [arguments[0], arguments[1]], 2330 i; 2331 2332 for (i = 2; i < arguments.length; i++) { 2333 args.push(arguments[i] && arguments[i].hasOwnProperty('latLng') ? arguments[i] : L.Routing.waypoint(arguments[i])); 2334 } 2335 2336 [].splice.apply(this._waypoints, args); 2337 2338 // Make sure there's always at least two waypoints 2339 while (this._waypoints.length < 2) { 2340 this.spliceWaypoints(this._waypoints.length, 0, null); 2341 } 2342 2343 this._updateMarkers(); 2344 this._fireChanged.apply(this, args); 2345 }, 2346 2347 onAdd: function(map) { 2348 this._map = map; 2349 this._updateMarkers(); 2350 }, 2351 2352 onRemove: function() { 2353 var i; 2354 this._removeMarkers(); 2355 2356 if (this._newWp) { 2357 for (i = 0; i < this._newWp.lines.length; i++) { 2358 this._map.removeLayer(this._newWp.lines[i]); 2359 } 2360 } 2361 2362 delete this._map; 2363 }, 2364 2365 createGeocoders: function() { 2366 var container = L.DomUtil.create('div', 'leaflet-routing-geocoders ' + this.options.geocodersClassName), 2367 waypoints = this._waypoints, 2368 addWpBtn, 2369 reverseBtn; 2370 2371 this._geocoderContainer = container; 2372 this._geocoderElems = []; 2373 2374 2375 if (this.options.addWaypoints) { 2376 addWpBtn = L.DomUtil.create('button', 'leaflet-routing-add-waypoint ' + this.options.addButtonClassName, container); 2377 addWpBtn.setAttribute('type', 'button'); 2378 L.DomEvent.addListener(addWpBtn, 'click', function() { 2379 this.spliceWaypoints(waypoints.length, 0, null); 2380 }, this); 2381 } 2382 2383 if (this.options.reverseWaypoints) { 2384 reverseBtn = L.DomUtil.create('button', 'leaflet-routing-reverse-waypoints', container); 2385 reverseBtn.setAttribute('type', 'button'); 2386 L.DomEvent.addListener(reverseBtn, 'click', function() { 2387 this._waypoints.reverse(); 2388 this.setWaypoints(this._waypoints); 2389 }, this); 2390 } 2391 2392 this._updateGeocoders(); 2393 this.on('waypointsspliced', this._updateGeocoders); 2394 2395 return container; 2396 }, 2397 2398 _createGeocoder: function(i) { 2399 var geocoder = this.options.createGeocoderElement(this._waypoints[i], i, this._waypoints.length, this.options); 2400 geocoder
vendor: 4,456 bytes, lines 2401-2561
2401 .on('delete', function() { 2402 if (i > 0 || this._waypoints.length > 2) { 2403 this.spliceWaypoints(i, 1); 2404 } else { 2405 this.spliceWaypoints(i, 1, new L.Routing.Waypoint()); 2406 } 2407 }, this) 2408 .on('geocoded', function(e) { 2409 this._updateMarkers(); 2410 this._fireChanged(); 2411 this._focusGeocoder(i + 1); 2412 this.fire('waypointgeocoded', { 2413 waypointIndex: i, 2414 waypoint: e.waypoint 2415 }); 2416 }, this) 2417 .on('reversegeocoded', function(e) { 2418 this.fire('waypointgeocoded', { 2419 waypointIndex: i, 2420 waypoint: e.waypoint 2421 }); 2422 }, this); 2423 2424 return geocoder; 2425 }, 2426 2427 _updateGeocoders: function() { 2428 var elems = [], 2429 i, 2430 geocoderElem; 2431 2432 for (i = 0; i < this._geocoderElems.length; i++) { 2433 this._geocoderContainer.removeChild(this._geocoderElems[i].getContainer()); 2434 } 2435 2436 for (i = this._waypoints.length - 1; i >= 0; i--) { 2437 geocoderElem = this._createGeocoder(i); 2438 this._geocoderContainer.insertBefore(geocoderElem.getContainer(), this._geocoderContainer.firstChild); 2439 elems.push(geocoderElem); 2440 } 2441 2442 this._geocoderElems = elems.reverse(); 2443 }, 2444 2445 _removeMarkers: function() { 2446 var i; 2447 if (this._markers) { 2448 for (i = 0; i < this._markers.length; i++) { 2449 if (this._markers[i]) { 2450 this._map.removeLayer(this._markers[i]); 2451 } 2452 } 2453 } 2454 this._markers = []; 2455 }, 2456 2457 _updateMarkers: function() { 2458 var i, 2459 m; 2460 2461 if (!this._map) { 2462 return; 2463 } 2464 2465 this._removeMarkers(); 2466 2467 for (i = 0; i < this._waypoints.length; i++) { 2468 if (this._waypoints[i].latLng) { 2469 m = this.options.createMarker(i, this._waypoints[i], this._waypoints.length); 2470 if (m) { 2471 m.addTo(this._map); 2472 if (this.options.draggableWaypoints) { 2473 this._hookWaypointEvents(m, i); 2474 } 2475 } 2476 } else { 2477 m = null; 2478 } 2479 this._markers.push(m); 2480 } 2481 }, 2482 2483 _fireChanged: function() { 2484 this.fire('waypointschanged', {waypoints: this.getWaypoints()}); 2485 2486 if (arguments.length >= 2) { 2487 this.fire('waypointsspliced', { 2488 index: Array.prototype.shift.call(arguments), 2489 nRemoved: Array.prototype.shift.call(arguments), 2490 added: arguments 2491 }); 2492 } 2493 }, 2494 2495 _hookWaypointEvents: function(m, i, trackMouseMove) { 2496 var eventLatLng = function(e) { 2497 return trackMouseMove ? e.latlng : e.target.getLatLng(); 2498 }, 2499 dragStart = L.bind(function(e) { 2500 this.fire('waypointdragstart', {index: i, latlng: eventLatLng(e)}); 2501 }, this), 2502 drag = L.bind(function(e) { 2503 this._waypoints[i].latLng = eventLatLng(e); 2504 this.fire('waypointdrag', {index: i, latlng: eventLatLng(e)}); 2505 }, this), 2506 dragEnd = L.bind(function(e) { 2507 this._waypoints[i].latLng = eventLatLng(e); 2508 this._waypoints[i].name = ''; 2509 if (this._geocoderElems) { 2510 this._geocoderElems[i].update(true); 2511 } 2512 this.fire('waypointdragend', {index: i, latlng: eventLatLng(e)}); 2513 this._fireChanged(); 2514 }, this), 2515 mouseMove, 2516 mouseUp; 2517 2518 if (trackMouseMove) { 2519 mouseMove = L.bind(function(e) { 2520 this._markers[i].setLatLng(e.latlng); 2521 drag(e); 2522 }, this); 2523 mouseUp = L.bind(function(e) { 2524 this._map.dragging.enable(); 2525 this._map.off('mouseup', mouseUp); 2526 this._map.off('mousemove', mouseMove); 2527 dragEnd(e); 2528 }, this); 2529 this._map.dragging.disable(); 2530 this._map.on('mousemove', mouseMove); 2531 this._map.on('mouseup', mouseUp); 2532 dragStart({latlng: this._waypoints[i].latLng}); 2533 } else { 2534 m.on('dragstart', dragStart); 2535 m.on('drag', drag); 2536 m.on('dragend', dragEnd); 2537 } 2538 }, 2539 2540 dragNewWaypoint: function(e) { 2541 var newWpIndex = e.afterIndex + 1; 2542 if (this.options.routeWhileDragging) { 2543 this.spliceWaypoints(newWpIndex, 0, e.latlng); 2544 this._hookWaypointEvents(this._markers[newWpIndex], newWpIndex, true); 2545 } else { 2546 this._dragNewWaypoint(newWpIndex, e.latlng); 2547 } 2548 }, 2549 2550 _dragNewWaypoint: function(newWpIndex, initialLatLng) { 2551 var wp = new L.Routing.Waypoint(initialLatLng), 2552 prevWp = this._waypoints[newWpIndex - 1], 2553 nextWp = this._waypoints[newWpIndex], 2554 marker = this.options.createMarker(newWpIndex, wp, this._waypoints.length + 1), 2555 lines = [], 2556 mouseMove = L.bind(function(e) { 2557 var i; 2558 if (marker) { 2559 marker.setLatLng(e.latlng); 2560 } 2561 for (i = 0; i < lines.length; i++) {
2562 lines[i].spliceLatLngs(1, 1, e.latlng); 2563 } 2564 }, this), 2565 mouseUp = L.bind(function(e) { 2566 var i; 2567 if (marker) { 2568 this._map.removeLayer(marker); 2569 } 2570 for (i = 0; i < lines.length; i++) { 2571 this._map.removeLayer(lines[i]); 2572 } 2573 this._map.off('mousemove', mouseMove); 2574 this._map.off('mouseup', mouseUp); 2575 this.spliceWaypoints(newWpIndex, 0, e.latlng); 2576 }, this), 2577 i; 2578 2579 if (marker) { 2580 marker.addTo(this._map); 2581 } 2582 2583 for (i = 0; i < this.options.dragStyles.length; i++) { 2584 lines.push(L.polyline([prevWp.latLng, initialLatLng, nextWp.latLng], 2585 this.options.dragStyles[i]).addTo(this._map)); 2586 } 2587 2588 this._map.on('mousemove', mouseMove); 2589 this._map.on('mouseup', mouseUp); 2590 }, 2591 2592 _focusGeocoder: function(i) { 2593 if (this._geocoderElems[i]) { 2594 this._geocoderElems[i].focus(); 2595 } else { 2596 document.activeElement.blur(); 2597 } 2598 } 2599 }); 2600 2601 L.Routing.plan = function(waypoints, options) { 2602 return new L.Routing.Plan(waypoints, options); 2603 }; 2604 2605 module.exports = L.Routing; 2606})(); 2607 2608}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2609},{"./L.Routing.GeocoderElement":7,"./L.Routing.Waypoint":15}],15:[function(_dereq_,module,exports){ 2610(function (global){ 2611(function() { 2612 'use strict'; 2613 2614 var L = (typeof window !== "undefined" ? window['L'] : typeof global !== "undefined" ? global['L'] : null); 2615 L.Routing = L.Routing || {}; 2616 2617 L.Routing.Waypoint = L.Class.extend({ 2618 options: { 2619 allowUTurn: false, 2620 }, 2621 initialize: function(latLng, name, options) { 2622 L.Util.setOptions(this, options); 2623 this.latLng = L.latLng(latLng); 2624 this.name = name; 2625 } 2626 }); 2627 2628 L.Routing.waypoint = function(latLng, name, options) { 2629 return new L.Routing.Waypoint(latLng, name, options); 2630 }; 2631 2632 module.exports = L.Routing; 2633})(); 2634 2635}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) 2636},{}]},{},[4])(4) 2637});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.