1(function(window, document, undefined) { 2 var oldL = window.L, 3 L = {}; 4 L.version = '0.7.3'; 5 if (typeof module === 'object' && typeof module.exports === 'object') { 6 module.exports = L 7 } else if (typeof define === 'function' && define.amd) { 8 define(L) 9 } 10 L.noConflict = function() { 11 window.L = oldL; 12 return this 13 }; 14 window.L = L; 15 L.Util = { 16 extend: function(dest) { 17 var sources = Array.prototype.slice.call(arguments, 1), 18 i, j, len, src; 19 for (j = 0, len = sources.length; j < len; j++) { 20 src = sources[j] || {}; 21 for (i in src) { 22 if (src.hasOwnProperty(i)) { 23 dest[i] = src[i] 24 } 25 } 26 } 27 return dest 28 }, 29 bind: function(fn, obj) { 30 var args = arguments.length > 2 ? Array.prototype.slice.call(arguments, 2) : null; 31 return function() { 32 return fn.apply(obj, args || arguments) 33 } 34 }, 35 stamp: (function() { 36 var lastId = 0, 37 key = '_leaflet_id'; 38 return function(obj) { 39 obj[key] = obj[key] || ++lastId; 40 return obj[key] 41 } 42 }()), 43 invokeEach: function(obj, method, context) { 44 var i, args; 45 if (typeof obj === 'object') { 46 args = Array.prototype.slice.call(arguments, 3); 47 for (i in obj) { 48 method.apply(context, [i, obj[i]].concat(args)) 49 } 50 return true 51 } 52 return false 53 }, 54 limitExecByInterval: function(fn, time, context) { 55 var lock, execOnUnlock; 56 return function wrapperFn() { 57 var args = arguments; 58 if (lock) { 59 execOnUnlock = true; 60 return 61 } 62 lock = true; 63 setTimeout(function() { 64 lock = false; 65 if (execOnUnlock) { 66 wrapperFn.apply(context, args); 67 execOnUnlock = false 68 } 69 }, time); 70 fn.apply(context, args) 71 } 72 }, 73 falseFn: function() { 74 return false 75 }, 76 formatNum: function(num, digits) { 77 var pow = Math.pow(10, digits || 5); 78 return Math.round(num * pow) / pow 79 }, 80 trim: function(str) { 81 return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '') 82 }, 83 splitWords: function(str) { 84 return L.Util.trim(str).split(/\s+/) 85 }, 86 setOptions: function(obj, options) { 87 obj.options = L.extend({}, obj.options, options); 88 return obj.options 89 }, 90 getParamString: function(obj, existingUrl, uppercase) { 91 var params = []; 92 for (var i in obj) { 93 params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i])) 94 } 95 return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&') 96 }, 97 template: function(str, data) { 98 return str.replace(/\{ *([\w_]+) *\}/g, function(str, key) { 99 var value = data[key]; 100 if (value === undefined) { 101 throw new Error('No value provided for variable ' + str) 102 } else if (typeof value === 'function') { 103 value = value(data) 104 } 105 return value 106 }) 107 }, 108 isArray: Array.isArray || function(obj) { 109 return (Object.prototype.toString.call(obj) === '[object Array]') 110 }, 111 emptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=' 112 }; 113 (function() { 114 function getPrefixed(name) { 115 var i, fn, prefixes = ['webkit', 'moz', 'o', 'ms']; 116 for (i = 0; i < prefixes.length && !fn; i++) { 117 fn = window[prefixes[i] + name] 118 } 119 return fn 120 } 121 var lastTime = 0; 122 123 function timeoutDefer(fn) { 124 var time = +new Date(), 125 timeToCall = Math.max(0, 16 - (time - lastTime)); 126 lastTime = time + timeToCall; 127 return window.setTimeout(fn, timeToCall) 128 } 129 var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer; 130 var cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') || getPrefixed('CancelRequestAnimationFrame') || function(id) { 131 window.clearTimeout(id) 132 }; 133 L.Util.requestAnimFrame = function(fn, context, immediate, element) { 134 fn = L.bind(fn, context); 135 if (immediate && requestFn === timeoutDefer) { 136 fn() 137 } else { 138 return requestFn.call(window, fn, element) 139 } 140 }; 141 L.Util.cancelAnimFrame = function(id) { 142 if (id) { 143 cancelFn.call(window, id) 144 } 145 } 146 }()); 147 L.extend = L.Util.extend; 148 L.bind = L.Util.bind; 149 L.stamp = L.Util.stamp; 150 L.setOptions = L.Util.setOptions; 151 L.Class = function() {}; 152 L.Class.extend = function(props) { 153 var NewClass = function() { 154 if (this.initialize) { 155 this.initialize.apply(this, arguments) 156 } 157 if (this._initHooks) { 158 this.callInitHooks() 159 } 160 }; 161 var F = function() {}; 162 F.prototype = this.prototype; 163 var proto = new F(); 164 proto.constructor = NewClass; 165 NewClass.prototype = proto; 166 for (var i in this) { 167 if (this.hasOwnProperty(i) && i !== 'prototype') { 168 NewClass[i] = this[i] 169 } 170 } 171 if (props.statics) { 172 L.extend(NewClass, props.statics); 173 delete props.statics 174 } 175 if (props.includes) { 176 L.Util.extend.apply(null, [proto].concat(props.includes)); 177 delete props.includes 178 } 179 if (props.options && proto.options) { 180 props.options = L.extend({}, proto.options, props.options) 181 } 182 L.extend(proto, props); 183 proto._initHooks = []; 184 var parent = this; 185 NewClass.__super__ = parent.prototype; 186 proto.callInitHooks = function() { 187 if (this._initHooksCalled) { 188 return 189 } 190 if (parent.prototype.callInitHooks) { 191 parent.prototype.callInitHooks.call(this) 192 } 193 this._initHooksCalled = true; 194 for (var i = 0, len = proto._initHooks.length; i < len; i++) { 195 proto._initHooks[i].call(this) 196 } 197 }; 198 return NewClass 199 }; 200 L.Class.include = function(props) { 201 L.extend(this.prototype, props) 202 }; 203 L.Class.mergeOptions = function(options) { 204 L.extend(this.prototype.options, options) 205 }; 206 L.Class.addInitHook = function(fn) { 207 var args = Array.prototype.slice.call(arguments, 1); 208 var init = typeof fn === 'function' ? fn : function() { 209 this[fn].apply(this, args) 210 }; 211 this.prototype._initHooks = this.prototype._initHooks || []; 212 this.prototype._initHooks.push(init) 213 }; 214 var eventsKey = '_leaflet_events'; 215 L.Mixin = {}; 216 L.Mixin.Events = { 217 addEventListener: function(types, fn, context) { 218 if (L.Util.invokeEach(types, this.addEventListener, this, fn, context)) { 219 return this 220 } 221 var events = this[eventsKey] = this[eventsKey] || {}, 222 contextId = context && context !== this && L.stamp(context), 223 i, len, event, type, indexKey, indexLenKey, typeIndex; 224 types = L.Util.splitWords(types); 225 for (i = 0, len = types.length; i < len; i++) { 226 event = { 227 action: fn, 228 context: context || this 229 }; 230 type = types[i];
231 if (contextId) { 232 indexKey = type + '_idx'; 233 indexLenKey = indexKey + '_len'; 234 typeIndex = events[indexKey] = events[indexKey] || {}; 235 if (!typeIndex[contextId]) { 236 typeIndex[contextId] = []; 237 events[indexLenKey] = (events[indexLenKey] || 0) + 1 238 } 239 typeIndex[contextId].push(event) 240 } else { 241 events[type] = events[type] || []; 242 events[type].push(event) 243 } 244 } 245 return this 246 }, 247 hasEventListeners: function(type) { 248 var events = this[eventsKey]; 249 return !!events && ((type in events && events[type].length > 0) || (type + '_idx' in events && events[type + '_idx_len'] > 0)) 250 }, 251 removeEventListener: function(types, fn, context) { 252 if (!this[eventsKey]) { 253 return this 254 } 255 if (!types) { 256 return this.clearAllEventListeners() 257 } 258 if (L.Util.invokeEach(types, this.removeEventListener, this, fn, context)) { 259 return this 260 } 261 var events = this[eventsKey], 262 contextId = context && context !== this && L.stamp(context), 263 i, len, type, listeners, j, indexKey, indexLenKey, typeIndex, removed; 264 types = L.Util.splitWords(types); 265 for (i = 0, len = types.length; i < len; i++) { 266 type = types[i]; 267 indexKey = type + '_idx'; 268 indexLenKey = indexKey + '_len'; 269 typeIndex = events[indexKey]; 270 if (!fn) { 271 delete events[type]; 272 delete events[indexKey]; 273 delete events[indexLenKey] 274 } else { 275 listeners = contextId && typeIndex ? typeIndex[contextId] : events[type]; 276 if (listeners) { 277 for (j = listeners.length - 1; j >= 0; j--) { 278 if ((listeners[j].action === fn) && (!context || (listeners[j].context === context))) { 279 removed = listeners.splice(j, 1); 280 removed[0].action = L.Util.falseFn 281 } 282 } 283 if (context && typeIndex && (listeners.length === 0)) { 284 delete typeIndex[contextId]; 285 events[indexLenKey]-- 286 } 287 } 288 } 289 } 290 return this 291 }, 292 clearAllEventListeners: function() { 293 delete this[eventsKey]; 294 return this 295 }, 296 fireEvent: function(type, data) { 297 if (!this.hasEventListeners(type)) { 298 return this 299 } 300 var event = L.Util.extend({}, data, { 301 type: type, 302 target: this 303 }); 304 var events = this[eventsKey], 305 listeners, i, len, typeIndex, contextId; 306 if (events[type]) { 307 listeners = events[type].slice(); 308 for (i = 0, len = listeners.length; i < len; i++) { 309 listeners[i].action.call(listeners[i].context, event) 310 } 311 } 312 typeIndex = events[type + '_idx']; 313 for (contextId in typeIndex) { 314 listeners = typeIndex[contextId].slice(); 315 if (listeners) { 316 for (i = 0, len = listeners.length; i < len; i++) { 317 listeners[i].action.call(listeners[i].context, event) 318 } 319 } 320 } 321 return this 322 }, 323 addOneTimeEventListener: function(types, fn, context) { 324 if (L.Util.invokeEach(types, this.addOneTimeEventListener, this, fn, context)) { 325 return this 326 } 327 var handler = L.bind(function() { 328 this.removeEventListener(types, fn, context).removeEventListener(types, handler, context) 329 }, this); 330 return this.addEventListener(types, fn, context).addEventListener(types, handler, context) 331 } 332 }; 333 L.Mixin.Events.on = L.Mixin.Events.addEventListener; 334 L.Mixin.Events.off = L.Mixin.Events.removeEventListener; 335 L.Mixin.Events.once = L.Mixin.Events.addOneTimeEventListener; 336 L.Mixin.Events.fire = L.Mixin.Events.fireEvent; 337 (function() { 338 var ie = 'ActiveXObject' in window, 339 ielt9 = ie && !document.addEventListener, 340 ua = navigator.userAgent.toLowerCase(), 341 webkit = ua.indexOf('webkit') !== -1, 342 chrome = ua.indexOf('chrome') !== -1, 343 phantomjs = ua.indexOf('phantom') !== -1, 344 android = ua.indexOf('android') !== -1, 345 android23 = ua.search('android [23]') !== -1, 346 gecko = ua.indexOf('gecko') !== -1, 347 mobile = typeof orientation !== undefined + '', 348 msPointer = window.navigator && window.navigator.msPointerEnabled && window.navigator.msMaxTouchPoints && !window.PointerEvent, 349 pointer = (window.PointerEvent && window.navigator.pointerEnabled && window.navigator.maxTouchPoints) || msPointer, 350 retina = ('devicePixelRatio' in window && window.devicePixelRatio > 1) || ('matchMedia' in window && window.matchMedia('(min-resolution:144dpi)') && window.matchMedia('(min-resolution:144dpi)').matches), 351 doc = document.documentElement, 352 ie3d = ie && ('transition' in doc.style), 353 webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23, 354 gecko3d = 'MozPerspective' in doc.style, 355 opera3d = 'OTransition' in doc.style, 356 any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs; 357 var touch = !window.L_NO_TOUCH && !phantomjs && (function() { 358 var startName = 'ontouchstart'; 359 if (pointer || (startName in doc)) { 360 return true 361 } 362 var div = document.createElement('div'), 363 supported = false; 364 if (!div.setAttribute) { 365 return false 366 } 367 div.setAttribute(startName, 'return;'); 368 if (typeof div[startName] === 'function') { 369 supported = true 370 } 371 div.removeAttribute(startName); 372 div = null; 373 return supported 374 }()); 375 L.Browser = { 376 ie: ie, 377 ielt9: ielt9, 378 webkit: webkit, 379 gecko: gecko && !webkit && !window.opera && !ie, 380 android: android, 381 android23: android23, 382 chrome: chrome, 383 ie3d: ie3d, 384 webkit3d: webkit3d, 385 gecko3d: gecko3d, 386 opera3d: opera3d, 387 any3d: any3d, 388 mobile: mobile, 389 mobileWebkit: mobile && webkit, 390 mobileWebkit3d: mobile && webkit3d, 391 mobileOpera: mobile && window.opera, 392 touch: touch, 393 msPointer: msPointer, 394 pointer: pointer, 395 retina: retina 396 } 397 }()); 398 L.Point = function(x, y, round) { 399 this.x = (round ? Math.round(x) : x); 400 this.y = (round ? Math.round(y) : y) 401 }; 402 L.Point.prototype = { 403 clone: function() { 404 return new L.Point(this.x, this.y) 405 }, 406 add: function(point) { 407 return this.clone()._add(L.point(point)) 408 }, 409 _add: function(point) { 410 this.x += point.x; 411 this.y += point.y; 412 return this 413 }, 414 subtract: function(point) { 415 return this.clone()._subtract(L.point(point)) 416 }, 417 _subtract: function(point) { 418 this.x -= point.x; 419 this.y -= point.y; 420 return this 421 }, 422 divideBy: function(num) { 423 return this.clone()._divideBy(num) 424 }, 425 _divideBy: function(num) { 426 this.x /= num; 427 this.y /= num; 428 return this 429 }, 430 multiplyBy: function(num) { 431 return this.clone()._multiplyBy(num) 432 }, 433 _multiplyBy: function(num) { 434 this.x *= num; 435 this.y *= num; 436 return this 437 }, 438 round: function() { 439 return this.clone()._round() 440 }, 441 _round: function() { 442 this.x = Math.round(this.x); 443 this.y = Math.round(this.y); 444 return this 445 }, 446 floor: function() { 447 return this.clone()._floor() 448 }, 449 _floor: function() { 450 this.x = Math.floor(this.x); 451 this.y = Math.floor(this.y); 452 return this 453 }, 454 distanceTo: function(point) { 455 point = L.point(point); 456 var x = point.x - this.x, 457 y = point.y - this.y; 458 return Math.sqrt(x * x + y * y) 459 }, 460 equals: function(point) { 461 point = L.point(point); 462 return point.x === this.x && point.y === this.y 463 }, 464 contains: function(point) { 465 point = L.point(point); 466 return Math.abs(point.x) <= Math.abs(this.x) && Math.abs(point.y) <= Math.abs(this.y) 467 }, 468 toString: function() {
469 return 'Point(' + L.Util.formatNum(this.x) + ', ' + L.Util.formatNum(this.y) + ')' 470 } 471 }; 472 L.point = function(x, y, round) { 473 if (x instanceof L.Point) { 474 return x 475 } 476 if (L.Util.isArray(x)) { 477 return new L.Point(x[0], x[1]) 478 } 479 if (x === undefined || x === null) { 480 return x 481 } 482 return new L.Point(x, y, round) 483 }; 484 L.Bounds = function(a, b) { 485 if (!a) { 486 return 487 } 488 var points = b ? [a, b] : a; 489 for (var i = 0, len = points.length; i < len; i++) { 490 this.extend(points[i]) 491 } 492 }; 493 L.Bounds.prototype = { 494 extend: function(point) { 495 point = L.point(point); 496 if (!this.min && !this.max) { 497 this.min = point.clone(); 498 this.max = point.clone() 499 } else { 500 this.min.x = Math.min(point.x, this.min.x); 501 this.max.x = Math.max(point.x, this.max.x); 502 this.min.y = Math.min(point.y, this.min.y); 503 this.max.y = Math.max(point.y, this.max.y) 504 } 505 return this 506 }, 507 getCenter: function(round) { 508 return new L.Point((this.min.x + this.max.x) / 2, (this.min.y + this.max.y) / 2, round) 509 }, 510 getBottomLeft: function() { 511 return new L.Point(this.min.x, this.max.y) 512 }, 513 getTopRight: function() { 514 return new L.Point(this.max.x, this.min.y) 515 }, 516 getSize: function() { 517 return this.max.subtract(this.min) 518 }, 519 contains: function(obj) { 520 var min, max; 521 if (typeof obj[0] === 'number' || obj instanceof L.Point) { 522 obj = L.point(obj) 523 } else { 524 obj = L.bounds(obj) 525 } 526 if (obj instanceof L.Bounds) { 527 min = obj.min; 528 max = obj.max 529 } else { 530 min = max = obj 531 } 532 return (min.x >= this.min.x) && (max.x <= this.max.x) && (min.y >= this.min.y) && (max.y <= this.max.y) 533 }, 534 intersects: function(bounds) { 535 bounds = L.bounds(bounds); 536 var min = this.min, 537 max = this.max, 538 min2 = bounds.min, 539 max2 = bounds.max, 540 xIntersects = (max2.x >= min.x) && (min2.x <= max.x), 541 yIntersects = (max2.y >= min.y) && (min2.y <= max.y); 542 return xIntersects && yIntersects 543 }, 544 isValid: function() { 545 return !!(this.min && this.max) 546 } 547 }; 548 L.bounds = function(a, b) { 549 if (!a || a instanceof L.Bounds) { 550 return a 551 } 552 return new L.Bounds(a, b) 553 }; 554 L.Transformation = function(a, b, c, d) { 555 this._a = a; 556 this._b = b; 557 this._c = c; 558 this._d = d 559 }; 560 L.Transformation.prototype = { 561 transform: function(point, scale) { 562 return this._transform(point.clone(), scale) 563 }, 564 _transform: function(point, scale) { 565 scale = scale || 1; 566 point.x = scale * (this._a * point.x + this._b); 567 point.y = scale * (this._c * point.y + this._d); 568 return point 569 }, 570 untransform: function(point, scale) { 571 scale = scale || 1; 572 return new L.Point((point.x / scale - this._b) / this._a, (point.y / scale - this._d) / this._c) 573 } 574 }; 575 L.DomUtil = { 576 get: function(id) { 577 return (typeof id === 'string' ? document.getElementById(id) : id) 578 }, 579 getStyle: function(el, style) { 580 var value = el.style[style]; 581 if (!value && el.currentStyle) { 582 value = el.currentStyle[style] 583 } 584 if ((!value || value === 'auto') && document.defaultView) { 585 var css = document.defaultView.getComputedStyle(el, null); 586 value = css ? css[style] : null 587 } 588 return value === 'auto' ? null : value 589 }, 590 getViewportOffset: function(element) { 591 var top = 0, 592 left = 0, 593 el = element, 594 docBody = document.body, 595 docEl = document.documentElement, 596 pos; 597 do { 598 top += el.offsetTop || 0; 599 left += el.offsetLeft || 0; 600 top += parseInt(L.DomUtil.getStyle(el, 'borderTopWidth'), 10) || 0; 601 left += parseInt(L.DomUtil.getStyle(el, 'borderLeftWidth'), 10) || 0; 602 pos = L.DomUtil.getStyle(el, 'position'); 603 if (el.offsetParent === docBody && pos === 'absolute') { 604 break 605 } 606 if (pos === 'fixed') { 607 top += docBody.scrollTop || docEl.scrollTop || 0; 608 left += docBody.scrollLeft || docEl.scrollLeft || 0; 609 break 610 } 611 if (pos === 'relative' && !el.offsetLeft) { 612 var width = L.DomUtil.getStyle(el, 'width'), 613 maxWidth = L.DomUtil.getStyle(el, 'max-width'), 614 r = el.getBoundingClientRect(); 615 if (width !== 'none' || maxWidth !== 'none') { 616 left += r.left + el.clientLeft 617 } 618 top += r.top + (docBody.scrollTop || docEl.scrollTop || 0); 619 break 620 } 621 el = el.offsetParent 622 } while (el); 623 el = element; 624 do { 625 if (el === docBody) { 626 break 627 } 628 top -= el.scrollTop || 0; 629 left -= el.scrollLeft || 0; 630 el = el.parentNode 631 } while (el); 632 return new L.Point(left, top) 633 }, 634 documentIsLtr: function() { 635 if (!L.DomUtil._docIsLtrCached) { 636 L.DomUtil._docIsLtrCached = true; 637 L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === 'ltr' 638 } 639 return L.DomUtil._docIsLtr 640 }, 641 create: function(tagName, className, container) { 642 var el = document.createElement(tagName); 643 el.className = className; 644 if (container) { 645 container.appendChild(el) 646 } 647 return el 648 }, 649 hasClass: function(el, name) { 650 if (el.classList !== undefined) { 651 return el.classList.contains(name) 652 } 653 var className = L.DomUtil._getClass(el); 654 return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className) 655 }, 656 addClass: function(el, name) { 657 if (el.classList !== undefined) { 658 var classes = L.Util.splitWords(name); 659 for (var i = 0, len = classes.length; i < len; i++) { 660 el.classList.add(classes[i]) 661 } 662 } else if (!L.DomUtil.hasClass(el, name)) { 663 var className = L.DomUtil._getClass(el); 664 L.DomUtil._setClass(el, (className ? className + ' ' : '') + name) 665 } 666 }, 667 removeClass: function(el, name) { 668 if (el.classList !== undefined) { 669 el.classList.remove(name) 670 } else { 671 L.DomUtil._setClass(el, L.Util.trim((' ' + L.DomUtil._getClass(el) + ' ').replace(' ' + name + ' ', ' '))) 672 } 673 }, 674 _setClass: function(el, name) { 675 if (el.className.baseVal === undefined) { 676 el.className = name 677 } else { 678 el.className.baseVal = name 679 } 680 }, 681 _getClass: function(el) { 682 return el.className.baseVal === undefined ? el.className : el.className.baseVal 683 }, 684 setOpacity: function(el, value) { 685 if ('opacity' in el.style) { 686 el.style.opacity = value 687 } else if ('filter' in el.style) { 688 var filter = false, 689 filterName = 'DXImageTransform.Microsoft.Alpha'; 690 try { 691 filter = el.filters.item(filterName) 692 } catch (e) { 693 if (value === 1) { 694 return 695 } 696 } 697 value = Math.round(value * 100); 698 if (filter) { 699 filter.Enabled = (value !== 100); 700 filter.Opacity = value 701 } else { 702 el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')' 703 } 704 } 705 }, 706 testProp: function(props) { 707 var style = document.documentElement.style; 708 for (var i = 0; i < props.length; i++) { 709 if (props[i] in style) { 710 return props[i] 711 } 712 } 713 return false 714 }, 715 getTranslateString: function(point) { 716 var is3d = L.Browser.webkit3d, 717 open = 'translate' + (is3d ? '3d' : '') + '(', 718 close = (is3d ? ',0' : '') + ')'; 719 return open + point.x + 'px,' + point.y + 'px' + close 720 },
721 getScaleString: function(scale, origin) { 722 var preTranslateStr = L.DomUtil.getTranslateString(origin.add(origin.multiplyBy(-1 * scale))), 723 scaleStr = ' scale(' + scale + ') '; 724 return preTranslateStr + scaleStr 725 }, 726 setPosition: function(el, point, disable3D) { 727 el._leaflet_pos = point; 728 if (!disable3D && L.Browser.any3d) { 729 el.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(point) 730 } else { 731 el.style.left = point.x + 'px'; 732 el.style.top = point.y + 'px' 733 } 734 }, 735 getPosition: function(el) { 736 return el._leaflet_pos 737 } 738 }; 739 L.DomUtil.TRANSFORM = L.DomUtil.testProp(['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']); 740 L.DomUtil.TRANSITION = L.DomUtil.testProp(['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']); 741 L.DomUtil.TRANSITION_END = L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ? L.DomUtil.TRANSITION + 'End' : 'transitionend'; 742 (function() { 743 if ('onselectstart' in document) { 744 L.extend(L.DomUtil, { 745 disableTextSelection: function() { 746 L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault) 747 }, 748 enableTextSelection: function() { 749 L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault) 750 } 751 }) 752 } else { 753 var userSelectProperty = L.DomUtil.testProp(['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']); 754 L.extend(L.DomUtil, { 755 disableTextSelection: function() { 756 if (userSelectProperty) { 757 var style = document.documentElement.style; 758 this._userSelect = style[userSelectProperty]; 759 style[userSelectProperty] = 'none' 760 } 761 }, 762 enableTextSelection: function() { 763 if (userSelectProperty) { 764 document.documentElement.style[userSelectProperty] = this._userSelect; 765 delete this._userSelect 766 } 767 } 768 }) 769 } 770 L.extend(L.DomUtil, { 771 disableImageDrag: function() { 772 L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault) 773 }, 774 enableImageDrag: function() { 775 L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault) 776 } 777 }) 778 })(); 779 L.LatLng = function(lat, lng, alt) { 780 lat = parseFloat(lat); 781 lng = parseFloat(lng); 782 if (isNaN(lat) || isNaN(lng)) { 783 throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')') 784 } 785 this.lat = lat; 786 this.lng = lng; 787 if (alt !== undefined) { 788 this.alt = parseFloat(alt) 789 } 790 }; 791 L.extend(L.LatLng, { 792 DEG_TO_RAD: Math.PI / 180, 793 RAD_TO_DEG: 180 / Math.PI, 794 MAX_MARGIN: 1.0E-9 795 }); 796 L.LatLng.prototype = { 797 equals: function(obj) { 798 if (!obj) { 799 return false 800 } 801 obj = L.latLng(obj); 802 var margin = Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lng - obj.lng)); 803 return margin <= L.LatLng.MAX_MARGIN 804 }, 805 toString: function(precision) { 806 return 'LatLng(' + L.Util.formatNum(this.lat, precision) + ', ' + L.Util.formatNum(this.lng, precision) + ')' 807 }, 808 distanceTo: function(other) { 809 other = L.latLng(other); 810 var R = 6378137, 811 d2r = L.LatLng.DEG_TO_RAD, 812 dLat = (other.lat - this.lat) * d2r, 813 dLon = (other.lng - this.lng) * d2r, 814 lat1 = this.lat * d2r, 815 lat2 = other.lat * d2r, 816 sin1 = Math.sin(dLat / 2), 817 sin2 = Math.sin(dLon / 2); 818 var a = sin1 * sin1 + sin2 * sin2 * Math.cos(lat1) * Math.cos(lat2); 819 return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)) 820 }, 821 wrap: function(a, b) { 822 var lng = this.lng; 823 a = a || -180; 824 b = b || 180; 825 lng = (lng + b) % (b - a) + (lng < a || lng === b ? b : a); 826 return new L.LatLng(this.lat, lng) 827 } 828 }; 829 L.latLng = function(a, b) { 830 if (a instanceof L.LatLng) { 831 return a 832 } 833 if (L.Util.isArray(a)) { 834 if (typeof a[0] === 'number' || typeof a[0] === 'string') { 835 return new L.LatLng(a[0], a[1], a[2]) 836 } else { 837 return null 838 } 839 } 840 if (a === undefined || a === null) { 841 return a 842 } 843 if (typeof a === 'object' && 'lat' in a) { 844 return new L.LatLng(a.lat, 'lng' in a ? a.lng : a.lon) 845 } 846 if (b === undefined) { 847 return null 848 } 849 return new L.LatLng(a, b) 850 }; 851 L.LatLngBounds = function(southWest, northEast) { 852 if (!southWest) { 853 return 854 } 855 var latlngs = northEast ? [southWest, northEast] : southWest; 856 for (var i = 0, len = latlngs.length; i < len; i++) { 857 this.extend(latlngs[i]) 858 } 859 }; 860 L.LatLngBounds.prototype = { 861 extend: function(obj) { 862 if (!obj) { 863 return this 864 } 865 var latLng = L.latLng(obj); 866 if (latLng !== null) { 867 obj = latLng 868 } else { 869 obj = L.latLngBounds(obj) 870 } 871 if (obj instanceof L.LatLng) { 872 if (!this._southWest && !this._northEast) { 873 this._southWest = new L.LatLng(obj.lat, obj.lng); 874 this._northEast = new L.LatLng(obj.lat, obj.lng) 875 } else { 876 this._southWest.lat = Math.min(obj.lat, this._southWest.lat); 877 this._southWest.lng = Math.min(obj.lng, this._southWest.lng); 878 this._northEast.lat = Math.max(obj.lat, this._northEast.lat); 879 this._northEast.lng = Math.max(obj.lng, this._northEast.lng) 880 } 881 } else if (obj instanceof L.LatLngBounds) { 882 this.extend(obj._southWest); 883 this.extend(obj._northEast) 884 } 885 return this 886 }, 887 pad: function(bufferRatio) { 888 var sw = this._southWest, 889 ne = this._northEast, 890 heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio, 891 widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
892 return new L.LatLngBounds(new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer), new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer)) 893 }, 894 getCenter: function() { 895 return new L.LatLng((this._southWest.lat + this._northEast.lat) / 2, (this._southWest.lng + this._northEast.lng) / 2) 896 }, 897 getSouthWest: function() { 898 return this._southWest 899 }, 900 getNorthEast: function() { 901 return this._northEast 902 }, 903 getNorthWest: function() { 904 return new L.LatLng(this.getNorth(), this.getWest()) 905 }, 906 getSouthEast: function() { 907 return new L.LatLng(this.getSouth(), this.getEast()) 908 }, 909 getWest: function() { 910 return this._southWest.lng 911 }, 912 getSouth: function() { 913 return this._southWest.lat 914 }, 915 getEast: function() { 916 return this._northEast.lng 917 }, 918 getNorth: function() { 919 return this._northEast.lat 920 }, 921 contains: function(obj) { 922 if (typeof obj[0] === 'number' || obj instanceof L.LatLng) { 923 obj = L.latLng(obj) 924 } else { 925 obj = L.latLngBounds(obj) 926 } 927 var sw = this._southWest, 928 ne = this._northEast, 929 sw2, ne2; 930 if (obj instanceof L.LatLngBounds) {
931 sw2 = obj.getSouthWest(); 932 ne2 = obj.getNorthEast() 933 } else { 934 sw2 = ne2 = obj 935 } 936 return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) && (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng) 937 }, 938 intersects: function(bounds) { 939 bounds = L.latLngBounds(bounds); 940 var sw = this._southWest, 941 ne = this._northEast, 942 sw2 = bounds.getSouthWest(), 943 ne2 = bounds.getNorthEast(), 944 latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat), 945 lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng); 946 return latIntersects && lngIntersects 947 }, 948 toBBoxString: function() { 949 return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',') 950 }, 951 equals: function(bounds) { 952 if (!bounds) { 953 return false 954 } 955 bounds = L.latLngBounds(bounds); 956 return this._southWest.equals(bounds.getSouthWest()) && this._northEast.equals(bounds.getNorthEast()) 957 }, 958 isValid: function() { 959 return !!(this._southWest && this._northEast) 960 } 961 }; 962 L.latLngBounds = function(a, b) { 963 if (!a || a instanceof L.LatLngBounds) { 964 return a 965 } 966 return new L.LatLngBounds(a, b) 967 }; 968 L.Projection = {}; 969 L.Projection.SphericalMercator = { 970 MAX_LATITUDE: 85.0511287798, 971 project: function(latlng) { 972 var d = L.LatLng.DEG_TO_RAD, 973 max = this.MAX_LATITUDE, 974 lat = Math.max(Math.min(max, latlng.lat), -max), 975 x = latlng.lng * d, 976 y = lat * d; 977 y = Math.log(Math.tan((Math.PI / 4) + (y / 2))); 978 return new L.Point(x, y) 979 }, 980 unproject: function(point) { 981 var d = L.LatLng.RAD_TO_DEG, 982 lng = point.x * d, 983 lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d; 984 return new L.LatLng(lat, lng) 985 } 986 }; 987 L.Projection.LonLat = { 988 project: function(latlng) { 989 return new L.Point(latlng.lng, latlng.lat) 990 }, 991 unproject: function(point) { 992 return new L.LatLng(point.y, point.x) 993 } 994 }; 995 L.CRS = { 996 latLngToPoint: function(latlng, zoom) { 997 var projectedPoint = this.projection.project(latlng), 998 scale = this.scale(zoom); 999 return this.transformation._transform(projectedPoint, scale) 1000 }, 1001 pointToLatLng: function(point, zoom) { 1002 var scale = this.scale(zoom), 1003 untransformedPoint = this.transformation.untransform(point, scale); 1004 return this.projection.unproject(untransformedPoint) 1005 }, 1006 project: function(latlng) { 1007 return this.projection.project(latlng) 1008 }, 1009 scale: function(zoom) { 1010 return 256 * Math.pow(2, zoom) 1011 }, 1012 getSize: function(zoom) { 1013 var s = this.scale(zoom); 1014 return L.point(s, s) 1015 } 1016 }; 1017 L.CRS.Simple = L.extend({}, L.CRS, { 1018 projection: L.Projection.LonLat, 1019 transformation: new L.Transformation(1, 0, -1, 0), 1020 scale: function(zoom) { 1021 return Math.pow(2, zoom) 1022 } 1023 }); 1024 L.CRS.EPSG3857 = L.extend({}, L.CRS, { 1025 code: 'EPSG:3857', 1026 projection: L.Projection.SphericalMercator, 1027 transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5), 1028 project: function(latlng) { 1029 var projectedPoint = this.projection.project(latlng), 1030 earthRadius = 6378137; 1031 return projectedPoint.multiplyBy(earthRadius) 1032 } 1033 }); 1034 L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, { 1035 code: 'EPSG:900913' 1036 }); 1037 L.CRS.EPSG4326 = L.extend({}, L.CRS, { 1038 code: 'EPSG:4326', 1039 projection: L.Projection.LonLat, 1040 transformation: new L.Transformation(1 / 360, 0.5, -1 / 360, 0.5) 1041 }); 1042 L.Map = L.Class.extend({ 1043 includes: L.Mixin.Events, 1044 options: { 1045 crs: L.CRS.EPSG3857, 1046 fadeAnimation: L.DomUtil.TRANSITION && !L.Browser.android23, 1047 trackResize: true, 1048 markerZoomAnimation: L.DomUtil.TRANSITION && L.Browser.any3d 1049 }, 1050 initialize: function(id, options) { 1051 options = L.setOptions(this, options); 1052 this._initContainer(id); 1053 this._initLayout(); 1054 this._onResize = L.bind(this._onResize, this); 1055 this._initEvents(); 1056 if (options.maxBounds) { 1057 this.setMaxBounds(options.maxBounds) 1058 } 1059 if (options.center && options.zoom !== undefined) { 1060 this.setView(L.latLng(options.center), options.zoom, { 1061 reset: true 1062 }) 1063 } 1064 this._handlers = []; 1065 this._layers = {}; 1066 this._zoomBoundLayers = {}; 1067 this._tileLayersNum = 0; 1068 this.callInitHooks(); 1069 this._addLayers(options.layers) 1070 },
1071 setView: function(center, zoom) { 1072 zoom = zoom === undefined ? this.getZoom() : zoom; 1073 this._resetView(L.latLng(center), this._limitZoom(zoom)); 1074 return this 1075 }, 1076 setZoom: function(zoom, options) { 1077 if (!this._loaded) { 1078 this._zoom = this._limitZoom(zoom); 1079 return this 1080 } 1081 return this.setView(this.getCenter(), zoom, { 1082 zoom: options 1083 }) 1084 }, 1085 zoomIn: function(delta, options) { 1086 return this.setZoom(this._zoom + (delta || 1), options) 1087 }, 1088 zoomOut: function(delta, options) { 1089 return this.setZoom(this._zoom - (delta || 1), options) 1090 }, 1091 setZoomAround: function(latlng, zoom, options) { 1092 var scale = this.getZoomScale(zoom), 1093 viewHalf = this.getSize().divideBy(2), 1094 containerPoint = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng), 1095 centerOffset = containerPoint.subtract(viewHalf).multiplyBy(1 - 1 / scale), 1096 newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset)); 1097 return this.setView(newCenter, zoom, { 1098 zoom: options 1099 }) 1100 }, 1101 fitBounds: function(bounds, options) { 1102 options = options || {}; 1103 bounds = bounds.getBounds ? bounds.getBounds() : L.latLngBounds(bounds); 1104 var paddingTL = L.point(options.paddingTopLeft || options.padding || [0, 0]), 1105 paddingBR = L.point(options.paddingBottomRight || options.padding || [0, 0]), 1106 zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR)), 1107 paddingOffset = paddingBR.subtract(paddingTL).divideBy(2),
1108 swPoint = this.project(bounds.getSouthWest(), zoom), 1109 nePoint = this.project(bounds.getNorthEast(), zoom), 1110 center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom); 1111 zoom = options && options.maxZoom ? Math.min(options.maxZoom, zoom) : zoom; 1112 return this.setView(center, zoom, options) 1113 }, 1114 fitWorld: function(options) { 1115 return this.fitBounds([ 1116 [-90, -180], 1117 [90, 180] 1118 ], options) 1119 }, 1120 panTo: function(center, options) { 1121 return this.setView(center, this._zoom, { 1122 pan: options 1123 }) 1124 }, 1125 panBy: function(offset) { 1126 this.fire('movestart'); 1127 this._rawPanBy(L.point(offset)); 1128 this.fire('move'); 1129 return this.fire('moveend') 1130 }, 1131 setMaxBounds: function(bounds) { 1132 bounds = L.latLngBounds(bounds); 1133 this.options.maxBounds = bounds; 1134 if (!bounds) { 1135 return this.off('moveend', this._panInsideMaxBounds, this) 1136 } 1137 if (this._loaded) { 1138 this._panInsideMaxBounds() 1139 } 1140 return this.on('moveend', this._panInsideMaxBounds, this) 1141 }, 1142 panInsideBounds: function(bounds, options) { 1143 var center = this.getCenter(), 1144 newCenter = this._limitCenter(center, this._zoom, bounds); 1145 if (center.equals(newCenter)) { 1146 return this 1147 } 1148 return this.panTo(newCenter, options) 1149 }, 1150 addLayer: function(layer) { 1151 var id = L.stamp(layer); 1152 if (this._layers[id]) { 1153 return this 1154 } 1155 this._layers[id] = layer; 1156 if (layer.options && (!isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom))) { 1157 this._zoomBoundLayers[id] = layer; 1158 this._updateZoomLevels() 1159 } 1160 if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) { 1161 this._tileLayersNum++; 1162 this._tileLayersToLoad++; 1163 layer.on('load', this._onTileLayerLoad, this) 1164 } 1165 if (this._loaded) { 1166 this._layerAdd(layer) 1167 } 1168 return this 1169 }, 1170 removeLayer: function(layer) { 1171 var id = L.stamp(layer); 1172 if (!this._layers[id]) { 1173 return this 1174 } 1175 if (this._loaded) { 1176 layer.onRemove(this) 1177 } 1178 delete this._layers[id]; 1179 if (this._loaded) { 1180 this.fire('layerremove', { 1181 layer: layer 1182 }) 1183 } 1184 if (this._zoomBoundLayers[id]) { 1185 delete this._zoomBoundLayers[id]; 1186 this._updateZoomLevels() 1187 } 1188 if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) { 1189 this._tileLayersNum--; 1190 this._tileLayersToLoad--; 1191 layer.off('load', this._onTileLayerLoad, this) 1192 } 1193 return this 1194 }, 1195 hasLayer: function(layer) { 1196 if (!layer) { 1197 return false 1198 } 1199 return (L.stamp(layer) in this._layers) 1200 }, 1201 eachLayer: function(method, context) { 1202 for (var i in this._layers) { 1203 method.call(context, this._layers[i]) 1204 } 1205 return this 1206 }, 1207 invalidateSize: function(options) { 1208 if (!this._loaded) { 1209 return this 1210 } 1211 options = L.extend({ 1212 animate: false, 1213 pan: true 1214 }, options === true ? { 1215 animate: true 1216 } : options); 1217 var oldSize = this.getSize(); 1218 this._sizeChanged = true; 1219 this._initialCenter = null; 1220 var newSize = this.getSize(), 1221 oldCenter = oldSize.divideBy(2).round(), 1222 newCenter = newSize.divideBy(2).round(), 1223 offset = oldCenter.subtract(newCenter); 1224 if (!offset.x && !offset.y) { 1225 return this 1226 } 1227 if (options.animate && options.pan) { 1228 this.panBy(offset) 1229 } else { 1230 if (options.pan) { 1231 this._rawPanBy(offset) 1232 } 1233 this.fire('move'); 1234 if (options.debounceMoveend) { 1235 clearTimeout(this._sizeTimer); 1236 this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200) 1237 } else { 1238 this.fire('moveend') 1239 } 1240 } 1241 return this.fire('resize', { 1242 oldSize: oldSize, 1243 newSize: newSize 1244 }) 1245 }, 1246 addHandler: function(name, HandlerClass) { 1247 if (!HandlerClass) { 1248 return this 1249 } 1250 var handler = this[name] = new HandlerClass(this); 1251 this._handlers.push(handler); 1252 if (this.options[name]) { 1253 handler.enable() 1254 } 1255 return this 1256 }, 1257 remove: function() { 1258 if (this._loaded) { 1259 this.fire('unload') 1260 } 1261 this._initEvents('off');
1262 try { 1263 delete this._container._leaflet 1264 } catch (e) { 1265 this._container._leaflet = undefined 1266 } 1267 this._clearPanes(); 1268 if (this._clearControlPos) { 1269 this._clearControlPos() 1270 } 1271 this._clearHandlers(); 1272 return this 1273 }, 1274 getCenter: function() { 1275 this._checkIfLoaded(); 1276 if (this._initialCenter && !this._moved()) { 1277 return this._initialCenter 1278 } 1279 return this.layerPointToLatLng(this._getCenterLayerPoint()) 1280 }, 1281 getZoom: function() { 1282 return this._zoom 1283 }, 1284 getBounds: function() { 1285 var bounds = this.getPixelBounds(), 1286 sw = this.unproject(bounds.getBottomLeft()), 1287 ne = this.unproject(bounds.getTopRight()); 1288 return new L.LatLngBounds(sw, ne) 1289 }, 1290 getMinZoom: function() { 1291 return this.options.minZoom === undefined ? (this._layersMinZoom === undefined ? 0 : this._layersMinZoom) : this.options.minZoom 1292 }, 1293 getMaxZoom: function() { 1294 return this.options.maxZoom === undefined ? (this._layersMaxZoom === undefined ? Infinity : this._layersMaxZoom) : this.options.maxZoom 1295 }, 1296 getBoundsZoom: function(bounds, inside, padding) { 1297 bounds = L.latLngBounds(bounds); 1298 var zoom = this.getMinZoom() - (inside ? 1 : 0), 1299 maxZoom = this.getMaxZoom(), 1300 size = this.getSize(), 1301 nw = bounds.getNorthWest(), 1302 se = bounds.getSouthEast(), 1303 zoomNotFound = true, 1304 boundsSize; 1305 padding = L.point(padding || [0, 0]); 1306 do { 1307 zoom++; 1308 boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)).add(padding); 1309 zoomNotFound = !inside ? size.contains(boundsSize) : boundsSize.x < size.x || boundsSize.y < size.y 1310 } while (zoomNotFound && zoom <= maxZoom); 1311 if (zoomNotFound && inside) { 1312 return null 1313 } 1314 return inside ? zoom : zoom - 1 1315 }, 1316 getSize: function() { 1317 if (!this._size || this._sizeChanged) { 1318 this._size = new L.Point(this._container.clientWidth, this._container.clientHeight); 1319 this._sizeChanged = false 1320 } 1321 return this._size.clone() 1322 }, 1323 getPixelBounds: function() { 1324 var topLeftPoint = this._getTopLeftPoint(); 1325 return new L.Bounds(topLeftPoint, topLeftPoint.add(this.getSize())) 1326 }, 1327 getPixelOrigin: function() { 1328 this._checkIfLoaded(); 1329 return this._initialTopLeftPoint 1330 }, 1331 getPanes: function() { 1332 return this._panes 1333 }, 1334 getContainer: function() { 1335 return this._container 1336 }, 1337 getZoomScale: function(toZoom) { 1338 var crs = this.options.crs; 1339 return crs.scale(toZoom) / crs.scale(this._zoom) 1340 }, 1341 getScaleZoom: function(scale) { 1342 return this._zoom + (Math.log(scale) / Math.LN2) 1343 }, 1344 project: function(latlng, zoom) { 1345 zoom = zoom === undefined ? this._zoom : zoom; 1346 return this.options.crs.latLngToPoint(L.latLng(latlng), zoom) 1347 }, 1348 unproject: function(point, zoom) { 1349 zoom = zoom === undefined ? this._zoom : zoom; 1350 return this.options.crs.pointToLatLng(L.point(point), zoom) 1351 }, 1352 layerPointToLatLng: function(point) { 1353 var projectedPoint = L.point(point).add(this.getPixelOrigin()); 1354 return this.unproject(projectedPoint) 1355 }, 1356 latLngToLayerPoint: function(latlng) { 1357 var projectedPoint = this.project(L.latLng(latlng))._round(); 1358 return projectedPoint._subtract(this.getPixelOrigin()) 1359 }, 1360 containerPointToLayerPoint: function(point) { 1361 return L.point(point).subtract(this._getMapPanePos()) 1362 }, 1363 layerPointToContainerPoint: function(point) { 1364 return L.point(point).add(this._getMapPanePos()) 1365 }, 1366 containerPointToLatLng: function(point) { 1367 var layerPoint = this.containerPointToLayerPoint(L.point(point)); 1368 return this.layerPointToLatLng(layerPoint) 1369 }, 1370 latLngToContainerPoint: function(latlng) { 1371 return this.layerPointToContainerPoint(this.latLngToLayerPoint(L.latLng(latlng))) 1372 }, 1373 mouseEventToContainerPoint: function(e) { 1374 return L.DomEvent.getMousePosition(e, this._container) 1375 }, 1376 mouseEventToLayerPoint: function(e) { 1377 return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e)) 1378 }, 1379 mouseEventToLatLng: function(e) { 1380 return this.layerPointToLatLng(this.mouseEventToLayerPoint(e)) 1381 }, 1382 _initContainer: function(id) { 1383 var container = this._container = L.DomUtil.get(id); 1384 if (!container) { 1385 throw new Error('Map container not found.') 1386 } else if (container._leaflet) { 1387 throw new Error('Map container is already initialized.') 1388 } 1389 container._leaflet = true 1390 }, 1391 _initLayout: function() { 1392 var container = this._container; 1393 L.DomUtil.addClass(container, 'leaflet-container' + (L.Browser.touch ? ' leaflet-touch' : '') + (L.Browser.retina ? ' leaflet-retina' : '') + (L.Browser.ielt9 ? ' leaflet-oldie' : '') + (this.options.fadeAnimation ? ' leaflet-fade-anim' : '')); 1394 var position = L.DomUtil.getStyle(container, 'position'); 1395 if (position !== 'absolute' && position !== 'relative' && position !== 'fixed') { 1396 container.style.position = 'relative' 1397 } 1398 this._initPanes(); 1399 if (this._initControlPos) { 1400 this._initControlPos() 1401 } 1402 }, 1403 _initPanes: function() { 1404 var panes = this._panes = {}; 1405 this._mapPane = panes.mapPane = this._createPane('leaflet-map-pane', this._container); 1406 this._tilePane = panes.tilePane = this._createPane('leaflet-tile-pane', this._mapPane); 1407 panes.objectsPane = this._createPane('leaflet-objects-pane', this._mapPane);
1408 panes.shadowPane = this._createPane('leaflet-shadow-pane'); 1409 panes.overlayPane = this._createPane('leaflet-overlay-pane'); 1410 panes.markerPane = this._createPane('leaflet-marker-pane'); 1411 panes.popupPane = this._createPane('leaflet-popup-pane'); 1412 var zoomHide = ' leaflet-zoom-hide'; 1413 if (!this.options.markerZoomAnimation) { 1414 L.DomUtil.addClass(panes.markerPane, zoomHide); 1415 L.DomUtil.addClass(panes.shadowPane, zoomHide); 1416 L.DomUtil.addClass(panes.popupPane, zoomHide) 1417 } 1418 }, 1419 _createPane: function(className, container) { 1420 return L.DomUtil.create('div', className, container || this._panes.objectsPane) 1421 }, 1422 _clearPanes: function() { 1423 this._container.removeChild(this._mapPane) 1424 }, 1425 _addLayers: function(layers) { 1426 layers = layers ? (L.Util.isArray(layers) ? layers : [layers]) : []; 1427 for (var i = 0, len = layers.length; i < len; i++) { 1428 this.addLayer(layers[i]) 1429 } 1430 }, 1431 _resetView: function(center, zoom, preserveMapOffset, afterZoomAnim) { 1432 var zoomChanged = (this._zoom !== zoom); 1433 if (!afterZoomAnim) { 1434 this.fire('movestart'); 1435 if (zoomChanged) { 1436 this.fire('zoomstart') 1437 } 1438 } 1439 this._zoom = zoom; 1440 this._initialCenter = center; 1441 this._initialTopLeftPoint = this._getNewTopLeftPoint(center); 1442 if (!preserveMapOffset) { 1443 L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0)) 1444 } else { 1445 this._initialTopLeftPoint._add(this._getMapPanePos()) 1446 } 1447 this._tileLayersToLoad = this._tileLayersNum; 1448 var loading = !this._loaded; 1449 this._loaded = true; 1450 this.fire('viewreset', { 1451 hard: !preserveMapOffset 1452 }); 1453 if (loading) { 1454 this.fire('load'); 1455 this.eachLayer(this._layerAdd, this) 1456 } 1457 this.fire('move'); 1458 if (zoomChanged || afterZoomAnim) { 1459 this.fire('zoomend') 1460 } 1461 this.fire('moveend', { 1462 hard: !preserveMapOffset 1463 }) 1464 }, 1465 _rawPanBy: function(offset) { 1466 L.DomUtil.setPosition(this._mapPane, this._getMapPanePos().subtract(offset)) 1467 }, 1468 _getZoomSpan: function() { 1469 return this.getMaxZoom() - this.getMinZoom() 1470 }, 1471 _updateZoomLevels: function() { 1472 var i, minZoom = Infinity, 1473 maxZoom = -Infinity, 1474 oldZoomSpan = this._getZoomSpan(); 1475 for (i in this._zoomBoundLayers) { 1476 var layer = this._zoomBoundLayers[i]; 1477 if (!isNaN(layer.options.minZoom)) { 1478 minZoom = Math.min(minZoom, layer.options.minZoom) 1479 } 1480 if (!isNaN(layer.options.maxZoom)) { 1481 maxZoom = Math.max(maxZoom, layer.options.maxZoom) 1482 } 1483 } 1484 if (i === undefined) { 1485 this._layersMaxZoom = this._layersMinZoom = undefined 1486 } else { 1487 this._layersMaxZoom = maxZoom; 1488 this._layersMinZoom = minZoom 1489 } 1490 if (oldZoomSpan !== this._getZoomSpan()) { 1491 this.fire('zoomlevelschange') 1492 } 1493 }, 1494 _panInsideMaxBounds: function() { 1495 this.panInsideBounds(this.options.maxBounds) 1496 }, 1497 _checkIfLoaded: function() { 1498 if (!this._loaded) { 1499 throw new Error('Set map center and zoom first.') 1500 } 1501 }, 1502 _initEvents: function(onOff) { 1503 if (!L.DomEvent) { 1504 return 1505 } 1506 onOff = onOff || 'on'; 1507 L.DomEvent[onOff](this._container, 'click', this._onMouseClick, this); 1508 var events = ['dblclick', 'mousedown', 'mouseup', 'mouseenter', 'mouseleave', 'mousemove', 'contextmenu'], 1509 i, len; 1510 for (i = 0, len = events.length; i < len; i++) { 1511 L.DomEvent[onOff](this._container, events[i], this._fireMouseEvent, this) 1512 } 1513 if (this.options.trackResize) { 1514 L.DomEvent[onOff](window, 'resize', this._onResize, this) 1515 } 1516 }, 1517 _onResize: function() { 1518 L.Util.cancelAnimFrame(this._resizeRequest); 1519 this._resizeRequest = L.Util.requestAnimFrame(function() { 1520 this.invalidateSize({ 1521 debounceMoveend: true 1522 }) 1523 }, this, false, this._container) 1524 }, 1525 _onMouseClick: function(e) { 1526 if (!this._loaded || (!e._simulated && ((this.dragging && this.dragging.moved()) || (this.boxZoom && this.boxZoom.moved()))) || L.DomEvent._skipped(e)) { 1527 return 1528 } 1529 this.fire('preclick'); 1530 this._fireMouseEvent(e) 1531 }, 1532 _fireMouseEvent: function(e) { 1533 if (!this._loaded || L.DomEvent._skipped(e)) { 1534 return 1535 } 1536 var type = e.type; 1537 type = (type === 'mouseenter' ? 'mouseover' : (type === 'mouseleave' ? 'mouseout' : type)); 1538 if (!this.hasEventListeners(type)) { 1539 return 1540 } 1541 if (type === 'contextmenu') { 1542 L.DomEvent.preventDefault(e) 1543 } 1544 var containerPoint = this.mouseEventToContainerPoint(e), 1545 layerPoint = this.containerPointToLayerPoint(containerPoint), 1546 latlng = this.layerPointToLatLng(layerPoint); 1547 this.fire(type, { 1548 latlng: latlng, 1549 layerPoint: layerPoint, 1550 containerPoint: containerPoint, 1551 originalEvent: e 1552 }) 1553 }, 1554 _onTileLayerLoad: function() { 1555 this._tileLayersToLoad--; 1556 if (this._tileLayersNum && !this._tileLayersToLoad) { 1557 this.fire('tilelayersload') 1558 } 1559 }, 1560 _clearHandlers: function() { 1561 for (var i = 0, len = this._handlers.length; i < len; i++) { 1562 this._handlers[i].disable() 1563 } 1564 }, 1565 whenReady: function(callback, context) { 1566 if (this._loaded) { 1567 callback.call(context || this, this) 1568 } else { 1569 this.on('load', callback, context) 1570 } 1571 return this 1572 }, 1573 _layerAdd: function(layer) { 1574 layer.onAdd(this); 1575 this.fire('layeradd', { 1576 layer: layer 1577 }) 1578 }, 1579 _getMapPanePos: function() { 1580 return L.DomUtil.getPosition(this._mapPane) 1581 }, 1582 _moved: function() { 1583 var pos = this._getMapPanePos(); 1584 return pos && !pos.equals([0, 0]) 1585 }, 1586 _getTopLeftPoint: function() { 1587 return this.getPixelOrigin().subtract(this._getMapPanePos()) 1588 }, 1589 _getNewTopLeftPoint: function(center, zoom) {
1590 var viewHalf = this.getSize()._divideBy(2); 1591 return this.project(center, zoom)._subtract(viewHalf)._round() 1592 }, 1593 _latLngToNewLayerPoint: function(latlng, newZoom, newCenter) { 1594 var topLeft = this._getNewTopLeftPoint(newCenter, newZoom).add(this._getMapPanePos()); 1595 return this.project(latlng, newZoom)._subtract(topLeft) 1596 }, 1597 _getCenterLayerPoint: function() { 1598 return this.containerPointToLayerPoint(this.getSize()._divideBy(2)) 1599 }, 1600 _getCenterOffset: function(latlng) { 1601 return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint()) 1602 }, 1603 _limitCenter: function(center, zoom, bounds) { 1604 if (!bounds) { 1605 return center 1606 } 1607 var centerPoint = this.project(center, zoom), 1608 viewHalf = this.getSize().divideBy(2), 1609 viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)), 1610 offset = this._getBoundsOffset(viewBounds, bounds, zoom); 1611 return this.unproject(centerPoint.add(offset), zoom) 1612 }, 1613 _limitOffset: function(offset, bounds) { 1614 if (!bounds) { 1615 return offset 1616 } 1617 var viewBounds = this.getPixelBounds(), 1618 newBounds = new L.Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset)); 1619 return offset.add(this._getBoundsOffset(newBounds, bounds)) 1620 }, 1621 _getBoundsOffset: function(pxBounds, maxBounds, zoom) { 1622 var nwOffset = this.project(maxBounds.getNorthWest(), zoom).subtract(pxBounds.min), 1623 seOffset = this.project(maxBounds.getSouthEast(), zoom).subtract(pxBounds.max), 1624 dx = this._rebound(nwOffset.x, -seOffset.x), 1625 dy = this._rebound(nwOffset.y, -seOffset.y); 1626 return new L.Point(dx, dy) 1627 }, 1628 _rebound: function(left, right) { 1629 return left + right > 0 ? Math.round(left - right) / 2 : Math.max(0, Math.ceil(left)) - Math.max(0, Math.floor(right)) 1630 }, 1631 _limitZoom: function(zoom) { 1632 var min = this.getMinZoom(), 1633 max = this.getMaxZoom(); 1634 return Math.max(min, Math.min(max, zoom)) 1635 } 1636 }); 1637 L.map = function(id, options) { 1638 return new L.Map(id, options) 1639 }; 1640 L.Projection.Mercator = { 1641 MAX_LATITUDE: 85.0840591556, 1642 R_MINOR: 6356752.314245179, 1643 R_MAJOR: 6378137, 1644 project: function(latlng) { 1645 var d = L.LatLng.DEG_TO_RAD, 1646 max = this.MAX_LATITUDE, 1647 lat = Math.max(Math.min(max, latlng.lat), -max), 1648 r = this.R_MAJOR, 1649 r2 = this.R_MINOR, 1650 x = latlng.lng * d * r, 1651 y = lat * d, 1652 tmp = r2 / r, 1653 eccent = Math.sqrt(1.0 - tmp * tmp), 1654 con = eccent * Math.sin(y); 1655 con = Math.pow((1 - con) / (1 + con), eccent * 0.5); 1656 var ts = Math.tan(0.5 * ((Math.PI * 0.5) - y)) / con; 1657 y = -r * Math.log(ts); 1658 return new L.Point(x, y) 1659 }, 1660 unproject: function(point) { 1661 var d = L.LatLng.RAD_TO_DEG, 1662 r = this.R_MAJOR, 1663 r2 = this.R_MINOR, 1664 lng = point.x * d / r, 1665 tmp = r2 / r, 1666 eccent = Math.sqrt(1 - (tmp * tmp)), 1667 ts = Math.exp(-point.y / r), 1668 phi = (Math.PI / 2) - 2 * Math.atan(ts), 1669 numIter = 15, 1670 tol = 1e-7, 1671 i = numIter, 1672 dphi = 0.1, 1673 con; 1674 while ((Math.abs(dphi) > tol) && (--i > 0)) { 1675 con = eccent * Math.sin(phi); 1676 dphi = (Math.PI / 2) - 2 * Math.atan(ts * Math.pow((1.0 - con) / (1.0 + con), 0.5 * eccent)) - phi; 1677 phi += dphi 1678 } 1679 return new L.LatLng(phi * d, lng) 1680 } 1681 }; 1682 L.CRS.EPSG3395 = L.extend({}, L.CRS, { 1683 code: 'EPSG:3395', 1684 projection: L.Projection.Mercator, 1685 transformation: (function() { 1686 var m = L.Projection.Mercator, 1687 r = m.R_MAJOR, 1688 scale = 0.5 / (Math.PI * r); 1689 return new L.Transformation(scale, 0.5, -scale, 0.5) 1690 }()) 1691 }); 1692 L.TileLayer = L.Class.extend({ 1693 includes: L.Mixin.Events, 1694 options: { 1695 minZoom: 0, 1696 maxZoom: 18, 1697 tileSize: 256, 1698 subdomains: 'abc', 1699 errorTileUrl: '', 1700 attribution: '', 1701 zoomOffset: 0, 1702 opacity: 1, 1703 unloadInvisibleTiles: L.Browser.mobile, 1704 updateWhenIdle: L.Browser.mobile 1705 }, 1706 initialize: function(url, options) { 1707 options = L.setOptions(this, options); 1708 if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) { 1709 options.tileSize = Math.floor(options.tileSize / 2); 1710 options.zoomOffset++; 1711 if (options.minZoom > 0) { 1712 options.minZoom-- 1713 } 1714 this.options.maxZoom-- 1715 } 1716 if (options.bounds) { 1717 options.bounds = L.latLngBounds(options.bounds) 1718 } 1719 this._url = url; 1720 var subdomains = this.options.subdomains; 1721 if (typeof subdomains === 'string') { 1722 this.options.subdomains = subdomains.split('') 1723 } 1724 }, 1725 onAdd: function(map) { 1726 this._map = map; 1727 this._animated = map._zoomAnimated; 1728 this._initContainer(); 1729 map.on({ 1730 'viewreset': this._reset, 1731 'moveend': this._update 1732 }, this); 1733 if (this._animated) { 1734 map.on({ 1735 'zoomanim': this._animateZoom, 1736 'zoomend': this._endZoomAnim 1737 }, this) 1738 } 1739 if (!this.options.updateWhenIdle) { 1740 this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this); 1741 map.on('move', this._limitedUpdate, this) 1742 } 1743 this._reset(); 1744 this._update() 1745 }, 1746 addTo: function(map) { 1747 map.addLayer(this); 1748 return this 1749 }, 1750 onRemove: function(map) { 1751 this._container.parentNode.removeChild(this._container); 1752 map.off({ 1753 'viewreset': this._reset, 1754 'moveend': this._update 1755 }, this); 1756 if (this._animated) { 1757 map.off({ 1758 'zoomanim': this._animateZoom, 1759 'zoomend': this._endZoomAnim 1760 }, this) 1761 } 1762 if (!this.options.updateWhenIdle) { 1763 map.off('move', this._limitedUpdate, this) 1764 } 1765 this._container = null; 1766 this._map = null 1767 }, 1768 bringToFront: function() { 1769 var pane = this._map._panes.tilePane; 1770 if (this._container) { 1771 pane.appendChild(this._container); 1772 this._setAutoZIndex(pane, Math.max) 1773 } 1774 return this 1775 }, 1776 bringToBack: function() { 1777 var pane = this._map._panes.tilePane; 1778 if (this._container) { 1779 pane.insertBefore(this._container, pane.firstChild); 1780 this._setAutoZIndex(pane, Math.min) 1781 } 1782 return this 1783 }, 1784 getAttribution: function() { 1785 return this.options.attribution 1786 }, 1787 getContainer: function() { 1788 return this._container 1789 }, 1790 setOpacity: function(opacity) { 1791 this.options.opacity = opacity; 1792 if (this._map) { 1793 this._updateOpacity() 1794 } 1795 return this 1796 }, 1797 setZIndex: function(zIndex) { 1798 this.options.zIndex = zIndex; 1799 this._updateZIndex(); 1800 return this 1801 }, 1802 setUrl: function(url, noRedraw) { 1803 this._url = url; 1804 if (!noRedraw) { 1805 this.redraw() 1806 } 1807 return this 1808 }, 1809 redraw: function() { 1810 if (this._map) { 1811 this._reset({ 1812 hard: true 1813 }); 1814 this._update() 1815 } 1816 return this 1817 }, 1818 _updateZIndex: function() { 1819 if (this._container && this.options.zIndex !== undefined) { 1820 this._container.style.zIndex = this.options.zIndex 1821 } 1822 }, 1823 _setAutoZIndex: function(pane, compare) { 1824 var layers = pane.children, 1825 edgeZIndex = -compare(Infinity, -Infinity), 1826 zIndex, i, len; 1827 for (i = 0, len = layers.length; i < len; i++) { 1828 if (layers[i] !== this._container) { 1829 zIndex = parseInt(layers[i].style.zIndex, 10); 1830 if (!isNaN(zIndex)) { 1831 edgeZIndex = compare(edgeZIndex, zIndex) 1832 } 1833 } 1834 } 1835 this.options.zIndex = this._container.style.zIndex = (isFinite(edgeZIndex) ? edgeZIndex : 0) + compare(1, -1) 1836 }, 1837 _updateOpacity: function() { 1838 var i, tiles = this._tiles; 1839 if (L.Browser.ielt9) { 1840 for (i in tiles) { 1841 L.DomUtil.setOpacity(tiles[i], this.options.opacity) 1842 } 1843 } else { 1844 L.DomUtil.setOpacity(this._container, this.options.opacity) 1845 } 1846 }, 1847 _initContainer: function() { 1848 var tilePane = this._map._panes.tilePane; 1849 if (!this._container) { 1850 this._container = L.DomUtil.create('div', 'leaflet-layer'); 1851 this._updateZIndex(); 1852 if (this._animated) { 1853 var className = 'leaflet-tile-container'; 1854 this._bgBuffer = L.DomUtil.create('div', className, this._container); 1855 this._tileContainer = L.DomUtil.create('div', className, this._container) 1856 } else { 1857 this._tileContainer = this._container 1858 } 1859 tilePane.appendChild(this._container); 1860 if (this.options.opacity < 1) { 1861 this._updateOpacity() 1862 } 1863 } 1864 }, 1865 _reset: function(e) { 1866 for (var key in this._tiles) { 1867 this.fire('tileunload', { 1868 tile: this._tiles[key] 1869 }) 1870 } 1871 this._tiles = {}; 1872 this._tilesToLoad = 0; 1873 if (this.options.reuseTiles) { 1874 this._unusedTiles = [] 1875 } 1876 this._tileContainer.innerHTML = ''; 1877 if (this._animated && e && e.hard) { 1878 this._clearBgBuffer() 1879 } 1880 this._initContainer() 1881 }, 1882 _getTileSize: function() { 1883 var map = this._map, 1884 zoom = map.getZoom() + this.options.zoomOffset, 1885 zoomN = this.options.maxNativeZoom, 1886 tileSize = this.options.tileSize; 1887 if (zoomN && zoom > zoomN) { 1888 tileSize = Math.round(map.getZoomScale(zoom) / map.getZoomScale(zoomN) * tileSize) 1889 } 1890 return tileSize 1891 }, 1892 _update: function() { 1893 if (!this._map) { 1894 return 1895 } 1896 var map = this._map, 1897 bounds = map.getPixelBounds(), 1898 zoom = map.getZoom(), 1899 tileSize = this._getTileSize(); 1900 if (zoom > this.options.maxZoom || zoom < this.options.minZoom) { 1901 return 1902 } 1903 var tileBounds = L.bounds(bounds.min.divideBy(tileSize)._floor(), bounds.max.divideBy(tileSize)._floor()); 1904 this._addTilesFromCenterOut(tileBounds); 1905 if (this.options.unloadInvisibleTiles || this.options.reuseTiles) { 1906 this._removeOtherTiles(tileBounds) 1907 } 1908 },
1909 _addTilesFromCenterOut: function(bounds) { 1910 var queue = [], 1911 center = bounds.getCenter(); 1912 var j, i, point; 1913 for (j = bounds.min.y; j <= bounds.max.y; j++) { 1914 for (i = bounds.min.x; i <= bounds.max.x; i++) { 1915 point = new L.Point(i, j); 1916 if (this._tileShouldBeLoaded(point)) { 1917 queue.push(point) 1918 } 1919 } 1920 } 1921 var tilesToLoad = queue.length; 1922 if (tilesToLoad === 0) { 1923 return 1924 } 1925 queue.sort(function(a, b) { 1926 return a.distanceTo(center) - b.distanceTo(center) 1927 }); 1928 var fragment = document.createDocumentFragment(); 1929 if (!this._tilesToLoad) { 1930 this.fire('loading') 1931 } 1932 this._tilesToLoad += tilesToLoad; 1933 for (i = 0; i < tilesToLoad; i++) { 1934 this._addTile(queue[i], fragment) 1935 } 1936 this._tileContainer.appendChild(fragment) 1937 }, 1938 _tileShouldBeLoaded: function(tilePoint) { 1939 if ((tilePoint.x + ':' + tilePoint.y) in this._tiles) { 1940 return false 1941 } 1942 var options = this.options; 1943 if (!options.continuousWorld) { 1944 var limit = this._getWrapTileNum(); 1945 if ((options.noWrap && (tilePoint.x < 0 || tilePoint.x >= limit.x)) || tilePoint.y < 0 || tilePoint.y >= limit.y) { 1946 return false 1947 } 1948 } 1949 if (options.bounds) { 1950 var tileSize = options.tileSize, 1951 nwPoint = tilePoint.multiplyBy(tileSize), 1952 sePoint = nwPoint.add([tileSize, tileSize]), 1953 nw = this._map.unproject(nwPoint), 1954 se = this._map.unproject(sePoint); 1955 if (!options.continuousWorld && !options.noWrap) { 1956 nw = nw.wrap(); 1957 se = se.wrap() 1958 } 1959 if (!options.bounds.intersects([nw, se])) { 1960 return false 1961 } 1962 } 1963 return true 1964 }, 1965 _removeOtherTiles: function(bounds) { 1966 var kArr, x, y, key; 1967 for (key in this._tiles) { 1968 kArr = key.split(':'); 1969 x = parseInt(kArr[0], 10); 1970 y = parseInt(kArr[1], 10); 1971 if (x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) { 1972 this._removeTile(key) 1973 } 1974 } 1975 }, 1976 _removeTile: function(key) { 1977 var tile = this._tiles[key]; 1978 this.fire('tileunload', { 1979 tile: tile, 1980 url: tile.src 1981 }); 1982 if (this.options.reuseTiles) { 1983 L.DomUtil.removeClass(tile, 'leaflet-tile-loaded'); 1984 this._unusedTiles.push(tile) 1985 } else if (tile.parentNode === this._tileContainer) { 1986 this._tileContainer.removeChild(tile) 1987 } 1988 if (!L.Browser.android) { 1989 tile.onload = null; 1990 tile.src = L.Util.emptyImageUrl 1991 } 1992 delete this._tiles[key] 1993 }, 1994 _addTile: function(tilePoint, container) { 1995 var tilePos = this._getTilePos(tilePoint); 1996 var tile = this._getTile(); 1997 L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome); 1998 this._tiles[tilePoint.x + ':' + tilePoint.y] = tile; 1999 this._loadTile(tile, tilePoint); 2000 if (tile.parentNode !== this._tileContainer) { 2001 container.appendChild(tile) 2002 } 2003 }, 2004 _getZoomForUrl: function() { 2005 var options = this.options, 2006 zoom = this._map.getZoom(); 2007 if (options.zoomReverse) { 2008 zoom = options.maxZoom - zoom 2009 } 2010 zoom += options.zoomOffset; 2011 return options.maxNativeZoom ? Math.min(zoom, options.maxNativeZoom) : zoom 2012 }, 2013 _getTilePos: function(tilePoint) { 2014 var origin = this._map.getPixelOrigin(), 2015 tileSize = this._getTileSize(); 2016 return tilePoint.multiplyBy(tileSize).subtract(origin) 2017 }, 2018 getTileUrl: function(tilePoint) { 2019 return L.Util.template(this._url, L.extend({ 2020 s: this._getSubdomain(tilePoint), 2021 z: tilePoint.z, 2022 x: tilePoint.x, 2023 y: tilePoint.y 2024 }, this.options)) 2025 }, 2026 _getWrapTileNum: function() { 2027 var crs = this._map.options.crs, 2028 size = crs.getSize(this._map.getZoom()); 2029 return size.divideBy(this._getTileSize())._floor() 2030 }, 2031 _adjustTilePoint: function(tilePoint) { 2032 var limit = this._getWrapTileNum(); 2033 if (!this.options.continuousWorld && !this.options.noWrap) { 2034 tilePoint.x = ((tilePoint.x % limit.x) + limit.x) % limit.x 2035 } 2036 if (this.options.tms) { 2037 tilePoint.y = limit.y - tilePoint.y - 1 2038 } 2039 tilePoint.z = this._getZoomForUrl() 2040 }, 2041 _getSubdomain: function(tilePoint) { 2042 var index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length; 2043 return this.options.subdomains[index] 2044 }, 2045 _getTile: function() { 2046 if (this.options.reuseTiles && this._unusedTiles.length > 0) { 2047 var tile = this._unusedTiles.pop(); 2048 this._resetTile(tile); 2049 return tile 2050 } 2051 return this._createTile() 2052 }, 2053 _resetTile: function() {}, 2054 _createTile: function() { 2055 var tile = L.DomUtil.create('img', 'leaflet-tile'); 2056 tile.style.width = tile.style.height = this._getTileSize() + 'px'; 2057 tile.galleryimg = 'no'; 2058 tile.onselectstart = tile.onmousemove = L.Util.falseFn; 2059 if (L.Browser.ielt9 && this.options.opacity !== undefined) { 2060 L.DomUtil.setOpacity(tile, this.options.opacity) 2061 } 2062 if (L.Browser.mobileWebkit3d) { 2063 tile.style.WebkitBackfaceVisibility = 'hidden' 2064 } 2065 return tile 2066 }, 2067 _loadTile: function(tile, tilePoint) { 2068 tile._layer = this; 2069 tile.onload = this._tileOnLoad; 2070 tile.onerror = this._tileOnError; 2071 this._adjustTilePoint(tilePoint); 2072 tile.src = this.getTileUrl(tilePoint); 2073 this.fire('tileloadstart', { 2074 tile: tile, 2075 url: tile.src 2076 }) 2077 }, 2078 _tileLoaded: function() { 2079 this._tilesToLoad--; 2080 if (this._animated) { 2081 L.DomUtil.addClass(this._tileContainer, 'leaflet-zoom-animated') 2082 } 2083 if (!this._tilesToLoad) { 2084 this.fire('load'); 2085 if (this._animated) { 2086 clearTimeout(this._clearBgBufferTimer); 2087 this._clearBgBufferTimer = setTimeout(L.bind(this._clearBgBuffer, this), 500) 2088 } 2089 } 2090 }, 2091 _tileOnLoad: function() { 2092 var layer = this._layer; 2093 if (this.src !== L.Util.emptyImageUrl) { 2094 L.DomUtil.addClass(this, 'leaflet-tile-loaded'); 2095 layer.fire('tileload', { 2096 tile: this, 2097 url: this.src 2098 }) 2099 } 2100 layer._tileLoaded() 2101 }, 2102 _tileOnError: function() { 2103 var layer = this._layer; 2104 layer.fire('tileerror', { 2105 tile: this, 2106 url: this.src 2107 }); 2108 var newUrl = layer.options.errorTileUrl; 2109 if (newUrl) { 2110 this.src = newUrl 2111 } 2112 layer._tileLoaded() 2113 } 2114 }); 2115 L.tileLayer = function(url, options) { 2116 return new L.TileLayer(url, options) 2117 }; 2118 L.TileLayer.WMS = L.TileLayer.extend({ 2119 defaultWmsParams: { 2120 service: 'WMS', 2121 request: 'GetMap', 2122 version: '1.1.1', 2123 layers: '', 2124 styles: '', 2125 format: 'image/jpeg', 2126 transparent: false 2127 }, 2128 initialize: function(url, options) { 2129 this._url = url; 2130 var wmsParams = L.extend({}, this.defaultWmsParams), 2131 tileSize = options.tileSize || this.options.tileSize; 2132 if (options.detectRetina && L.Browser.retina) { 2133 wmsParams.width = wmsParams.height = tileSize * 2 2134 } else { 2135 wmsParams.width = wmsParams.height = tileSize 2136 } 2137 for (var i in options) { 2138 if (!this.options.hasOwnProperty(i) && i !== 'crs') { 2139 wmsParams[i] = options[i] 2140 } 2141 } 2142 this.wmsParams = wmsParams; 2143 L.setOptions(this, options) 2144 }, 2145 onAdd: function(map) { 2146 this._crs = this.options.crs || map.options.crs; 2147 this._wmsVersion = parseFloat(this.wmsParams.version); 2148 var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs'; 2149 this.wmsParams[projectionKey] = this._crs.code; 2150 L.TileLayer.prototype.onAdd.call(this, map) 2151 }, 2152 getTileUrl: function(tilePoint) { 2153 var map = this._map, 2154 tileSize = this.options.tileSize, 2155 nwPoint = tilePoint.multiplyBy(tileSize), 2156 sePoint = nwPoint.add([tileSize, tileSize]), 2157 nw = this._crs.project(map.unproject(nwPoint, tilePoint.z)), 2158 se = this._crs.project(map.unproject(sePoint, tilePoint.z)), 2159 bbox = this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ? [se.y, nw.x, nw.y, se.x].join(',') : [nw.x, se.y, se.x, nw.y].join(','), 2160 url = L.Util.template(this._url, { 2161 s: this._getSubdomain(tilePoint) 2162 }); 2163 return url + L.Util.getParamString(this.wmsParams, url, true) + '&BBOX=' + bbox 2164 }, 2165 setParams: function(params, noRedraw) { 2166 L.extend(this.wmsParams, params); 2167 if (!noRedraw) { 2168 this.redraw() 2169 } 2170 return this 2171 } 2172 }); 2173 L.tileLayer.wms = function(url, options) { 2174 return new L.TileLayer.WMS(url, options) 2175 }; 2176 L.TileLayer.WMTS = L.TileLayer.extend({ 2177 defaultWmtsParams: { 2178 service: 'WMTS', 2179 request: 'GetTile', 2180 version: '1.0.0', 2181 layer: '', 2182 style: '', 2183 tilematrixset: '', 2184 format: 'image/jpeg' 2185 }, 2186 initialize: function(url, options) { 2187 this._url = url; 2188 var lOptions = {}; 2189 var cOptions = Object.keys(options); 2190 for (var i1 in cOptions) { 2191 lOptions[cOptions[i1].toLowerCase()] = options[cOptions[i1]] 2192 } 2193 var wmtsParams = L.extend({}, this.defaultWmtsParams); 2194 var tileSize = lOptions.tileSize || this.options.tileSize; 2195 if (lOptions.detectRetina && L.Browser.retina) { 2196 wmtsParams.width = wmtsParams.height = tileSize * 2 2197 } else { 2198 wmtsParams.width = wmtsParams.height = tileSize 2199 } 2200 for (var i in lOptions) { 2201 if (wmtsParams.hasOwnProperty(i) && i != "matrixIds") { 2202 wmtsParams[i] = lOptions[i] 2203 } 2204 } 2205 this.wmtsParams = wmtsParams; 2206 this.matrixIds = options.matrixIds || this.getDefaultMatrix(); 2207 L.setOptions(this, options) 2208 }, 2209 onAdd: function(map) { 2210 this._crs = this.options.crs || map.options.crs; 2211 L.TileLayer.prototype.onAdd.call(this, map) 2212 }, 2213 getTileUrl: function(coords) { 2214 var tileSize = this.options.tileSize; 2215 var nwPoint = coords.multiplyBy(tileSize); 2216 nwPoint.x += 1;
2217 nwPoint.y -= 1; 2218 var sePoint = nwPoint.add(new L.Point(tileSize, tileSize)); 2219 var zoom = this._map.getZoom(); 2220 var nw = this._crs.project(this._map.unproject(nwPoint, zoom)); 2221 var se = this._crs.project(this._map.unproject(sePoint, zoom)); 2222 tilewidth = se.x - nw.x; 2223 var ident = this.matrixIds[zoom].identifier; 2224 var tilematrix = this.wmtsParams.tilematrixset + ":" + ident; 2225 var X0 = this.matrixIds[zoom].topLeftCorner.lng; 2226 var Y0 = this.matrixIds[zoom].topLeftCorner.lat; 2227 var tilecol = Math.floor((nw.x - X0) / tilewidth); 2228 var tilerow = -Math.floor((nw.y - Y0) / tilewidth); 2229 var url = L.Util.template(this._url, { 2230 s: this._getSubdomain(coords) 2231 }); 2232 return url + L.Util.getParamString(this.wmtsParams, url) + "&tilematrix=" + tilematrix + "&tilerow=" + tilerow + "&tilecol=" + tilecol 2233 }, 2234 setParams: function(params, noRedraw) { 2235 L.extend(this.wmtsParams, params); 2236 if (!noRedraw) { 2237 this.redraw() 2238 } 2239 return this 2240 }, 2241 getDefaultMatrix: function() { 2242 var matrixIds3857 = new Array(22); 2243 for (var i = 0; i < 22; i++) { 2244 matrixIds3857[i] = { 2245 identifier: "" + i, 2246 topLeftCorner: new L.LatLng(20037508.3428, -20037508.3428) 2247 } 2248 } 2249 return matrixIds3857 2250 } 2251 }); 2252 L.tileLayer.wmts = function(url, options) { 2253 return new L.TileLayer.WMTS(url, options) 2254 }; 2255 L.TileLayer.Canvas = L.TileLayer.extend({ 2256 options: { 2257 async: false 2258 }, 2259 initialize: function(options) { 2260 L.setOptions(this, options) 2261 }, 2262 redraw: function() { 2263 if (this._map) { 2264 this._reset({ 2265 hard: true 2266 }); 2267 this._update() 2268 } 2269 for (var i in this._tiles) { 2270 this._redrawTile(this._tiles[i]) 2271 } 2272 return this 2273 }, 2274 _redrawTile: function(tile) { 2275 this.drawTile(tile, tile._tilePoint, this._map._zoom) 2276 }, 2277 _createTile: function() { 2278 var tile = L.DomUtil.create('canvas', 'leaflet-tile'); 2279 tile.width = tile.height = this.options.tileSize; 2280 tile.onselectstart = tile.onmousemove = L.Util.falseFn; 2281 return tile 2282 }, 2283 _loadTile: function(tile, tilePoint) { 2284 tile._layer = this; 2285 tile._tilePoint = tilePoint; 2286 this._redrawTile(tile); 2287 if (!this.options.async) { 2288 this.tileDrawn(tile) 2289 } 2290 }, 2291 drawTile: function() {}, 2292 tileDrawn: function(tile) { 2293 this._tileOnLoad.call(tile) 2294 } 2295 }); 2296 L.tileLayer.canvas = function(options) { 2297 return new L.TileLayer.Canvas(options) 2298 }; 2299 L.ImageOverlay = L.Class.extend({ 2300 includes: L.Mixin.Events, 2301 options: { 2302 opacity: 1 2303 }, 2304 initialize: function(url, bounds, options) { 2305 this._url = url; 2306 this._bounds = L.latLngBounds(bounds); 2307 L.setOptions(this, options) 2308 }, 2309 onAdd: function(map) { 2310 this._map = map; 2311 if (!this._image) { 2312 this._initImage() 2313 } 2314 map._panes.overlayPane.appendChild(this._image); 2315 map.on('viewreset', this._reset, this); 2316 if (map.options.zoomAnimation && L.Browser.any3d) { 2317 map.on('zoomanim', this._animateZoom, this) 2318 } 2319 this._reset() 2320 }, 2321 onRemove: function(map) { 2322 map.getPanes().overlayPane.removeChild(this._image); 2323 map.off('viewreset', this._reset, this); 2324 if (map.options.zoomAnimation) { 2325 map.off('zoomanim', this._animateZoom, this) 2326 } 2327 }, 2328 addTo: function(map) { 2329 map.addLayer(this); 2330 return this 2331 }, 2332 setOpacity: function(opacity) { 2333 this.options.opacity = opacity; 2334 this._updateOpacity(); 2335 return this 2336 }, 2337 bringToFront: function() { 2338 if (this._image) { 2339 this._map._panes.overlayPane.appendChild(this._image) 2340 } 2341 return this 2342 }, 2343 bringToBack: function() { 2344 var pane = this._map._panes.overlayPane; 2345 if (this._image) { 2346 pane.insertBefore(this._image, pane.firstChild) 2347 } 2348 return this 2349 }, 2350 setUrl: function(url) { 2351 this._url = url; 2352 this._image.src = this._url 2353 }, 2354 getAttribution: function() { 2355 return this.options.attribution 2356 }, 2357 _initImage: function() { 2358 this._image = L.DomUtil.create('img', 'leaflet-image-layer'); 2359 if (this._map.options.zoomAnimation && L.Browser.any3d) { 2360 L.DomUtil.addClass(this._image, 'leaflet-zoom-animated') 2361 } else { 2362 L.DomUtil.addClass(this._image, 'leaflet-zoom-hide') 2363 } 2364 this._updateOpacity(); 2365 L.extend(this._image, { 2366 galleryimg: 'no', 2367 onselectstart: L.Util.falseFn, 2368 onmousemove: L.Util.falseFn, 2369 onload: L.bind(this._onImageLoad, this), 2370 src: this._url 2371 }) 2372 }, 2373 _animateZoom: function(e) { 2374 var map = this._map, 2375 image = this._image, 2376 scale = map.getZoomScale(e.zoom), 2377 nw = this._bounds.getNorthWest(), 2378 se = this._bounds.getSouthEast(), 2379 topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center), 2380 size = map._latLngToNewLayerPoint(se, e.zoom, e.center)._subtract(topLeft), 2381 origin = topLeft._add(size._multiplyBy((1 / 2) * (1 - 1 / scale))); 2382 image.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') ' 2383 }, 2384 _reset: function() { 2385 var image = this._image, 2386 topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()), 2387 size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft); 2388 L.DomUtil.setPosition(image, topLeft); 2389 image.style.width = size.x + 'px'; 2390 image.style.height = size.y + 'px' 2391 }, 2392 _onImageLoad: function() { 2393 this.fire('load') 2394 }, 2395 _updateOpacity: function() { 2396 L.DomUtil.setOpacity(this._image, this.options.opacity) 2397 } 2398 }); 2399 L.imageOverlay = function(url, bounds, options) { 2400 return new L.ImageOverlay(url, bounds, options) 2401 }; 2402 L.Icon = L.Class.extend({ 2403 options: { 2404 className: '' 2405 }, 2406 initialize: function(options) { 2407 L.setOptions(this, options) 2408 }, 2409 createIcon: function(oldIcon) { 2410 return this._createIcon('icon', oldIcon) 2411 }, 2412 createShadow: function(oldIcon) { 2413 return this._createIcon('shadow', oldIcon) 2414 }, 2415 _createIcon: function(name, oldIcon) { 2416 var src = this._getIconUrl(name); 2417 if (!src) { 2418 if (name === 'icon') { 2419 throw new Error('iconUrl not set in Icon options (see the docs).') 2420 } 2421 return null 2422 } 2423 var img; 2424 if (!oldIcon || oldIcon.tagName !== 'IMG') {
2425 img = this._createImg(src) 2426 } else { 2427 img = this._createImg(src, oldIcon) 2428 } 2429 this._setIconStyles(img, name); 2430 return img 2431 }, 2432 _setIconStyles: function(img, name) { 2433 var options = this.options, 2434 size = L.point(options[name + 'Size']), 2435 anchor; 2436 if (name === 'shadow') { 2437 anchor = L.point(options.shadowAnchor || options.iconAnchor) 2438 } else { 2439 anchor = L.point(options.iconAnchor) 2440 } 2441 if (!anchor && size) { 2442 anchor = size.divideBy(2, true) 2443 } 2444 img.className = 'leaflet-marker-' + name + ' ' + options.className; 2445 if (anchor) { 2446 img.style.marginLeft = (-anchor.x) + 'px'; 2447 img.style.marginTop = (-anchor.y) + 'px' 2448 } 2449 if (size) { 2450 img.style.width = size.x + 'px'; 2451 img.style.height = size.y + 'px' 2452 } 2453 }, 2454 _createImg: function(src, el) { 2455 el = el || document.createElement('img'); 2456 el.src = src; 2457 return el 2458 }, 2459 _getIconUrl: function(name) { 2460 if (L.Browser.retina && this.options[name + 'RetinaUrl']) { 2461 return this.options[name + 'RetinaUrl'] 2462 } 2463 return this.options[name + 'Url'] 2464 } 2465 }); 2466 L.icon = function(options) { 2467 return new L.Icon(options) 2468 }; 2469 L.Icon.Default = L.Icon.extend({ 2470 options: { 2471 iconSize: [25, 41], 2472 iconAnchor: [12, 41], 2473 popupAnchor: [1, -34], 2474 shadowSize: [41, 41] 2475 }, 2476 _getIconUrl: function(name) { 2477 var key = name + 'Url'; 2478 if (this.options[key]) { 2479 return this.options[key] 2480 } 2481 if (L.Browser.retina && name === 'icon') { 2482 name += '-2x' 2483 } 2484 var path = L.Icon.Default.imagePath; 2485 if (!path) { 2486 throw new Error('Couldn\'t autodetect L.Icon.Default.imagePath, set it manually.') 2487 } 2488 return path + '/marker-' + name + '.png' 2489 } 2490 }); 2491 L.Icon.Default.imagePath = (function() { 2492 var scripts = document.getElementsByTagName('script'), 2493 leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/; 2494 var i, len, src, matches, path; 2495 for (i = 0, len = scripts.length; i < len; i++) { 2496 src = scripts[i].src; 2497 matches = src.match(leafletRe); 2498 if (matches) { 2499 path = src.split(leafletRe)[0]; 2500 return (path ? path + '/' : '') + 'images' 2501 } 2502 } 2503 }()); 2504 L.Marker = L.Class.extend({ 2505 includes: L.Mixin.Events, 2506 options: { 2507 icon: new L.Icon.Default(), 2508 title: '', 2509 alt: '', 2510 clickable: true, 2511 draggable: false, 2512 keyboard: true, 2513 zIndexOffset: 0, 2514 opacity: 1, 2515 riseOnHover: false, 2516 riseOffset: 250 2517 }, 2518 initialize: function(latlng, options) { 2519 L.setOptions(this, options); 2520 this._latlng = L.latLng(latlng) 2521 }, 2522 onAdd: function(map) { 2523 this._map = map; 2524 map.on('viewreset', this.update, this); 2525 this._initIcon(); 2526 this.update(); 2527 this.fire('add'); 2528 if (map.options.zoomAnimation && map.options.markerZoomAnimation) { 2529 map.on('zoomanim', this._animateZoom, this) 2530 } 2531 }, 2532 addTo: function(map) { 2533 map.addLayer(this); 2534 return this 2535 }, 2536 onRemove: function(map) { 2537 if (this.dragging) { 2538 this.dragging.disable() 2539 } 2540 this._removeIcon(); 2541 this._removeShadow(); 2542 this.fire('remove'); 2543 map.off({ 2544 'viewreset': this.update, 2545 'zoomanim': this._animateZoom 2546 }, this); 2547 this._map = null 2548 }, 2549 getLatLng: function() { 2550 return this._latlng 2551 }, 2552 setLatLng: function(latlng) { 2553 this._latlng = L.latLng(latlng); 2554 this.update(); 2555 return this.fire('move', { 2556 latlng: this._latlng 2557 }) 2558 }, 2559 setZIndexOffset: function(offset) { 2560 this.options.zIndexOffset = offset; 2561 this.update(); 2562 return this 2563 }, 2564 setIcon: function(icon) { 2565 this.options.icon = icon; 2566 if (this._map) { 2567 this._initIcon(); 2568 this.update() 2569 } 2570 if (this._popup) { 2571 this.bindPopup(this._popup) 2572 } 2573 return this 2574 }, 2575 update: function() { 2576 if (this._icon) { 2577 var pos = this._map.latLngToLayerPoint(this._latlng).round(); 2578 this._setPos(pos) 2579 } 2580 return this 2581 }, 2582 _initIcon: function() { 2583 var options = this.options, 2584 map = this._map, 2585 animation = (map.options.zoomAnimation && map.options.markerZoomAnimation), 2586 classToAdd = animation ? 'leaflet-zoom-animated' : 'leaflet-zoom-hide'; 2587 var icon = options.icon.createIcon(this._icon), 2588 addIcon = false; 2589 if (icon !== this._icon) { 2590 if (this._icon) { 2591 this._removeIcon() 2592 } 2593 addIcon = true; 2594 if (options.title) { 2595 icon.title = options.title 2596 } 2597 if (options.alt) { 2598 icon.alt = options.alt 2599 } 2600 } 2601 L.DomUtil.addClass(icon, classToAdd); 2602 if (options.keyboard) { 2603 icon.tabIndex = '0' 2604 } 2605 this._icon = icon; 2606 this._initInteraction(); 2607 if (options.riseOnHover) { 2608 L.DomEvent.on(icon, 'mouseover', this._bringToFront, this).on(icon, 'mouseout', this._resetZIndex, this) 2609 } 2610 var newShadow = options.icon.createShadow(this._shadow), 2611 addShadow = false; 2612 if (newShadow !== this._shadow) { 2613 this._removeShadow(); 2614 addShadow = true 2615 } 2616 if (newShadow) { 2617 L.DomUtil.addClass(newShadow, classToAdd) 2618 } 2619 this._shadow = newShadow; 2620 if (options.opacity < 1) { 2621 this._updateOpacity() 2622 } 2623 var panes = this._map._panes; 2624 if (addIcon) { 2625 panes.markerPane.appendChild(this._icon) 2626 } 2627 if (newShadow && addShadow) { 2628 panes.shadowPane.appendChild(this._shadow) 2629 } 2630 }, 2631 _removeIcon: function() { 2632 if (this.options.riseOnHover) { 2633 L.DomEvent.off(this._icon, 'mouseover', this._bringToFront).off(this._icon, 'mouseout', this._resetZIndex) 2634 } 2635 this._map._panes.markerPane.removeChild(this._icon); 2636 this._icon = null 2637 }, 2638 _removeShadow: function() { 2639 if (this._shadow) { 2640 this._map._panes.shadowPane.removeChild(this._shadow) 2641 } 2642 this._shadow = null 2643 }, 2644 _setPos: function(pos) { 2645 L.DomUtil.setPosition(this._icon, pos); 2646 if (this._shadow) { 2647 L.DomUtil.setPosition(this._shadow, pos) 2648 } 2649 this._zIndex = pos.y + this.options.zIndexOffset; 2650 this._resetZIndex() 2651 }, 2652 _updateZIndex: function(offset) { 2653 this._icon.style.zIndex = this._zIndex + offset 2654 }, 2655 _animateZoom: function(opt) { 2656 var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round(); 2657 this._setPos(pos) 2658 }, 2659 _initInteraction: function() { 2660 if (!this.options.clickable) { 2661 return 2662 } 2663 var icon = this._icon, 2664 events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu']; 2665 L.DomUtil.addClass(icon, 'leaflet-clickable'); 2666 L.DomEvent.on(icon, 'click', this._onMouseClick, this); 2667 L.DomEvent.on(icon, 'keypress', this._onKeyPress, this); 2668 for (var i = 0; i < events.length; i++) { 2669 L.DomEvent.on(icon, events[i], this._fireMouseEvent, this) 2670 } 2671 if (L.Handler.MarkerDrag) { 2672 this.dragging = new L.Handler.MarkerDrag(this); 2673 if (this.options.draggable) { 2674 this.dragging.enable() 2675 } 2676 } 2677 }, 2678 _onMouseClick: function(e) { 2679 var wasDragged = this.dragging && this.dragging.moved(); 2680 if (this.hasEventListeners(e.type) || wasDragged) { 2681 L.DomEvent.stopPropagation(e) 2682 } 2683 if (wasDragged) { 2684 return 2685 } 2686 if ((!this.dragging || !this.dragging._enabled) && this._map.dragging && this._map.dragging.moved()) { 2687 return 2688 } 2689 this.fire(e.type, { 2690 originalEvent: e, 2691 latlng: this._latlng 2692 }) 2693 }, 2694 _onKeyPress: function(e) { 2695 if (e.keyCode === 13) { 2696 this.fire('click', { 2697 originalEvent: e, 2698 latlng: this._latlng 2699 }) 2700 } 2701 }, 2702 _fireMouseEvent: function(e) { 2703 this.fire(e.type, { 2704 originalEvent: e, 2705 latlng: this._latlng 2706 }); 2707 if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) { 2708 L.DomEvent.preventDefault(e) 2709 } 2710 if (e.type !== 'mousedown') { 2711 L.DomEvent.stopPropagation(e) 2712 } else { 2713 L.DomEvent.preventDefault(e) 2714 } 2715 }, 2716 setOpacity: function(opacity) { 2717 this.options.opacity = opacity; 2718 if (this._map) { 2719 this._updateOpacity() 2720 } 2721 return this 2722 }, 2723 _updateOpacity: function() { 2724 L.DomUtil.setOpacity(this._icon, this.options.opacity); 2725 if (this._shadow) { 2726 L.DomUtil.setOpacity(this._shadow, this.options.opacity) 2727 } 2728 }, 2729 _bringToFront: function() { 2730 this._updateZIndex(this.options.riseOffset) 2731 }, 2732 _resetZIndex: function() { 2733 this._updateZIndex(0) 2734 } 2735 }); 2736 L.marker = function(latlng, options) { 2737 return new L.Marker(latlng, options) 2738 }; 2739 L.DivIcon = L.Icon.extend({ 2740 options: { 2741 iconSize: [12, 12], 2742 className: 'leaflet-div-icon', 2743 html: false 2744 }, 2745 createIcon: function(oldIcon) { 2746 var div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'), 2747 options = this.options; 2748 if (options.html !== false) { 2749 div.innerHTML = options.html 2750 } else { 2751 div.innerHTML = '' 2752 } 2753 if (options.bgPos) { 2754 div.style.backgroundPosition = (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px' 2755 } 2756 this._setIconStyles(div, 'icon'); 2757 return div 2758 }, 2759 createShadow: function() { 2760 return null 2761 } 2762 }); 2763 L.divIcon = function(options) { 2764 return new L.DivIcon(options) 2765 }; 2766 L.Map.mergeOptions({ 2767 closePopupOnClick: true 2768 }); 2769 L.Popup = L.Class.extend({ 2770 includes: L.Mixin.Events, 2771 options: { 2772 minWidth: 50, 2773 maxWidth: 300, 2774 autoPan: true, 2775 closeButton: true, 2776 offset: [0, 7], 2777 autoPanPadding: [5, 5], 2778 keepInView: false, 2779 className: '', 2780 zoomAnimation: true 2781 }, 2782 initialize: function(options, source) { 2783 L.setOptions(this, options); 2784 this._source = source; 2785 this._animated = L.Browser.any3d && this.options.zoomAnimation; 2786 this._isOpen = false 2787 }, 2788 onAdd: function(map) { 2789 this._map = map; 2790 if (!this._container) { 2791 this._initLayout() 2792 } 2793 var animFade = map.options.fadeAnimation; 2794 if (animFade) { 2795 L.DomUtil.setOpacity(this._container, 0) 2796 } 2797 map._panes.popupPane.appendChild(this._container); 2798 map.on(this._getEvents(), this); 2799 this.update(); 2800 if (animFade) { 2801 L.DomUtil.setOpacity(this._container, 1) 2802 } 2803 this.fire('open'); 2804 map.fire('popupopen', { 2805 popup: this 2806 }); 2807 if (this._source) { 2808 this._source.fire('popupopen', { 2809 popup: this 2810 }) 2811 } 2812 }, 2813 addTo: function(map) { 2814 map.addLayer(this); 2815 return this 2816 }, 2817 openOn: function(map) { 2818 map.openPopup(this); 2819 return this 2820 }, 2821 onRemove: function(map) { 2822 map._panes.popupPane.removeChild(this._container); 2823 L.Util.falseFn(this._container.offsetWidth);
2824 map.off(this._getEvents(), this); 2825 if (map.options.fadeAnimation) { 2826 L.DomUtil.setOpacity(this._container, 0) 2827 } 2828 this._map = null; 2829 this.fire('close'); 2830 map.fire('popupclose', { 2831 popup: this 2832 }); 2833 if (this._source) { 2834 this._source.fire('popupclose', { 2835 popup: this 2836 }) 2837 } 2838 }, 2839 getLatLng: function() { 2840 return this._latlng 2841 }, 2842 setLatLng: function(latlng) { 2843 this._latlng = L.latLng(latlng); 2844 if (this._map) { 2845 this._updatePosition(); 2846 this._adjustPan() 2847 } 2848 return this 2849 }, 2850 getContent: function() { 2851 return this._content 2852 }, 2853 setContent: function(content) { 2854 this._content = content; 2855 this.update(); 2856 return this 2857 }, 2858 update: function() { 2859 if (!this._map) { 2860 return 2861 } 2862 this._container.style.visibility = 'hidden'; 2863 this._updateContent(); 2864 this._updateLayout(); 2865 this._updatePosition(); 2866 this._container.style.visibility = ''; 2867 this._adjustPan() 2868 }, 2869 _getEvents: function() { 2870 var events = { 2871 viewreset: this._updatePosition 2872 }; 2873 if (this._animated) { 2874 events.zoomanim = this._zoomAnimation 2875 } 2876 if ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) { 2877 events.preclick = this._close 2878 } 2879 if (this.options.keepInView) { 2880 events.moveend = this._adjustPan 2881 } 2882 return events 2883 }, 2884 _close: function() { 2885 if (this._map) { 2886 this._map.closePopup(this) 2887 } 2888 }, 2889 _initLayout: function() { 2890 var prefix = 'leaflet-popup', 2891 containerClass = prefix + ' ' + this.options.className + ' leaflet-zoom-' + (this._animated ? 'animated' : 'hide'), 2892 container = this._container = L.DomUtil.create('div', containerClass), 2893 closeButton; 2894 if (this.options.closeButton) { 2895 closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container); 2896 closeButton.href = '#close'; 2897 closeButton.innerHTML = '×'; 2898 L.DomEvent.disableClickPropagation(closeButton); 2899 L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this) 2900 } 2901 var wrapper = this._wrapper = L.DomUtil.create('div', prefix + '-content-wrapper', container); 2902 L.DomEvent.disableClickPropagation(wrapper); 2903 this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper); 2904 L.DomEvent.disableScrollPropagation(this._contentNode); 2905 L.DomEvent.on(wrapper, 'contextmenu', L.DomEvent.stopPropagation); 2906 this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container); 2907 this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer) 2908 }, 2909 _updateContent: function() { 2910 if (!this._content) { 2911 return 2912 } 2913 if (typeof this._content === 'string') { 2914 this._contentNode.innerHTML = this._content 2915 } else { 2916 while (this._contentNode.hasChildNodes()) { 2917 this._contentNode.removeChild(this._contentNode.firstChild) 2918 } 2919 this._contentNode.appendChild(this._content) 2920 } 2921 this.fire('contentupdate') 2922 }, 2923 _updateLayout: function() { 2924 var container = this._contentNode, 2925 style = container.style; 2926 style.width = ''; 2927 style.whiteSpace = 'nowrap'; 2928 var width = container.offsetWidth; 2929 width = Math.min(width, this.options.maxWidth); 2930 width = Math.max(width, this.options.minWidth); 2931 style.width = (width + 1) + 'px'; 2932 style.whiteSpace = ''; 2933 style.height = ''; 2934 var height = container.offsetHeight, 2935 maxHeight = this.options.maxHeight, 2936 scrolledClass = 'leaflet-popup-scrolled'; 2937 if (maxHeight && height > maxHeight) { 2938 style.height = maxHeight + 'px'; 2939 L.DomUtil.addClass(container, scrolledClass) 2940 } else { 2941 L.DomUtil.removeClass(container, scrolledClass) 2942 } 2943 this._containerWidth = this._container.offsetWidth 2944 }, 2945 _updatePosition: function() { 2946 if (!this._map) { 2947 return 2948 } 2949 var pos = this._map.latLngToLayerPoint(this._latlng), 2950 animated = this._animated, 2951 offset = L.point(this.options.offset); 2952 if (animated) { 2953 L.DomUtil.setPosition(this._container, pos) 2954 } 2955 this._containerBottom = -offset.y - (animated ? 0 : pos.y); 2956 this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (animated ? 0 : pos.x); 2957 this._container.style.bottom = this._containerBottom + 'px'; 2958 this._container.style.left = this._containerLeft + 'px' 2959 }, 2960 _zoomAnimation: function(opt) { 2961 var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center); 2962 L.DomUtil.setPosition(this._container, pos) 2963 }, 2964 _adjustPan: function() { 2965 if (!this.options.autoPan) { 2966 return 2967 } 2968 var map = this._map, 2969 containerHeight = this._container.offsetHeight, 2970 containerWidth = this._containerWidth, 2971 layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom); 2972 if (this._animated) { 2973 layerPos._add(L.DomUtil.getPosition(this._container)) 2974 } 2975 var containerPos = map.layerPointToContainerPoint(layerPos), 2976 padding = L.point(this.options.autoPanPadding), 2977 paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding), 2978 paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding), 2979 size = map.getSize(), 2980 dx = 0, 2981 dy = 0; 2982 if (containerPos.x + containerWidth + paddingBR.x > size.x) { 2983 dx = containerPos.x + containerWidth - size.x + paddingBR.x 2984 } 2985 if (containerPos.x - dx - paddingTL.x < 0) { 2986 dx = containerPos.x - paddingTL.x 2987 } 2988 if (containerPos.y + containerHeight + paddingBR.y > size.y) { 2989 dy = containerPos.y + containerHeight - size.y + paddingBR.y 2990 } 2991 if (containerPos.y - dy - paddingTL.y < 0) { 2992 dy = containerPos.y - paddingTL.y 2993 } 2994 if (dx || dy) { 2995 map.fire('autopanstart').panBy([dx, dy]) 2996 } 2997 }, 2998 _onCloseButtonClick: function(e) { 2999 this._close(); 3000 L.DomEvent.stop(e) 3001 } 3002 }); 3003 L.popup = function(options, source) { 3004 return new L.Popup(options, source) 3005 }; 3006 L.Map.include({ 3007 openPopup: function(popup, latlng, options) { 3008 this.closePopup(); 3009 if (!(popup instanceof L.Popup)) { 3010 var content = popup; 3011 popup = new L.Popup(options).setLatLng(latlng).setContent(content) 3012 } 3013 popup._isOpen = true; 3014 this._popup = popup; 3015 return this.addLayer(popup) 3016 }, 3017 closePopup: function(popup) { 3018 if (!popup || popup === this._popup) { 3019 popup = this._popup; 3020 this._popup = null 3021 } 3022 if (popup) { 3023 this.removeLayer(popup); 3024 popup._isOpen = false 3025 } 3026 return this 3027 } 3028 }); 3029 L.Marker.include({ 3030 openPopup: function() { 3031 if (this._popup && this._map && !this._map.hasLayer(this._popup)) { 3032 this._popup.setLatLng(this._latlng); 3033 this._map.openPopup(this._popup) 3034 } 3035 return this 3036 }, 3037 closePopup: function() { 3038 if (this._popup) { 3039 this._popup._close() 3040 } 3041 return this 3042 }, 3043 togglePopup: function() { 3044 if (this._popup) { 3045 if (this._popup._isOpen) { 3046 this.closePopup() 3047 } else { 3048 this.openPopup() 3049 } 3050 } 3051 return this 3052 }, 3053 bindPopup: function(content, options) { 3054 var anchor = L.point(this.options.icon.options.popupAnchor || [0, 0]); 3055 anchor = anchor.add(L.Popup.prototype.options.offset); 3056 if (options && options.offset) { 3057 anchor = anchor.add(options.offset) 3058 } 3059 options = L.extend({ 3060 offset: anchor 3061 }, options); 3062 if (!this._popupHandlersAdded) { 3063 this.on('click', this.togglePopup, this).on('remove', this.closePopup, this).on('move', this._movePopup, this); 3064 this._popupHandlersAdded = true 3065 } 3066 if (content instanceof L.Popup) { 3067 L.setOptions(content, options); 3068 this._popup = content 3069 } else { 3070 this._popup = new L.Popup(options, this).setContent(content) 3071 } 3072 return this 3073 }, 3074 setPopupContent: function(content) { 3075 if (this._popup) { 3076 this._popup.setContent(content) 3077 } 3078 return this 3079 }, 3080 unbindPopup: function() { 3081 if (this._popup) { 3082 this._popup = null; 3083 this.off('click', this.togglePopup, this).off('remove', this.closePopup, this).off('move', this._movePopup, this); 3084 this._popupHandlersAdded = false 3085 } 3086 return this 3087 }, 3088 getPopup: function() { 3089 return this._popup 3090 }, 3091 _movePopup: function(e) { 3092 this._popup.setLatLng(e.latlng) 3093 } 3094 }); 3095 L.LayerGroup = L.Class.extend({ 3096 initialize: function(layers) { 3097 this._layers = {}; 3098 var i, len; 3099 if (layers) { 3100 for (i = 0, len = layers.length; i < len; i++) { 3101 this.addLayer(layers[i]) 3102 } 3103 } 3104 }, 3105 addLayer: function(layer) { 3106 var id = this.getLayerId(layer); 3107 this._layers[id] = layer; 3108 if (this._map) { 3109 this._map.addLayer(layer) 3110 } 3111 return this 3112 }, 3113 removeLayer: function(layer) { 3114 var id = layer in this._layers ? layer : this.getLayerId(layer); 3115 if (this._map && this._layers[id]) { 3116 this._map.removeLayer(this._layers[id]) 3117 } 3118 delete this._layers[id]; 3119 return this 3120 }, 3121 hasLayer: function(layer) { 3122 if (!layer) { 3123 return false 3124 } 3125 return (layer in this._layers || this.getLayerId(layer) in this._layers) 3126 }, 3127 clearLayers: function() { 3128 this.eachLayer(this.removeLayer, this); 3129 return this 3130 }, 3131 invoke: function(methodName) { 3132 var args = Array.prototype.slice.call(arguments, 1), 3133 i, layer; 3134 for (i in this._layers) { 3135 layer = this._layers[i];
3136 if (layer[methodName]) { 3137 layer[methodName].apply(layer, args) 3138 } 3139 } 3140 return this 3141 }, 3142 onAdd: function(map) { 3143 this._map = map; 3144 this.eachLayer(map.addLayer, map) 3145 }, 3146 onRemove: function(map) { 3147 this.eachLayer(map.removeLayer, map); 3148 this._map = null 3149 }, 3150 addTo: function(map) { 3151 map.addLayer(this); 3152 return this 3153 }, 3154 eachLayer: function(method, context) { 3155 for (var i in this._layers) { 3156 method.call(context, this._layers[i]) 3157 } 3158 return this 3159 }, 3160 getLayer: function(id) { 3161 return this._layers[id] 3162 }, 3163 getLayers: function() { 3164 var layers = []; 3165 for (var i in this._layers) { 3166 layers.push(this._layers[i]) 3167 } 3168 return layers 3169 }, 3170 setZIndex: function(zIndex) { 3171 return this.invoke('setZIndex', zIndex) 3172 }, 3173 getLayerId: function(layer) { 3174 return L.stamp(layer) 3175 } 3176 }); 3177 L.layerGroup = function(layers) { 3178 return new L.LayerGroup(layers) 3179 }; 3180 L.FeatureGroup = L.LayerGroup.extend({ 3181 includes: L.Mixin.Events, 3182 statics: { 3183 EVENTS: 'click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose' 3184 }, 3185 addLayer: function(layer) { 3186 if (this.hasLayer(layer)) { 3187 return this 3188 } 3189 if ('on' in layer) { 3190 layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this) 3191 } 3192 L.LayerGroup.prototype.addLayer.call(this, layer); 3193 if (this._popupContent && layer.bindPopup) { 3194 layer.bindPopup(this._popupContent, this._popupOptions) 3195 } 3196 return this.fire('layeradd', { 3197 layer: layer 3198 }) 3199 }, 3200 removeLayer: function(layer) { 3201 if (!this.hasLayer(layer)) { 3202 return this 3203 } 3204 if (layer in this._layers) { 3205 layer = this._layers[layer] 3206 } 3207 layer.off(L.FeatureGroup.EVENTS, this._propagateEvent, this); 3208 L.LayerGroup.prototype.removeLayer.call(this, layer); 3209 if (this._popupContent) { 3210 this.invoke('unbindPopup') 3211 } 3212 return this.fire('layerremove', { 3213 layer: layer 3214 }) 3215 }, 3216 bindPopup: function(content, options) { 3217 this._popupContent = content; 3218 this._popupOptions = options; 3219 return this.invoke('bindPopup', content, options) 3220 }, 3221 openPopup: function(latlng) { 3222 for (var id in this._layers) { 3223 this._layers[id].openPopup(latlng); 3224 break 3225 } 3226 return this 3227 }, 3228 setStyle: function(style) { 3229 return this.invoke('setStyle', style) 3230 }, 3231 bringToFront: function() { 3232 return this.invoke('bringToFront') 3233 }, 3234 bringToBack: function() { 3235 return this.invoke('bringToBack') 3236 }, 3237 getBounds: function() { 3238 var bounds = new L.LatLngBounds(); 3239 this.eachLayer(function(layer) { 3240 bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds()) 3241 }); 3242 return bounds 3243 }, 3244 _propagateEvent: function(e) { 3245 e = L.extend({ 3246 layer: e.target, 3247 target: this 3248 }, e); 3249 this.fire(e.type, e) 3250 } 3251 }); 3252 L.featureGroup = function(layers) { 3253 return new L.FeatureGroup(layers) 3254 }; 3255 L.Path = L.Class.extend({ 3256 includes: [L.Mixin.Events], 3257 statics: { 3258 CLIP_PADDING: (function() { 3259 var max = L.Browser.mobile ? 1280 : 2000, 3260 target = (max / Math.max(window.outerWidth, window.outerHeight) - 1) / 2; 3261 return Math.max(0, Math.min(0.5, target)) 3262 })() 3263 }, 3264 options: { 3265 stroke: true, 3266 color: '#0033ff', 3267 dashArray: null, 3268 lineCap: null, 3269 lineJoin: null, 3270 weight: 5, 3271 opacity: 0.5, 3272 fill: false, 3273 fillColor: null, 3274 fillOpacity: 0.2, 3275 clickable: true 3276 }, 3277 initialize: function(options) { 3278 L.setOptions(this, options) 3279 }, 3280 onAdd: function(map) { 3281 this._map = map; 3282 if (!this._container) { 3283 this._initElements(); 3284 this._initEvents() 3285 } 3286 this.projectLatlngs(); 3287 this._updatePath(); 3288 if (this._container) { 3289 this._map._pathRoot.appendChild(this._container) 3290 } 3291 this.fire('add'); 3292 map.on({ 3293 'viewreset': this.projectLatlngs, 3294 'moveend': this._updatePath 3295 }, this) 3296 }, 3297 addTo: function(map) { 3298 map.addLayer(this); 3299 return this 3300 }, 3301 onRemove: function(map) { 3302 map._pathRoot.removeChild(this._container); 3303 this.fire('remove'); 3304 this._map = null; 3305 if (L.Browser.vml) { 3306 this._container = null; 3307 this._stroke = null; 3308 this._fill = null 3309 } 3310 map.off({ 3311 'viewreset': this.projectLatlngs, 3312 'moveend': this._updatePath 3313 }, this) 3314 }, 3315 projectLatlngs: function() {}, 3316 setStyle: function(style) { 3317 L.setOptions(this, style); 3318 if (this._container) { 3319 this._updateStyle() 3320 } 3321 return this 3322 }, 3323 redraw: function() { 3324 if (this._map) { 3325 this.projectLatlngs(); 3326 this._updatePath() 3327 } 3328 return this 3329 } 3330 }); 3331 L.Map.include({ 3332 _updatePathViewport: function() { 3333 var p = L.Path.CLIP_PADDING,
3334 size = this.getSize(), 3335 panePos = L.DomUtil.getPosition(this._mapPane), 3336 min = panePos.multiplyBy(-1)._subtract(size.multiplyBy(p)._round()), 3337 max = min.add(size.multiplyBy(1 + p * 2)._round()); 3338 this._pathViewport = new L.Bounds(min, max) 3339 } 3340 }); 3341 L.Path.SVG_NS = 'http://www.w3.org/2000/svg'; 3342 L.Browser.svg = !!(document.createElementNS && document.createElementNS(L.Path.SVG_NS, 'svg').createSVGRect); 3343 L.Path = L.Path.extend({ 3344 statics: { 3345 SVG: L.Browser.svg 3346 }, 3347 bringToFront: function() { 3348 var root = this._map._pathRoot, 3349 path = this._container; 3350 if (path && root.lastChild !== path) { 3351 root.appendChild(path) 3352 } 3353 return this 3354 }, 3355 bringToBack: function() { 3356 var root = this._map._pathRoot, 3357 path = this._container, 3358 first = root.firstChild; 3359 if (path && first !== path) { 3360 root.insertBefore(path, first) 3361 } 3362 return this 3363 }, 3364 getPathString: function() {}, 3365 _createElement: function(name) { 3366 return document.createElementNS(L.Path.SVG_NS, name) 3367 }, 3368 _initElements: function() { 3369 this._map._initPathRoot(); 3370 this._initPath(); 3371 this._initStyle() 3372 }, 3373 _initPath: function() { 3374 this._container = this._createElement('g'); 3375 this._path = this._createElement('path'); 3376 if (this.options.className) { 3377 L.DomUtil.addClass(this._path, this.options.className) 3378 } 3379 this._container.appendChild(this._path) 3380 }, 3381 _initStyle: function() { 3382 if (this.options.stroke) { 3383 this._path.setAttribute('stroke-linejoin', 'round'); 3384 this._path.setAttribute('stroke-linecap', 'round') 3385 } 3386 if (this.options.fill) { 3387 this._path.setAttribute('fill-rule', 'evenodd') 3388 } 3389 if (this.options.pointerEvents) { 3390 this._path.setAttribute('pointer-events', this.options.pointerEvents) 3391 } 3392 if (!this.options.clickable && !this.options.pointerEvents) { 3393 this._path.setAttribute('pointer-events', 'none') 3394 } 3395 this._updateStyle() 3396 }, 3397 _updateStyle: function() { 3398 if (this.options.stroke) { 3399 this._path.setAttribute('stroke', this.options.color); 3400 this._path.setAttribute('stroke-opacity', this.options.opacity); 3401 this._path.setAttribute('stroke-width', this.options.weight); 3402 if (this.options.dashArray) { 3403 this._path.setAttribute('stroke-dasharray', this.options.dashArray) 3404 } else { 3405 this._path.removeAttribute('stroke-dasharray') 3406 } 3407 if (this.options.lineCap) { 3408 this._path.setAttribute('stroke-linecap', this.options.lineCap) 3409 } 3410 if (this.options.lineJoin) { 3411 this._path.setAttribute('stroke-linejoin', this.options.lineJoin) 3412 } 3413 } else { 3414 this._path.setAttribute('stroke', 'none') 3415 } 3416 if (this.options.fill) { 3417 this._path.setAttribute('fill', this.options.fillColor || this.options.color); 3418 this._path.setAttribute('fill-opacity', this.options.fillOpacity) 3419 } else { 3420 this._path.setAttribute('fill', 'none') 3421 } 3422 }, 3423 _updatePath: function() { 3424 var str = this.getPathString(); 3425 if (!str) { 3426 str = 'M0 0' 3427 } 3428 this._path.setAttribute('d', str) 3429 }, 3430 _initEvents: function() { 3431 if (this.options.clickable) { 3432 if (L.Browser.svg || !L.Browser.vml) { 3433 L.DomUtil.addClass(this._path, 'leaflet-clickable') 3434 } 3435 L.DomEvent.on(this._container, 'click', this._onMouseClick, this); 3436 var events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'mousemove', 'contextmenu']; 3437 for (var i = 0; i < events.length; i++) { 3438 L.DomEvent.on(this._container, events[i], this._fireMouseEvent, this) 3439 } 3440 } 3441 }, 3442 _onMouseClick: function(e) { 3443 if (this._map.dragging && this._map.dragging.moved()) { 3444 return 3445 } 3446 this._fireMouseEvent(e) 3447 }, 3448 _fireMouseEvent: function(e) { 3449 if (!this.hasEventListeners(e.type)) { 3450 return 3451 } 3452 var map = this._map, 3453 containerPoint = map.mouseEventToContainerPoint(e), 3454 layerPoint = map.containerPointToLayerPoint(containerPoint), 3455 latlng = map.layerPointToLatLng(layerPoint); 3456 this.fire(e.type, { 3457 latlng: latlng, 3458 layerPoint: layerPoint, 3459 containerPoint: containerPoint, 3460 originalEvent: e 3461 }); 3462 if (e.type === 'contextmenu') { 3463 L.DomEvent.preventDefault(e) 3464 } 3465 if (e.type !== 'mousemove') { 3466 L.DomEvent.stopPropagation(e) 3467 } 3468 } 3469 }); 3470 L.Map.include({ 3471 _initPathRoot: function() { 3472 if (!this._pathRoot) { 3473 this._pathRoot = L.Path.prototype._createElement('svg'); 3474 this._panes.overlayPane.appendChild(this._pathRoot); 3475 if (this.options.zoomAnimation && L.Browser.any3d) { 3476 L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-animated'); 3477 this.on({ 3478 'zoomanim': this._animatePathZoom, 3479 'zoomend': this._endPathZoom 3480 }) 3481 } else { 3482 L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-hide') 3483 } 3484 this.on('moveend', this._updateSvgViewport); 3485 this._updateSvgViewport() 3486 } 3487 }, 3488 _animatePathZoom: function(e) { 3489 var scale = this.getZoomScale(e.zoom), 3490 offset = this._getCenterOffset(e.center)._multiplyBy(-scale)._add(this._pathViewport.min); 3491 this._pathRoot.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ') '; 3492 this._pathZooming = true 3493 }, 3494 _endPathZoom: function() { 3495 this._pathZooming = false 3496 }, 3497 _updateSvgViewport: function() { 3498 if (this._pathZooming) { 3499 return 3500 } 3501 this._updatePathViewport(); 3502 var vp = this._pathViewport, 3503 min = vp.min, 3504 max = vp.max, 3505 width = max.x - min.x, 3506 height = max.y - min.y, 3507 root = this._pathRoot, 3508 pane = this._panes.overlayPane; 3509 if (L.Browser.mobileWebkit) { 3510 pane.removeChild(root) 3511 } 3512 L.DomUtil.setPosition(root, min); 3513 root.setAttribute('width', width); 3514 root.setAttribute('height', height); 3515 root.setAttribute('viewBox', [min.x, min.y, width, height].join(' '));
3516 if (L.Browser.mobileWebkit) { 3517 pane.appendChild(root) 3518 } 3519 } 3520 }); 3521 L.Path.include({ 3522 bindPopup: function(content, options) { 3523 if (content instanceof L.Popup) { 3524 this._popup = content 3525 } else { 3526 if (!this._popup || options) { 3527 this._popup = new L.Popup(options, this) 3528 } 3529 this._popup.setContent(content) 3530 } 3531 if (!this._popupHandlersAdded) { 3532 this.on('click', this._openPopup, this).on('remove', this.closePopup, this); 3533 this._popupHandlersAdded = true 3534 } 3535 return this 3536 }, 3537 unbindPopup: function() { 3538 if (this._popup) { 3539 this._popup = null; 3540 this.off('click', this._openPopup).off('remove', this.closePopup); 3541 this._popupHandlersAdded = false 3542 } 3543 return this 3544 }, 3545 openPopup: function(latlng) { 3546 if (this._popup) { 3547 latlng = latlng || this._latlng || this._latlngs[Math.floor(this._latlngs.length / 2)]; 3548 this._openPopup({ 3549 latlng: latlng 3550 }) 3551 } 3552 return this 3553 }, 3554 closePopup: function() { 3555 if (this._popup) { 3556 this._popup._close() 3557 } 3558 return this 3559 }, 3560 _openPopup: function(e) { 3561 this._popup.setLatLng(e.latlng); 3562 this._map.openPopup(this._popup) 3563 } 3564 }); 3565 L.Browser.vml = !L.Browser.svg && (function() { 3566 try { 3567 var div = document.createElement('div'); 3568 div.innerHTML = '<v:shape adj="1"/>'; 3569 var shape = div.firstChild; 3570 shape.style.behavior = 'url(#default#VML)'; 3571 return shape && (typeof shape.adj === 'object') 3572 } catch (e) { 3573 return false 3574 } 3575 }()); 3576 L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({ 3577 statics: { 3578 VML: true, 3579 CLIP_PADDING: 0.02 3580 }, 3581 _createElement: (function() { 3582 try { 3583 document.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml'); 3584 return function(name) { 3585 return document.createElement('<lvml:' + name + ' class="lvml">') 3586 } 3587 } catch (e) { 3588 return function(name) { 3589 return document.createElement('<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">') 3590 } 3591 } 3592 }()), 3593 _initPath: function() { 3594 var container = this._container = this._createElement('shape'); 3595 L.DomUtil.addClass(container, 'leaflet-vml-shape' + (this.options.className ? ' ' + this.options.className : '')); 3596 if (this.options.clickable) { 3597 L.DomUtil.addClass(container, 'leaflet-clickable') 3598 } 3599 container.coordsize = '1 1'; 3600 this._path = this._createElement('path'); 3601 container.appendChild(this._path); 3602 this._map._pathRoot.appendChild(container) 3603 }, 3604 _initStyle: function() { 3605 this._updateStyle() 3606 }, 3607 _updateStyle: function() { 3608 var stroke = this._stroke, 3609 fill = this._fill, 3610 options = this.options, 3611 container = this._container; 3612 container.stroked = options.stroke; 3613 container.filled = options.fill; 3614 if (options.stroke) { 3615 if (!stroke) { 3616 stroke = this._stroke = this._createElement('stroke'); 3617 stroke.endcap = 'round'; 3618 container.appendChild(stroke) 3619 } 3620 stroke.weight = options.weight + 'px'; 3621 stroke.color = options.color; 3622 stroke.opacity = options.opacity; 3623 if (options.dashArray) { 3624 stroke.dashStyle = L.Util.isArray(options.dashArray) ? options.dashArray.join(' ') : options.dashArray.replace(/( *, *)/g, ' ') 3625 } else { 3626 stroke.dashStyle = '' 3627 } 3628 if (options.lineCap) { 3629 stroke.endcap = options.lineCap.replace('butt', 'flat') 3630 } 3631 if (options.lineJoin) { 3632 stroke.joinstyle = options.lineJoin 3633 } 3634 } else if (stroke) { 3635 container.removeChild(stroke); 3636 this._stroke = null 3637 } 3638 if (options.fill) { 3639 if (!fill) { 3640 fill = this._fill = this._createElement('fill'); 3641 container.appendChild(fill) 3642 } 3643 fill.color = options.fillColor || options.color; 3644 fill.opacity = options.fillOpacity 3645 } else if (fill) { 3646 container.removeChild(fill); 3647 this._fill = null 3648 } 3649 }, 3650 _updatePath: function() { 3651 var style = this._container.style; 3652 style.display = 'none'; 3653 this._path.v = this.getPathString() + ' '; 3654 style.display = '' 3655 } 3656 }); 3657 L.Map.include(L.Browser.svg || !L.Browser.vml ? {} : { 3658 _initPathRoot: function() { 3659 if (this._pathRoot) { 3660 return 3661 } 3662 var root = this._pathRoot = document.createElement('div'); 3663 root.className = 'leaflet-vml-container'; 3664 this._panes.overlayPane.appendChild(root); 3665 this.on('moveend', this._updatePathViewport); 3666 this._updatePathViewport() 3667 } 3668 }); 3669 L.Browser.canvas = (function() { 3670 return !!document.createElement('canvas').getContext 3671 }());
3672 L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : L.Path.extend({ 3673 statics: { 3674 CANVAS: true, 3675 SVG: false 3676 }, 3677 redraw: function() { 3678 if (this._map) { 3679 this.projectLatlngs(); 3680 this._requestUpdate() 3681 } 3682 return this 3683 }, 3684 setStyle: function(style) { 3685 L.setOptions(this, style); 3686 if (this._map) { 3687 this._updateStyle(); 3688 this._requestUpdate() 3689 } 3690 return this 3691 }, 3692 onRemove: function(map) { 3693 map.off('viewreset', this.projectLatlngs, this).off('moveend', this._updatePath, this); 3694 if (this.options.clickable) { 3695 this._map.off('click', this._onClick, this); 3696 this._map.off('mousemove', this._onMouseMove, this) 3697 } 3698 this._requestUpdate(); 3699 this.fire('remove'); 3700 this._map = null 3701 }, 3702 _requestUpdate: function() { 3703 if (this._map && !L.Path._updateRequest) { 3704 L.Path._updateRequest = L.Util.requestAnimFrame(this._fireMapMoveEnd, this._map) 3705 } 3706 }, 3707 _fireMapMoveEnd: function() { 3708 L.Path._updateRequest = null; 3709 this.fire('moveend') 3710 }, 3711 _initElements: function() { 3712 this._map._initPathRoot(); 3713 this._ctx = this._map._canvasCtx 3714 }, 3715 _updateStyle: function() { 3716 var options = this.options; 3717 if (options.stroke) { 3718 this._ctx.lineWidth = options.weight; 3719 this._ctx.strokeStyle = options.color 3720 } 3721 if (options.fill) { 3722 this._ctx.fillStyle = options.fillColor || options.color 3723 } 3724 }, 3725 _drawPath: function() { 3726 var i, j, len, len2, point, drawMethod; 3727 this._ctx.beginPath(); 3728 for (i = 0, len = this._parts.length; i < len; i++) { 3729 for (j = 0, len2 = this._parts[i].length; j < len2; j++) { 3730 point = this._parts[i][j]; 3731 drawMethod = (j === 0 ? 'move' : 'line') + 'To'; 3732 this._ctx[drawMethod](point.x, point.y) 3733 } 3734 if (this instanceof L.Polygon) { 3735 this._ctx.closePath() 3736 } 3737 } 3738 }, 3739 _checkIfEmpty: function() { 3740 return !this._parts.length 3741 }, 3742 _updatePath: function() { 3743 if (this._checkIfEmpty()) { 3744 return 3745 } 3746 var ctx = this._ctx, 3747 options = this.options; 3748 this._drawPath(); 3749 ctx.save(); 3750 this._updateStyle(); 3751 if (options.fill) { 3752 ctx.globalAlpha = options.fillOpacity; 3753 ctx.fill() 3754 } 3755 if (options.stroke) { 3756 ctx.globalAlpha = options.opacity; 3757 ctx.stroke() 3758 } 3759 ctx.restore() 3760 }, 3761 _initEvents: function() { 3762 if (this.options.clickable) { 3763 this._map.on('mousemove', this._onMouseMove, this); 3764 this._map.on('click', this._onClick, this) 3765 } 3766 }, 3767 _onClick: function(e) { 3768 if (this._containsPoint(e.layerPoint)) { 3769 this.fire('click', e) 3770 } 3771 }, 3772 _onMouseMove: function(e) { 3773 if (!this._map || this._map._animatingZoom) { 3774 return 3775 } 3776 if (this._containsPoint(e.layerPoint)) { 3777 this._ctx.canvas.style.cursor = 'pointer'; 3778 this._mouseInside = true; 3779 this.fire('mouseover', e) 3780 } else if (this._mouseInside) { 3781 this._ctx.canvas.style.cursor = ''; 3782 this._mouseInside = false; 3783 this.fire('mouseout', e) 3784 } 3785 } 3786 }); 3787 L.Map.include((L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? {} : { 3788 _initPathRoot: function() { 3789 var root = this._pathRoot, 3790 ctx; 3791 if (!root) { 3792 root = this._pathRoot = document.createElement('canvas'); 3793 root.style.position = 'absolute'; 3794 ctx = this._canvasCtx = root.getContext('2d'); 3795 ctx.lineCap = 'round'; 3796 ctx.lineJoin = 'round'; 3797 this._panes.overlayPane.appendChild(root); 3798 if (this.options.zoomAnimation) { 3799 this._pathRoot.className = 'leaflet-zoom-animated'; 3800 this.on('zoomanim', this._animatePathZoom); 3801 this.on('zoomend', this._endPathZoom) 3802 } 3803 this.on('moveend', this._updateCanvasViewport); 3804 this._updateCanvasViewport() 3805 } 3806 }, 3807 _updateCanvasViewport: function() { 3808 if (this._pathZooming) { 3809 return 3810 } 3811 this._updatePathViewport(); 3812 var vp = this._pathViewport, 3813 min = vp.min, 3814 size = vp.max.subtract(min), 3815 root = this._pathRoot; 3816 L.DomUtil.setPosition(root, min); 3817 root.width = size.x; 3818 root.height = size.y; 3819 root.getContext('2d').translate(-min.x, -min.y) 3820 } 3821 }); 3822 L.LineUtil = { 3823 simplify: function(points, tolerance) { 3824 if (!tolerance || !points.length) { 3825 return points.slice() 3826 } 3827 var sqTolerance = tolerance * tolerance; 3828 points = this._reducePoints(points, sqTolerance); 3829 points = this._simplifyDP(points, sqTolerance); 3830 return points 3831 }, 3832 pointToSegmentDistance: function(p, p1, p2) { 3833 return Math.sqrt(this._sqClosestPointOnSegment(p, p1, p2, true)) 3834 }, 3835 closestPointOnSegment: function(p, p1, p2) { 3836 return this._sqClosestPointOnSegment(p, p1, p2) 3837 }, 3838 _simplifyDP: function(points, sqTolerance) { 3839 var len = points.length, 3840 ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array, 3841 markers = new ArrayConstructor(len); 3842 markers[0] = markers[len - 1] = 1; 3843 this._simplifyDPStep(points, markers, sqTolerance, 0, len - 1); 3844 var i, newPoints = []; 3845 for (i = 0; i < len; i++) { 3846 if (markers[i]) { 3847 newPoints.push(points[i]) 3848 } 3849 } 3850 return newPoints 3851 }, 3852 _simplifyDPStep: function(points, markers, sqTolerance, first, last) { 3853 var maxSqDist = 0, 3854 index, i, sqDist; 3855 for (i = first + 1; i <= last - 1; i++) { 3856 sqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true); 3857 if (sqDist > maxSqDist) { 3858 index = i; 3859 maxSqDist = sqDist 3860 } 3861 } 3862 if (maxSqDist > sqTolerance) { 3863 markers[index] = 1; 3864 this._simplifyDPStep(points, markers, sqTolerance, first, index); 3865 this._simplifyDPStep(points, markers, sqTolerance, index, last) 3866 } 3867 }, 3868 _reducePoints: function(points, sqTolerance) { 3869 var reducedPoints = [points[0]]; 3870 for (var i = 1, prev = 0, len = points.length; i < len; i++) { 3871 if (this._sqDist(points[i], points[prev]) > sqTolerance) { 3872 reducedPoints.push(points[i]); 3873 prev = i 3874 } 3875 } 3876 if (prev < len - 1) { 3877 reducedPoints.push(points[len - 1]) 3878 } 3879 return reducedPoints 3880 }, 3881 clipSegment: function(a, b, bounds, useLastCode) { 3882 var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds), 3883 codeB = this._getBitCode(b, bounds), 3884 codeOut, p, newCode; 3885 this._lastCode = codeB; 3886 while (true) { 3887 if (!(codeA | codeB)) { 3888 return [a, b] 3889 } else if (codeA & codeB) { 3890 return false 3891 } else { 3892 codeOut = codeA || codeB;
3893 p = this._getEdgeIntersection(a, b, codeOut, bounds); 3894 newCode = this._getBitCode(p, bounds); 3895 if (codeOut === codeA) { 3896 a = p; 3897 codeA = newCode 3898 } else { 3899 b = p; 3900 codeB = newCode 3901 } 3902 } 3903 } 3904 }, 3905 _getEdgeIntersection: function(a, b, code, bounds) { 3906 var dx = b.x - a.x, 3907 dy = b.y - a.y, 3908 min = bounds.min, 3909 max = bounds.max; 3910 if (code & 8) { 3911 return new L.Point(a.x + dx * (max.y - a.y) / dy, max.y) 3912 } else if (code & 4) { 3913 return new L.Point(a.x + dx * (min.y - a.y) / dy, min.y) 3914 } else if (code & 2) { 3915 return new L.Point(max.x, a.y + dy * (max.x - a.x) / dx) 3916 } else if (code & 1) { 3917 return new L.Point(min.x, a.y + dy * (min.x - a.x) / dx) 3918 } 3919 }, 3920 _getBitCode: function(p, bounds) { 3921 var code = 0; 3922 if (p.x < bounds.min.x) { 3923 code |= 1 3924 } else if (p.x > bounds.max.x) { 3925 code |= 2 3926 } 3927 if (p.y < bounds.min.y) { 3928 code |= 4 3929 } else if (p.y > bounds.max.y) { 3930 code |= 8 3931 } 3932 return code 3933 }, 3934 _sqDist: function(p1, p2) { 3935 var dx = p2.x - p1.x, 3936 dy = p2.y - p1.y; 3937 return dx * dx + dy * dy 3938 }, 3939 _sqClosestPointOnSegment: function(p, p1, p2, sqDist) { 3940 var x = p1.x, 3941 y = p1.y, 3942 dx = p2.x - x, 3943 dy = p2.y - y, 3944 dot = dx * dx + dy * dy, 3945 t; 3946 if (dot > 0) { 3947 t = ((p.x - x) * dx + (p.y - y) * dy) / dot; 3948 if (t > 1) { 3949 x = p2.x; 3950 y = p2.y 3951 } else if (t > 0) { 3952 x += dx * t; 3953 y += dy * t 3954 } 3955 } 3956 dx = p.x - x; 3957 dy = p.y - y; 3958 return sqDist ? dx * dx + dy * dy : new L.Point(x, y) 3959 } 3960 }; 3961 L.Polyline = L.Path.extend({ 3962 initialize: function(latlngs, options) { 3963 L.Path.prototype.initialize.call(this, options); 3964 this._latlngs = this._convertLatLngs(latlngs) 3965 }, 3966 options: { 3967 smoothFactor: 1.0, 3968 noClip: false 3969 }, 3970 projectLatlngs: function() { 3971 this._originalPoints = []; 3972 for (var i = 0, len = this._latlngs.length; i < len; i++) { 3973 this._originalPoints[i] = this._map.latLngToLayerPoint(this._latlngs[i]) 3974 } 3975 }, 3976 getPathString: function() { 3977 for (var i = 0, len = this._parts.length, str = ''; i < len; i++) { 3978 str += this._getPathPartStr(this._parts[i]) 3979 } 3980 return str 3981 }, 3982 getLatLngs: function() { 3983 return this._latlngs 3984 }, 3985 setLatLngs: function(latlngs) { 3986 this._latlngs = this._convertLatLngs(latlngs); 3987 return this.redraw() 3988 }, 3989 addLatLng: function(latlng) { 3990 this._latlngs.push(L.latLng(latlng)); 3991 return this.redraw() 3992 }, 3993 spliceLatLngs: function() { 3994 var removed = [].splice.apply(this._latlngs, arguments); 3995 this._convertLatLngs(this._latlngs, true); 3996 this.redraw(); 3997 return removed 3998 }, 3999 closestLayerPoint: function(p) { 4000 var minDistance = Infinity, 4001 parts = this._parts, 4002 p1, p2, minPoint = null; 4003 for (var j = 0, jLen = parts.length; j < jLen; j++) { 4004 var points = parts[j]; 4005 for (var i = 1, len = points.length; i < len; i++) { 4006 p1 = points[i - 1]; 4007 p2 = points[i]; 4008 var sqDist = L.LineUtil._sqClosestPointOnSegment(p, p1, p2, true); 4009 if (sqDist < minDistance) { 4010 minDistance = sqDist; 4011 minPoint = L.LineUtil._sqClosestPointOnSegment(p, p1, p2) 4012 } 4013 } 4014 } 4015 if (minPoint) { 4016 minPoint.distance = Math.sqrt(minDistance) 4017 } 4018 return minPoint 4019 }, 4020 getBounds: function() { 4021 return new L.LatLngBounds(this.getLatLngs()) 4022 }, 4023 _convertLatLngs: function(latlngs, overwrite) { 4024 var i, len, target = overwrite ? latlngs : []; 4025 for (i = 0, len = latlngs.length; i < len; i++) { 4026 if (L.Util.isArray(latlngs[i]) && typeof latlngs[i][0] !== 'number') { 4027 return 4028 } 4029 target[i] = L.latLng(latlngs[i]) 4030 } 4031 return target 4032 }, 4033 _initEvents: function() { 4034 L.Path.prototype._initEvents.call(this) 4035 }, 4036 _getPathPartStr: function(points) { 4037 var round = L.Path.VML; 4038 for (var j = 0, len2 = points.length, str = '', p; j < len2; j++) { 4039 p = points[j];
4040 if (round) { 4041 p._round() 4042 } 4043 str += (j ? 'L' : 'M') + p.x + ' ' + p.y 4044 } 4045 return str 4046 }, 4047 _clipPoints: function() { 4048 var points = this._originalPoints, 4049 len = points.length, 4050 i, k, segment; 4051 if (this.options.noClip) { 4052 this._parts = [points]; 4053 return 4054 } 4055 this._parts = []; 4056 var parts = this._parts, 4057 vp = this._map._pathViewport, 4058 lu = L.LineUtil; 4059 for (i = 0, k = 0; i < len - 1; i++) { 4060 segment = lu.clipSegment(points[i], points[i + 1], vp, i); 4061 if (!segment) { 4062 continue 4063 } 4064 parts[k] = parts[k] || []; 4065 parts[k].push(segment[0]); 4066 if ((segment[1] !== points[i + 1]) || (i === len - 2)) { 4067 parts[k].push(segment[1]); 4068 k++ 4069 } 4070 } 4071 }, 4072 _simplifyPoints: function() { 4073 var parts = this._parts, 4074 lu = L.LineUtil; 4075 for (var i = 0, len = parts.length; i < len; i++) { 4076 parts[i] = lu.simplify(parts[i], this.options.smoothFactor) 4077 } 4078 }, 4079 _updatePath: function() { 4080 if (!this._map) { 4081 return 4082 } 4083 this._clipPoints();
4084 this._simplifyPoints(); 4085 L.Path.prototype._updatePath.call(this) 4086 } 4087 }); 4088 L.polyline = function(latlngs, options) { 4089 return new L.Polyline(latlngs, options) 4090 }; 4091 L.PolyUtil = {}; 4092 L.PolyUtil.clipPolygon = function(points, bounds) { 4093 var clippedPoints, edges = [1, 4, 2, 8], 4094 i, j, k, a, b, len, edge, p, lu = L.LineUtil; 4095 for (i = 0, len = points.length; i < len; i++) { 4096 points[i]._code = lu._getBitCode(points[i], bounds) 4097 } 4098 for (k = 0; k < 4; k++) { 4099 edge = edges[k]; 4100 clippedPoints = []; 4101 for (i = 0, len = points.length, j = len - 1; i < len; j = i++) { 4102 a = points[i]; 4103 b = points[j]; 4104 if (!(a._code & edge)) { 4105 if (b._code & edge) { 4106 p = lu._getEdgeIntersection(b, a, edge, bounds); 4107 p._code = lu._getBitCode(p, bounds); 4108 clippedPoints.push(p) 4109 } 4110 clippedPoints.push(a) 4111 } else if (!(b._code & edge)) { 4112 p = lu._getEdgeIntersection(b, a, edge, bounds); 4113 p._code = lu._getBitCode(p, bounds); 4114 clippedPoints.push(p) 4115 } 4116 } 4117 points = clippedPoints 4118 } 4119 return points 4120 }; 4121 L.Polygon = L.Polyline.extend({ 4122 options: { 4123 fill: true 4124 }, 4125 initialize: function(latlngs, options) { 4126 L.Polyline.prototype.initialize.call(this, latlngs, options); 4127 this._initWithHoles(latlngs) 4128 }, 4129 _initWithHoles: function(latlngs) { 4130 var i, len, hole; 4131 if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) { 4132 this._latlngs = this._convertLatLngs(latlngs[0]); 4133 this._holes = latlngs.slice(1); 4134 for (i = 0, len = this._holes.length; i < len; i++) { 4135 hole = this._holes[i] = this._convertLatLngs(this._holes[i]); 4136 if (hole[0].equals(hole[hole.length - 1])) { 4137 hole.pop() 4138 } 4139 } 4140 } 4141 latlngs = this._latlngs; 4142 if (latlngs.length >= 2 && latlngs[0].equals(latlngs[latlngs.length - 1])) { 4143 latlngs.pop() 4144 } 4145 }, 4146 projectLatlngs: function() { 4147 L.Polyline.prototype.projectLatlngs.call(this); 4148 this._holePoints = []; 4149 if (!this._holes) { 4150 return 4151 } 4152 var i, j, len, len2; 4153 for (i = 0, len = this._holes.length; i < len; i++) { 4154 this._holePoints[i] = []; 4155 for (j = 0, len2 = this._holes[i].length; j < len2; j++) { 4156 this._holePoints[i][j] = this._map.latLngToLayerPoint(this._holes[i][j]) 4157 } 4158 } 4159 }, 4160 setLatLngs: function(latlngs) { 4161 if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) { 4162 this._initWithHoles(latlngs); 4163 return this.redraw() 4164 } else { 4165 return L.Polyline.prototype.setLatLngs.call(this, latlngs) 4166 } 4167 }, 4168 _clipPoints: function() { 4169 var points = this._originalPoints, 4170 newParts = []; 4171 this._parts = [points].concat(this._holePoints); 4172 if (this.options.noClip) { 4173 return 4174 } 4175 for (var i = 0, len = this._parts.length; i < len; i++) { 4176 var clipped = L.PolyUtil.clipPolygon(this._parts[i], this._map._pathViewport); 4177 if (clipped.length) { 4178 newParts.push(clipped) 4179 } 4180 } 4181 this._parts = newParts 4182 }, 4183 _getPathPartStr: function(points) { 4184 var str = L.Polyline.prototype._getPathPartStr.call(this, points); 4185 return str + (L.Browser.svg ? 'z' : 'x') 4186 } 4187 }); 4188 L.polygon = function(latlngs, options) { 4189 return new L.Polygon(latlngs, options) 4190 }; 4191 (function() { 4192 function createMulti(Klass) { 4193 return L.FeatureGroup.extend({ 4194 initialize: function(latlngs, options) { 4195 this._layers = {}; 4196 this._options = options; 4197 this.setLatLngs(latlngs) 4198 }, 4199 setLatLngs: function(latlngs) { 4200 var i = 0, 4201 len = latlngs.length; 4202 this.eachLayer(function(layer) { 4203 if (i < len) { 4204 layer.setLatLngs(latlngs[i++]) 4205 } else { 4206 this.removeLayer(layer) 4207 } 4208 }, this); 4209 while (i < len) { 4210 this.addLayer(new Klass(latlngs[i++], this._options)) 4211 } 4212 return this 4213 }, 4214 getLatLngs: function() { 4215 var latlngs = []; 4216 this.eachLayer(function(layer) { 4217 latlngs.push(layer.getLatLngs()) 4218 }); 4219 return latlngs 4220 } 4221 }) 4222 } 4223 L.MultiPolyline = createMulti(L.Polyline); 4224 L.MultiPolygon = createMulti(L.Polygon); 4225 L.multiPolyline = function(latlngs, options) { 4226 return new L.MultiPolyline(latlngs, options) 4227 }; 4228 L.multiPolygon = function(latlngs, options) { 4229 return new L.MultiPolygon(latlngs, options) 4230 } 4231 }()); 4232 L.Rectangle = L.Polygon.extend({ 4233 initialize: function(latLngBounds, options) { 4234 L.Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options) 4235 }, 4236 setBounds: function(latLngBounds) { 4237 this.setLatLngs(this._boundsToLatLngs(latLngBounds)) 4238 }, 4239 _boundsToLatLngs: function(latLngBounds) { 4240 latLngBounds = L.latLngBounds(latLngBounds);
4241 return [latLngBounds.getSouthWest(), latLngBounds.getNorthWest(), latLngBounds.getNorthEast(), latLngBounds.getSouthEast()] 4242 } 4243 }); 4244 L.rectangle = function(latLngBounds, options) { 4245 return new L.Rectangle(latLngBounds, options) 4246 }; 4247 L.Circle = L.Path.extend({ 4248 initialize: function(latlng, radius, options) { 4249 L.Path.prototype.initialize.call(this, options); 4250 this._latlng = L.latLng(latlng); 4251 this._mRadius = radius 4252 }, 4253 options: { 4254 fill: true 4255 }, 4256 setLatLng: function(latlng) { 4257 this._latlng = L.latLng(latlng); 4258 return this.redraw() 4259 }, 4260 setRadius: function(radius) { 4261 this._mRadius = radius; 4262 return this.redraw() 4263 }, 4264 projectLatlngs: function() { 4265 var lngRadius = this._getLngRadius(), 4266 latlng = this._latlng, 4267 pointLeft = this._map.latLngToLayerPoint([latlng.lat, latlng.lng - lngRadius]); 4268 this._point = this._map.latLngToLayerPoint(latlng); 4269 this._radius = Math.max(this._point.x - pointLeft.x, 1) 4270 }, 4271 getBounds: function() { 4272 var lngRadius = this._getLngRadius(), 4273 latRadius = (this._mRadius / 40075017) * 360, 4274 latlng = this._latlng; 4275 return new L.LatLngBounds([latlng.lat - latRadius, latlng.lng - lngRadius], [latlng.lat + latRadius, latlng.lng + lngRadius]) 4276 }, 4277 getLatLng: function() { 4278 return this._latlng 4279 }, 4280 getPathString: function() { 4281 var p = this._point, 4282 r = this._radius; 4283 if (this._checkIfEmpty()) { 4284 return '' 4285 } 4286 if (L.Browser.svg) { 4287 return 'M' + p.x + ',' + (p.y - r) + 'A' + r + ',' + r + ',0,1,1,' + (p.x - 0.1) + ',' + (p.y - r) + ' z' 4288 } else { 4289 p._round(); 4290 r = Math.round(r); 4291 return 'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r + ' 0,' + (65535 * 360) 4292 } 4293 }, 4294 getRadius: function() { 4295 return this._mRadius 4296 }, 4297 _getLatRadius: function() { 4298 return (this._mRadius / 40075017) * 360 4299 }, 4300 _getLngRadius: function() { 4301 return this._getLatRadius() / Math.cos(L.LatLng.DEG_TO_RAD * this._latlng.lat) 4302 }, 4303 _checkIfEmpty: function() { 4304 if (!this._map) { 4305 return false 4306 } 4307 var vp = this._map._pathViewport, 4308 r = this._radius, 4309 p = this._point; 4310 return p.x - r > vp.max.x || p.y - r > vp.max.y || p.x + r < vp.min.x || p.y + r < vp.min.y 4311 } 4312 }); 4313 L.circle = function(latlng, radius, options) { 4314 return new L.Circle(latlng, radius, options) 4315 }; 4316 L.CircleMarker = L.Circle.extend({ 4317 options: { 4318 radius: 10, 4319 weight: 2 4320 }, 4321 initialize: function(latlng, options) { 4322 L.Circle.prototype.initialize.call(this, latlng, null, options); 4323 this._radius = this.options.radius 4324 }, 4325 projectLatlngs: function() { 4326 this._point = this._map.latLngToLayerPoint(this._latlng) 4327 }, 4328 _updateStyle: function() { 4329 L.Circle.prototype._updateStyle.call(this); 4330 this.setRadius(this.options.radius) 4331 }, 4332 setLatLng: function(latlng) { 4333 L.Circle.prototype.setLatLng.call(this, latlng); 4334 if (this._popup && this._popup._isOpen) { 4335 this._popup.setLatLng(latlng) 4336 } 4337 return this 4338 }, 4339 setRadius: function(radius) { 4340 this.options.radius = this._radius = radius; 4341 return this.redraw() 4342 }, 4343 getRadius: function() { 4344 return this._radius 4345 } 4346 }); 4347 L.circleMarker = function(latlng, options) { 4348 return new L.CircleMarker(latlng, options) 4349 }; 4350 L.Polyline.include(!L.Path.CANVAS ? {} : { 4351 _containsPoint: function(p, closed) { 4352 var i, j, k, len, len2, dist, part, w = this.options.weight / 2; 4353 if (L.Browser.touch) { 4354 w += 10 4355 } 4356 for (i = 0, len = this._parts.length; i < len; i++) { 4357 part = this._parts[i]; 4358 for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { 4359 if (!closed && (j === 0)) { 4360 continue 4361 } 4362 dist = L.LineUtil.pointToSegmentDistance(p, part[k], part[j]); 4363 if (dist <= w) { 4364 return true 4365 } 4366 } 4367 } 4368 return false 4369 } 4370 }); 4371 L.Polygon.include(!L.Path.CANVAS ? {} : { 4372 _containsPoint: function(p) { 4373 var inside = false, 4374 part, p1, p2, i, j, k, len, len2; 4375 if (L.Polyline.prototype._containsPoint.call(this, p, true)) { 4376 return true 4377 } 4378 for (i = 0, len = this._parts.length; i < len; i++) { 4379 part = this._parts[i];
4380 for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) { 4381 p1 = part[j]; 4382 p2 = part[k]; 4383 if (((p1.y > p.y) !== (p2.y > p.y)) && (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) { 4384 inside = !inside 4385 } 4386 } 4387 } 4388 return inside 4389 } 4390 }); 4391 L.Circle.include(!L.Path.CANVAS ? {} : { 4392 _drawPath: function() { 4393 var p = this._point; 4394 this._ctx.beginPath(); 4395 this._ctx.arc(p.x, p.y, this._radius, 0, Math.PI * 2, false) 4396 }, 4397 _containsPoint: function(p) { 4398 var center = this._point, 4399 w2 = this.options.stroke ? this.options.weight / 2 : 0; 4400 return (p.distanceTo(center) <= this._radius + w2) 4401 } 4402 }); 4403 L.CircleMarker.include(!L.Path.CANVAS ? {} : { 4404 _updateStyle: function() { 4405 L.Path.prototype._updateStyle.call(this) 4406 } 4407 }); 4408 L.GeoJSON = L.FeatureGroup.extend({ 4409 initialize: function(geojson, options) { 4410 L.setOptions(this, options); 4411 this._layers = {}; 4412 if (geojson) { 4413 this.addData(geojson) 4414 } 4415 }, 4416 addData: function(geojson) { 4417 var features = L.Util.isArray(geojson) ? geojson : geojson.features, 4418 i, len, feature; 4419 if (features) { 4420 for (i = 0, len = features.length; i < len; i++) { 4421 feature = features[i]; 4422 if (feature.geometries || feature.geometry || feature.features || feature.coordinates) { 4423 this.addData(features[i]) 4424 } 4425 } 4426 return this 4427 } 4428 var options = this.options; 4429 if (options.filter && !options.filter(geojson)) { 4430 return 4431 } 4432 var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer, options.coordsToLatLng, options); 4433 layer.feature = L.GeoJSON.asFeature(geojson); 4434 layer.defaultOptions = layer.options; 4435 this.resetStyle(layer); 4436 if (options.onEachFeature) { 4437 options.onEachFeature(geojson, layer) 4438 } 4439 return this.addLayer(layer) 4440 }, 4441 resetStyle: function(layer) { 4442 var style = this.options.style; 4443 if (style) { 4444 L.Util.extend(layer.options, layer.defaultOptions); 4445 this._setLayerStyle(layer, style) 4446 } 4447 }, 4448 setStyle: function(style) { 4449 this.eachLayer(function(layer) { 4450 this._setLayerStyle(layer, style) 4451 }, this) 4452 }, 4453 _setLayerStyle: function(layer, style) { 4454 if (typeof style === 'function') { 4455 style = style(layer.feature) 4456 } 4457 if (layer.setStyle) { 4458 layer.setStyle(style) 4459 } 4460 } 4461 }); 4462 L.extend(L.GeoJSON, { 4463 geometryToLayer: function(geojson, pointToLayer, coordsToLatLng, vectorOptions) { 4464 var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson, 4465 coords = geometry.coordinates, 4466 layers = [], 4467 latlng, latlngs, i, len; 4468 coordsToLatLng = coordsToLatLng || this.coordsToLatLng; 4469 switch (geometry.type) { 4470 case 'Point': 4471 latlng = coordsToLatLng(coords); 4472 return pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng); 4473 case 'MultiPoint': 4474 for (i = 0, len = coords.length; i < len; i++) { 4475 latlng = coordsToLatLng(coords[i]); 4476 layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng)) 4477 } 4478 return new L.FeatureGroup(layers); 4479 case 'LineString': 4480 latlngs = this.coordsToLatLngs(coords, 0, coordsToLatLng); 4481 return new L.Polyline(latlngs, vectorOptions); 4482 case 'Polygon': 4483 if (coords.length === 2 && !coords[1].length) { 4484 throw new Error('Invalid GeoJSON object.') 4485 } 4486 latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng); 4487 return new L.Polygon(latlngs, vectorOptions); 4488 case 'MultiLineString': 4489 latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng); 4490 return new L.MultiPolyline(latlngs, vectorOptions); 4491 case 'MultiPolygon': 4492 latlngs = this.coordsToLatLngs(coords, 2, coordsToLatLng); 4493 return new L.MultiPolygon(latlngs, vectorOptions); 4494 case 'GeometryCollection': 4495 for (i = 0, len = geometry.geometries.length; i < len; i++) { 4496 layers.push(this.geometryToLayer({ 4497 geometry: geometry.geometries[i], 4498 type: 'Feature', 4499 properties: geojson.properties 4500 }, pointToLayer, coordsToLatLng, vectorOptions)) 4501 } 4502 return new L.FeatureGroup(layers); 4503 default: 4504 throw new Error('Invalid GeoJSON object.') 4505 } 4506 }, 4507 coordsToLatLng: function(coords) { 4508 return new L.LatLng(coords[1], coords[0], coords[2]) 4509 }, 4510 coordsToLatLngs: function(coords, levelsDeep, coordsToLatLng) { 4511 var latlng, i, len, latlngs = [];
4512 for (i = 0, len = coords.length; i < len; i++) { 4513 latlng = levelsDeep ? this.coordsToLatLngs(coords[i], levelsDeep - 1, coordsToLatLng) : (coordsToLatLng || this.coordsToLatLng)(coords[i]); 4514 latlngs.push(latlng) 4515 } 4516 return latlngs 4517 }, 4518 latLngToCoords: function(latlng) { 4519 var coords = [latlng.lng, latlng.lat]; 4520 if (latlng.alt !== undefined) { 4521 coords.push(latlng.alt) 4522 } 4523 return coords 4524 }, 4525 latLngsToCoords: function(latLngs) { 4526 var coords = []; 4527 for (var i = 0, len = latLngs.length; i < len; i++) { 4528 coords.push(L.GeoJSON.latLngToCoords(latLngs[i])) 4529 } 4530 return coords 4531 }, 4532 getFeature: function(layer, newGeometry) { 4533 return layer.feature ? L.extend({}, layer.feature, { 4534 geometry: newGeometry 4535 }) : L.GeoJSON.asFeature(newGeometry) 4536 }, 4537 asFeature: function(geoJSON) { 4538 if (geoJSON.type === 'Feature') { 4539 return geoJSON 4540 } 4541 return { 4542 type: 'Feature', 4543 properties: {}, 4544 geometry: geoJSON 4545 } 4546 } 4547 }); 4548 var PointToGeoJSON = { 4549 toGeoJSON: function() { 4550 return L.GeoJSON.getFeature(this, { 4551 type: 'Point', 4552 coordinates: L.GeoJSON.latLngToCoords(this.getLatLng()) 4553 }) 4554 } 4555 }; 4556 L.Marker.include(PointToGeoJSON); 4557 L.Circle.include(PointToGeoJSON); 4558 L.CircleMarker.include(PointToGeoJSON); 4559 L.Polyline.include({ 4560 toGeoJSON: function() { 4561 return L.GeoJSON.getFeature(this, { 4562 type: 'LineString', 4563 coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs()) 4564 }) 4565 } 4566 }); 4567 L.Polygon.include({ 4568 toGeoJSON: function() { 4569 var coords = [L.GeoJSON.latLngsToCoords(this.getLatLngs())], 4570 i, len, hole; 4571 coords[0].push(coords[0][0]); 4572 if (this._holes) { 4573 for (i = 0, len = this._holes.length; i < len; i++) { 4574 hole = L.GeoJSON.latLngsToCoords(this._holes[i]); 4575 hole.push(hole[0]); 4576 coords.push(hole) 4577 } 4578 } 4579 return L.GeoJSON.getFeature(this, { 4580 type: 'Polygon', 4581 coordinates: coords 4582 }) 4583 } 4584 }); 4585 (function() { 4586 function multiToGeoJSON(type) { 4587 return function() { 4588 var coords = []; 4589 this.eachLayer(function(layer) { 4590 coords.push(layer.toGeoJSON().geometry.coordinates) 4591 }); 4592 return L.GeoJSON.getFeature(this, { 4593 type: type, 4594 coordinates: coords 4595 }) 4596 } 4597 } 4598 L.MultiPolyline.include({ 4599 toGeoJSON: multiToGeoJSON('MultiLineString') 4600 }); 4601 L.MultiPolygon.include({ 4602 toGeoJSON: multiToGeoJSON('MultiPolygon') 4603 }); 4604 L.LayerGroup.include({ 4605 toGeoJSON: function() { 4606 var geometry = this.feature && this.feature.geometry, 4607 jsons = [], 4608 json; 4609 if (geometry && geometry.type === 'MultiPoint') { 4610 return multiToGeoJSON('MultiPoint').call(this) 4611 } 4612 var isGeometryCollection = geometry && geometry.type === 'GeometryCollection'; 4613 this.eachLayer(function(layer) { 4614 if (layer.toGeoJSON) { 4615 json = layer.toGeoJSON(); 4616 jsons.push(isGeometryCollection ? json.geometry : L.GeoJSON.asFeature(json)) 4617 } 4618 }); 4619 if (isGeometryCollection) { 4620 return L.GeoJSON.getFeature(this, { 4621 geometries: jsons, 4622 type: 'GeometryCollection' 4623 }) 4624 } 4625 return { 4626 type: 'FeatureCollection', 4627 features: jsons 4628 } 4629 } 4630 }) 4631 }()); 4632 L.geoJson = function(geojson, options) { 4633 return new L.GeoJSON(geojson, options) 4634 }; 4635 L.DomEvent = { 4636 addListener: function(obj, type, fn, context) { 4637 var id = L.stamp(fn), 4638 key = '_leaflet_' + type + id, 4639 handler, originalHandler, newType; 4640 if (obj[key]) { 4641 return this 4642 } 4643 handler = function(e) { 4644 return fn.call(context || obj, e || L.DomEvent._getEvent()) 4645 }; 4646 if (L.Browser.pointer && type.indexOf('touch') === 0) { 4647 return this.addPointerListener(obj, type, handler, id) 4648 } 4649 if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) { 4650 this.addDoubleTapListener(obj, handler, id) 4651 } 4652 if ('addEventListener' in obj) { 4653 if (type === 'mousewheel') { 4654 obj.addEventListener('DOMMouseScroll', handler, false); 4655 obj.addEventListener(type, handler, false) 4656 } else if ((type === 'mouseenter') || (type === 'mouseleave')) { 4657 originalHandler = handler;
4658 newType = (type === 'mouseenter' ? 'mouseover' : 'mouseout'); 4659 handler = function(e) { 4660 if (!L.DomEvent._checkMouse(obj, e)) { 4661 return 4662 } 4663 return originalHandler(e) 4664 }; 4665 obj.addEventListener(newType, handler, false) 4666 } else if (type === 'click' && L.Browser.android) { 4667 originalHandler = handler; 4668 handler = function(e) { 4669 return L.DomEvent._filterClick(e, originalHandler) 4670 }; 4671 obj.addEventListener(type, handler, false) 4672 } else { 4673 obj.addEventListener(type, handler, false) 4674 } 4675 } else if ('attachEvent' in obj) { 4676 obj.attachEvent('on' + type, handler) 4677 } 4678 obj[key] = handler; 4679 return this 4680 }, 4681 removeListener: function(obj, type, fn) { 4682 var id = L.stamp(fn), 4683 key = '_leaflet_' + type + id, 4684 handler = obj[key]; 4685 if (!handler) { 4686 return this 4687 } 4688 if (L.Browser.pointer && type.indexOf('touch') === 0) { 4689 this.removePointerListener(obj, type, id) 4690 } else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) { 4691 this.removeDoubleTapListener(obj, id) 4692 } else if ('removeEventListener' in obj) { 4693 if (type === 'mousewheel') { 4694 obj.removeEventListener('DOMMouseScroll', handler, false); 4695 obj.removeEventListener(type, handler, false) 4696 } else if ((type === 'mouseenter') || (type === 'mouseleave')) { 4697 obj.removeEventListener((type === 'mouseenter' ? 'mouseover' : 'mouseout'), handler, false) 4698 } else { 4699 obj.removeEventListener(type, handler, false) 4700 } 4701 } else if ('detachEvent' in obj) { 4702 obj.detachEvent('on' + type, handler) 4703 } 4704 obj[key] = null; 4705 return this 4706 }, 4707 stopPropagation: function(e) { 4708 if (e.stopPropagation) { 4709 e.stopPropagation() 4710 } else { 4711 e.cancelBubble = true 4712 } 4713 L.DomEvent._skipped(e); 4714 return this 4715 }, 4716 disableScrollPropagation: function(el) { 4717 var stop = L.DomEvent.stopPropagation; 4718 return L.DomEvent.on(el, 'mousewheel', stop).on(el, 'MozMousePixelScroll', stop) 4719 }, 4720 disableClickPropagation: function(el) { 4721 var stop = L.DomEvent.stopPropagation; 4722 for (var i = L.Draggable.START.length - 1; i >= 0; i--) { 4723 L.DomEvent.on(el, L.Draggable.START[i], stop) 4724 } 4725 return L.DomEvent.on(el, 'click', L.DomEvent._fakeStop).on(el, 'dblclick', stop) 4726 }, 4727 preventDefault: function(e) { 4728 if (e.preventDefault) { 4729 e.preventDefault() 4730 } else { 4731 e.returnValue = false 4732 } 4733 return this 4734 }, 4735 stop: function(e) { 4736 return L.DomEvent.preventDefault(e).stopPropagation(e) 4737 }, 4738 getMousePosition: function(e, container) { 4739 if (!container) { 4740 return new L.Point(e.clientX, e.clientY) 4741 } 4742 var rect = container.getBoundingClientRect(); 4743 return new L.Point(e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop) 4744 }, 4745 getWheelDelta: function(e) { 4746 var delta = 0; 4747 if (e.wheelDelta) { 4748 delta = e.wheelDelta / 120 4749 } 4750 if (e.detail) { 4751 delta = -e.detail / 3 4752 } 4753 return delta 4754 }, 4755 _skipEvents: {}, 4756 _fakeStop: function(e) { 4757 L.DomEvent._skipEvents[e.type] = true 4758 }, 4759 _skipped: function(e) { 4760 var skipped = this._skipEvents[e.type]; 4761 this._skipEvents[e.type] = false; 4762 return skipped 4763 }, 4764 _checkMouse: function(el, e) { 4765 var related = e.relatedTarget; 4766 if (!related) { 4767 return true 4768 } 4769 try { 4770 while (related && (related !== el)) { 4771 related = related.parentNode 4772 } 4773 } catch (err) { 4774 return false 4775 } 4776 return (related !== el) 4777 }, 4778 _getEvent: function() { 4779 var e = window.event; 4780 if (!e) { 4781 var caller = arguments.callee.caller; 4782 while (caller) { 4783 e = caller['arguments'][0]; 4784 if (e && window.Event === e.constructor) { 4785 break 4786 } 4787 caller = caller.caller 4788 } 4789 } 4790 return e 4791 }, 4792 _filterClick: function(e, handler) { 4793 var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),
4794 elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick); 4795 if ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) { 4796 L.DomEvent.stop(e); 4797 return 4798 } 4799 L.DomEvent._lastClick = timeStamp; 4800 return handler(e) 4801 } 4802 }; 4803 L.DomEvent.on = L.DomEvent.addListener; 4804 L.DomEvent.off = L.DomEvent.removeListener; 4805 L.Draggable = L.Class.extend({ 4806 includes: L.Mixin.Events, 4807 statics: { 4808 START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'], 4809 END: { 4810 mousedown: 'mouseup', 4811 touchstart: 'touchend', 4812 pointerdown: 'touchend', 4813 MSPointerDown: 'touchend' 4814 }, 4815 MOVE: { 4816 mousedown: 'mousemove', 4817 touchstart: 'touchmove', 4818 pointerdown: 'touchmove', 4819 MSPointerDown: 'touchmove' 4820 } 4821 }, 4822 initialize: function(element, dragStartTarget) { 4823 this._element = element; 4824 this._dragStartTarget = dragStartTarget || element 4825 }, 4826 enable: function() { 4827 if (this._enabled) { 4828 return 4829 } 4830 for (var i = L.Draggable.START.length - 1; i >= 0; i--) { 4831 L.DomEvent.on(this._dragStartTarget, L.Draggable.START[i], this._onDown, this) 4832 } 4833 this._enabled = true 4834 }, 4835 disable: function() { 4836 if (!this._enabled) { 4837 return 4838 } 4839 for (var i = L.Draggable.START.length - 1; i >= 0; i--) { 4840 L.DomEvent.off(this._dragStartTarget, L.Draggable.START[i], this._onDown, this) 4841 } 4842 this._enabled = false; 4843 this._moved = false 4844 }, 4845 _onDown: function(e) { 4846 this._moved = false; 4847 if (e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { 4848 return 4849 } 4850 L.DomEvent.stopPropagation(e); 4851 if (L.Draggable._disabled) { 4852 return 4853 } 4854 L.DomUtil.disableImageDrag(); 4855 L.DomUtil.disableTextSelection(); 4856 if (this._moving) { 4857 return 4858 } 4859 var first = e.touches ? e.touches[0] : e; 4860 this._startPoint = new L.Point(first.clientX, first.clientY); 4861 this._startPos = this._newPos = L.DomUtil.getPosition(this._element); 4862 L.DomEvent.on(document, L.Draggable.MOVE[e.type], this._onMove, this).on(document, L.Draggable.END[e.type], this._onUp, this) 4863 }, 4864 _onMove: function(e) { 4865 if (e.touches && e.touches.length > 1) { 4866 this._moved = true; 4867 return 4868 } 4869 var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e), 4870 newPoint = new L.Point(first.clientX, first.clientY), 4871 offset = newPoint.subtract(this._startPoint); 4872 if (!offset.x && !offset.y) { 4873 return 4874 } 4875 if (L.Browser.touch && Math.abs(offset.x) + Math.abs(offset.y) < 3) { 4876 return 4877 } 4878 L.DomEvent.preventDefault(e); 4879 if (!this._moved) { 4880 this.fire('dragstart'); 4881 this._moved = true; 4882 this._startPos = L.DomUtil.getPosition(this._element).subtract(offset); 4883 L.DomUtil.addClass(document.body, 'leaflet-dragging'); 4884 this._lastTarget = e.target || e.srcElement; 4885 L.DomUtil.addClass(this._lastTarget, 'leaflet-drag-target') 4886 } 4887 this._newPos = this._startPos.add(offset); 4888 this._moving = true; 4889 L.Util.cancelAnimFrame(this._animRequest); 4890 this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true, this._dragStartTarget) 4891 }, 4892 _updatePosition: function() { 4893 this.fire('predrag'); 4894 L.DomUtil.setPosition(this._element, this._newPos); 4895 this.fire('drag') 4896 }, 4897 _onUp: function() { 4898 L.DomUtil.removeClass(document.body, 'leaflet-dragging'); 4899 if (this._lastTarget) { 4900 L.DomUtil.removeClass(this._lastTarget, 'leaflet-drag-target'); 4901 this._lastTarget = null 4902 } 4903 for (var i in L.Draggable.MOVE) { 4904 L.DomEvent.off(document, L.Draggable.MOVE[i], this._onMove).off(document, L.Draggable.END[i], this._onUp) 4905 } 4906 L.DomUtil.enableImageDrag(); 4907 L.DomUtil.enableTextSelection(); 4908 if (this._moved && this._moving) {
4909 L.Util.cancelAnimFrame(this._animRequest); 4910 this.fire('dragend', { 4911 distance: this._newPos.distanceTo(this._startPos) 4912 }) 4913 } 4914 this._moving = false 4915 } 4916 }); 4917 L.Handler = L.Class.extend({ 4918 initialize: function(map) { 4919 this._map = map 4920 }, 4921 enable: function() { 4922 if (this._enabled) { 4923 return 4924 } 4925 this._enabled = true; 4926 this.addHooks() 4927 }, 4928 disable: function() { 4929 if (!this._enabled) { 4930 return 4931 } 4932 this._enabled = false; 4933 this.removeHooks() 4934 }, 4935 enabled: function() { 4936 return !!this._enabled 4937 } 4938 }); 4939 L.Map.mergeOptions({ 4940 dragging: true, 4941 inertia: !L.Browser.android23, 4942 inertiaDeceleration: 3400, 4943 inertiaMaxSpeed: Infinity, 4944 inertiaThreshold: L.Browser.touch ? 32 : 18, 4945 easeLinearity: 0.25, 4946 worldCopyJump: false 4947 }); 4948 L.Map.Drag = L.Handler.extend({ 4949 addHooks: function() { 4950 if (!this._draggable) { 4951 var map = this._map; 4952 this._draggable = new L.Draggable(map._mapPane, map._container); 4953 this._draggable.on({ 4954 'dragstart': this._onDragStart, 4955 'drag': this._onDrag, 4956 'dragend': this._onDragEnd 4957 }, this); 4958 if (map.options.worldCopyJump) { 4959 this._draggable.on('predrag', this._onPreDrag, this); 4960 map.on('viewreset', this._onViewReset, this); 4961 map.whenReady(this._onViewReset, this) 4962 } 4963 } 4964 this._draggable.enable() 4965 }, 4966 removeHooks: function() { 4967 this._draggable.disable() 4968 }, 4969 moved: function() { 4970 return this._draggable && this._draggable._moved 4971 }, 4972 _onDragStart: function() { 4973 var map = this._map; 4974 if (map._panAnim) { 4975 map._panAnim.stop() 4976 } 4977 map.fire('movestart').fire('dragstart'); 4978 if (map.options.inertia) { 4979 this._positions = []; 4980 this._times = [] 4981 } 4982 }, 4983 _onDrag: function() { 4984 if (this._map.options.inertia) { 4985 var time = this._lastTime = +new Date(), 4986 pos = this._lastPos = this._draggable._newPos; 4987 this._positions.push(pos); 4988 this._times.push(time); 4989 if (time - this._times[0] > 200) { 4990 this._positions.shift(); 4991 this._times.shift() 4992 } 4993 } 4994 this._map.fire('move').fire('drag') 4995 }, 4996 _onViewReset: function() { 4997 var pxCenter = this._map.getSize()._divideBy(2), 4998 pxWorldCenter = this._map.latLngToLayerPoint([0, 0]); 4999 this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x; 5000 this._worldWidth = this._map.project([0, 180]).x 5001 }, 5002 _onPreDrag: function() { 5003 var worldWidth = this._worldWidth, 5004 halfWidth = Math.round(worldWidth / 2), 5005 dx = this._initialWorldOffset, 5006 x = this._draggable._newPos.x, 5007 newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx, 5008 newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx, 5009 newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2; 5010 this._draggable._newPos.x = newX 5011 }, 5012 _onDragEnd: function(e) { 5013 var map = this._map, 5014 options = map.options, 5015 delay = +new Date() - this._lastTime, 5016 noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0]; 5017 map.fire('dragend', e); 5018 if (noInertia) { 5019 map.fire('moveend') 5020 } else { 5021 var direction = this._lastPos.subtract(this._positions[0]), 5022 duration = (this._lastTime + delay - this._times[0]) / 1000, 5023 ease = options.easeLinearity, 5024 speedVector = direction.multiplyBy(ease / duration), 5025 speed = speedVector.distanceTo([0, 0]), 5026 limitedSpeed = Math.min(options.inertiaMaxSpeed, speed), 5027 limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed), 5028 decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease), 5029 offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round(); 5030 if (!offset.x || !offset.y) { 5031 map.fire('moveend') 5032 } else { 5033 offset = map._limitOffset(offset, map.options.maxBounds);
5034 L.Util.requestAnimFrame(function() { 5035 map.panBy(offset, { 5036 duration: decelerationDuration, 5037 easeLinearity: ease, 5038 noMoveStart: true 5039 }) 5040 }) 5041 } 5042 } 5043 } 5044 }); 5045 L.Map.addInitHook('addHandler', 'dragging', L.Map.Drag); 5046 L.Map.mergeOptions({ 5047 doubleClickZoom: true 5048 }); 5049 L.Map.DoubleClickZoom = L.Handler.extend({ 5050 addHooks: function() { 5051 this._map.on('dblclick', this._onDoubleClick, this) 5052 }, 5053 removeHooks: function() { 5054 this._map.off('dblclick', this._onDoubleClick, this) 5055 }, 5056 _onDoubleClick: function(e) { 5057 var map = this._map, 5058 zoom = map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1); 5059 if (map.options.doubleClickZoom === 'center') { 5060 map.setZoom(zoom) 5061 } else { 5062 map.setZoomAround(e.containerPoint, zoom) 5063 } 5064 } 5065 }); 5066 L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom); 5067 L.Map.mergeOptions({ 5068 scrollWheelZoom: true 5069 }); 5070 L.Map.ScrollWheelZoom = L.Handler.extend({ 5071 addHooks: function() { 5072 L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this); 5073 L.DomEvent.on(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault); 5074 this._delta = 0 5075 }, 5076 removeHooks: function() { 5077 L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll); 5078 L.DomEvent.off(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault) 5079 }, 5080 _onWheelScroll: function(e) { 5081 var delta = L.DomEvent.getWheelDelta(e); 5082 this._delta += delta; 5083 this._lastMousePos = this._map.mouseEventToContainerPoint(e); 5084 if (!this._startTime) { 5085 this._startTime = +new Date() 5086 } 5087 var left = Math.max(40 - (+new Date() - this._startTime), 0); 5088 clearTimeout(this._timer); 5089 this._timer = setTimeout(L.bind(this._performZoom, this), left); 5090 L.DomEvent.preventDefault(e); 5091 L.DomEvent.stopPropagation(e) 5092 }, 5093 _performZoom: function() { 5094 var map = this._map, 5095 delta = this._delta, 5096 zoom = map.getZoom(); 5097 delta = delta > 0 ? Math.ceil(delta) : Math.floor(delta); 5098 delta = Math.max(Math.min(delta, 4), -4); 5099 delta = map._limitZoom(zoom + delta) - zoom; 5100 this._delta = 0; 5101 this._startTime = null; 5102 if (!delta) { 5103 return 5104 } 5105 if (map.options.scrollWheelZoom === 'center') { 5106 map.setZoom(zoom + delta) 5107 } else { 5108 map.setZoomAround(this._lastMousePos, zoom + delta) 5109 } 5110 } 5111 }); 5112 L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom); 5113 L.extend(L.DomEvent, { 5114 _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart', 5115 _touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend', 5116 addDoubleTapListener: function(obj, handler, id) { 5117 var last, doubleTap = false, 5118 delay = 250, 5119 touch, pre = '_leaflet_', 5120 touchstart = this._touchstart, 5121 touchend = this._touchend, 5122 trackedTouches = []; 5123 5124 function onTouchStart(e) { 5125 var count; 5126 if (L.Browser.pointer) { 5127 trackedTouches.push(e.pointerId); 5128 count = trackedTouches.length 5129 } else { 5130 count = e.touches.length 5131 } 5132 if (count > 1) { 5133 return 5134 } 5135 var now = Date.now(), 5136 delta = now - (last || now); 5137 touch = e.touches ? e.touches[0] : e; 5138 doubleTap = (delta > 0 && delta <= delay); 5139 last = now 5140 } 5141 5142 function onTouchEnd(e) { 5143 if (L.Browser.pointer) { 5144 var idx = trackedTouches.indexOf(e.pointerId); 5145 if (idx === -1) { 5146 return 5147 } 5148 trackedTouches.splice(idx, 1) 5149 } 5150 if (doubleTap) { 5151 if (L.Browser.pointer) { 5152 var newTouch = {}, 5153 prop; 5154 for (var i in touch) { 5155 prop = touch[i]; 5156 if (typeof prop === 'function') { 5157 newTouch[i] = prop.bind(touch) 5158 } else { 5159 newTouch[i] = prop 5160 } 5161 } 5162 touch = newTouch 5163 } 5164 touch.type = 'dblclick'; 5165 handler(touch); 5166 last = null 5167 } 5168 } 5169 obj[pre + touchstart + id] = onTouchStart; 5170 obj[pre + touchend + id] = onTouchEnd; 5171 var endElement = L.Browser.pointer ? document.documentElement : obj; 5172 obj.addEventListener(touchstart, onTouchStart, false); 5173 endElement.addEventListener(touchend, onTouchEnd, false); 5174 if (L.Browser.pointer) { 5175 endElement.addEventListener(L.DomEvent.POINTER_CANCEL, onTouchEnd, false) 5176 } 5177 return this 5178 }, 5179 removeDoubleTapListener: function(obj, id) { 5180 var pre = '_leaflet_'; 5181 obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false); 5182 (L.Browser.pointer ? document.documentElement : obj).removeEventListener(this._touchend, obj[pre + this._touchend + id], false); 5183 if (L.Browser.pointer) { 5184 document.documentElement.removeEventListener(L.DomEvent.POINTER_CANCEL, obj[pre + this._touchend + id], false) 5185 } 5186 return this 5187 } 5188 }); 5189 L.extend(L.DomEvent, { 5190 POINTER_DOWN: L.Browser.msPointer ? 'MSPointerDown' : 'pointerdown',
5191 POINTER_MOVE: L.Browser.msPointer ? 'MSPointerMove' : 'pointermove', 5192 POINTER_UP: L.Browser.msPointer ? 'MSPointerUp' : 'pointerup', 5193 POINTER_CANCEL: L.Browser.msPointer ? 'MSPointerCancel' : 'pointercancel', 5194 _pointers: [], 5195 _pointerDocumentListener: false, 5196 addPointerListener: function(obj, type, handler, id) { 5197 switch (type) { 5198 case 'touchstart': 5199 return this.addPointerListenerStart(obj, type, handler, id); 5200 case 'touchend': 5201 return this.addPointerListenerEnd(obj, type, handler, id); 5202 case 'touchmove': 5203 return this.addPointerListenerMove(obj, type, handler, id); 5204 default: 5205 throw 'Unknown touch event type' 5206 } 5207 }, 5208 addPointerListenerStart: function(obj, type, handler, id) { 5209 var pre = '_leaflet_', 5210 pointers = this._pointers; 5211 var cb = function(e) { 5212 L.DomEvent.preventDefault(e); 5213 var alreadyInArray = false; 5214 for (var i = 0; i < pointers.length; i++) { 5215 if (pointers[i].pointerId === e.pointerId) { 5216 alreadyInArray = true; 5217 break 5218 } 5219 } 5220 if (!alreadyInArray) { 5221 pointers.push(e) 5222 } 5223 e.touches = pointers.slice(); 5224 e.changedTouches = [e]; 5225 handler(e) 5226 }; 5227 obj[pre + 'touchstart' + id] = cb; 5228 obj.addEventListener(this.POINTER_DOWN, cb, false); 5229 if (!this._pointerDocumentListener) { 5230 var internalCb = function(e) { 5231 for (var i = 0; i < pointers.length; i++) { 5232 if (pointers[i].pointerId === e.pointerId) { 5233 pointers.splice(i, 1); 5234 break 5235 } 5236 } 5237 }; 5238 document.documentElement.addEventListener(this.POINTER_UP, internalCb, false); 5239 document.documentElement.addEventListener(this.POINTER_CANCEL, internalCb, false); 5240 this._pointerDocumentListener = true 5241 } 5242 return this 5243 }, 5244 addPointerListenerMove: function(obj, type, handler, id) { 5245 var pre = '_leaflet_', 5246 touches = this._pointers; 5247 5248 function cb(e) { 5249 if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { 5250 return 5251 } 5252 for (var i = 0; i < touches.length; i++) { 5253 if (touches[i].pointerId === e.pointerId) { 5254 touches[i] = e; 5255 break 5256 } 5257 } 5258 e.touches = touches.slice(); 5259 e.changedTouches = [e]; 5260 handler(e) 5261 } 5262 obj[pre + 'touchmove' + id] = cb; 5263 obj.addEventListener(this.POINTER_MOVE, cb, false); 5264 return this 5265 }, 5266 addPointerListenerEnd: function(obj, type, handler, id) { 5267 var pre = '_leaflet_', 5268 touches = this._pointers; 5269 var cb = function(e) { 5270 for (var i = 0; i < touches.length; i++) { 5271 if (touches[i].pointerId === e.pointerId) { 5272 touches.splice(i, 1); 5273 break 5274 } 5275 } 5276 e.touches = touches.slice(); 5277 e.changedTouches = [e]; 5278 handler(e) 5279 }; 5280 obj[pre + 'touchend' + id] = cb; 5281 obj.addEventListener(this.POINTER_UP, cb, false); 5282 obj.addEventListener(this.POINTER_CANCEL, cb, false); 5283 return this 5284 }, 5285 removePointerListener: function(obj, type, id) { 5286 var pre = '_leaflet_', 5287 cb = obj[pre + type + id]; 5288 switch (type) { 5289 case 'touchstart': 5290 obj.removeEventListener(this.POINTER_DOWN, cb, false); 5291 break; 5292 case 'touchmove': 5293 obj.removeEventListener(this.POINTER_MOVE, cb, false); 5294 break; 5295 case 'touchend': 5296 obj.removeEventListener(this.POINTER_UP, cb, false); 5297 obj.removeEventListener(this.POINTER_CANCEL, cb, false); 5298 break 5299 } 5300 return this 5301 } 5302 }); 5303 L.Map.mergeOptions({ 5304 touchZoom: L.Browser.touch && !L.Browser.android23, 5305 bounceAtZoomLimits: true 5306 }); 5307 L.Map.TouchZoom = L.Handler.extend({ 5308 addHooks: function() { 5309 L.DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this) 5310 }, 5311 removeHooks: function() { 5312 L.DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this) 5313 }, 5314 _onTouchStart: function(e) { 5315 var map = this._map; 5316 if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { 5317 return 5318 } 5319 var p1 = map.mouseEventToLayerPoint(e.touches[0]), 5320 p2 = map.mouseEventToLayerPoint(e.touches[1]), 5321 viewCenter = map._getCenterLayerPoint(); 5322 this._startCenter = p1.add(p2)._divideBy(2); 5323 this._startDist = p1.distanceTo(p2); 5324 this._moved = false; 5325 this._zooming = true; 5326 this._centerOffset = viewCenter.subtract(this._startCenter); 5327 if (map._panAnim) { 5328 map._panAnim.stop() 5329 } 5330 L.DomEvent.on(document, 'touchmove', this._onTouchMove, this).on(document, 'touchend', this._onTouchEnd, this); 5331 L.DomEvent.preventDefault(e) 5332 }, 5333 _onTouchMove: function(e) { 5334 var map = this._map; 5335 if (!e.touches || e.touches.length !== 2 || !this._zooming) { 5336 return 5337 } 5338 var p1 = map.mouseEventToLayerPoint(e.touches[0]), 5339 p2 = map.mouseEventToLayerPoint(e.touches[1]); 5340 this._scale = p1.distanceTo(p2) / this._startDist; 5341 this._delta = p1._add(p2)._divideBy(2)._subtract(this._startCenter); 5342 if (this._scale === 1) { 5343 return 5344 } 5345 if (!map.options.bounceAtZoomLimits) { 5346 if ((map.getZoom() === map.getMinZoom() && this._scale < 1) || (map.getZoom() === map.getMaxZoom() && this._scale > 1)) { 5347 return 5348 } 5349 } 5350 if (!this._moved) { 5351 L.DomUtil.addClass(map._mapPane, 'leaflet-touching'); 5352 map.fire('movestart').fire('zoomstart'); 5353 this._moved = true 5354 }
5355 L.Util.cancelAnimFrame(this._animRequest); 5356 this._animRequest = L.Util.requestAnimFrame(this._updateOnMove, this, true, this._map._container); 5357 L.DomEvent.preventDefault(e) 5358 }, 5359 _updateOnMove: function() { 5360 var map = this._map, 5361 origin = this._getScaleOrigin(), 5362 center = map.layerPointToLatLng(origin), 5363 zoom = map.getScaleZoom(this._scale); 5364 map._animateZoom(center, zoom, this._startCenter, this._scale, this._delta, false, true) 5365 }, 5366 _onTouchEnd: function() { 5367 if (!this._moved || !this._zooming) { 5368 this._zooming = false; 5369 return 5370 } 5371 var map = this._map; 5372 this._zooming = false; 5373 L.DomUtil.removeClass(map._mapPane, 'leaflet-touching'); 5374 L.Util.cancelAnimFrame(this._animRequest); 5375 L.DomEvent.off(document, 'touchmove', this._onTouchMove).off(document, 'touchend', this._onTouchEnd); 5376 var origin = this._getScaleOrigin(), 5377 center = map.layerPointToLatLng(origin), 5378 oldZoom = map.getZoom(), 5379 floatZoomDelta = map.getScaleZoom(this._scale) - oldZoom, 5380 roundZoomDelta = (floatZoomDelta > 0 ? Math.ceil(floatZoomDelta) : Math.floor(floatZoomDelta)), 5381 zoom = map._limitZoom(oldZoom + roundZoomDelta), 5382 scale = map.getZoomScale(zoom) / this._scale; 5383 map._animateZoom(center, zoom, origin, scale) 5384 }, 5385 _getScaleOrigin: function() { 5386 var centerOffset = this._centerOffset.subtract(this._delta).divideBy(this._scale); 5387 return this._startCenter.add(centerOffset) 5388 } 5389 }); 5390 L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom); 5391 L.Map.mergeOptions({ 5392 tap: true, 5393 tapTolerance: 15 5394 }); 5395 L.Map.Tap = L.Handler.extend({ 5396 addHooks: function() { 5397 L.DomEvent.on(this._map._container, 'touchstart', this._onDown, this) 5398 }, 5399 removeHooks: function() { 5400 L.DomEvent.off(this._map._container, 'touchstart', this._onDown, this) 5401 }, 5402 _onDown: function(e) { 5403 if (!e.touches) { 5404 return 5405 } 5406 L.DomEvent.preventDefault(e); 5407 this._fireClick = true; 5408 if (e.touches.length > 1) { 5409 this._fireClick = false; 5410 clearTimeout(this._holdTimeout); 5411 return 5412 } 5413 var first = e.touches[0], 5414 el = first.target; 5415 this._startPos = this._newPos = new L.Point(first.clientX, first.clientY); 5416 if (el.tagName && el.tagName.toLowerCase() === 'a') { 5417 L.DomUtil.addClass(el, 'leaflet-active') 5418 } 5419 this._holdTimeout = setTimeout(L.bind(function() { 5420 if (this._isTapValid()) { 5421 this._fireClick = false; 5422 this._onUp(); 5423 this._simulateEvent('contextmenu', first) 5424 } 5425 }, this), 1000); 5426 L.DomEvent.on(document, 'touchmove', this._onMove, this).on(document, 'touchend', this._onUp, this) 5427 }, 5428 _onUp: function(e) { 5429 clearTimeout(this._holdTimeout); 5430 L.DomEvent.off(document, 'touchmove', this._onMove, this).off(document, 'touchend', this._onUp, this); 5431 if (this._fireClick && e && e.changedTouches) { 5432 var first = e.changedTouches[0], 5433 el = first.target; 5434 if (el && el.tagName && el.tagName.toLowerCase() === 'a') { 5435 L.DomUtil.removeClass(el, 'leaflet-active') 5436 } 5437 if (this._isTapValid()) { 5438 this._simulateEvent('click', first) 5439 } 5440 } 5441 }, 5442 _isTapValid: function() { 5443 return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance 5444 }, 5445 _onMove: function(e) { 5446 var first = e.touches[0]; 5447 this._newPos = new L.Point(first.clientX, first.clientY) 5448 }, 5449 _simulateEvent: function(type, e) { 5450 var simulatedEvent = document.createEvent('MouseEvents'); 5451 simulatedEvent._simulated = true; 5452 e.target._simulatedClick = true; 5453 simulatedEvent.initMouseEvent(type, true, true, window, 1, e.screenX, e.screenY, e.clientX, e.clientY, false, false, false, false, 0, null); 5454 e.target.dispatchEvent(simulatedEvent) 5455 } 5456 }); 5457 if (L.Browser.touch && !L.Browser.pointer) { 5458 L.Map.addInitHook('addHandler', 'tap', L.Map.Tap) 5459 } 5460 L.Map.mergeOptions({ 5461 boxZoom: true 5462 }); 5463 L.Map.BoxZoom = L.Handler.extend({ 5464 initialize: function(map) { 5465 this._map = map; 5466 this._container = map._container; 5467 this._pane = map._panes.overlayPane; 5468 this._moved = false 5469 }, 5470 addHooks: function() { 5471 L.DomEvent.on(this._container, 'mousedown', this._onMouseDown, this) 5472 }, 5473 removeHooks: function() { 5474 L.DomEvent.off(this._container, 'mousedown', this._onMouseDown);
5475 this._moved = false 5476 }, 5477 moved: function() { 5478 return this._moved 5479 }, 5480 _onMouseDown: function(e) { 5481 this._moved = false; 5482 if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { 5483 return false 5484 } 5485 L.DomUtil.disableTextSelection(); 5486 L.DomUtil.disableImageDrag(); 5487 this._startLayerPoint = this._map.mouseEventToLayerPoint(e); 5488 L.DomEvent.on(document, 'mousemove', this._onMouseMove, this).on(document, 'mouseup', this._onMouseUp, this).on(document, 'keydown', this._onKeyDown, this) 5489 }, 5490 _onMouseMove: function(e) { 5491 if (!this._moved) { 5492 this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane); 5493 L.DomUtil.setPosition(this._box, this._startLayerPoint); 5494 this._container.style.cursor = 'crosshair'; 5495 this._map.fire('boxzoomstart') 5496 } 5497 var startPoint = this._startLayerPoint, 5498 box = this._box, 5499 layerPoint = this._map.mouseEventToLayerPoint(e), 5500 offset = layerPoint.subtract(startPoint), 5501 newPos = new L.Point(Math.min(layerPoint.x, startPoint.x), Math.min(layerPoint.y, startPoint.y)); 5502 L.DomUtil.setPosition(box, newPos); 5503 this._moved = true; 5504 box.style.width = (Math.max(0, Math.abs(offset.x) - 4)) + 'px'; 5505 box.style.height = (Math.max(0, Math.abs(offset.y) - 4)) + 'px' 5506 }, 5507 _finish: function() { 5508 if (this._moved) { 5509 this._pane.removeChild(this._box); 5510 this._container.style.cursor = '' 5511 } 5512 L.DomUtil.enableTextSelection(); 5513 L.DomUtil.enableImageDrag(); 5514 L.DomEvent.off(document, 'mousemove', this._onMouseMove).off(document, 'mouseup', this._onMouseUp).off(document, 'keydown', this._onKeyDown) 5515 }, 5516 _onMouseUp: function(e) { 5517 this._finish(); 5518 var map = this._map, 5519 layerPoint = map.mouseEventToLayerPoint(e); 5520 if (this._startLayerPoint.equals(layerPoint)) { 5521 return 5522 } 5523 var bounds = new L.LatLngBounds(map.layerPointToLatLng(this._startLayerPoint), map.layerPointToLatLng(layerPoint)); 5524 map.fitBounds(bounds); 5525 map.fire('boxzoomend', { 5526 boxZoomBounds: bounds 5527 }) 5528 }, 5529 _onKeyDown: function(e) { 5530 if (e.keyCode === 27) { 5531 this._finish() 5532 } 5533 } 5534 }); 5535 L.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom); 5536 L.Map.mergeOptions({ 5537 keyboard: true, 5538 keyboardPanOffset: 80, 5539 keyboardZoomOffset: 1 5540 }); 5541 L.Map.Keyboard = L.Handler.extend({ 5542 keyCodes: { 5543 left: [37], 5544 right: [39], 5545 down: [40], 5546 up: [38], 5547 zoomIn: [187, 107, 61, 171], 5548 zoomOut: [189, 109, 173] 5549 }, 5550 initialize: function(map) { 5551 this._map = map; 5552 this._setPanOffset(map.options.keyboardPanOffset); 5553 this._setZoomOffset(map.options.keyboardZoomOffset) 5554 }, 5555 addHooks: function() { 5556 var container = this._map._container; 5557 if (container.tabIndex === -1) { 5558 container.tabIndex = '0' 5559 } 5560 L.DomEvent.on(container, 'focus', this._onFocus, this).on(container, 'blur', this._onBlur, this).on(container, 'mousedown', this._onMouseDown, this); 5561 this._map.on('focus', this._addHooks, this).on('blur', this._removeHooks, this) 5562 }, 5563 removeHooks: function() { 5564 this._removeHooks(); 5565 var container = this._map._container; 5566 L.DomEvent.off(container, 'focus', this._onFocus, this).off(container, 'blur', this._onBlur, this).off(container, 'mousedown', this._onMouseDown, this); 5567 this._map.off('focus', this._addHooks, this).off('blur', this._removeHooks, this) 5568 }, 5569 _onMouseDown: function() { 5570 if (this._focused) { 5571 return 5572 } 5573 var body = document.body, 5574 docEl = document.documentElement, 5575 top = body.scrollTop || docEl.scrollTop, 5576 left = body.scrollLeft || docEl.scrollLeft; 5577 this._map._container.focus(); 5578 window.scrollTo(left, top) 5579 }, 5580 _onFocus: function() { 5581 this._focused = true; 5582 this._map.fire('focus') 5583 }, 5584 _onBlur: function() { 5585 this._focused = false; 5586 this._map.fire('blur') 5587 }, 5588 _setPanOffset: function(pan) { 5589 var keys = this._panKeys = {}, 5590 codes = this.keyCodes, 5591 i, len; 5592 for (i = 0, len = codes.left.length; i < len; i++) { 5593 keys[codes.left[i]] = [-1 * pan, 0] 5594 } 5595 for (i = 0, len = codes.right.length; i < len; i++) { 5596 keys[codes.right[i]] = [pan, 0] 5597 } 5598 for (i = 0, len = codes.down.length; i < len; i++) { 5599 keys[codes.down[i]] = [0, pan] 5600 } 5601 for (i = 0, len = codes.up.length; i < len; i++) { 5602 keys[codes.up[i]] = [0, -1 * pan] 5603 } 5604 }, 5605 _setZoomOffset: function(zoom) { 5606 var keys = this._zoomKeys = {}, 5607 codes = this.keyCodes, 5608 i, len; 5609 for (i = 0, len = codes.zoomIn.length; i < len; i++) { 5610 keys[codes.zoomIn[i]] = zoom 5611 } 5612 for (i = 0, len = codes.zoomOut.length; i < len; i++) { 5613 keys[codes.zoomOut[i]] = -zoom 5614 } 5615 }, 5616 _addHooks: function() { 5617 L.DomEvent.on(document, 'keydown', this._onKeyDown, this) 5618 }, 5619 _removeHooks: function() { 5620 L.DomEvent.off(document, 'keydown', this._onKeyDown, this) 5621 }, 5622 _onKeyDown: function(e) { 5623 var key = e.keyCode,
5624 map = this._map; 5625 if (key in this._panKeys) { 5626 if (map._panAnim && map._panAnim._inProgress) { 5627 return 5628 } 5629 map.panBy(this._panKeys[key]); 5630 if (map.options.maxBounds) { 5631 map.panInsideBounds(map.options.maxBounds) 5632 } 5633 } else if (key in this._zoomKeys) { 5634 map.setZoom(map.getZoom() + this._zoomKeys[key]) 5635 } else { 5636 return 5637 } 5638 L.DomEvent.stop(e) 5639 } 5640 }); 5641 L.Map.addInitHook('addHandler', 'keyboard', L.Map.Keyboard); 5642 L.Handler.MarkerDrag = L.Handler.extend({ 5643 initialize: function(marker) { 5644 this._marker = marker 5645 }, 5646 addHooks: function() { 5647 var icon = this._marker._icon; 5648 if (!this._draggable) { 5649 this._draggable = new L.Draggable(icon, icon) 5650 } 5651 this._draggable.on('dragstart', this._onDragStart, this).on('drag', this._onDrag, this).on('dragend', this._onDragEnd, this); 5652 this._draggable.enable(); 5653 L.DomUtil.addClass(this._marker._icon, 'leaflet-marker-draggable') 5654 }, 5655 removeHooks: function() { 5656 this._draggable.off('dragstart', this._onDragStart, this).off('drag', this._onDrag, this).off('dragend', this._onDragEnd, this); 5657 this._draggable.disable(); 5658 L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable') 5659 }, 5660 moved: function() { 5661 return this._draggable && this._draggable._moved 5662 }, 5663 _onDragStart: function() { 5664 this._marker.closePopup().fire('movestart').fire('dragstart') 5665 }, 5666 _onDrag: function() { 5667 var marker = this._marker, 5668 shadow = marker._shadow, 5669 iconPos = L.DomUtil.getPosition(marker._icon), 5670 latlng = marker._map.layerPointToLatLng(iconPos); 5671 if (shadow) { 5672 L.DomUtil.setPosition(shadow, iconPos) 5673 } 5674 marker._latlng = latlng; 5675 marker.fire('move', { 5676 latlng: latlng 5677 }).fire('drag') 5678 }, 5679 _onDragEnd: function(e) { 5680 this._marker.fire('moveend').fire('dragend', e) 5681 } 5682 }); 5683 L.Control = L.Class.extend({ 5684 options: { 5685 position: 'topright' 5686 }, 5687 initialize: function(options) { 5688 L.setOptions(this, options) 5689 }, 5690 getPosition: function() { 5691 return this.options.position 5692 }, 5693 setPosition: function(position) { 5694 var map = this._map; 5695 if (map) { 5696 map.removeControl(this) 5697 } 5698 this.options.position = position; 5699 if (map) { 5700 map.addControl(this) 5701 } 5702 return this 5703 }, 5704 getContainer: function() { 5705 return this._container 5706 }, 5707 addTo: function(map) { 5708 this._map = map; 5709 var container = this._container = this.onAdd(map), 5710 pos = this.getPosition(), 5711 corner = map._controlCorners[pos]; 5712 L.DomUtil.addClass(container, 'leaflet-control'); 5713 if (pos.indexOf('bottom') !== -1) { 5714 corner.insertBefore(container, corner.firstChild) 5715 } else { 5716 corner.appendChild(container) 5717 } 5718 return this 5719 }, 5720 removeFrom: function(map) { 5721 var pos = this.getPosition(), 5722 corner = map._controlCorners[pos]; 5723 corner.removeChild(this._container); 5724 this._map = null; 5725 if (this.onRemove) { 5726 this.onRemove(map) 5727 } 5728 return this 5729 }, 5730 _refocusOnMap: function() { 5731 if (this._map) { 5732 this._map.getContainer().focus() 5733 } 5734 } 5735 }); 5736 L.control = function(options) { 5737 return new L.Control(options) 5738 }; 5739 L.Map.include({ 5740 addControl: function(control) { 5741 control.addTo(this); 5742 return this 5743 }, 5744 removeControl: function(control) { 5745 control.removeFrom(this); 5746 return this 5747 }, 5748 _initControlPos: function() { 5749 var corners = this._controlCorners = {}, 5750 l = 'leaflet-', 5751 container = this._controlContainer = L.DomUtil.create('div', l + 'control-container', this._container); 5752 5753 function createCorner(vSide, hSide) { 5754 var className = l + vSide + ' ' + l + hSide; 5755 corners[vSide + hSide] = L.DomUtil.create('div', className, container) 5756 } 5757 createCorner('top', 'left'); 5758 createCorner('top', 'right'); 5759 createCorner('bottom', 'left'); 5760 createCorner('bottom', 'right') 5761 }, 5762 _clearControlPos: function() { 5763 this._container.removeChild(this._controlContainer) 5764 } 5765 }); 5766 L.Control.Zoom = L.Control.extend({ 5767 options: { 5768 position: 'topleft', 5769 zoomInText: '+', 5770 zoomInTitle: 'Zoom in', 5771 zoomOutText: '-', 5772 zoomOutTitle: 'Zoom out' 5773 }, 5774 onAdd: function(map) { 5775 var zoomName = 'leaflet-control-zoom', 5776 container = L.DomUtil.create('div', zoomName + ' leaflet-bar'); 5777 this._map = map; 5778 this._zoomInButton = this._createButton(this.options.zoomInText, this.options.zoomInTitle, zoomName + '-in', container, this._zoomIn, this); 5779 this._zoomOutButton = this._createButton(this.options.zoomOutText, this.options.zoomOutTitle, zoomName + '-out', container, this._zoomOut, this); 5780 this._updateDisabled(); 5781 map.on('zoomend zoomlevelschange', this._updateDisabled, this); 5782 return container 5783 }, 5784 onRemove: function(map) { 5785 map.off('zoomend zoomlevelschange', this._updateDisabled, this) 5786 }, 5787 _zoomIn: function(e) { 5788 this._map.zoomIn(e.shiftKey ? 3 : 1) 5789 }, 5790 _zoomOut: function(e) { 5791 this._map.zoomOut(e.shiftKey ? 3 : 1) 5792 }, 5793 _createButton: function(html, title, className, container, fn, context) { 5794 var link = L.DomUtil.create('a', className, container); 5795 link.innerHTML = html; 5796 link.href = '#'; 5797 link.title = title; 5798 var stop = L.DomEvent.stopPropagation;
5799 L.DomEvent.on(link, 'click', stop).on(link, 'mousedown', stop).on(link, 'dblclick', stop).on(link, 'click', L.DomEvent.preventDefault).on(link, 'click', fn, context).on(link, 'click', this._refocusOnMap, context); 5800 return link 5801 }, 5802 _updateDisabled: function() { 5803 var map = this._map, 5804 className = 'leaflet-disabled'; 5805 L.DomUtil.removeClass(this._zoomInButton, className); 5806 L.DomUtil.removeClass(this._zoomOutButton, className); 5807 if (map._zoom === map.getMinZoom()) { 5808 L.DomUtil.addClass(this._zoomOutButton, className) 5809 } 5810 if (map._zoom === map.getMaxZoom()) { 5811 L.DomUtil.addClass(this._zoomInButton, className) 5812 } 5813 } 5814 }); 5815 L.Map.mergeOptions({ 5816 zoomControl: true 5817 }); 5818 L.Map.addInitHook(function() { 5819 if (this.options.zoomControl) { 5820 this.zoomControl = new L.Control.Zoom(); 5821 this.addControl(this.zoomControl) 5822 } 5823 }); 5824 L.control.zoom = function(options) { 5825 return new L.Control.Zoom(options) 5826 }; 5827 L.Control.Attribution = L.Control.extend({ 5828 options: { 5829 position: 'bottomright', 5830 prefix: '<a href="http://leafletjs.com" title="A JS library for interactive maps">Leaflet</a>' 5831 }, 5832 initialize: function(options) { 5833 L.setOptions(this, options); 5834 this._attributions = {} 5835 }, 5836 onAdd: function(map) { 5837 this._container = L.DomUtil.create('div', 'leaflet-control-attribution'); 5838 L.DomEvent.disableClickPropagation(this._container); 5839 for (var i in map._layers) { 5840 if (map._layers[i].getAttribution) { 5841 this.addAttribution(map._layers[i].getAttribution()) 5842 } 5843 } 5844 map.on('layeradd', this._onLayerAdd, this).on('layerremove', this._onLayerRemove, this); 5845 this._update(); 5846 return this._container 5847 }, 5848 onRemove: function(map) { 5849 map.off('layeradd', this._onLayerAdd).off('layerremove', this._onLayerRemove) 5850 }, 5851 setPrefix: function(prefix) { 5852 this.options.prefix = prefix; 5853 this._update(); 5854 return this 5855 }, 5856 addAttribution: function(text) { 5857 if (!text) { 5858 return 5859 } 5860 if (!this._attributions[text]) { 5861 this._attributions[text] = 0 5862 } 5863 this._attributions[text]++; 5864 this._update(); 5865 return this 5866 }, 5867 removeAttribution: function(text) { 5868 if (!text) { 5869 return 5870 } 5871 if (this._attributions[text]) { 5872 this._attributions[text]--; 5873 this._update() 5874 } 5875 return this 5876 }, 5877 _update: function() { 5878 if (!this._map) { 5879 return 5880 } 5881 var attribs = []; 5882 for (var i in this._attributions) { 5883 if (this._attributions[i]) { 5884 attribs.push(i) 5885 } 5886 } 5887 var prefixAndAttribs = []; 5888 if (this.options.prefix) { 5889 prefixAndAttribs.push(this.options.prefix) 5890 } 5891 if (attribs.length) { 5892 prefixAndAttribs.push(attribs.join(', ')) 5893 } 5894 this._container.innerHTML = prefixAndAttribs.join(' | ') 5895 }, 5896 _onLayerAdd: function(e) { 5897 if (e.layer.getAttribution) { 5898 this.addAttribution(e.layer.getAttribution()) 5899 } 5900 }, 5901 _onLayerRemove: function(e) { 5902 if (e.layer.getAttribution) { 5903 this.removeAttribution(e.layer.getAttribution()) 5904 } 5905 } 5906 }); 5907 L.Map.mergeOptions({ 5908 attributionControl: true 5909 }); 5910 L.Map.addInitHook(function() { 5911 if (this.options.attributionControl) { 5912 this.attributionControl = (new L.Control.Attribution()).addTo(this) 5913 } 5914 }); 5915 L.control.attribution = function(options) { 5916 return new L.Control.Attribution(options) 5917 }; 5918 L.Control.Scale = L.Control.extend({ 5919 options: { 5920 position: 'bottomleft', 5921 maxWidth: 100, 5922 metric: true, 5923 imperial: true, 5924 updateWhenIdle: false 5925 }, 5926 onAdd: function(map) { 5927 this._map = map; 5928 var className = 'leaflet-control-scale', 5929 container = L.DomUtil.create('div', className), 5930 options = this.options; 5931 this._addScales(options, className, container); 5932 map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this); 5933 map.whenReady(this._update, this); 5934 return container 5935 }, 5936 onRemove: function(map) { 5937 map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this) 5938 }, 5939 _addScales: function(options, className, container) { 5940 if (options.metric) { 5941 this._mScale = L.DomUtil.create('div', className + '-line', container) 5942 } 5943 if (options.imperial) { 5944 this._iScale = L.DomUtil.create('div', className + '-line', container) 5945 } 5946 }, 5947 _update: function() { 5948 var bounds = this._map.getBounds(), 5949 centerLat = bounds.getCenter().lat, 5950 halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180), 5951 dist = halfWorldMeters * (bounds.getNorthEast().lng - bounds.getSouthWest
5951().lng) / 180, 5952 size = this._map.getSize(), 5953 options = this.options, 5954 maxMeters = 0; 5955 if (size.x > 0) { 5956 maxMeters = dist * (options.maxWidth / size.x) 5957 } 5958 this._updateScales(options, maxMeters) 5959 }, 5960 _updateScales: function(options, maxMeters) { 5961 if (options.metric && maxMeters) { 5962 this._updateMetric(maxMeters) 5963 } 5964 if (options.imperial && maxMeters) { 5965 this._updateImperial(maxMeters) 5966 } 5967 }, 5968 _updateMetric: function(maxMeters) { 5969 var meters = this._getRoundNum(maxMeters); 5970 this._mScale.style.width = this._getScaleWidth(meters / maxMeters) + 'px'; 5971 this._mScale.innerHTML = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km' 5972 }, 5973 _updateImperial: function(maxMeters) { 5974 var maxFeet = maxMeters * 3.2808399, 5975 scale = this._iScale, 5976 maxMiles, miles, feet; 5977 if (maxFeet > 5280) { 5978 maxMiles = maxFeet / 5280; 5979 miles = this._getRoundNum(maxMiles); 5980 scale.style.width = this._getScaleWidth(miles / maxMiles) + 'px'; 5981 scale.innerHTML = miles + ' mi' 5982 } else { 5983 feet = this._getRoundNum(maxFeet); 5984 scale.style.width = this._getScaleWidth(feet / maxFeet) + 'px'; 5985 scale.innerHTML = feet + ' ft' 5986 } 5987 }, 5988 _getScaleWidth: function(ratio) { 5989 return Math.round(this.options.maxWidth * ratio) - 10 5990 }, 5991 _getRoundNum: function(num) { 5992 var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1), 5993 d = num / pow10; 5994 d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1; 5995 return pow10 * d 5996 } 5997 }); 5998 L.control.scale = function(options) { 5999 return new L.Control.Scale(options) 6000 }; 6001 L.Control.Layers = L.Control.extend({ 6002 options: { 6003 collapsed: true, 6004 position: 'topright', 6005 autoZIndex: true 6006 }, 6007 initialize: function(baseLayers, overlays, options) { 6008 L.setOptions(this, options); 6009 this._layers = {}; 6010 this._lastZIndex = 0; 6011 this._handlingClick = false; 6012 for (var i in baseLayers) { 6013 this._addLayer(baseLayers[i], i) 6014 } 6015 for (i in overlays) { 6016 this._addLayer(overlays[i], i, true) 6017 } 6018 }, 6019 onAdd: function(map) { 6020 this._initLayout(); 6021 this._update(); 6022 map.on('layeradd', this._onLayerChange, this).on('layerremove', this._onLayerChange, this); 6023 return this._container 6024 }, 6025 onRemove: function(map) { 6026 map.off('layeradd', this._onLayerChange, this).off('layerremove', this._onLayerChange, this) 6027 }, 6028 addBaseLayer: function(layer, name) { 6029 this._addLayer(layer, name); 6030 this._update(); 6031 return this 6032 }, 6033 addOverlay: function(layer, name) { 6034 this._addLayer(layer, name, true); 6035 this._update(); 6036 return this 6037 }, 6038 removeLayer: function(layer) { 6039 var id = L.stamp(layer); 6040 delete this._layers[id]; 6041 this._update(); 6042 return this 6043 }, 6044 _initLayout: function() { 6045 var className = 'leaflet-control-layers', 6046 container = this._container = L.DomUtil.create('div', className); 6047 container.setAttribute('aria-haspopup', true); 6048 if (!L.Browser.touch) { 6049 L.DomEvent.disableClickPropagation(container).disableScrollPropagation(container) 6050 } else { 6051 L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation) 6052 } 6053 var form = this._form = L.DomUtil.create('form', className + '-list'); 6054 if (this.options.collapsed) { 6055 if (!L.Browser.android) { 6056 L.DomEvent.on(container, 'mouseover', this._expand, this).on(container, 'mouseout', this._collapse, this) 6057 } 6058 var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container); 6059 link.href = '#'; 6060 link.title = 'Layers'; 6061 if (L.Browser.touch) { 6062 L.DomEvent.on(link, 'click', L.DomEvent.stop).on(link, 'click', this._expand, this) 6063 } else { 6064 L.DomEvent.on(link, 'focus', this._expand, this) 6065 } 6066 L.DomEvent.on(form, 'click', function() { 6067 setTimeout(L.bind(this._onInputClick, this), 0) 6068 }, this); 6069 this._map.on('click', this._collapse, this) 6070 } else { 6071 this._expand() 6072 } 6073 this._baseLayersList = L.DomUtil.create('div', className + '-base', form); 6074 this._separator = L.DomUtil.create('div', className + '-separator', form); 6075 this._overlaysList = L.DomUtil.create('div', className + '-overlays', form); 6076 container.appendChild(form) 6077 }, 6078 _addLayer: function(layer, name, overlay) { 6079 var id = L.stamp(layer); 6080 this._layers[id] = { 6081 layer: layer, 6082 name: name, 6083 overlay: overlay 6084 };
6085 if (this.options.autoZIndex && layer.setZIndex) { 6086 this._lastZIndex++; 6087 layer.setZIndex(this._lastZIndex) 6088 } 6089 }, 6090 _update: function() { 6091 if (!this._container) { 6092 return 6093 } 6094 this._baseLayersList.innerHTML = ''; 6095 this._overlaysList.innerHTML = ''; 6096 var baseLayersPresent = false, 6097 overlaysPresent = false, 6098 i, obj; 6099 for (i in this._layers) { 6100 obj = this._layers[i]; 6101 this._addItem(obj); 6102 overlaysPresent = overlaysPresent || obj.overlay; 6103 baseLayersPresent = baseLayersPresent || !obj.overlay 6104 } 6105 this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none' 6106 }, 6107 _onLayerChange: function(e) { 6108 var obj = this._layers[L.stamp(e.layer)]; 6109 if (!obj) { 6110 return 6111 } 6112 if (!this._handlingClick) { 6113 this._update() 6114 } 6115 var type = obj.overlay ? (e.type === 'layeradd' ? 'overlayadd' : 'overlayremove') : (e.type === 'layeradd' ? 'baselayerchange' : null); 6116 if (type) { 6117 this._map.fire(type, obj) 6118 } 6119 }, 6120 _createRadioElement: function(name, checked) { 6121 var radioHtml = '<input type="radio" class="leaflet-control-layers-selector" name="' + name + '"'; 6122 if (checked) { 6123 radioHtml += ' checked="checked"' 6124 } 6125 radioHtml += '/>'; 6126 var radioFragment = document.createElement('div'); 6127 radioFragment.innerHTML = radioHtml; 6128 return radioFragment.firstChild 6129 }, 6130 _addItem: function(obj) { 6131 var label = document.createElement('label'), 6132 input, checked = this._map.hasLayer(obj.layer); 6133 if (obj.overlay) { 6134 input = document.createElement('input'); 6135 input.type = 'checkbox'; 6136 input.className = 'leaflet-control-layers-selector'; 6137 input.defaultChecked = checked 6138 } else { 6139 input = this._createRadioElement('leaflet-base-layers', checked) 6140 } 6141 input.layerId = L.stamp(obj.layer); 6142 L.DomEvent.on(input, 'click', this._onInputClick, this); 6143 var name = document.createElement('span'); 6144 name.innerHTML = ' ' + obj.name; 6145 label.appendChild(input); 6146 label.appendChild(name); 6147 var container = obj.overlay ? this._overlaysList : this._baseLayersList; 6148 container.appendChild(label); 6149 return label 6150 }, 6151 _onInputClick: function() { 6152 var i, input, obj, inputs = this._form.getElementsByTagName('input'), 6153 inputsLen = inputs.length; 6154 this._handlingClick = true; 6155 for (i = 0; i < inputsLen; i++) { 6156 input = inputs[i]; 6157 obj = this._layers[input.layerId]; 6158 if (input.checked && !this._map.hasLayer(obj.layer)) { 6159 this._map.addLayer(obj.layer) 6160 } else if (!input.checked && this._map.hasLayer(obj.layer)) { 6161 this._map.removeLayer(obj.layer) 6162 } 6163 } 6164 this._handlingClick = false; 6165 this._refocusOnMap() 6166 }, 6167 _expand: function() { 6168 L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded') 6169 }, 6170 _collapse: function() { 6171 this._container.className = this._container.className.replace(' leaflet-control-layers-expanded', '') 6172 } 6173 }); 6174 L.control.layers = function(baseLayers, overlays, options) { 6175 return new L.Control.Layers(baseLayers, overlays, options) 6176 }; 6177 L.PosAnimation = L.Class.extend({ 6178 includes: L.Mixin.Events, 6179 run: function(el, newPos, duration, easeLinearity) { 6180 this.stop(); 6181 this._el = el; 6182 this._inProgress = true; 6183 this._newPos = newPos; 6184 this.fire('start'); 6185 el.style[L.DomUtil.TRANSITION] = 'all ' + (duration || 0.25) + 's cubic-bezier(0,0,' + (easeLinearity || 0.5) + ',1)'; 6186 L.DomEvent.on(el, L.DomUtil.TRANSITION_END, this._onTransitionEnd, this); 6187 L.DomUtil.setPosition(el, newPos); 6188 L.Util.falseFn(el.offsetWidth); 6189 this._stepTimer = setInterval(L.bind(this._onStep, this), 50) 6190 }, 6191 stop: function() { 6192 if (!this._inProgress) { 6193 return 6194 } 6195 L.DomUtil.setPosition(this._el, this._getPos()); 6196 this._onTransitionEnd(); 6197 L.Util.falseFn(this._el.offsetWidth) 6198 }, 6199 _onStep: function() { 6200 var stepPos = this._getPos(); 6201 if (!stepPos) { 6202 this._onTransitionEnd(); 6203 return 6204 } 6205 this._el._leaflet_pos = stepPos; 6206 this.fire('step') 6207 }, 6208 _transformRe: /([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/, 6209 _getPos: function() { 6210 var left, top, matches, el = this._el, 6211 style = window.getComputedStyle(el); 6212 if (L.Browser.any3d) { 6213 matches = style[L.DomUtil.TRANSFORM].match(this._transformRe); 6214 if (!matches) { 6215 return 6216 } 6217 left = parseFloat(matches[1]); 6218 top = parseFloat(matches[2]) 6219 } else { 6220 left = parseFloat(style.left); 6221 top = parseFloat(style.top) 6222 } 6223 return new L.Point(left, top, true) 6224 }, 6225 _onTransitionEnd: function() { 6226 L.DomEvent.off(this._el, L.DomUtil.TRANSITION_END, this._onTransitionEnd, this); 6227 if (!this._inProgress) { 6228 return 6229 } 6230 this._inProgress = false; 6231 this._el.style[L.DomUtil.TRANSITION] = ''; 6232 this._el._leaflet_pos = this._newPos; 6233 clearInterval(this._stepTimer); 6234 this.fire('step').fire('end') 6235 } 6236 }); 6237 L.Map.include({
6238 setView: function(center, zoom, options) { 6239 zoom = zoom === undefined ? this._zoom : this._limitZoom(zoom); 6240 center = this._limitCenter(L.latLng(center), zoom, this.options.maxBounds); 6241 options = options || {}; 6242 if (this._panAnim) { 6243 this._panAnim.stop() 6244 } 6245 if (this._loaded && !options.reset && options !== true) { 6246 if (options.animate !== undefined) { 6247 options.zoom = L.extend({ 6248 animate: options.animate 6249 }, options.zoom); 6250 options.pan = L.extend({ 6251 animate: options.animate 6252 }, options.pan) 6253 } 6254 var animated = (this._zoom !== zoom) ? this._tryAnimatedZoom && this._tryAnimatedZoom(center, zoom, options.zoom) : this._tryAnimatedPan(center, options.pan); 6255 if (animated) { 6256 clearTimeout(this._sizeTimer); 6257 return this 6258 } 6259 } 6260 this._resetView(center, zoom); 6261 return this 6262 }, 6263 panBy: function(offset, options) { 6264 offset = L.point(offset).round(); 6265 options = options || {}; 6266 if (!offset.x && !offset.y) { 6267 return this 6268 } 6269 if (!this._panAnim) { 6270 this._panAnim = new L.PosAnimation(); 6271 this._panAnim.on({ 6272 'step': this._onPanTransitionStep, 6273 'end': this._onPanTransitionEnd 6274 }, this) 6275 } 6276 if (!options.noMoveStart) { 6277 this.fire('movestart') 6278 } 6279 if (options.animate !== false) { 6280 L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim'); 6281 var newPos = this._getMapPanePos().subtract(offset); 6282 this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity) 6283 } else { 6284 this._rawPanBy(offset); 6285 this.fire('move').fire('moveend') 6286 } 6287 return this 6288 }, 6289 _onPanTransitionStep: function() { 6290 this.fire('move') 6291 }, 6292 _onPanTransitionEnd: function() { 6293 L.DomUtil.removeClass(this._mapPane, 'leaflet-pan-anim'); 6294 this.fire('moveend') 6295 }, 6296 _tryAnimatedPan: function(center, options) { 6297 var offset = this._getCenterOffset(center)._floor(); 6298 if ((options && options.animate) !== true && !this.getSize().contains(offset)) { 6299 return false 6300 } 6301 this.panBy(offset, options); 6302 return true 6303 } 6304 }); 6305 L.PosAnimation = L.DomUtil.TRANSITION ? L.PosAnimation : L.PosAnimation.extend({ 6306 run: function(el, newPos, duration, easeLinearity) { 6307 this.stop(); 6308 this._el = el; 6309 this._inProgress = true; 6310 this._duration = duration || 0.25; 6311 this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2); 6312 this._startPos = L.DomUtil.getPosition(el); 6313 this._offset = newPos.subtract(this._startPos); 6314 this._startTime = +new Date(); 6315 this.fire('start'); 6316 this._animate() 6317 }, 6318 stop: function() { 6319 if (!this._inProgress) { 6320 return 6321 } 6322 this._step(); 6323 this._complete() 6324 }, 6325 _animate: function() { 6326 this._animId = L.Util.requestAnimFrame(this._animate, this); 6327 this._step() 6328 }, 6329 _step: function() { 6330 var elapsed = (+new Date()) - this._startTime, 6331 duration = this._duration * 1000; 6332 if (elapsed < duration) { 6333 this._runFrame(this._easeOut(elapsed / duration)) 6334 } else { 6335 this._runFrame(1); 6336 this._complete() 6337 } 6338 }, 6339 _runFrame: function(progress) { 6340 var pos = this._startPos.add(this._offset.multiplyBy(progress)); 6341 L.DomUtil.setPosition(this._el, pos); 6342 this.fire('step') 6343 }, 6344 _complete: function() { 6345 L.Util.cancelAnimFrame(this._animId); 6346 this._inProgress = false; 6347 this.fire('end') 6348 }, 6349 _easeOut: function(t) { 6350 return 1 - Math.pow(1 - t, this._easeOutPower) 6351 } 6352 }); 6353 L.Map.mergeOptions({ 6354 zoomAnimation: true, 6355 zoomAnimationThreshold: 4 6356 }); 6357 if (L.DomUtil.TRANSITION) { 6358 L.Map.addInitHook(function() { 6359 this._zoomAnimated = this.options.zoomAnimation && L.DomUtil.TRANSITION && L.Browser.any3d && !L.Browser.android23 && !L.Browser.mobileOpera; 6360 if (this._zoomAnimated) { 6361 L.DomEvent.on(this._mapPane, L.DomUtil.TRANSITION_END, this._catchTransitionEnd, this) 6362 } 6363 }) 6364 } 6365 L.Map.include(!L.DomUtil.TRANSITION ? {}
6365 : { 6366 _catchTransitionEnd: function(e) { 6367 if (this._animatingZoom && e.propertyName.indexOf('transform') >= 0) { 6368 this._onZoomTransitionEnd() 6369 } 6370 }, 6371 _nothingToAnimate: function() { 6372 return !this._container.getElementsByClassName('leaflet-zoom-animated').length 6373 }, 6374 _tryAnimatedZoom: function(center, zoom, options) { 6375 if (this._animatingZoom) { 6376 return true 6377 } 6378 options = options || {}; 6379 if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() || Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { 6380 return false 6381 } 6382 var scale = this.getZoomScale(zoom), 6383 offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale), 6384 origin = this._getCenterLayerPoint()._add(offset); 6385 if (options.animate !== true && !this.getSize().contains(offset)) { 6386 return false 6387 } 6388 this.fire('movestart').fire('zoomstart'); 6389 this._animateZoom(center, zoom, origin, scale, null, true); 6390 return true 6391 }, 6392 _animateZoom: function(center, zoom, origin, scale, delta, backwards, forTouchZoom) { 6393 if (!forTouchZoom) { 6394 this._animatingZoom = true 6395 } 6396 L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim'); 6397 this._animateToCenter = center; 6398 this._animateToZoom = zoom; 6399 if (L.Draggable) { 6400 L.Draggable._disabled = true 6401 } 6402 L.Util.requestAnimFrame(function() { 6403 this.fire('zoomanim', { 6404 center: center, 6405 zoom: zoom, 6406 origin: origin, 6407 scale: scale, 6408 delta: delta, 6409 backwards: backwards 6410 }) 6411 }, this) 6412 }, 6413 _onZoomTransitionEnd: function() { 6414 this._animatingZoom = false; 6415 L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim'); 6416 this._resetView(this._animateToCenter, this._animateToZoom, true, true); 6417 if (L.Draggable) { 6418 L.Draggable._disabled = false 6419 } 6420 } 6421 }); 6422 L.TileLayer.include({ 6423 _animateZoom: function(e) { 6424 if (!this._animating) { 6425 this._animating = true; 6426 this._prepareBgBuffer() 6427 } 6428 var bg = this._bgBuffer, 6429 transform = L.DomUtil.TRANSFORM, 6430 initialTransform = e.delta ? L.DomUtil.getTranslateString(e.delta) : bg.style[transform], 6431 scaleStr = L.DomUtil.getScaleString(e.scale, e.origin); 6432 bg.style[transform] = e.backwards ? scaleStr + ' ' + initialTransform : initialTransform + ' ' + scaleStr 6433 }, 6434 _endZoomAnim: function() { 6435 var front = this._tileContainer, 6436 bg = this._bgBuffer; 6437 front.style.visibility = ''; 6438 front.parentNode.appendChild(front); 6439 L.Util.falseFn(bg.offsetWidth); 6440 this._animating = false 6441 }, 6442 _clearBgBuffer: function() { 6443 var map = this._map; 6444 if (map && !map._animatingZoom && !map.touchZoom._zooming) { 6445 this._bgBuffer.innerHTML = ''; 6446 this._bgBuffer.style[L.DomUtil.TRANSFORM] = '' 6447 } 6448 }, 6449 _prepareBgBuffer: function() { 6450 var front = this._tileContainer, 6451 bg = this._bgBuffer; 6452 var bgLoaded = this._getLoadedTilesPercentage(bg), 6453 frontLoaded = this._getLoadedTilesPercentage(front); 6454 if (bg && bgLoaded > 0.5 && frontLoaded < 0.5) { 6455 front.style.visibility = 'hidden'; 6456 this._stopLoadingImages(front); 6457 return 6458 } 6459 bg.style.visibility = 'hidden'; 6460 bg.style[L.DomUtil.TRANSFORM] = ''; 6461 this._tileContainer = bg; 6462 bg = this._bgBuffer = front; 6463 this._stopLoadingImages(bg); 6464 clearTimeout(this._clearBgBufferTimer) 6465 }, 6466 _getLoadedTilesPercentage: function(container) { 6467 var tiles = container.getElementsByTagName('img'), 6468 i, len, count = 0; 6469 for (i = 0, len = tiles.length; i < len; i++) { 6470 if (tiles[i].complete) { 6471 count++ 6472 } 6473 } 6474 return count / len 6475 }, 6476 _stopLoadingImages: function(container) { 6477 var tiles = Array.prototype.slice.call(container.getElementsByTagName('img')), 6478 i, len, tile; 6479 for (i = 0, len = tiles.length; i < len; i++) { 6480 tile = tiles[i]; 6481 if (!tile.complete) { 6482 tile.onload = L.Util.falseFn; 6483 tile.onerror = L.Util.falseFn; 6484 tile.src = L.Util.emptyImageUrl; 6485 tile.parentNode.removeChild(tile) 6486 } 6487 } 6488 } 6489 }); 6490 L.Map.include({ 6491 _defaultLocateOptions: { 6492 watch: false,
6493 setView: false, 6494 maxZoom: Infinity, 6495 timeout: 10000, 6496 maximumAge: 0, 6497 enableHighAccuracy: false 6498 }, 6499 locate: function(options) { 6500 options = this._locateOptions = L.extend(this._defaultLocateOptions, options); 6501 if (!navigator.geolocation) { 6502 this._handleGeolocationError({ 6503 code: 0, 6504 message: 'Geolocation not supported.' 6505 }); 6506 return this 6507 } 6508 var onResponse = L.bind(this._handleGeolocationResponse, this), 6509 onError = L.bind(this._handleGeolocationError, this); 6510 if (options.watch) { 6511 this._locationWatchId = navigator.geolocation.watchPosition(onResponse, onError, options) 6512 } else { 6513 navigator.geolocation.getCurrentPosition(onResponse, onError, options) 6514 } 6515 return this 6516 }, 6517 stopLocate: function() { 6518 if (navigator.geolocation) { 6519 navigator.geolocation.clearWatch(this._locationWatchId) 6520 } 6521 if (this._locateOptions) { 6522 this._locateOptions.setView = false 6523 } 6524 return this 6525 }, 6526 _handleGeolocationError: function(error) { 6527 var c = error.code, 6528 message = error.message || (c === 1 ? 'permission denied' : (c === 2 ? 'position unavailable' : 'timeout')); 6529 if (this._locateOptions.setView && !this._loaded) { 6530 this.fitWorld() 6531 } 6532 this.fire('locationerror', { 6533 code: c, 6534 message: 'Geolocation error: ' + message + '.' 6535 }) 6536 }, 6537 _handleGeolocationResponse: function(pos) { 6538 var lat = pos.coords.latitude, 6539 lng = pos.coords.longitude, 6540 latlng = new L.LatLng(lat, lng), 6541 latAccuracy = 180 * pos.coords.accuracy / 40075017, 6542 lngAccuracy = latAccuracy / Math.cos(L.LatLng.DEG_TO_RAD * lat), 6543 bounds = L.latLngBounds([lat - latAccuracy, lng - lngAccuracy], [lat + latAccuracy, lng + lngAccuracy]), 6544 options = this._locateOptions; 6545 if (options.setView) { 6546 var zoom = Math.min(this.getBoundsZoom(bounds), options.maxZoom); 6547 this.setView(latlng, zoom) 6548 } 6549 var data = { 6550 latlng: latlng, 6551 bounds: bounds, 6552 timestamp: pos.timestamp 6553 }; 6554 for (var i in pos.coords) { 6555 if (typeof pos.coords[i] === 'number') { 6556 data[i] = pos.coords[i] 6557 } 6558 } 6559 this.fire('locationfound', data) 6560 } 6561 }) 6562}(window, document)); 6563E = window.location.protocol != 'https:' ? 'http:' : 'https:'; 6564var queryStringTestAdd = window.location.search; 6565try { 6566 var urlParamsTestAdd = new URLSearchParams(queryStringTestAdd); 6567 var urlParamsTestAddUrl = urlParamsTestAdd.get('testURLAddString') 6568} catch (exception) {} 6569if (urlParamsTestAddUrl == null) { 6570 urlParamsTestAddUrl = "" 6571} 6572EmAPI = EMAPI = E = { 6573 protocol: E, 6574 server: { 6575 API: E + '//server' + urlParamsTestAddUrl + '.emapi.pl/', 6576 IMG: E + '//img{s}' + urlParamsTestAddUrl + '.emapi.pl/?fun=GetMap&zoom={z}&tileX={x}&tileY={y}&layer={l}&userID=', 6577 POI: E + '//poi{s}' + urlParamsTestAddUrl + '.emapi.pl/?fun=GetObjectMap&zoom={z}&tileX={x}&tileY={y}&categories={c}&userID=', 6578 POIAPI: E + '//poi' + urlParamsTestAddUrl + '.emapi.pl/' 6579 }, 6580 on: L.DomEvent.on, 6581 off: L.DomEvent.off, 6582 newElem: L.DomUtil.create, 6583 newElem$: function(a, b, c) { 6584 return E.$(E.newElem(a, !b ? '' : b, c)) 6585 }, 6586 mousePos: L.DomEvent.getMousePosition, 6587 bind: function(fn, obj) { 6588 var args = arguments.length > 2 ? Array.prototype.slice.call(arguments, 2) : null; 6589 return function() { 6590 return fn.apply(obj, args ? args.concat(arguments) : arguments) 6591 } 6592 }, 6593 block: function(a) { 6594 L.DomEvent.stopPropagation(a) 6595 }, 6596 body: function() { 6597 return E.$(document.body) 6598 }, 6599 windowSize: function() { 6600 return [window.innerWidth || document.body.clientWidth || document.documentElement.clientWidth, window.innerHeit || document.body.clientHeight || document.documentElement.clientHeight] 6601 }, 6602 windowScroll: function() { 6603 return [document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft, document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop] 6604 }, 6605 $: function(a) { 6606 return new E.JQuery(a) 6607 }, 6608 $$: function(a) { 6609 var a = new E.JQuery(a); 6610 return a.exist() ? a : null 6611 }, 6612 resize: function(a, b, c) { 6613 if (c) this.on(window, 'resize', a, b); 6614 else this.off(window, 'resize', a, b) 6615 }, 6616 scroll: function(a, b, c) { 6617 if (c) this.on(window, 'scrool', a, b); 6618 else this.off(window, 'scrool', a, b) 6619 }, 6620 extend: L.Util.extend, 6621 type: function(a) { 6622 if (a == undefined) return 'u'; 6623 else if (a == null) return 'u'; 6624 else if (typeof a === 'string') return 's'; 6625 else if (a instanceof Array) return 'a'; 6626 else if (typeof a === 'object') return 'o'; 6627 else if (typeof a === 'function') return 'f'; 6628 else return typeof a 6629 }, 6630 ext: function(a, b, c) { 6631 if (E.type(a[b]) == 'u') a[b] = c 6632 }, 6633 CSS: 'css/', 6634 format: function(a, b) { 6635 for (var i = 0; i < b.length; i++) { 6636 a = a.replace(new RegExp('\\{' + i + '\\}', "g"), b[i]) 6637 } 6638 return a 6639 }, 6640 nl2a: function(a) { 6641 var res = []; 6642 for (var i = 0; i < a.length; i++) res.push(a[i]); 6643 return res 6644 }, 6645 indexOf: function(a, b) { 6646 var len = a.length; 6647 var from = Number(arguments[2]) || 0; 6648 from = (from < 0) ? Math.ceil(from) : Math.floor(from); 6649 if (from < 0) from += len; 6650 for (; from < len; from++) 6651 if (from in a && a[from] === b) return from; 6652 return -1 6653 }, 6654 getElementsByAtt: function(a, b, c) { 6655 var elts = a.getElementsByTagName('*'); 6656 var classArray = new Array(); 6657 for (var i = 0; i < elts.length; ++i) 6658 if ((elts[i].getAttribute(c)) && (E.indexOf(elts[i].getAttribute(c).split(' '), b) != -1)) classArray.push(elts[i]); 6659 return classArray 6660 }, 6661 getElementsByCN: function(a, b, c) { 6662 var elts = a.getElementsByTagName('*'); 6663 var classArray = new Array(); 6664 for (var i = 0; i < elts.length; ++i) 6665 if ((elts[i].className) && (E.indexOf(elts[i].className.split(' '), b) != -1)) classArray.push(elts[i]); 6666 return classArray 6667 }, 6668 getElementsByClassName: function(a, b) { 6669 if (a.getElementsByClassName) return E.nl2a(a.getElementsByClassName(b)); 6670 return E.getElementsByCN(a, b, 'className') 6671 }, 6672 getElementById: function(a, b) { 6673 if (a.getElementById) return a.getElementById(b); 6674 var elts = a.getElementsByTagName('*'); 6675 for (var i = 0; i < elts.length; ++i) 6676 if (elts[i].id == b) return elts[i];
6677 return null 6678 }, 6679 LL2XY: function(lon, lat, zoom) { 6680 var x1, x2, x3, x4, y1, y2, y3, y4, pi = Math.PI, 6681 lon1 = lon * (Math.PI / 180); 6682 x1 = ((lon1 + pi) / (2 * pi)) * (256 << zoom); 6683 x2 = Math.floor(Math.floor(x1) / 256); 6684 x3 = Math.floor(Math.floor(x1) % 256); 6685 var lat1 = lat * (pi / 180); 6686 y1 = Math.tan((pi / 4) + (lat1 / 2)); 6687 if (y1 < 0) { 6688 y1 = Math.log(-y1) 6689 } else { 6690 y1 = Math.log(y1) 6691 } 6692 y1 = (Math.PI - y1) * (256 << zoom) / (2 * Math.PI); 6693 y2 = Math.floor(Math.floor(y1) / 256); 6694 y3 = Math.floor(Math.floor(y1) % 256); 6695 return [x2, x3, y2, y3] 6696 }, 6697 XY2LL: function(xtile, xpos, ytile, ypos, zoom) { 6698 var x1, y1, lon, lat; 6699 x1 = xtile * 256 + xpos; 6700 x1 = x1 * (2 * Math.PI) / (256 << zoom); 6701 lon = (x1 - Math.PI) * 180 / Math.PI; 6702 y1 = ytile * 256 + ypos; 6703 y1 = y1 * (2 * Math.PI) / (256 << zoom); 6704 y1 = (Math.PI - y1); 6705 if (y1 > 0) y1 = 2 * Math.atan(Math.exp(y1)) - Math.PI / 2; 6706 else y1 = -(2 * Math.atan(Math.exp(-y1)) - Math.PI / 2); 6707 lat = y1 * 180 / Math.PI; 6708 return [lon, lat] 6709 }, 6710 subs: function(a, b, c) { 6711 a.substring(b, c) 6712 }, 6713 timeout: function(a, b, c) { 6714 return setTimeout(c ? E.bind(b, c) : c, a) 6715 }, 6716 doc: document, 6717 docw: function(a) { 6718 E.doc.writeln(a) 6719 }, 6720 linkCSS: function(a) { 6721 return "<link rel='stylesheet' href='" + a + "'/>" 6722 }, 6723 Url: function() { 6724 if (this._url) return this._url; 6725 var scripts = document.getElementsByTagName('script'); 6726 for (var i = 0; i < scripts.length; i++) { 6727 var src = scripts[i].src; 6728 if (src) { 6729 var res = src.match(/^(.*)LoadApi\.aspx(.*)$/); 6730 if (res) return this._url = res[1] 6731 } 6732 } 6733 return "" 6734 }, 6735 addI: function(a, b) { 6736 b = (E.type(a) != 'a') ? [a, b] : a, a = ''; 6737 for (var i = 0; i < b.length; i++) a += ((b[i] && (b[i].length > 0)) ? ((a.length > 0) ? ', ' : '') + b[i] : ''); 6738 return a 6739 }, 6740 blank: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCJljYAAAAAIAAfRxZKYAAAAASUVORK5CYII=", 6741 trim: function(str) { 6742 return str.replace(/^\s* /, "").replace(/\s*$/, "") 6743 }, 6744 isA: function(a) { 6745 return E.type(a) == 'a' 6746 }, 6747 isU: function(a) { 6748 return E.type(a) == 'u' 6749 }, 6750 setPos: L.DomUtil.setPosition, 6751 extFun: function(a, b) { 6752 return function() { 6753 a.call(this), b.call(this) 6754 } 6755 }, 6756 VERSION_NUMBER: "2.3.201" 6757}; 6758E.docw(E.linkCSS(E.Url() + "css/pl/style.css")); 6759E.docw("<!--[if lte IE 8]>" + E.linkCSS(E.Url() + "css/c/u/ie.css") + "<![endif]-->"); 6760E.JQuery = L.Class.extend({ 6761 _elem: null, 6762 initialize: function(elem) { 6763 this._elem = this._getElem(elem) 6764 }, 6765 e: function(a) { 6766 return a == undefined 6767 }, 6768 onP: function(a, b, c) { 6769 for (var i = 0; i < this._elem.length; i++) { 6770 var d = this._elem[i], 6771 e = function(e) { 6772 return b.call(c, e || L.DomEvent._getEvent(), d) 6773 }; 6774 E.on(this._elem[i], a, e, this._elem[i]) 6775 } 6776 return this 6777 }, 6778 on: function(a, b, c, d) { 6779 var e = d ? function(e) { 6780 return b.call(c, e || L.DomEvent._getEvent(), d) 6781 } : b; 6782 for (var i = 0; i < this._elem.length; i++) E.on(this._elem[i], a, e, d ? this._elem[i] : c); 6783 return this 6784 }, 6785 off: function(a, b, c) { 6786 for (var i = 0; i < this._elem.length; i++) E.off(this._elem[i], a, b, c); 6787 return this 6788 }, 6789 click: function(a, b, c) { 6790 if (!a) { 6791 for (var i = 0; i < this._elem.length; i++) this._elem[i].click(); 6792 return this 6793 } 6794 return this.on('click', a, b, c) 6795 }, 6796 clickP: function(a, b) { 6797 return this.onP('click', a, b) 6798 }, 6799 blur: function(a, b, c) { 6800 return this.on('blur', a, b, c) 6801 }, 6802 blurP: function(a, b, c) { 6803 return this.onP('blur', a, b, c) 6804 }, 6805 focus: function(a, b, c) { 6806 if (arguments.length == 0) { 6807 this._elem[0].focus(); 6808 return this 6809 } else return this.on('focus', a, b, c) 6810 }, 6811 focusP: function(a, b) { 6812 return this.onP('focus', a, b) 6813 }, 6814 over: function(a, b, c) { 6815 return this.on('mouseover', a, b, c) 6816 }, 6817 out: function(a, b, c) { 6818 return this.on('mouseout', a, b, c) 6819 }, 6820 submit: function(a, b, c) { 6821 return this.on('submit', a, b, c) 6822 }, 6823 submitP: function(a, b) { 6824 for (var i = 0; i < this._elem.length; i++) this._elem[i].onsubmit = E.bind(a, b) 6825 }, 6826 change: function(a, b, c) { 6827 return this.on('change', a, b, c) 6828 }, 6829 changeP: function(a, b, c) { 6830 return this.onP('change', a, b, c) 6831 }, 6832 key: function(a, b) { 6833 return this.on('keypress', a, b) 6834 },
6835 keyDownP: function(a, b) { 6836 return this.onP('keydown', a, b) 6837 }, 6838 runMouse: function(a) { 6839 if (this._elem[0].dispatchEvent) { 6840 var b = document.createEvent('MouseEvents'); 6841 b.initMouseEvent(a); 6842 this._elem[0].dispatchEvent(b) 6843 } else if (this._elem[0].fireEvent) this._elem[0].fireEvent('on' + a) 6844 }, 6845 block: function(a) { 6846 if (!a) a = ['mousedown', 'click', 'dbclick']; 6847 for (var i = 0; i < a.length; i++) this.on(a[i], L.DomEvent.stopPropagation), this.on(a[i], L.DomEvent.preventDefault); 6848 return this 6849 }, 6850 att: function(a, b) { 6851 if (this.e(b)) return this._elem[0].getAttribute(a); 6852 for (var i = 0; i < this._elem.length; i++) this._elem[i].setAttribute(a, b); 6853 return this 6854 }, 6855 id: function(a) { 6856 return this.att('id', a) 6857 }, 6858 delAtt: function(a) { 6859 for (var i = 0; i < this._elem.length; i++) this._elem[i].removeAttribute(a) 6860 }, 6861 css: function(a, b) { 6862 if ((!b) & (b !== "")) return this._elem[0].style[a]; 6863 if (E.type(a) != 'a') a = [ 6864 [a, b] 6865 ]; 6866 for (var i = 0; i < this._elem.length; i++) 6867 for (var j = 0; j < a.length; j++) this._elem[i].style[a[j][0]] = a[j][1]; 6868 return this 6869 }, 6870 bgUrl: function(a) { 6871 return this.css("background-image", a ? a = 'url(' + a + ')' : a) 6872 }, 6873 offset: function(a, b) { 6874 if (E.type(b) == 'u') return this._elem[0]['offset' + a]; 6875 return this.css(a.toLowerCase(), b + (typeof b === 'number' ? "px" : "")) 6876 }, 6877 width: function(a) { 6878 return this.offset('Width', a) 6879 }, 6880 height: function(a) { 6881 return this.offset('Height', a) 6882 }, 6883 left: function(a) { 6884 return this.offset('Left', a) 6885 }, 6886 right: function(a) { 6887 return this.offset('Right', a) 6888 }, 6889 top: function(a) { 6890 return this.offset('Top', a) 6891 }, 6892 size: function(a, b) { 6893 if ((!a) && (!b)) { 6894 return [this.width(), this.height()] 6895 } else { 6896 this.width(a + (typeof a === 'number' ? "px" : "")); 6897 this.height(b + (typeof b === 'number' ? "px" : "")); 6898 return this 6899 } 6900 }, 6901 pos: function(a, b) { 6902 if (E.isU(a) && E.isU(b)) { 6903 return [this.top(), this.left()] 6904 } else { 6905 this.left(a + (typeof a === 'number' ? "px" : "")); 6906 this.top(b + (typeof b === 'number' ? "px" : "")); 6907 return this 6908 } 6909 }, 6910 text: function(a) { 6911 if ((!a) & (a !== "")) return this._elem[0].innerHTML; 6912 for (var i = 0; i < this._elem.length; i++) this._elem[i].innerHTML = a; 6913 return this 6914 }, 6915 clear: function() { 6916 return this.text('') 6917 }, 6918 value: function(a) { 6919 if (this.e(a)) return this._elem[0].value; 6920 for (var i = 0; i < this._elem.length; i++) this._elem[i].value = a; 6921 return this 6922 }, 6923 _getElem: function(a) { 6924 var b = this._elem ? this._elem[0] : document; 6925 if (a instanceof E.JQuery) return a._elem; 6926 if (E.type(a) === 's') return (a.charAt(0) == '.') ? E.getElementsByClassName(b, a.substring(1)) : [E.getElementById(b, a)]; 6927 else if (E.type(a) === 'a') return a; 6928 else if (E.type(a) === 'o') return [a]; 6929 return [a] 6930 }, 6931 hide: function() { 6932 return this.css("display", "none") 6933 }, 6934 show: function(a) { 6935 if (a) this.pos(a.x, a.y); 6936 return this.css("display", "") 6937 }, 6938 visible: function(a) { 6939 if (E.type(a) == 'u') return this.css("display") != 'none'; 6940 else return a ? this.show() : this.hide() 6941 }, 6942 visibility: function(a) { 6943 if (E.type(a) == 'u') return this.css("visibility") != 'hidden'; 6944 else return this.css("visibility", a ? 'visible' : 'hidden') 6945 }, 6946 toggle: function() { 6947 this.visible(!this.visible()) 6948 }, 6949 bgImg: function(a) { 6950 return this.css("backgroundImage", a) 6951 }, 6952 hasClass: function(name, a) { 6953 var b = L.DomUtil.hasClass(this._elem[0], name); 6954 if (!E.isU(a)) { 6955 this.removeClass(name); 6956 this.removeClass(a); 6957 this.addClass(b ? a : name) 6958 } 6959 return b 6960 }, 6961 addClass: function(name) { 6962 for (var i = 0; i < this._elem.length; i++) L.DomUtil.addClass(this._elem[i], name); 6963 return this 6964 }, 6965 removeClass: function(name) { 6966 for (var i = 0; i < this._elem.length; i++) L.DomUtil.removeClass(this._elem[i], name); 6967 return this 6968 }, 6969 replaceClass: function(a, b) { 6970 return this.Class(this.Class().replace(a, b)) 6971 }, 6972 Class: function(a) { 6973 if (a) 6974 for (var i = 0; i < this._elem.length; i++) this._elem[i].className = a; 6975 else return this._elem[0].className; 6976 return this 6977 }, 6978 remove: function(a) { 6979 if (E.type(a) === 'u') 6980 for (var i = 0; i < this._elem.length; i++) this._elem[i].parentNode.removeChild(this._elem[i]); 6981 else 6982 for (var i = 0; i < this._elem.length; i++) this._elem[i].removeChild(this._elem[i].childNodes[a]); 6983 return this 6984 }, 6985 append: function(a, index) { 6986 if (E.type(a) == 'a') 6987 for (var i = 0; i < a.length;
6987 i++) this.append(a[i], index + i); 6988 else { 6989 if (a instanceof E.JQuery) a = a._elem[0]; 6990 else if (E.type(a) == 's') a = E.newElem$('span', '', '').text(a).elem()[0]; 6991 index = (index = (index < 0) ? index + this._elem[0].childNodes.length : index) < 0 ? 0 : index; 6992 if (!this.e(index) && (this._elem[0].childNodes.length > index)) { 6993 this._elem[0].insertBefore(a, this._elem[0].childNodes[index]) 6994 } else this._elem[0].appendChild(a) 6995 } 6996 return this 6997 }, 6998 appendTo: function(a, index) { 6999 E.$(a).append(this, index); 7000 return this 7001 }, 7002 firstChild: function() { 7003 return E.$(this._elem[0].firstChild) 7004 }, 7005 lastChild: function() { 7006 return E.$(this._elem[0].lastChild) 7007 }, 7008 prevSibling: function() { 7009 return E.$(this._elem[0].previousSibling) 7010 }, 7011 nextSibling: function() { 7012 with(this._elem[0]) return nextSibling ? E.$(nextSibling.nodeName == '#text' ? nextSibling.nextSibling : nextSibling) : null 7013 }, 7014 childs: function() { 7015 var items = []; 7016 for (var i = 0; i < this._elem[0].children.length; i++) items.push(E.$(this._elem[0].children[i])); 7017 return items 7018 }, 7019 childCount: function() { 7020 return this._elem[0].children.length 7021 }, 7022 elem: function() { 7023 return (this._elem.length != 1) ? this._elem : this._elem[0] 7024 }, 7025 parent: function(a) { 7026 var b = this._elem[0]; 7027 if (a) { 7028 a = E.type(a) == 'a' ? a : [a]; 7029 for (var i = 0; i < a.length; i++) { 7030 b = b.parentNode; 7031 while (b) { 7032 if (b.nodeName.toLowerCase() == a[i].toLowerCase()) break; 7033 b = b.parentNode 7034 } 7035 } 7036 } else b = this._elem[0].parentNode; 7037 return E.$(b) 7038 }, 7039 getElem: function(a) { 7040 return E.$(this._getElem(a)) 7041 }, 7042 selected: function(a) { 7043 with(this.elem()) for (var i = 0; i < options.length; i++) 7044 if (options[i].selected) return options[i][a ? a : 'value']; 7045 return null 7046 }, 7047 select: function(a, b) { 7048 with(this.elem()) if (b) { 7049 for (var i = 0; i < options.length; i++) 7050 if (options[i][b] == a) { 7051 options[i].selected = true; 7052 break 7053 } 7054 } else options[a].selected = true; 7055 return this 7056 }, 7057 type: function(a) { 7058 return this.att('type', a).toLowerCase() 7059 }, 7060 obj: function(a, b) { 7061 if (this.e(b)) return this._elem[0][a]; 7062 for (var i = 0; i < this._elem.length; i++) this._elem[0][a] = b; 7063 return this 7064 }, 7065 checked: function(a) { 7066 return this.obj('checked', a) 7067 }, 7068 name: function() { 7069 return this._elem[0].nodeName.toLowerCase() 7070 }, 7071 scroll: function(a, b) { 7072 if (E.type(b) == 'u') return this._elem[0]['scroll' + a]; 7073 return this.obj('scroll' + a, b) 7074 }, 7075 sTop: function(a) { 7076 return this.scroll('Top', a) 7077 }, 7078 index: function() { 7079 var i = 0, 7080 k = this._elem[0]; 7081 while (k = k.previousSibling) i++; 7082 return i 7083 }, 7084 exist: function() { 7085 var a = this.elem(); 7086 return E.isA(a) ? a.length > 0 : a != null 7087 } 7088}); 7089E.Util = { 7090 getParameters: function(url) { 7091 url = url || window.location.href; 7092 var paramsString = ""; 7093 if (url.indexOf('?') != -1) { 7094 var start = url.indexOf('?') + 1; 7095 var end = url.length; 7096 paramsString = url.substring(start, end) 7097 } 7098 var parameters = {}; 7099 var pairs = paramsString.split(/[&;]/); 7100 for (var i = 0, len = pairs.length; i < len; ++i) { 7101 var keyValue = pairs[i].split('='); 7102 if (keyValue[0]) { 7103 var key = decodeURIComponent(keyValue[0]); 7104 var value = keyValue[1] || ''; 7105 value = value.split(","); 7106 for (var j = 0, jlen = value.length; j < jlen; j++) { 7107 value[j] = decodeURIComponent(value[j]) 7108 } 7109 if (value.length == 1) { 7110 value = value[0] 7111 } 7112 parameters[key] = value 7113 } 7114 } 7115 return parameters 7116 }, 7117 decodeRepresentation: function(c, d) { 7118 d = Math.pow(10, -d); 7119 var f = c.length, 7120 e = 0, 7121 j = 0, 7122 k = 0, 7123 h = []; 7124 while (e < f) { 7125 var l, a = 0, 7126 m = 0; 7127 do {
7128 l = c.charCodeAt(e++) - 63; 7129 m |= (l & 31) << a; 7130 a += 5 7131 } while (l >= 32); 7132 var g = ((m & 1) ? ~(m >> 1) : (m >> 1)); 7133 j += g; 7134 a = 0; 7135 m = 0; 7136 do { 7137 l = c.charCodeAt(e++) - 63; 7138 m |= (l & 31) << a; 7139 a += 5 7140 } while (l >= 32); 7141 var i = ((m & 1) ? ~(m >> 1) : (m >> 1)); 7142 k += i; 7143 h.push([j * d, k * d]) 7144 } 7145 return h 7146 }, 7147 encodeRepresentation: function(c, d) { 7148 c = E.isA(c) ? c : [c]; 7149 d = Math.pow(10, d); 7150 var a, b, x = 0, 7151 y = 0, 7152 x1, y1, x2, y2 = 0; 7153 var res = ''; 7154 for (var i = 0; i < c.length; i++) { 7155 x2 = parseInt(c[i].lng * d); 7156 y2 = parseInt(c[i].lat * d); 7157 x1 = (x2 - x); 7158 x1 = (x1 < 0) ? ((~x1) << 1) + 1 : x1 << 1; 7159 y1 = (y2 - y); 7160 y1 = (y1 < 0) ? ((~y1) << 1) + 1 : y1 << 1; 7161 b = true; 7162 while ((y1 > 0) || (b)) { 7163 b = false; 7164 a = (y1 & 0x1F); 7165 y1 = y1 >> 5; 7166 a = (y1 > 0 ? a + 0x20 : a) + 63; 7167 res += String.fromCharCode(a) 7168 } 7169 b = true; 7170 while ((x1 > 0) || (b)) { 7171 b = false; 7172 a = (x1 & 0x1F); 7173 x1 = x1 >> 5; 7174 a = (x1 > 0 ? a + 0x20 : a) + 63; 7175 res += String.fromCharCode(a) 7176 } 7177 x = x2; 7178 y = y2 7179 } 7180 return res 7181 }, 7182 distToSegmentSquared: function(p, v, w) { 7183 function sqr(x) { 7184 return x * x 7185 } 7186 7187 function dist2(v, w) { 7188 return sqr(v.x - w.x) + sqr(v.y - w.y) 7189 } 7190 var l2 = dist2(v, w); 7191 if (l2 == 0) return dist2(p, v); 7192 var t = ((p.x - v.x) * (w.x - v.x) + (p.y - v.y) * (w.y - v.y)) / l2; 7193 if (t < 0) return dist2(p, v); 7194 if (t > 1) return dist2(p, w); 7195 return dist2(p, { 7196 x: v.x + t * (w.x - v.x), 7197 y: v.y + t * (w.y - v.y) 7198 }) 7199 }, 7200 distToSegment: function(p, v, w) { 7201 return Math.sqrt(this.distToSegmentSquared(p, v, w)) 7202 }, 7203 distToPoint: function(v, w) { 7204 function sqr(x) { 7205 return x * x 7206 } 7207 return Math.sqrt(sqr(v.x - w.x) + sqr(v.y - w.y)) 7208 } 7209}; 7210if (!Array.prototype.indexOf) { 7211 Array.prototype.indexOf = function(elt) { 7212 var len = this.length; 7213 var from = Number(arguments[1]) || 0; 7214 from = (from < 0) ? Math.ceil(from) : Math.floor(from); 7215 if (from < 0) from += len; 7216 for (; from < len; from++) { 7217 if (from in this && this[from] === elt) return from 7218 } 7219 return -1 7220 } 7221}; 7222E.Overlay = L.Class.extend({ 7223 _div: null, 7224 _onResize: function() { 7225 var s = E.windowSize(); 7226 this._div.size(s[0], s[1]) 7227 }, 7228 _onScroll: function() { 7229 var s = E.windowScroll(); 7230 this._div.pos(s[0], s[1]) 7231 }, 7232 show: function(div) { 7233 var s = E.windowSize(); 7234 this._div = E.$(E.newElem('div', 'OverlayPage', document.body)); 7235 this._div.size(s[0], s[1]).css("zIndex", E.Overlay.zIndex++).top(0); 7236 E.scroll(this._onScroll, this, true); 7237 E.resize(this._onResize, this, true); 7238 this._div.append(div); 7239 return this._div 7240 }, 7241 hide: function() { 7242 E.scroll(this._onScroll, this); 7243 E.resize(this._onResize, this); 7244 this._div.hide().remove() 7245 } 7246}); 7247E.Overlay.zIndex = 8000; 7248E.Overlay.showMessage = function(v) { 7249 var a = new E.Overlay.Form(), 7250 b = E.newElem$('div', 'OV_CL').click(a.hide, a), 7251 c = E.newElem$('div', 'OV_content').text(v), 7252 d = E.newElem$('div', 'OV_OK').click(a.hide, a); 7253 a.showWindow(E.newElem$('div', 'OV_Window').append([b, c, d])); 7254 b.left(c.width() - b.width()); 7255 d.left((c.width() - d.width()) / 2); 7256 return a 7257}; 7258E.Overlay.Form = L.Class.extend({ 7259 _div: null, 7260 _overlay: null, 7261 _oldOverflow: "", 7262 showWindow: function(div) { 7263 this._oldOverflow = E.body().css("overflow"); 7264 E.body().css("overflow", "hidden"); 7265 this._overlay = new E.Overlay(); 7266 this._div = E.$(E.newElem("div", "OverlayForm")); 7267 this._overlay.show(this._div); 7268 this._div.append(div); 7269 E.resize(this.updatePosition, this, true); 7270 this.updatePosition() 7271 }, 7272 hide: function() { 7273 E.body().css('overflow', this._oldOverflow); 7274 E.resize(this.updatePosition, this); 7275 this._div.hide().remove(); 7276 this._overlay.hide(); 7277 if (this._draggable) this._draggable.off('drag', this._onDrag, this) 7278 }, 7279 activateDrag: function(div) { 7280 this._draggable = new L.Draggable(this._div.elem(), div.elem()); 7281 this._draggable.enable() 7282 }, 7283 updatePosition: function() { 7284 var wSize = E.windowSize(); 7285 var cSize = this._div.size(); 7286 E.setPos(this._div.elem(), L.point(parseInt(((wSize[0] - cSize[0]) / 2)), parseInt(((wSize[1] - cSize[1]) / 2)))) 7287 } 7288}); 7289E.Hook = { 7290 executeHook: function(type) { 7291 var h = this._hook ? this._hook[type] : 0; 7292 if (h) 7293 for (var i = 0; i < h.length; i++) h[i].apply(this, Array.prototype.slice.call(arguments, 1)) 7294 },
7295 addHook: function(type, fn) { 7296 var args = Array.prototype.slice.call(arguments, 1); 7297 var init = typeof fn === 'function' ? fn : function() { 7298 this[fn].apply(this, args) 7299 }; 7300 E.ext(this, '_hook', []); 7301 E.ext(this._hook, type, []); 7302 this._hook[type].push(init) 7303 } 7304}; 7305E.Control = L.Control; 7306E.control = function(param) { 7307 new E.Control(param) 7308}; 7309E.Lang = { 7310 _code: 'pl', 7311 translate: function(key, context) { 7312 var dictionary = E.Lang[E.Lang._code]; 7313 var message = dictionary[key]; 7314 if (!message) { 7315 message = key 7316 } 7317 return message 7318 }, 7319 translateArray: function(key, context) { 7320 return E.Lang.translate(key, context).split('|') 7321 }, 7322 code: function(a) { 7323 if (a) this._code = a; 7324 return this._code 7325 }, 7326 add: function(items, prx) { 7327 prx = (prx ? prx : ''); 7328 for (var i in items) { 7329 E.ext(E.Lang, i, {}); 7330 for (var j in items[i]) E.Lang[i][prx + j] = items[i][j] 7331 } 7332 return this 7333 } 7334}; 7335E.lang = E.Lang.translate; 7336E.Lang.add({ 7337 pl: { 7338 'Center': 'Wycentruj', 7339 'DefaultView': 'Widok domyÅlny', 7340 'Print': 'Drukuj', 7341 'ReportError': 'ZgÅoÅ poprawkÄ', 7342 'PermaLink': 'Link aktualnego widoku', 7343 'Divider': '' 7344 } 7345}, "CM_").add({ 7346 pl: { 7347 "A": 'PrzesuÅ mapÄ' 7348 } 7349}, "M_").add({ 7350 pl: { 7351 "A": 'PowiÄksz w prostokÄ cie' 7352 } 7353}, "DR_").add({ 7354 "pl": { 7355 'D': 'OdlegÅoÅÄ: ', 7356 'A': 'Obliczanie odlegÅoÅci po prostej' 7357 } 7358}, 'DC_').add({ 7359 pl: { 7360 'Autostrada': 'autostrada', 7361 'Ekspresowa': 'droga ekspresowa', 7362 'Krajowa': 'droga krajowa', 7363 'Wojewodzka': 'droga wojewódzka', 7364 'Lokalna': 'droga lokalna', 7365 'UlicaGlowna': 'ulica gÅówna', 7366 'UlicaZwykla': 'ulica', 7367 'Prom': 'prom', 7368 'InternationalRoad': 'droga miÄdzynarodowa', 7369 'Przejsci': 'przejÅcie graniczne', 7370 'A': 'Informacje' 7371 } 7372}, "MI_").add({ 7373 pl: { 7374 'Lon': 'D\u0142ugoÅÄ geograficzna :', 7375 'Lat': 'Szeroko\u015bÄ geograficzna :', 7376 'A_LL': 'WspóÅrzÄdne geograficzne' 7377 } 7378}).add({ 7379 pl: { 7380 'PL_View': 'Link do aktualnego widoku mapy:' 7381 } 7382}).add({ 7383 pl: { 7384 '0': 'PrzesuÅ w górÄ', 7385 '1': 'PrzesuÅ w lewo', 7386 '2': 'PrzesuÅ w prawo', 7387 '3': 'PrzesuÅ w dóÅ', 7388 '4': 'PowiÄksz', 7389 '5': '', 7390 '6': 'Pomniejsz' 7391 } 7392}, 'Z_').add({ 7393 pl: { 7394 'em': 'Emapa Telematics sp. z o.o.' 7395 } 7396}, "A_").add({ 7397 pl: { 7398 'NotifyError': "ZgÅoszenie poprawki", 7399 'Describe': "Opis poprawki:", 7400 'Item_0': "Brak obiektu", 7401 'Item_1': "BÅÄdny przebieg", 7402 'Item_2': "BÅÄdna nazwa", 7403 'Item_3': "BÅÄ d kierunkowoÅci", 7404 'Item_4': "BÅÄdny typ drogi", 7405 'Item_5': "Brak przejazdu", 7406 'Item_6': "Zakaz nakaz / skrÄtu", 7407 'Item_7': "Zakaz zawracania", 7408 'Item_8': "Ograniczenie wys. wiaduktu", 7409 'Item_9': "Ograniczenia noÅnoÅci", 7410 'Item_10': "Droga dla pieszych / rowerów", 7411 'Item_11': "Inne", 7412 'Send': "ZgÅoÅ poprawkÄ", 7413 'MAX_FILE_SIZE': "Maksymalny rozmiar pliku: 5MB" 7414 } 7415}, 'RE_').add({ 7416 pl: { 7417 'UserName': 'Nazwa użytkownika:', 7418 'Pass': 'HasÅo:', 7419 'RememberMe': 'ZapamiÄtaj mnie', 7420 'Login': 'Zaloguj »', 7421 'Register': 'Zarejestruj', 7422 'ForgotPass': 'Nie pamiÄtasz hasÅa?', 7423 'UserEmpty': 'Nazwa użytkownika nie może byÄ pusta', 7424 'PassEmpty': 'HasÅo nie może byÄ puste', 7425 'ConnectionError': 'BÅÄ d poÅÄ czenia z serwerem', 7426 'UnknownError': 'WystÄ piÅ nieznany bÅad.', 7427 'BadLoginOrPasswordError': 'ZÅy użytkownik lub/i hasÅo.', 7428 'ServerSendUnknowResponse': 'Serwer zwróciÅ nieznany wynik.' 7429 } 7430}, 'LW_').add({ 7431 pl: { 7432 'how_report': 'Aby zgÅosiÄ bÅÄ d, zamknij okno Twojego profilu, prawym przyciskiem myszy wskaż na mapie dokÅadne miejsce wystÄpowania bÅÄdu i wybierz opcjÄ "ZgÅoÅ poprawkÄ".<br/><br/><br/><br/><br/><br/><br/><br/><br/>', 7433 'report_anonymous': 'zgÅoÅ anonimowo', 7434 'profil': 'profil', 7435 'report_error': 'zgÅoÅ poprawkÄ', 7436 'reported_errors_empty': 'Nie zgÅosiÅeÅ jeszcze żadnych bÅÄdów.', 7437 'reported_errors': 'zgÅoszone poprawki', 7438 'e-toll module': 'moduÅ e-myto', 7439 'logout': 'wyloguj', 7440 'login_privacy': 'W celu zapewnienia Twoim danym jak najwyższych standardów bezpieczeÅstwa, prosimy o potwierdzenie Twej tożsamoÅci:', 7441 'e_myto_info': 'ModuÅ e-myto na Emapi.pl dostÄpny jest jedynie po zalogowaniu w wersji komercyjnej. Wszystkich zainteresowanych przetestowaniem jego dziaÅania prosimy o <a href="?page=kontakt" style="color:blue">kontakt</a> z dziaÅem handlowym w celu otrzymania dostÄpu czasowego.<br/><br/>', 7442 'reported_errors_info': 'ZgÅosiÅeÅ/aÅ {0} bÅÄdy/ów w naszej mapie.<br>Za wszystkie zgÅoszenia dziÄkujemy!!<br/><br/><br/><br/><br/><br/><br/><br/><br/>', 7443 'viatoll_acces': 'Posiadasz dostÄp do moduÅu e-myto - możesz wytyczaÄ trasy dla pojazdów ciÄżarowych (zakÅadka "Oblicz trasÄ" -> opcja "ciÄżarowy").<br><br>Data ważnoÅci dostÄpu do moduÅu: ', 7444 'login': 'Zaloguj', 7445 'reported_errors_0': 'nie poprawione', 7446 'reported_errors_1': 'poprawione', 7447 'reported_errors_2': 'oczekujÄ ce na <br>wyjÄ snienie', 7448 'reported_errors_3': 'odrzucone' 7449 } 7450}, 'PM_').add({ 7451 pl: { 7452 'i0': '', 7453 'i1': 'Wyjazd z punktu', 7454 'i2': 'Dotarcie do punktu',
7455 'i3': 'SkrÄÄ w lewo', 7456 'i4': 'SkrÄÄ w prawo', 7457 'i5': 'Trzymaj siÄ lewej strony', 7458 'i6': 'Trzymaj siÄ prawej strony', 7459 'i7': 'WÅÄ cz siÄ w drogÄ', 7460 'i8': 'Jedź na wprost drogÄ ', 7461 'i9': 'ZawrÃ³Ä na drogÄ', 7462 'i10': 'SkrÄÄ na rondzie', 7463 'i11': 'Roboty drogowe', 7464 'i12': '', 7465 'i13': 'Zmiana nazwy drogi ', 7466 'i14': 'SkrÄÄ w lewo i chwilÄ potem w lewo', 7467 'i15': 'SkrÄÄ w lewo i chwilÄ potem w prawo', 7468 'i16': 'SkrÄÄ w prawo i chwilÄ potem w lewo', 7469 'i17': 'SkrÄÄ w prawo i chwilÄ potem w prawo', 7470 'i18': 'Jedź zjazdem na wprost', 7471 'i19': 'Jedź zjazdem w lewo', 7472 'i20': 'Jedź zjazdem w prawo', 7473 'i21': 'Jedź na wprost', 7474 'i22': 'Jedź w lewo', 7475 'i23': 'Jedź w prawo', 7476 'i24': 'PrzejÅcie graniczne . Wjeżdzasz do paÅstwa', 7477 'i25': 'RozpoczÄcie podróży. DzieÅ podróży ', 7478 'i26': 'ZakoÅczenie podróży w dniu ', 7479 'i27': 'PÅatna bramka. OpÅata ', 7480 'i28': 'PoczÄ tek drogi pÅatnej', 7481 'i29': 'Koniec drogi pÅatnej', 7482 'i30': 'PoczÄ tek odpoczynku kierowcy', 7483 'i31': 'Koniec odpoczynku kierowcy', 7484 'i32': 'PoczÄ tek podróży promem', 7485 'i33': 'Koniec podróży promem', 7486 'i34': 'Tankowanie pojazdu', 7487 'i35': 'beginningOfChargeRoad', 7488 'i36': 'endOfChargeRoad', 7489 'i37': 'PoczÄ tek drogi z mytem', 7490 'i38': 'Koniec drogi z mytem', 7491 'ix': 'NieobsÅużony kod raprtu nr ', 7492 'ic0': ' w ', 7493 'ic1': ' drogÄ ', 7494 'ic2': ' na drogÄ ', 7495 'ic3': ' na ', 7496 'ic4': '. Wjeżdzasz do paÅstwa ', 7497 'ic5': '. DzieÅ podróży ', 7498 'ic6': ' w dniu ', 7499 'ic7': '. OpÅata ', 7500 'ic8': ' zjazd nr ', 7501 'hkm': 'km', 7502 'hzl': 'zÅ', 7503 'htime': 'Czas', 7504 'hcost': 'Koszt', 7505 'hdist': 'OdlegÅoÅÄ', 7506 'hin': 'W tym ', 7507 'hVT': 'myto:', 7508 'hTR': 'drogi pÅatne:', 7509 'hfm': 'Z ', 7510 'hto': 'Do ', 7511 'lo': 'Odcinek ', 7512 'ld': 'Opis', 7513 'p_no1': 'Nie ustawiono punktu startowego', 7514 'p_no2': 'Nie ustawiono punktu koÅcowego', 7515 'MXR': 'Maksymalna liczba punktów trasy wynosi ' 7516 } 7517}, 'RR_').add({ 7518 pl: { 7519 'AddFromPoint': 'Jedź z', 7520 'AddViaPoint': 'Jedź przez', 7521 'AddToPoint': 'Jedź do' 7522 } 7523}, 'CM_').add({ 7524 pl: { 7525 'Highway': 'Autostrada', 7526 'Speedway': 'Ekspresowa', 7527 'NationalRoad': 'Krajowa', 7528 'RegionalRoad': 'Wojewódzka', 7529 'LocalRoad': 'Lokalna', 7530 'OtherRoad': 'PozostaÅa', 7531 'UnpavedRoad': 'Gruntowa', 7532 'VehicularStreet': 'Przejazdowa', 7533 'MainStreet': 'Ulica gÅówna', 7534 'OtherStreet': 'Ulica pozostaÅa', 7535 'Ferry': 'Prom', 7536 'Koszt': 'Obliczenie z uwzglÄdnieniem ...', 7537 'RM': 'Raport Myto' 7538 } 7539}, "RT_").add({ 7540 pl: { 7541 'D': ' w kierunku ', 7542 'DS': 'kier.', 7543 'OFA': 'Pieszo ok.', 7544 'ROF': 'pieszo', 7545 'RISL': 'w linii prostej', 7546 'RNOS': 'liczba przystanków', 7547 'RSS': 'pokaż wszystkie przystanki', 7548 'RHS': 'ukryj przystanki', 7549 'B': 'Autobus ', 7550 'T': 'Tramwaj ', 7551 'WE': 'W dni robocze', 7552 'SA': 'W soboty', 7553 'SU': 'W niedziele', 7554 'ET_TT': 'Rozk\u0142ad jazdy metra: ', 7555 'G': 'Godz.', 7556 'M': 'Minuty' 7557 } 7558}, 'ET_').add({ 7559 pl: { 7560 'ETR_BR': "<div style='width:400px;height:60px'>Twoje wyszukiwanie trasy dla komunikacji publicznej jest poza obszarem obj\u0119tym obecnie naszym zasiÄgiem. Sugerujemy wytyczenie szukanej trasy dla pojazdu. Lista zespoÅów miejskich, dla których na dzieÅ dzisiejszy można wytyczyÄ trasÄ dla komunikacji publicznej jest dostÄpna w zakÅadce \"O EMAPI\"." 7561 } 7562}).add({ 7563 pl: { 7564 'info': "<div style='width:300px;height:60px'>Warstwy <span style='color:red'>Traffic</span>, <span style='color:blue'>Inwestycje drogowe</span> i <span style='color:green'>Mapa turystyczna</span> nie mogÄ byÄ jednoczeÅnie wyÅwietlane. WybierajÄ c jednÄ z nich automatycznie jÄ aktywujesz, (wyÅÄ czajÄ c ewentualnÄ innÄ dotychczas widocznÄ warstwÄ).</div>", 7565 } 7566}, 'LC_').add({ 7567 pl: { 7568 'FA': 'PeÅny artykuÅ', 7569 'A': 'CaÅy tekst jest dostÄpny na warunkach Licencji GNU Wolnej Dokumentacji' 7570 } 7571}, 'LP_W').add({ 7572 pl: { 7573 'M': 'Mapa', 7574 'P': 'Hipsometria', 7575 'H': 'Hybryda' 7576 } 7577}, 'LP_PLN').add({ 7578 pl: { 7579 'WR': 'Utrudnienia w ruchu: ', 7580 'RDK': 'ruch dwukierunkowy', 7581 'DZ': 'droga zamkniÄta', 7582 'UW': 'Uwagi: ', 7583 'PD': 'prÄdkoÅci do ', 7584 'ND': 'noÅnoÅci do ', 7585 'SD': 'szerokoÅci do ', 7586 'WD': 'wysokoÅci do ', 7587 'OG': 'Ograniczenia: ', 7588 'OD': ' od ', 7589 'DO': ' do ', 7590 'OB': 'ObowiÄ zuje' 7591 } 7592}, 'LP_PU').add({ 7593 pl: { 7594 'AS': 'Autostrada', 7595 'DE': 'Droga ekspresowa', 7596 'D': 'Droga', 7597 '0': 'w budowie/projekt + budowa', 7598 '1': 'przetarg', 7599 '2': 'decyzja Årodowiskowa', 7600 '3': 'planowane', 7601 '4': 'istniejÄ ce', 7602 'RL': 'Etap budowy :', 7603 'CRS': 'Odcinek :', 7604 'CRE': 'Data zakoÅczenia :' 7605 } 7606}, 'LP_NR_').add({ 7607 pl: { 7608 'Scenic Route': 'Szlak widokowy', 7609 'Pedestrian Path': 'Szlak pieszy', 7610 'Bicycle Path': 'Szlak rowerowy', 7611 'Horse Path': 'Szlak konny', 7612 'Ski Trail': 'Szlak narciarski', 7613 'Bicycle Alley': 'Droga dla rowerów', 7614 'blue': 'niebieski', 7615 'green': 'zielony', 7616 'yellow': 'żóÅty', 7617 'black': 'czarny', 7618 'red': 'czerwony' 7619 } 7620}, 'LP_TR').add({ 7621 pl: { 7622 'CS': 'Obecna prÄdkoÅÄ:', 7623 'TD': 'Opó\u017anienie:' 7624 } 7625}, 'LP_TMC').add({ 7626 pl: { 7627 'CD': 'JadÄ autem', 7628 'PT': 'Jad\u0119 Årodkami komunikacji publicznej',
7629 'W': 'Id\u0119 pieszo', 7630 B: 'JadÄ rowerem', 7631 'dit': 'Wytycza trasÄ uwzglÄdniajÄ c utrudnienia GDDKiA', 7632 'tit': 'Wytycza trasÄ uwzglÄdniajÄ c aktualne natÄżenie ruchu na drogach (Traffic)', 7633 'tita': 'Wytycza trasÄ uwzglÄdniajÄ c prognozowane/archiwalne natÄżenie ruchu na drogach (Traffic)', 7634 'mit': 'Wytycza trasÄ z pominiÄciem dróg z poborem opÅat (myta)', 7635 'ulit': 'Wytycza trasÄ uwzglÄdniajÄ c parametry pojazdu: tonaż, wysokoÅÄ, nacisk na oÅ, itp.', 7636 'rt1t': 'Optymalne po\u0142Ä czenie sugerowane przez system', 7637 'rt2t': 'Zawiera jak najmniej przej\u015bÄ pieszych', 7638 'rt3t': 'Gwarantuje najszybsze dotarcie do celu', 7639 'rt4t': 'Zawiera jak najmniej przesiadek', 7640 'F': 'Z', 7641 'V': 'Przez', 7642 'T': 'Do', 7643 'Country': 'PL|Polska||--- wszystkie ---|AF|Afganistan|AL|Albania|DZ|Algieria|AD|Andora|AO|Angola|AI|Anguilla|AQ|Antarktyda|AG|Antigua i Barbuda|AN|Antyle Holenderskie|SA|Arabia Saudyjska|AR|Argentyna|AM|Armenia|AW|Aruba|AU|Australia|AT|Austria|PS|Autonomia PalestyÅska|AZ|Azerbejdżan|BS|Bahamy|BH|Bahrajn|BD|Bangladesz|BB|Barbados|BE|Belgia|BZ|Belize|BJ|Benin|BM|Bermudy|BT|Bhutan|BY|BiaÅoruÅ|BU|Birma|BO|Boliwia|BW|Botswana|BA|BoÅnia i Hercegowina|BR|Brazylia|BN|Brunei|IO|Brytyjskie Terytorium Oceanu Indyjskiego|VG|Brytyjskie Wyspy Dziewicze|BF|Burkina Faso|BI|Burundi|BG|BuÅgaria|CL|Chile|CN|Chiny|HR|Chorwacja|CY|Cypr|TD|Czad|ME|Czarnogóra|CZ|Czechy|UM|Dalekie Wyspy Mniejsze Stanów Zjednoczonych|DK|Dania|CD|Demokratyczna Republika Konga|DM|Dominika|DO|Dominikana|DJ|Dżibuti|EG|Egipt|EC|Ekwador|ER|Erytrea|EE|Estonia|ET|Etiopia|FK|Falklandy|FJ|Fidżi|PH|Filipiny|FI|Finlandia|FR|Francja|TF|Francuskie Terytoria PoÅudniowe|GA|Gabon|GM|Gambia|GH|Ghana|GI|Gibraltar|GR|Grecja|GD|Grenada|GL|Grenlandia|GE|Gruzja|GU|Guam|GY|Gujana|GF|Gujana Francuska|GP|Gwadelupa|GT|Gwatemala|GN|Gwinea|GQ|Gwinea Równikowa|GW|Gwinea-Bissau|HT|Haiti|ES|Hiszpania|NL|Holandia|HN|Honduras|HK|Hong Kong|IN|Indie|ID|Indonezja|IQ|Irak|IR|Iran|IE|Irlandia|IS|Islandia|IL|Izrael|JM|Jamajka|JP|Japonia|YE|Jemen|JO|Jordania|KY|Kajmany|KH|Kambodża|CM|Kamerun|CA|Kanada|QA|Katar|KZ|Kazachstan|KE|Kenia|KG|Kirgistan|KI|Kiribati|CO|Kolumbia|KM|Komory|KR|Korea PoÅudniowa|KP|Korea PóÅnocna|CR|Kostaryka|CU|Kuba|KW|Kuwejt|LA|Laos|LS|Lesotho|LB|Liban|LR|Liberia|LY|Libia|LI|Liechtenstein|LT|Litwa|LU|Luksemburg|LV|Åotwa|MK|Macedonia|MG|Madagaskar|YT|Majotta|MO|Makau|MW|Malawi|MV|Malediwy|MY|Malezja|ML|Mali|MT|Malta|MA|Maroko|MQ|Martynika|MR|Mauretania|MU|Mauritius|MX|Meksyk|FM|Mikronezja|MC|Monako|MN|Mongolia|MS|Montserrat|MZ|Mozambik|MD|MoÅdawia|MM|Myanmar|NA|Namibia|NR|Nauru|NP|Nepal|DE|Niemcy|NE|Niger|NG|Nigeria|NI|Nikaragua|NU|Niue|NF|Norfolk|NO|Norwegia|NC|Nowa Kaledonia|NZ|Nowa Zelandia|OM|Oman|PK|Pakistan|PW|Palau|PA|Panama|PG|Papua-Nowa Gwinea|PY|Paragwaj|PE|Peru|PN|Pitcairn|PF|Polinezja Francuska oraz Wyspa Clipperton|PL|Polska|PR|Portoryko|PT|Portugalia|MP|PóÅnocne Mariany|CG|Republika Konga|ZA|Republika PoÅudniowej Afryki|CF|Republika ÅrodkowoafrykaÅska|RU|Rosja|RO|Rumunia|RW|Rwanda|EH|Sahara Zachodnia|KN|Saint Kitts i Nevis|LC|Saint Lucia|VC|Saint Vincent i Grenadyny|PM|Saint-Pierre i Miquelon|SV|Salwador|WS|Samoa|AS|Samoa AmerykaÅskie|SM|San Marino|SN|Senegal|RS|Serbia|SC|Seszele|SL|Sierra Leone|SG|Singapur|SO|Somalia|LK|Sri Lanka|US|Stany Zjednoczone|SZ|Suazi|SD|Sudan|SR|Surinam|SY|Syria|CH|Szwajcaria|SE|Szwecja|SK|SÅowacja|SI|
7643SÅowenia|SH|ÅwiÄta Helena|TJ|Tadżykistan|TH|Tajlandia|TW|Tajwan|TZ|Tanzania|TL|Timor Wschodni|TG|Togo|TK|Tokelau|TO|Tonga|TT|Trynidad i Tobago|TN|Tunezja|TR|Turcja|TM|Turkmenistan|TC|Turks i Caicos|TV|Tuvalu|UG|Uganda|UA|Ukraina|UY|Urugwaj|UZ|Uzbekistan|VU|Vanuatu|WF|Wallis i Futuna|VA|Watykan|VE|Wenezuela|UK|Wielka Brytania|VN|Wietnam|CI|Wybrzeże KoÅci SÅoniowej|BV|Wyspa Bouveta|GG|Wyspa Guernsey|JE|Wyspa Jersey|IM|Wyspa Man|RE|Wyspa Reunion|AC|Wyspa WniebowstÄ pienia|AX|Wyspy Alandzkie|CX|Wyspy Bożego Narodzenia|CK|Wyspy Cooka|VI|Wyspy Dziewicze Stanów Zjednoczonych|GS|Wyspy Georgia PoÅudniowa i Sandwich PoÅudniowy|HM|Wyspy Heard i McDonalda|CC|Wyspy Kokosowe|MH|Wyspy Marshalla|FO|Wyspy Owcze|SB|Wyspy Salomona|CV|Wyspy Zielonego PrzylÄ dka|ST|Wyspy ÅwiÄtego Tomasza i KsiÄ Å¼Äca|IT|WÅochy|HU|WÄgry|ZM|Zambia|ZW|Zimbabwe|AE|Zjednoczone Emiraty Arabskie', 7644 'cats': 'Wszystkie kategorie', 7645 'rt': 'najszybsza|najkrótsza|najtaÅsza', 7646 'rtt': 'domyÅlna|wygodna|szybka|bezpoÅrednia', 7647 'vt': 'osobowy|ciÄżarowy', 7648 'lo': 'Wyloguj', 7649 'li': 'Zaloguj', 7650 'v1': "Pojazd (3,5t - 12t)", 7651 'v2': "Pojazd (>12t)", 7652 'v3': "Autobus", 7653 'pagePanelNoSearchResult': 'brak wyników', 7654 'pagePanelToManySearchResult': 'zbyt dużo wyników' 7655 } 7656}, 'TT_').add({ 7657 pl: { 7658 'from': 'Z', 7659 'to': 'Do', 7660 'cross': 'Przez', 7661 'AWP': 'Punkt poÅredni', 7662 'A': 'nie znaleziono adresu', 7663 'B': '<div style="width:300px;height:40px">Trasy wytyczane dla komunikacji publicznej biorÄ pod uwagÄ jedynie punkt poczÄ tkowy i koÅcowy trasy.</div>', 7664 eg: 'np. Åódź, ÅÄ kowa 11' 7665 } 7666}, 'LI_').add({ 7667 pl: { 7668 'OS_NR': 'brak wyników', 7669 'OS_FR': "zbyt dużo wyników", 7670 "OS_eg": 'np. Pub,Åódź' 7671 } 7672}).add({ 7673 pl: { 7674 'M': 'Mapa', 7675 'L': 'Warstwy', 7676 'P': 'POI', 7677 'O': 'WiÄcej', 7678 'MT': 'Mapa turystyczna' 7679 } 7680}, 'LP_SL').add({ 7681 pl: { 7682 'TvehicleWeight': 'Dopuszczalna masa caÅkowita [t]', 7683 'TvehicleWeightPerAxle': 'Nacisk na oÅ [t]', 7684 'TvehicleHeight': 'WysokoÅÄ [m]', 7685 'TvehicleWidth': 'SzerokoÅÄ [m]', 7686 'TroadType': 'Typ drogi', 7687 'Tuse': ' ', 7688 'Tspeed': 'PrÄdkoÅÄ [km/h]', 7689 'Tcombustion': 'Spalanie [l/100km]', 7690 'Ttoll': 'Koszt myta [zÅ]' 7691 } 7692}, 'TE_'); 7693E.langa = E.Lang.translateArray; 7694E.API = L.Class.extend({ 7695 _ajax: null, 7696 _server: '', 7697 _userID: 0, 7698 _index: 0, 7699 _items: [], 7700 _session: null, 7701 _querySession: null, 7702 initialize: function(userID, parent, server) { 7703 this._items = []; 7704 this._querySession = []; 7705 this._ajax = new E.API.Ajax(); 7706 this._userID = userID; 7707 this._server = server ? server : E.server.API; 7708 this._serverPOI = server ? server : E.server.POIAPI; 7709 this._key = this.regAction(this._onResponse, this); 7710 this._initFuncitons(parent); 7711 this._parent = parent; 7712 this._session = new E.API.Session(this) 7713 }, 7714 regAction: function(fun, sc) { 7715 var key = "X" + E.API.index; 7716 E.API.index++; 7717 E[key] = sc ? E.bind(fun, sc) : fun; 7718 return "E." + key 7719 }, 7720 _getFunction: function(name, session, server) { 7721 return function(params, callback, scope, object, onDone, paramType) { 7722 if ((session) && (!this._session.getId())) this._querySession.push([name, params, callback, scope, object, onDone, paramType]); 7723 else this._sendQuery(name, params, callback, scope, object, onDone, paramType, server) 7724 } 7725 }, 7726 _setApi: function(a, b, c, d) { 7727 for (var i = 0; i < a.length; i++) this[a[i].charAt(0).toLowerCase() + a[i].slice(1)] = this._getFunction(a[i], b, d); 7728 if (c) 7729 for (i = 0; i < a.length; i++) c[a[i].charAt(0).toLowerCase() + a[i].slice(1)] = E.bind(this._getFunction(a[i], b, d), this) 7730 }, 7731 _initFuncitons: function(obj) { 7732 this._setApi(['GetObjectsData', 'GetObjectData', 'SearchObjects', 'SearchPOI', 'GetObjectCategories', 'GetPOICategories', 'Degeocode'], false, obj, this._serverPOI); 7733 this._setApi(['KeepSession', 'GetCopyright', 'Login', 'Logout', 'AddWaypoint', 'CalculateRoute', 'OptimizeRoute', 'MultiDegeocode', 'ETR_StopLines', 'ETR_FindRoute', 'ETR_Timetable', 'Geocode', 'GeocodeExt', 'PostError', 'AddressSearch'], false, obj); 7734 this._setApi(['GetCoordinates', 'GetAdvert', 'ShapeRemove', 'ShapeAdd', 'ShapeSet', 'ShapeGet', 'ShapeDegeocodeGeometry'], false, obj); 7735 this._setApi(['Version'], false, obj); 7736 obj.url = E.bind(this.url, this); 7737 obj.regAction = E.bind(this.regAction, this); 7738 obj.setSession = E.bind(this.setSession, this) 7739 }, 7740 _bulidParams: function(fname, params, paramType, index) { 7741 var p = { 7742 userID: this._userID, 7743 key: this._key, 7744 idx: index, 7745 fun: fname 7746 }; 7747 if (this._session) p.SessionID = this._session.getId(); 7748 if (paramType == 1) L.Util.extend(p, params); 7749 else p.json = params; 7750 return p 7751 }, 7752 _sendQuery: function(fname, params, callback, scope, object, onDone, paramType, server) { 7753 var index = this._index++; 7754 this._items[index] = { 7755 fun: E.bind(callback, scope), 7756 item: object 7757 }; 7758 this._ajax.sendQuery(server ? server : this._server, this._bulidParams(fname, params, paramType, index), E.bind(this._onDone, this, onDone ? E.bind(onDone, scope) : undefined)) 7759 }, 7760 url: function(server, params, callback, scope, object, onDone, paramType) { 7761 var index = this._index++; 7762 this._items[index] = { 7763 fun: E.bind(callback, scope), 7764 item: object 7765 }; 7766 this._ajax.sendQuery(server, this._bulidParams('legend', params, paramType, index), E.bind(this._onDone, this, onDone ? E.bind(onDone, scope) : undefined)) 7767 }, 7768 setSession: function(a) { 7769 this._session._sessionId = a 7770 }, 7771 sessionInitialized: function() { 7772 for (var i = 0; i < this._querySession.length; i++) { 7773 var a = this._querySession[i]; 7774 this._sendQuery(a[0], a[1], a[2], a[3], a[4], a[5], a[6]) 7775 } 7776 }, 7777 _onResponse: function(index, result) { 7778 try { 7779 var item = this._items[index]; 7780 if (item && item.fun) item.fun(result, item.item) 7781 } catch (e) { 7782 console.warn(e.message); 7783 console.warn(e.stack); 7784 item.fun(result, item.item) 7785 } 7786 item = undefined; 7787 delete this._items[index] 7788 }, 7789 _onDone: function(call, params) { 7790 if (call) call(); 7791 if ((params[2] == 'error') && this._parent.fire) this._parent.fire('queryError') 7792 } 7793}); 7794E.API.index = 0; 7795E.API.Ajax = L.Class.extend({ 7796 options: { 7797 crossDomain: true 7798 }, 7799 _head: null, 7800 _json: null, 7801 initialize: function(options) { 7802 this._head = document.head || document.getElementsByTagName("head")[0] || document.documentElement; 7803 this._json = new E.API.JSON() 7804 }, 7805 _getHTTPObject: function() { 7806 try { 7807 return new XMLHttpRequest() 7808 } catch (e) {
7809 try { 7810 return new ActiveXObject("Msxml2.XMLHTTP") 7811 } catch (e) { 7812 try { 7813 return new ActiveXObject("Microsoft.XMLHTTP") 7814 } catch (e) { 7815 alert("Your browser broke!"); 7816 return false 7817 } 7818 } 7819 } 7820 }, 7821 getRequestCrossDomain: function(url, head, script) { 7822 return { 7823 send: function(_, callback) { 7824 script = document.createElement("script"); 7825 script.async = "async"; 7826 script.src = url; 7827 script.onerror = script.onload = script.onreadystatechange = function(_, isAbort) { 7828 if (isAbort || !script.readyState || /loaded|complete/.test(script.readyState)) { 7829 script.onload = script.onreadystatechange = null; 7830 if (script.parentNode) { 7831 script.parentNode.removeChild(script) 7832 } 7833 var state = script.readyState; 7834 script = undefined; 7835 if (callback) callback(url, state, _ ? _.type : null) 7836 } 7837 }; 7838 head.insertBefore(script, head.firstChild) 7839 }, 7840 abort: function() { 7841 if (script) { 7842 script.onload(0, 1) 7843 } 7844 } 7845 } 7846 }, 7847 _parseParams: function(parseParams) { 7848 return this._json.parse(parseParams) 7849 }, 7850 sendQuery: function(url, params, callback) { 7851 this.getRequestCrossDomain(url + "?" + this._parseParams(params), this._head).send('', callback) 7852 } 7853}); 7854E.API.JSON = L.Class.extend({ 7855 _ignoredItems: ['name', 'id'], 7856 _ignoreItems: function(item) { 7857 if (item == undefined) return true; 7858 if (item instanceof Function) return true; 7859 if (item instanceof String) { 7860 for (var i = 0; i < this._ignoredItems.length; i++) 7861 if (this._ignoredItems[i] == item) return true; 7862 if (item[0] == '$') return true 7863 } 7864 return false 7865 }, 7866 _getItem: function(item, addName, nameBrace, nameSign, resultSign) { 7867 var res = ''; 7868 var first = true; 7869 for (var obj in item) { 7870 if (!this._ignoreItems(item[obj])) { 7871 if (!first) res += resultSign; 7872 else first = false; 7873 if (addName) res += nameBrace + obj + nameBrace + nameSign; 7874 if (item[obj] instanceof Array) res += '[' + this._getItem(item[obj], false, '"', '', ',') + ']'; 7875 else if (item[obj] instanceof Object) res += '{' + this._getItem(item[obj], true, '"', ':', ',') + '}'; 7876 else res += nameBrace + item[obj] + nameBrace 7877 } 7878 } 7879 return res 7880 }, 7881 parse: function(object) { 7882 return this._getItem(object, true, '', '=', '&') 7883 } 7884}); 7885E.API.Session = L.Class.extend({ 7886 _sessionId: undefined, 7887 _api: null, 7888 _keepSessionTimer: null, 7889 _keepSessionInterval: 900000, 7890 initialize: function(api) { 7891 this._api = api 7892 }, 7893 initSession: function() { 7894 this._api.sessionStart(null, this.onGetSesstion, this) 7895 }, 7896 onGetSesstion: function(response) { 7897 if (response.result == 0) { 7898 this._sessionId = response.sessionid; 7899 this._api.sessionInitialized(); 7900 this._keepSessionTimer() 7901 } 7902 }, 7903 _keepSessionTimer: function() { 7904 this._keepSessionTimer = setTimeout(E.bind(function() { 7905 this._api.keepSession(this._onKeepSession, this) 7906 }, this), this._keepSessionInterval) 7907 }, 7908 onKeepSession: function(response) { 7909 if (response.result != 0) { 7910 this.initSession() 7911 } else this._keepSessionTimer() 7912 }, 7913 getId: function() { 7914 return this._sessionId 7915 } 7916}); 7917E.QueryList = L.Class.extend({ 7918 _queryList: null, 7919 _waitForResponse: false, 7920 _scope: null, 7921 initialize: function(scope) { 7922 this._scope = scope; 7923 this._queryList = new Array() 7924 }, 7925 clear: function() { 7926 this._queryList.length = 0; 7927 this._waitForResponse = false 7928 }, 7929 addQuery: function(fun, param) { 7930 this._queryList.unshift({ 7931 fun: fun, 7932 param: param 7933 }); 7934 this._checkSendRequest() 7935 }, 7936 removeQuery: function(property, val) { 7937 for (var i = 0; i < this._queryList.length; i++) 7938 if (this._queryList[i][property] == val) this._queryList.slice(i, 1) 7939 }, 7940 _checkSendRequest: function() { 7941 if ((!this._waitForResponse) && (this._queryList.length > 0)) { 7942 this._waitForResponse = true; 7943 var obj = this._queryList.pop();
7944 obj.fun.call(this._scope, obj.param) 7945 } 7946 }, 7947 nextQuery: function() { 7948 this._waitForResponse = false; 7949 this._checkSendRequest() 7950 } 7951}); 7952E.TileLayer = L.TileLayer; 7953E.TMS = E.TileLayer.extend({ 7954 onAdd: function(map) { 7955 L.TileLayer.prototype.onAdd.call(this, map); 7956 map.on("MapInitialized", this._onInitialize, this) 7957 }, 7958 _onInitialize: function() { 7959 this._map.getCopyright("", this._onCopyright, this) 7960 }, 7961 _onCopyright: function(result) { 7962 this.options.attribution = result.join(", "); 7963 this._map.fire('layerAttributionChange') 7964 }, 7965 getTileUrl: function(tilePoint) { 7966 this._adjustTilePoint(tilePoint); 7967 with(this.options) return L.Util.template(this._url, L.Util.extend({ 7968 s: this._getSubdomain(tilePoint), 7969 z: this._getZoomForUrl(), 7970 x: tilePoint.x, 7971 y: tilePoint.y, 7972 l: _layerZoom[_activeLayer][this._getZoomForUrl()] 7973 }, this.options)) 7974 }, 7975 setLayerType: function(a) { 7976 with(this.options) { 7977 if ((a = _layerTypes.indexOf(a)) != _activeLayer) { 7978 _activeLayer = a, this.redraw() 7979 } 7980 } 7981 } 7982}); 7983(function() { 7984 var l, i, a, b; 7985 for (i = 0, a = ['Marker', 'Polygon', 'Polyline', 'Circle']; i < a.length; i++) { 7986 b = E[a[i]] = L[a[i]].extend({ 7987 includes: E.Hook, 7988 _class: L[a[i]], 7989 proto: function(a, b, c) { 7990 this._class.prototype[a].call(this, b, c) 7991 }, 7992 openPopup: function() { 7993 this.proto('openPopup'); 7994 this.executeHook('openPopup'); 7995 if (this.options.riseOnInfo) this._bringToFront() 7996 }, 7997 closePopup: function() { 7998 this.proto('closePopup'); 7999 this.executeHook('closePopup'); 8000 if (this.options.riseOnInfo) this._resetZIndex() 8001 }, 8002 onAdd: function(map) { 8003 this.proto('onAdd', map); 8004 this.executeHook('onAdd', map) 8005 }, 8006 onRemove: function(map) { 8007 this.proto('onRemove', map); 8008 this.executeHook('onRemove', map) 8009 }, 8010 bindPopup: function(content, options) { 8011 this.proto('bindPopup', content, options); 8012 if (this.options.raiseOnHover) this.on('mouseover', this.openPopup, this); 8013 this._popup.on('close', this.closePopup, this); 8014 this.executeHook('bindPopup', content, options); 8015 return this 8016 }, 8017 unbindPopup: function() { 8018 this._popup.off('close', this.closePopup); 8019 this.proto('unbindPopup'); 8020 if (this.options.raiseOnHover) this.off('mouseover', this.openPopup, this); 8021 this.executeHook('unbindPopup'); 8022 return this 8023 } 8024 }); 8025 b.include({ 8026 _fireMouse: function(a) { 8027 if (a = { 8028 mouseover: 'objOver', 8029 mouseoout: 'objOut', 8030 click: 'objClick' 8031 } [a.type]) this._map.fire(a, { 8032 obj: this._mainObj 8033 }) 8034 } 8035 }); 8036 b.prototype.addHook('onAdd', function() { 8037 this.on('mouseover', this._fireMouse, this).on('mouseout', this._fireMouse, this).on('click', this._fireMouse, this) 8038 }); 8039 b.prototype.addHook('onRemove', function() { 8040 this.off('mouseover', this._fireMouse, this).off('mouseout', this._fireMouse, this).off('click', this._fireMouse, this) 8041 }); 8042 b.prototype.addHook('openPopup', function() { 8043 this._map.fire('objPopup', { 8044 obj: this._mainObj 8045 }) 8046 }) 8047 } 8048})(); 8049E.Marker.include({ 8050 _resetZIndex: function() { 8051 this._updateZIndex(0) 8052 }, 8053 _setPos: function(pos) { 8054 L.DomUtil.setPosition(this._icon, pos); 8055 if (this._shadow) L.DomUtil.setPosition(this._shadow, pos); 8056 this._zIndex = !E.isU(this.options.zIndex) ? this.options.zIndex : pos.y + this.options.zIndexOffset; 8057 this._resetZIndex() 8058 }, 8059 bringToFront: function() { 8060 this.options.zIndex = this._zIndex = this._layer._zIndex++; 8061 this._updateZIndex(0) 8062 } 8063}); 8064L.Map.include({ 8065 token: function() { 8066 return this.options.token 8067 }, 8068 setCursor: function(cursor) { 8069 if (this._lastCursor != cursor) { 8070 var a = E.$(this.getPanes().mapPane); 8071 a.removeClass("leaflet-cursor-" + this._lastCursor); 8072 a.addClass("leaflet-cursor-" + cursor);
8073 this._lastCursor = cursor 8074 } 8075 } 8076}); 8077E.Map = L.Control.extend({ 8078 _map: null, 8079 options: {}, 8080 _initHook: [], 8081 _isChanging: false, 8082 _callbacks: { 8083 'mapChange': 'moveend', 8084 'objClick': 'objClick', 8085 'objOver': 'objOver', 8086 'objOut': 'objOut', 8087 'onCategoriesChange': 'onCategoriesDone', 8088 'locationfound': 'locationfound', 8089 'locationerror': 'locationerror', 8090 'info': 'mapInfo', 8091 'queryError': 'queryError', 8092 'contextMenu': 'contextmenu' 8093 }, 8094 initialize: function(div, token, options) { 8095 L.Util.setOptions(this, options); 8096 var self = this; 8097 this._map = E.map.initializer(options).initializeMap(div, token, options, this._initHook).on("movestart", function() { 8098 self._isChanging = true 8099 }).on("moveend", function() { 8100 self._isChanging = false 8101 }) 8102 }, 8103 addMapAction: function(index, action, icon, callback) { 8104 if (arguments.length == 4) action = new E.Actions.Item.Context(action, { 8105 img: icon, 8106 onContext: callback 8107 }); 8108 this._map.addAction(action, index) 8109 }, 8110 removeMapAction: function(index) { 8111 this._map.removeAction(index) 8112 }, 8113 addLayer: function(layer) { 8114 this._map.addLayer(layer) 8115 }, 8116 removeLayer: function(layer) { 8117 this._map.removeLayer(layer) 8118 }, 8119 addLayerSwitcher: function(layer) { 8120 this._map.fire("layeraddswitcher", { 8121 layer: layer 8122 }) 8123 }, 8124 removeLayerSwitcher: function(layer) { 8125 this._map.fire("layerremoveswitcher", { 8126 layer: layer 8127 }) 8128 }, 8129 getBounds: function() { 8130 with(this._map.getBounds()) return new E.Bounds(_southWest.lng, _southWest.lat, _northEast.lng, _northEast.lat) 8131 }, 8132 setBounds: function(bounds) { 8133 if (!(bounds instanceof L.LatLngBounds)) with(new E.Bounds(bounds)) bounds = [ 8134 [bottom, left], 8135 [top, right] 8136 ]; 8137 this._map.fitBounds(bounds) 8138 }, 8139 showPopup: function(a, b, c) { 8140 this._map.showPopup(a, b, c) 8141 }, 8142 getCenterPos: function() { 8143 return this._map.getCenter().getLonLat() 8144 }, 8145 setCenterPos: function(center, zoom) {
8146 this._map.setView(center instanceof E.LonLat ? [center.lat, center.lon] : center, zoom ? zoom : this.getZoom()) 8147 }, 8148 _setCallback: function(a, b, c) { 8149 this._map.on(a, function(d) { 8150 try { 8151 if (d.latlng) d.lonlat = d.latlng.getLonLat(), delete d['latlng'], delete d['layerPoint'], delete d['containerPoint']; 8152 d.type = c; 8153 b(c, d.obj ? d.obj : d) 8154 } catch (e) {} 8155 }) 8156 }, 8157 setCallback: function(type, callback) { 8158 type = E.type(type) !== 'a' ? [type] : type; 8159 for (var i = 0; i < type.length; i++) 8160 if (this._callbacks[type[i]]) this._setCallback(this._callbacks[type[i]], callback, type[i]) 8161 }, 8162 categoryObjects: function() { 8163 return this._map._poi 8164 }, 8165 getZoom: function() { 8166 return this._map.getZoom() 8167 }, 8168 locate: function(options) { 8169 this._map.locate(options) 8170 }, 8171 updateSize: function() { 8172 this._map._onResize() 8173 }, 8174 convertLonLatToScreen: function(lonLat) { 8175 (lonLat = this._map.latLngToContainerPoint(lonLat.getLatLng())); 8176 return new E.Pixel(lonLat.x, lonLat.y) 8177 }, 8178 convertScreenToLonLat: function(px) { 8179 return this._map.containerPointToLatLng([px.x, px.y]).getLonLat() 8180 }, 8181 getVersion: function(callback) { 8182 return this._map.version({}, callback) 8183 }, 8184 isChanging: function() { 8185 return this._isChanging 8186 } 8187}); 8188E.map = function(div, token, options) { 8189 return new EMAPI.Map(div, token, options) 8190}; 8191E.Map.addInitHook = function(fn) { 8192 this.prototype._initHook.push(fn) 8193}; 8194E.Map.Initializer = L.Control.extend({ 8195 options: { 8196 layerConfig: { 8197 attribution: 'EMAPA', 8198 subdomains: '1234', 8199 _layerZoom: [ 8200 [], 8201 [], 8202 [] 8203 ], 8204 _activeLayer: 0, 8205 _layerTypes: ['std', 'hipso', 'hybrid'], 8206 baseLayer: true, 8207 maxZoom: 19, 8208 name: "EMAPA" 8209 }, 8210 layerUrl: E.server.IMG, 8211 defaultPos: new L.LatLng(51.770694796548376, 19.461057186126705), 8212 defaultZoom: 15 8213 }, 8214 initialize: function(options) { 8215 if (options && options.lang) E.Lang.code(options.lang); 8216 L.extend(this.options, options) 8217 }, 8218 initializeBaseLayer: function(userId) { 8219 with(this.options) { 8220 var a = [ 8221 [ 8222 ['std', 20] 8223 ], 8224 [ 8225 ['HipsometryView', 11], 8226 ['HillShadingView', 9] 8227 ], 8228 [ 8229 ['hybrid', 20] 8230 ] 8231 ], 8232 i, j, k; 8233 for (i = 0; i < a.length; i++) 8234 for (j = 0; j < a[i].length; j++) 8235 for (k = 0; k < a[i][j][1]; k++) layerConfig._layerZoom[i].push(a[i][j][0]); 8236 var layer = new E.TMS(layerUrl + userId, layerConfig); 8237 return layer 8238 } 8239 }, 8240 initializePOILayer: function(userId) { 8241 this.options.layerUrl = E.server.POI; 8242 var layer = new E.POILayer(this.options.layerUrl + userId, this.options.layerConfig); 8243 return layer 8244 }, 8245 initializeLayers: function(token) { 8246 var layers = [this.initializeBaseLayer(token)]; 8247 return layers 8248 }, 8249 initializeControls: function(options, map, token) { 8250 if (!this.options.noZoom)(this.options.noZoomSlider ? L.control.zoom() : new E.Control.ZoomSlider()).addTo(map); 8251 if (!this.options.noScale) L.control.scale().addTo(map); 8252 if (!this.options.noMiniMap) new L.Control.MiniMap(new L.TileLayer(E.server.IMG.replace("{l}", "std") + token, { 8253 subdomains: '1234' 8254 }), { 8255 toggleDisplay: 1 8256 }).addTo(map); 8257 if (this.options.layerSwitcher) new E.Control.Layers().addTo(map) 8258 }, 8259 initializeActions: function(map) { 8260 E.actions.actionsContainer(map); 8261 if (!this.options.noActionPanel) { 8262 E.control.actionPanel().addTo(map); 8263 map.addAction(new E.Actions.Item.MoveMap("MoveMap")); 8264 map.addAction(new E.Actions.Item.DragRectangle("DragRectangle")); 8265 map.addAction(new E.Actions.Item.DistanceCalculator("DistanceCalculator")); 8266 map.addAction(new E.Actions.Item.MapInfo("MapInfo")); 8267 map.addAction(new E.Actions.Item.Coordinates("Coordinates")) 8268 } 8269 if (!this.options.noContextMenu) { 8270 E.control.contextMenu().addTo(map); 8271 map.addAction(new E.Actions.Item.Context.Center('Center')); 8272 map.addAction(new E.Actions.Item.Context.DefaultView('DefaultView')); 8273 map.addAction(new E.Actions.Item.Context('Divider')); 8274 map.addAction(new E.Actions.Item.Context.PermaLink('PermaLink')); 8275 map.addAction(new E.Actions.Item.Context.ReportError('ReportError')); 8276 map.addAction(new E.Actions.Item.Context('Divider')); 8277 map.addAction(new E.Actions.Item.Context.Print('Print')) 8278 } 8279 }, 8280 initializeAPI: function(token, map) { 8281 new E.API(token, map) 8282 }, 8283 initializeMap: function(div, token, options, hooks) { 8284 var map = new L.Map(div, { 8285 token: token, 8286 center: this.options.defaultPos, 8287 zoom: this.options.defaultZoom, 8288 minZoom: 5, 8289 maxZoom: 19, 8290 layers: this.initializeLayers(token) 8291 }), 8292 i; 8293 for (i = 0; i < hooks.length; i++) hooks[i].call(map); 8294 this.initializeAPI(token, map); 8295 this.initializeActions(map); 8296 this.initializeControls(options, map, token); 8297 map.fire("MapInitialized"); 8298 map.fire("MapInitializedA", { 8299 options: options 8300 });
8301 return map 8302 } 8303}); 8304L.Popup.prototype.options.maxWidth = 400; 8305E.map.initializer = function(options) { 8306 return new E.Map.Initializer(options) 8307}; 8308E.ArgParser = L.Class.extend({ 8309 _map: null, 8310 _useCookie: true, 8311 _layers: [], 8312 _poi: '', 8313 initialize: function(map) { 8314 this._map = map; 8315 this._base = document.location.href; 8316 map.on("MapInitializedA", this.initMap, this); 8317 this._poi = map._poi 8318 }, 8319 initMap: function() { 8320 this._poi = this._map._poi; 8321 var args = E.Util.getParameters(), 8322 c, i, a; 8323 if (this._useCookie) { 8324 c = E.Cookie.getCookie('DV'); 8325 if ((E.type(c) == 's') && (c.length > 0)) { 8326 for (i = 0, a = ['long', 'lat', 'zoom', 'l'], c = c.split('&'); i < a.length; i++) 8327 if (!args[a[i]]) args[a[i]] = c[i] 8328 } 8329 } 8330 if (args['lat'] && args['long']) { 8331 var z = this._map.getZoom(); 8332 if (args["zoom"]) z = parseInt(args['zoom']); 8333 this._map.setView(L.latLng(args['lat'], args['long']), z) 8334 } 8335 if (args['l']) { 8336 this._layers = args['l'].split('|'); 8337 this._map.on('onCategoriesDone', this._onCategoriesChange, this); 8338 for (var i = 0, a = this._layers; i < a.length; i++) 8339 if (a[i] == 'P' || a[i] == 'H') with(this._poi._layer) { 8340 setCetegoryVisible('M', false); 8341 setCetegoryVisible(a[i], true) 8342 } 8343 } 8344 if (this._useCookie) { 8345 this._map.on('moveend', this._onChange, this); 8346 this._poi._layer.on('onVisibleChange', this._onChange, this) 8347 } 8348 }, 8349 _onChange: function() { 8350 var p = this._map.getCenter(); 8351 p = p.lng + '&' + p.lat + '&' + this._map.getZoom() + '&' + this._poi.getVisibleLayers(); 8352 E.Cookie.setCookie('DV', p) 8353 }, 8354 _onCategoriesChange: function(a) { 8355 var a = a.categories; 8356 for (var i = 0; i < a.length; i++) 8357 if (this._layers.indexOf('' + a[i].id) != -1) this._poi.showCategory(a[i].id); 8358 else if (a[i].visible) this._poi.hideCategory(a[i].id) 8359 }, 8360 _getLinkParams: function() { 8361 var p = this._map.getCenter(); 8362 return "long=" + p.lng + "&lat=" + p.lat + "&zoom=" + this._map.getZoom() + '&l=' + this._poi.getVisibleLayers() 8363 }, 8364 getLink: function() { 8365 var href = this._base; 8366 if (href.indexOf('?') != -1) href = href.substring(0, href.indexOf('?')); 8367 return href + '?' + this._getLinkParams() 8368 } 8369}); 8370E.Map.addInitHook(function() { 8371 this._argParser = new E.ArgParser(this) 8372}); 8373E.PopupController = L.Class.extend({ 8374 _map: null, 8375 _popup: null, 8376 initialize: function(map) { 8377 this._map = map; 8378 this._popup = L.popup() 8379 }, 8380 showPopup: function(pos, innerHTML, params) { 8381 this._hidePopup(); 8382 this._popup.setOptions(params).setLatLng(pos).setContent(innerHTML).openOn(this._map) 8383 }, 8384 _hidePopup: function(cancel) { 8385 this._map.removeLayer(this._popup) 8386 } 8387}); 8388L.Map.include({ 8389 showPopup: function(pos, innerHTML, params) { 8390 this.popup.showPopup(pos, innerHTML, params) 8391 } 8392}); 8393E.Map.addInitHook(function() { 8394 this.popup = new E.PopupController(this) 8395}); 8396L.Popup.include({ 8397 _initLayout: function() { 8398 var prefix = 'leaflet-popup', 8399 containerClass = prefix + ' ' + this.options.className + ' leaflet-zoom-' + (this._animated ? 'animated' : 'hide'), 8400 container = this._container = L.DomUtil.create('div', containerClass), 8401 closeButton; 8402 if (this.options.closeButton) { 8403 closeButton = this._closeButton = L.DomUtil.create('a', prefix + '-close-button', container); 8404 closeButton.href = '#close'; 8405 closeButton.innerHTML = '<div class="leaflet-popup-close-button-div"></div>'; 8406 L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this) 8407 } 8408 var wrapper = this._wrapper = L.DomUtil.create('div', prefix + '-content-wrapper', container); 8409 L.DomEvent.disableClickPropagation(wrapper); 8410 this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper); 8411 L.DomEvent.on(this._contentNode, 'mousewheel', L.DomEvent.stopPropagation); 8412 this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container); 8413 this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer) 8414 }, 8415 setOptions: function(options) { 8416 L.setOptions(this, options); 8417 return this 8418 } 8419}); 8420L.Map.mergeOptions({ 8421 boxZoom: false 8422}); 8423E.Map.BoxZoom = L.Map.BoxZoom.extend({ 8424 _withoutShift: false, 8425 _onMouseDown: function(e) { 8426 this._moved = false; 8427 if (((!e.shiftKey) && (!this.withoutShift)) || ((e.which !== 1) && (e.button !== 1))) { 8428 return false 8429 } 8430 L.DomUtil.disableTextSelection(); 8431 L.DomUtil.disableImageDrag(); 8432 this._startLayerPoint = this._map.mouseEventToLayerPoint(e); 8433 L.DomEvent.on(document, 'mousemove', this._onMouseMove, this).on(document, 'mouseup', this._onMouseUp, this).on(document, 'keydown', this._onKeyDown, this); 8434 this._map.fire("boxzoomstart") 8435 } 8436}); 8437E.Actions = {}; 8438E.actions = {}; 8439E.Actions.ActionsContainer = L.Control.extend({ 8440 includes: L.Mixin.Events, 8441 _items: [], 8442 _map: null, 8443 _activeAction: null, 8444 _prevAction: null, 8445 initialize: function(map) { 8446 this._items = []; 8447 this._map = map 8448 }, 8449 addAction: function(action, index) { 8450 action._id = this._genActionID(action.getName()); 8451 this._items[action._id] = action; 8452 action.onAdd(this, this._map); 8453 this.fire('onAddAction', { 8454 action: action, 8455 actionIndex: index 8456 });
8457 if (action.options.activeAfterAdd) this.activateAction(action) 8458 }, 8459 removeAction: function(index) { 8460 this.fire('onRemoveAction', { 8461 actionIndex: index 8462 }) 8463 }, 8464 activateAction: function(action) { 8465 if (!action) return; 8466 var act = this._items[action._id]; 8467 if ((act) && (!act._active)) { 8468 var prevAction = this._activeAction; 8469 this._prevAction = null; 8470 if (this._activeAction) this._activeAction.deactivate(); 8471 this._prevAction = prevAction; 8472 act._active = true; 8473 act.onActivate(); 8474 this._activeAction = action 8475 } 8476 this.fire('onActivateAction', { 8477 action: action 8478 }) 8479 }, 8480 deactivateAction: function(action) { 8481 if (!action) return; 8482 var act = this._items[action._id]; 8483 if ((act) && (act._active)) { 8484 act.onDeactivate(); 8485 act._active = false; 8486 this._activeAction = null; 8487 if (this._prevAction) this._prevAction.activate() 8488 } 8489 this.fire('onDeactivateAction', { 8490 action: action 8491 }) 8492 }, 8493 _genActionID: function(name) { 8494 return name + '_' + this._items.length 8495 } 8496}); 8497E.actions.actionsContainer = function(params) { 8498 return new E.Actions.ActionsContainer(params) 8499}; 8500L.Map.include({ 8501 addAction: function(action, index) { 8502 this.actions.addAction(action, index) 8503 }, 8504 removeAction: function(index) { 8505 this.actions.removeAction(index) 8506 } 8507}); 8508E.Map.addInitHook(function() { 8509 this.actions = E.actions.actionsContainer(this) 8510}); 8511E.Actions.Item = E.Control.extend({ 8512 _container: null, 8513 _map: null, 8514 options: { 8515 hasActiveState: true, 8516 actionPanel: true, 8517 activeAfterAdd: false 8518 }, 8519 _name: "", 8520 _active: false, 8521 initialize: function(name, options) { 8522 L.Util.setOptions(this, options); 8523 this._name = name 8524 }, 8525 onAdd: function(container, map) { 8526 this._container = container; 8527 this._map = map 8528 }, 8529 onAdded: function(a) { 8530 this._item = a 8531 }, 8532 getName: function() { 8533 return this._name 8534 }, 8535 getDescription: function() { 8536 return this.options.description 8537 }, 8538 isActive: function() { 8539 return this._active 8540 }, 8541 onActivate: function() {}, 8542 onDeactivate: function() {}, 8543 activate: function() { 8544 this._container.activateAction(this); 8545 if (this.options.cursor) this._map.setCursor(this.options.cursor) 8546 }, 8547 deactivate: function() { 8548 this._container.deactivateAction(this) 8549 } 8550}); 8551E.actions.item = function(name, icon) { 8552 return new E.Actions.Item(name, icon) 8553}; 8554E.Actions.MapClick = E.Actions.Item.extend({ 8555 _item: 0, 8556 initialize: function(name, options) { 8557 this._name = name; 8558 L.Util.setOptions(this, options) 8559 }, 8560 onAdded: function(a) { 8561 this._item = a; 8562 this.setStyle(0) 8563 }, 8564 setStyle: function(a) { 8565 with(this) if (a && _item && options.activeURL) _item.bgImg("url(" + options.activeURL + ")"); 8566 else if (!a && _item && options.inactiveURL) _item.bgImg("url(" + options.inactiveURL + ")") 8567 }, 8568 onActivate: function() { 8569 this.setStyle(1); 8570 this._map.on('click', this._onClick, this) 8571 }, 8572 onDeactivate: function() { 8573 this.setStyle(0); 8574 this._map.off('click', this._onClick, this) 8575 }, 8576 _onClick: function(e) { 8577 this.options.action(e.latlng.getLonLat()) 8578 } 8579}); 8580E.Actions.Item.MoveMap = E.Actions.Item.extend({ 8581 initialize: function(name) { 8582 this._name = name; 8583 L.setOptions(this, { 8584 description: E.lang("M_A"), 8585 activeAfterAdd: true, 8586 cursor: 'dragPan' 8587 }) 8588 }, 8589 onActivate: function() { 8590 this._map["dragging"].enable(); 8591 this._map['doubleClickZoom'].enable(); 8592 this._map.on('click', this._onClick, this) 8593 }, 8594 onDeactivate: function() { 8595 this._map["dragging"].disable(); 8596 this._map['doubleClickZoom'].disable(); 8597 this._map.off('click', this._onClick, this) 8598 }, 8599 _onClick: function(e) { 8600 this._map.fire('clickMapInfo', { 8601 latlng: e.latlng 8602 }) 8603 } 8604}); 8605E.Actions.Item.DragRectangle = E.Actions.Item.extend({ 8606 handler: null, 8607 initialize: function(name) { 8608 this._name = name; 8609 L.setOptions(this, { 8610 description: E.lang("DR_A"), 8611 activeAfterAdd: false, 8612 cursor: 'zoom' 8613 }) 8614 }, 8615 onAdd: function(container, map) { 8616 E.Actions.Item.prototype.onAdd.call(this, container, map); 8617 this.handler = new E.Map.BoxZoom(map); 8618 this.handler.enable() 8619 }, 8620 onActivate: function() { 8621 this.handler.withoutShift = true 8622 }, 8623 onDeactivate: function() { 8624 this.handler.withoutShift = false 8625 } 8626}); 8627E.Actions.Item.DistanceCalculator = E.Actions.Item.extend({ 8628 _distance: 0, 8629 _lastPoint: null, 8630 initialize: function(name) { 8631 this._name = name; 8632 L.setOptions(this, { 8633 description: E.lang("DC_A"), 8634 activeAfterAdd: false, 8635 cursor: 'measure' 8636 });
8637 this._layerGroup = L.layerGroup([]) 8638 }, 8639 onActivate: function() { 8640 this._map.on('click', this._onClick, this).on('dblclick', this._clear, this).addLayer(this._layerGroup) 8641 }, 8642 onDeactivate: function() { 8643 this._map.off('click', this._onClick, this).off('dblclick', this._clear, this).removeLayer(this._layerGroup); 8644 this._clear() 8645 }, 8646 _clear: function() { 8647 this._layerGroup.clearLayers(); 8648 this._distance = 0; 8649 this._lastPoint = null 8650 }, 8651 _onClick: function(e) { 8652 if (this._lastPoint) { 8653 this._layerGroup.addLayer(L.polygon([e.latlng, this._lastPoint])); 8654 this._distance += e.latlng.distanceTo(this._lastPoint); 8655 L.popup().setLatLng(e.latlng).setContent(E.lang('DC_D') + (parseInt(this._distance) / 1000) + "km").openOn(this._map) 8656 } 8657 this._layerGroup.addLayer(L.marker(e.latlng)); 8658 this._lastPoint = e.latlng 8659 }, 8660 _onDbClick: function(e) { 8661 this._clear() 8662 } 8663}); 8664L.Icon.Default.imagePath = "http://emapi.pl/css/u/images/"; 8665E.Actions.Item.MapInfo = E.Actions.Item.extend({ 8666 initialize: function(name) { 8667 this._name = name; 8668 L.setOptions(this, { 8669 description: E.lang("MI_A"), 8670 activeAfterAdd: false, 8671 cursor: 'mapinformation' 8672 }) 8673 }, 8674 onActivate: function() { 8675 this._map.on('click', this._onClick, this) 8676 }, 8677 onDeactivate: function() { 8678 this._map.off('click', this._onClick, this) 8679 }, 8680 _onClick: function(e) { 8681 var point = e.latlng; 8682 this._map.degeocode({ 8683 lon: point.lng, 8684 lat: point.lat, 8685 zoom: this._map.getZoom() 8686 }, this._onData, this, { 8687 pos: point 8688 }) 8689 }, 8690 _onData: function(response, obj) { 8691 this._map.showPopup(obj.pos, this._parseItem(response)); 8692 delete response['TMC']; 8693 delete response['SpatialDataViewer']; 8694 this._map.fire('mapInfo', { 8695 position: response 8696 }) 8697 }, 8698 _parseItem: function(param) { 8699 function _ignoreItems(item) { 8700 return ((item == undefined) || (item == '')) ? true : false 8701 } 8702 8703 function eachArray(items, key) { 8704 var res = ''; 8705 for (var i in items) 8706 if (!_ignoreItems(items[i])) res += (E.type(items[i] == 'o') ? '<span class="' + key + '_' + i + '">' + items[i].name + '</span>' : res += '<span class="' + key + '_' + i + '">' + items[i] + '</span>'); 8707 return res 8708 } 8709 8710 function parseElem(item, val, key) { 8711 var result = ''; 8712 if (E.type(val) == 'a') { 8713 if (val.length > 0) result += '<span class="' + key + '_' + item + '">' + eachArray(val, key + item + '_') + '</span>' 8714 } else if (E.type(val) == 'o') result += '<span class="' + key + '_' + item + '">' + val.name + '</span>'; 8715 else if ((val) && (val != '')) result += '<span class="' + key + '_' + item + '">' + val + '</span>'; 8716 return result 8717 } 8718 8719 function parseStreetItems(item, val, key) { 8720 var res = ''; 8721 if (val) 8722 for (i = 0; i < val.length; i++) res += '<span class="' + key + '_' + item + '">' + E.lang(streetItems[val[i].typeIndex]) + ' ' + parseElem('name', val[i].name, key) + '</span>'; 8723 return res 8724 } 8725 8726 function parseInternationalRoad(item, val, key) { 8727 return (val) ? '<span class="' + key + '_' + item + '">' + E.lang('MI_InternationalRoad') + ' ' + parseElem('name', val.name, key) + '</span>' : '' 8728 } 8729 var streetItems = ['MI_Autostrada', 'MI_Ekspresowa', 'MI_Krajowa', 'MI_Wojewodzka', 'MI_Lokalna', 'MI_UlicaGlowna', 'MI_UlicaZwykla', 'MI_Prom']; 8730 var parseItems = ['cities', 'streets', 'zip', 'areaName0', 'areaName1', 'areaName2', 'roads', 'internationalRoad', 'square', 'building', 'forest', 'industrialArea', 'nationalPark', 'peak', 'river', 'sea', 'water']; 8731 var info = ''; 8732 var c = 'EMAPI_MapInfo'; 8733 for (var i in parseItems) { 8734 var a = parseItems[i]; 8735 info += (['streets', 'roads'].indexOf(a) != -1 ? parseStreetItems : (['internationalRoad'].indexOf(a) != -1 ? parseInternationalRoad : parseElem))(a, param[a], c) 8736 } 8737 if (param['borderCrossing']) info += parseElem('borderCrossing', E.lang('sMapInformationPrzejscie') + ' ' + param['borderCrossing'], c); 8738 if (info.length > 0) info = '<div class="' + c + '">' + info + '</div>'; 8739 var items = ''; 8740 if (items.length > 0) items = '<div class="' + c + '_features" >' + items + '</div>'; 8741 return info + items 8742 } 8743}); 8744E.Actions.Item.Coordinates = E.Actions.Item.extend({ 8745 initialize: function(name) { 8746 this._name = name; 8747 this.options.description = E.lang("A_LL"); 8748 this.options.activeAfterAdd = false; 8749 this.options.cursor = 'coordinates'; 8750 L.setOptions(this, { 8751 description: E.lang("A_LL"), 8752 activeAfterAdd: false, 8753 cursor: 'coordinates' 8754 }) 8755 }, 8756 onAdd: function(container, map) { 8757 E.Actions.Item.prototype.onAdd.call(this, container, map); 8758 map.on("MapInitializedA", this._onInitialize, this) 8759 }, 8760 onActivate: function() { 8761 this._map.on('click', this._onClick, this) 8762 }, 8763 onDeactivate: function() { 8764 this._map.off('click', this._onClick, this) 8765 }, 8766 _onInitialize: function(a) { 8767 if (a.options) this._coordinatesInfoDMS = a.options.coordinatesInfoDMS 8768 }, 8769 _parseLonLat: function(a) { 8770 function convertToDMS(b, c) {
8771 c = c[b < 0 ? 1 : 0]; 8772 return Math.floor(b < 0 ? b = -b : b) + "° " + Math.floor(b = (b - Math.floor(b)) * 60) + "' " + Math.floor((b - Math.floor(b)) * 60) + "\" " + c 8773 } 8774 return this._coordinatesInfoDMS ? [convertToDMS(a.lng, "EW"), convertToDMS(a.lat, "NS")] : [a.lng, a.lat] 8775 }, 8776 _onClick: function(e) { 8777 var f = this._parseLonLat(e.latlng); 8778 this._map.showPopup(e.latlng, '<div><div class="CO_lon">' + E.lang('Lon') + '</div><div class="CO_lon_pos">' + f[0] + '</div></div><div><div class="CO_lat">' + E.lang('Lat') + '</div>' + '<div class="CO_lat_pos">' + f[1] + '</div></div>') 8779 } 8780}); 8781E.Actions.Item.Context = E.Actions.Item.extend({ 8782 options: { 8783 hasActiveState: false, 8784 actionPanel: false, 8785 activeAfterAdd: false, 8786 contextAction: true 8787 }, 8788 activate: function(a) { 8789 if (this.options.hasActiveState) this._container.activateAction(this); 8790 else this.onContext(a) 8791 }, 8792 deactivate: function() { 8793 this._container.deactivateAction(this) 8794 }, 8795 onContext: function(point) { 8796 with(this) if (options.onContext) options.onContext(point.getLonLat()) 8797 }, 8798 getIcon: function() { 8799 return this.options.img 8800 } 8801}); 8802E.Actions.Item.Context.Center = E.Actions.Item.Context.extend({ 8803 onContext: function(point) { 8804 this._map.panTo(point) 8805 } 8806}); 8807E.Actions.Item.Context.DefaultView = E.Actions.Item.Context.extend({ 8808 onContext: function(point) {
8809 this._map.setView(this._map.options.center, this._map.options.zoom) 8810 } 8811}); 8812E.Actions.Item.Context.PermaLink = E.Actions.Item.Context.extend({ 8813 onContext: function(point) { 8814 this._overlay = new E.Overlay.Form(); 8815 this._overlay.showWindow(this.renderWindow()); 8816 E.$('PL_linkInputId').value(this._map._argParser.getLink()).click(function() { 8817 this.select() 8818 }).elem().select(); 8819 E.$('PL_close').click(E.bind(this._overlay.hide, this._overlay)) 8820 }, 8821 renderWindow: function(overlayForm) { 8822 return E.$(E.newElem('div', 'linkInputForm')).text('<div class="linkInputText">' + E.lang("PL_View") + '</div><div class="linkInputImage"><div id="PL_close"></div></div><input class="linkInputDiv" id="PL_linkInputId" type="text"></div>') 8823 } 8824}); 8825E.Actions.Item.Context.ReportError = E.Actions.Item.Context.extend({ 8826 onContext: function(point) { 8827 this._map.profile.reportError(point) 8828 } 8829}); 8830E.Actions.Item.Context.Print = E.Actions.Item.Context.extend({ 8831 onContext: function(point) { 8832 window.print() 8833 } 8834}); 8835E.Control = L.Control; 8836E.control = function(param) { 8837 new E.Control(param) 8838}; 8839E.Control.ZoomSlider = L.Control.Zoom.extend({ 8840 _slideFactor: 500, 8841 _slideHeight: 7, 8842 _startPoint: null, 8843 _slider: null, 8844 _positionItem: 0, 8845 _dragPositionItem: 0, 8846 _maxItems: 0, 8847 _maxZoom: 0, 8848 _namedZoom: null, 8849 _timer: 0, 8850 onAdd: function(map) { 8851 this._map = map; 8852 var className = 'leaflet-control-zoom-EMAPI', 8853 container = E.newElem('div', className), 8854 a = E.lang; 8855 this._createButton('', a('Z_0'), className + '-north-mini', container, this._panTop, this); 8856 this._createButton('', a('Z_1'), className + '-west-mini', container, this._panLeft, this); 8857 this._createButton('', a('Z_2'), className + '-east-mini', container, this._panRight, this); 8858 this._createButton('', a('Z_3'), className + '-south-mini', container, this._panBottom, this); 8859 this._createButton('', a('Z_4'), className + '-in', container, this._zoomIn, this); 8860 this._createButtonSlider(a('Z_5'), className + '-slider', container, map); 8861 this._createButton('', a('Z_6'), className + '-out', container, this._zoomOut, this); 8862 map.on('moveend', this._update, this).on('zoomlevelschange', this._updateRangeChange, this); 8863 return container 8864 }, 8865 onRemove: function(map) { 8866 map.off('moveend', this._update, this).off('zoomlevelschange', this._updateRangeChange, this) 8867 }, 8868 _createButtonSlider: function(title, className, container, map) { 8869 this._bar = E.newElem('div', className, container); 8870 this._maxZoom = map.getMaxZoom(); 8871 this._creteNamedzoomItems(className, this._bar, map); 8872 this._maxItems = map.getMaxZoom() - map.getMinZoom(); 8873 this._positionItem = this._maxZoom - map.getZoom(); 8874 this._slider = E.newElem('div', className + '-item', this._namedZoom); 8875 this._bar.style.height = this._maxItems * this._slideHeight + 8 + "px"; 8876 this._draggable = new L.Draggable(this._slider, this._slider).on('drag', this._onDrag, this).on('dragend', this._onEndBarAction, this); 8877 E.on(this._bar, 'click', this._barClick, this).on(this._bar, 'dblclick', this._barClick); 8878 events = ['dblclick', 'mousedown']; 8879 for (var i = 0; i < events.length; i++) E.on(this._slider, events[i], L.DomEvent.stopPropagation); 8880 this._update(); 8881 this._draggable.enable(); 8882 E.on(this._namedZoom, 'mouseover', this._showZoomInfo, this).on(this._namedZoom, 'mouseout', this._hideZoomInfo, this) 8883 }, 8884 _updateRangeChange: function() { 8885 with(this) { 8886 _maxZoom = _map.getMaxZoom(); 8887 _maxItems = _map.getMaxZoom() - _map.getMinZoom(); 8888 _bar.style.height = _maxItems * _slideHeight + 8 + "px"; 8889 _update() 8890 } 8891 }, 8892 _creteNamedzoomItems: function(className, container, map) { 8893 this._namedZoom = E.newElem('div', className + "-infoItem", container); 8894 this._namedZoomItems = E.newElem('div', className + "-infoItem-container", this._namedZoom); 8895 E.$(this._namedZoomItems).hide().block().over(function() { 8896 this._timerHide() 8897 }, this); 8898 this._creteNamedzoomItem("kraj", 6, className);
8899 this._creteNamedzoomItem("wojewodztwo", 9, className); 8900 this._creteNamedzoomItem("miasto", 13, className); 8901 this._creteNamedzoomItem("ulice", 16, className) 8902 }, 8903 _creteNamedzoomItem: function(title, zoom, className, container) { 8904 var item = this._createButton('', '', className + 'ZoomInfo-' + title, this._namedZoomItems, this._namedZoomClick, { 8905 z: zoom, 8906 c: this 8907 }); 8908 E.$(item).att('zoom', zoom).top((this._maxZoom - zoom) * this._slideHeight - 9 + "px").over(function() { 8909 this._timerHide() 8910 }, this) 8911 }, 8912 _update: function() { 8913 this._positionItem = this._maxZoom - this._map.getZoom(); 8914 this._updateSlider(this._positionItem) 8915 }, 8916 _barClick: function(e) { 8917 var l = E.mousePos(e, this._bar); 8918 this._setDragPositionitem(l.y / this._slideHeight); 8919 this._updateSlider(this._dragPositionItem); 8920 this._onEndBarAction(); 8921 L.DomEvent.stopPropagation(e) 8922 }, 8923 _namedZoomClick: function(e) { 8924 with(this) c._map.setZoom(z) 8925 }, 8926 _setDragPositionitem: function(a) { 8927 a = parseInt(a); 8928 if (a < 0) a = 0; 8929 if (a > this._maxItems) a = this._maxItems; 8930 this._dragPositionItem = a; 8931 this._updateSlider(a) 8932 }, 8933 _updateSlider: function(a) { 8934 E.$(this._slider).css("top", a * this._slideHeight + "px") 8935 }, 8936 _onDrag: function(e) { 8937 var sp = e.target._startPos; 8938 var ep = e.target._newPos; 8939 this._setDragPositionitem(this._positionItem - parseInt((sp.y - ep.y) / this._slideHeight)) 8940 }, 8941 _onEndBarAction: function() { 8942 this._positionItem = this._dragPositionItem; 8943 this._map.setZoom(this._maxZoom - this._positionItem) 8944 }, 8945 _panLeft: function() { 8946 this._map.panBy(new L.Point(-this._slideFactor, 0)) 8947 }, 8948 _panRight: function() { 8949 this._map.panBy(new L.Point(this._slideFactor, 0)) 8950 }, 8951 _panTop: function() { 8952 this._map.panBy(new L.Point(0, -this._slideFactor)) 8953 }, 8954 _panBottom: function() { 8955 this._map.panBy(new L.Point(0, this._slideFactor)) 8956 }, 8957 _timerHide: function(a) { 8958 clearTimeout(this._timer); 8959 if (a) this._timer = setTimeout(E.bind(function() { 8960 E.$(this._namedZoomItems).hide() 8961 }, this), 250) 8962 }, 8963 _showZoomInfo: function() { 8964 E.$(this._namedZoom).width("100px"); 8965 E.$(this._namedZoomItems).show() 8966 }, 8967 _hideZoomInfo: function() { 8968 E.$(this._namedZoom).width("120px"); 8969 this._timerHide(1) 8970 } 8971}); 8972L.Map.mergeOptions({ 8973 zoomControl: false 8974}); 8975E.Control.ActionPanel = E.Control.extend({ 8976 options: { 8977 position: 'topleft' 8978 }, 8979 _container: null, 8980 _containerItems: null, 8981 _items: [], 8982 _className: '', 8983 initialize: function() { 8984 this._items = [] 8985 }, 8986 onAdd: function(map) { 8987 this._map = map; 8988 this._className = 'emapi-control-actionPanel'; 8989 this._container = E.newElem('div', this._className); 8990 this._initializePanel(this._className); 8991 this._map.actions.on("onActivateAction", this._onActivateAction, this).on("onDeactivateAction", this._onDeactivateAction, this).on("onAddAction", this._addAction, this); 8992 L.DomUtil.setPosition(this._container, new L.Point(10, 250)); 8993 return this._container 8994 }, 8995 _initializePanel: function(className) { 8996 var bleka_up = E.newElem('div', className + '_up', this._container); 8997 E.$(bleka_up).block(); 8998 E.$(this._container).block(); 8999 this._draggable = new L.Draggable(this._container, bleka_up); 9000 this._containerItems = E.newElem('div', this._className + '_middle', this._container); 9001 E.newElem('div', className + '_down', this._container); 9002 this._draggable.enable() 9003 }, 9004 _addAction: function(event) { 9005 var action = event.action; 9006 if (action.options.actionPanel) { 9007 var div = E.newElem$('div', this._className + '-' + action.getName(), this._containerItems).att("title", action.getDescription()); 9008 div = E.newElem$('a', action.isActive() ? 'active' : 'inactive', div.elem()); 9009 this._items[action._id] = div; 9010 action.onAdded(div); 9011 div.block().click(action.activate, action) 9012 } 9013 }, 9014 _onActivateAction: function(event) { 9015 var action = event.action; 9016 if (action.options.actionPanel) E.$(this._items[action._id]).Class('active') 9017 }, 9018 _onDeactivateAction: function(event) { 9019 var action = event.action; 9020 if (action.options.actionPanel) E.$(this._items[action._id]).Class('inactive') 9021 } 9022}); 9023E.control.actionPanel = function(options) { 9024 return new E.Control.ActionPanel(options) 9025}; 9026L.Control.Attribution.include({ 9027 _layers: [], 9028 onAdd: function(map) { 9029 this.options.prefix = '<a href="http://www.emapa.pl/" target="_blank">' + E.lang("A_em") + '</a></div>'; 9030 this._container = L.DomUtil.create('div', 'leaflet-control-attribution'); 9031 L.DomEvent.disableClickPropagation(this._container); 9032 map.on('layeradd', this._onLayerAdd, this).on('layerremove', this._onLayerRemove, this).on('layerAttributionChange', this._update, this); 9033 this._layers = []; 9034 this._update(); 9035 map.eachLayer(function(l) { 9036 this._onLayerAdd({ 9037 layer: l 9038 }) 9039 }, this); 9040 return this._container 9041 }, 9042 _onLayerAdd: function(e) { 9043 if (e.layer.getAttribution) { 9044 this._layers.push(e.layer); 9045 this._update() 9046 } 9047 }, 9048 _onLayerRemove: function(e) { 9049 var i = this._layers.indexOf(e.layer); 9050 if (i != -1) { 9051 this._layers.splice(i, 1); 9052 this._update() 9053 } 9054 }, 9055 _update: function() { 9056 if (!this._map) { 9057 return 9058 } 9059 var attribs = []; 9060 for (var i = 0; i < this._layers.length; i++) { 9061 var layer = this._layers[i];
9062 if (layer.getAttribution) { 9063 var attrib = layer.getAttribution(); 9064 if (attrib) attribs.push(attrib) 9065 } 9066 } 9067 var prefixAndAttribs = []; 9068 if (this.options.prefix) { 9069 prefixAndAttribs.push(this.options.prefix) 9070 } 9071 if (attribs.length) { 9072 prefixAndAttribs.push(attribs.join(', ')) 9073 } 9074 this._container.innerHTML = prefixAndAttribs.join(' — ') 9075 } 9076}); 9077E.Control.ContextMenu = E.Control.extend({ 9078 options: { 9079 position: 'contextMenu' 9080 }, 9081 _container: null, 9082 _items: [], 9083 _className: '', 9084 _currPoint: null, 9085 onAdd: function(map) { 9086 this._map = map; 9087 this._className = 'emapi-control-contextMenu'; 9088 this._container = E.newElem('div', this._className); 9089 this._map.on("contextmenu", this._onContextMenu, this).on("mousedown", this._hideContext, this).on("beforeCalculateRoute", this._disableContext, this).on("afterCalculateRoute", this._enableContext, this); 9090 this._map.actions.on("onAddAction", this._addAction, this).on("onRemoveAction", this._removeAction, this).on("onActivateAction", this._hideContext, this).on("onDeactivateAction", this._hideContext, this); 9091 this._hideContext(); 9092 return this._container 9093 }, 9094 _getTableItem: function(a, b) { 9095 b = b ? 'style="background-image:url(' + b + ')"' : ''; 9096 a = E.lang('CM_' + a).replace('CM_', ''); 9097 return '<table><tr><td><div class="icon" ' + b + '></div></td><td><div class="description">' + a + '</div></td></tr></table>' 9098 }, 9099 _addAction: function(event) { 9100 var action = event.action; 9101 if (action.options.contextAction) { 9102 action.getName() != 'Divider' ? E.newElem$('a', this._className + '-' + action.getName()).att("href", '#').appendTo(this._container, event.actionIndex).text(this._getTableItem(action.getName(), action.getIcon())).block().click(this._actionExecute, { 9103 a: action, 9104 c: this 9105 }) : E.newElem$('div', this._className + '-' + action.getName()).appendTo(this._container, event.actionIndex) 9106 } 9107 }, 9108 _removeAction: function(event) { 9109 E.$(this._container).remove(event.actionIndex) 9110 }, 9111 _actionExecute: function(a) { 9112 this.c._hideContext(); 9113 this.a.activate(this.c._currPoint); 9114 E.block(a) 9115 }, 9116 _hideContext: function() { 9117 E.$(this._container).hide() 9118 }, 9119 _disableContext: function() { 9120 this._hideContext(); 9121 this.disabled = 1 9122 }, 9123 _enableContext: function() { 9124 this.disabled = 0 9125 }, 9126 _onContextMenu: function(e) { 9127 if (this.disabled) return; 9128 this._currPoint = e.latlng; 9129 var t = this._map.getSize(), 9130 c = E.$(this._container); 9131 c.show(); 9132 if ((e.containerPoint.x + c.width()) > t.x) e.containerPoint.x -= c.width(); 9133 if ((e.containerPoint.y + c.height()) > t.y) e.containerPoint.y -= c.height(); 9134 c.show(e.containerPoint) 9135 } 9136}); 9137E.Map.addInitHook(function() { 9138 this._controlCorners['contextMenu'] = E.newElem("div", "contextMenu", this._controlContainer) 9139}); 9140E.control.contextMenu = function(options) { 9141 return new E.Control.ContextMenu(options) 9142}; 9143L.Control.MiniMap = L.Control.extend({ 9144 options: { 9145 position: 'bottomright', 9146 toggleDisplay: false, 9147 zoomLevelOffset: -5, 9148 zoomLevelFixed: false, 9149 zoomAnimation: false, 9150 autoToggleDisplay: false, 9151 width: 120, 9152 height: 100 9153 }, 9154 initialize: function(layer, options) { 9155 L.Util.setOptions(this, options); 9156 this._layer = layer 9157 }, 9158 onAdd: function(map) { 9159 this._mainMap = map; 9160 this._container = L.DomUtil.create('div', 'leaflet-control-minimap'); 9161 this._container.style.width = this.options.width + 'px'; 9162 this._container.style.height = this.options.height + 'px'; 9163 L.DomEvent.disableClickPropagation(this._container); 9164 L.DomEvent.on(this._container, 'mousewheel', L.DomEvent.stopPropagation); 9165 this._miniMap = new L.Map(this._container, { 9166 attributionControl: false, 9167 zoomControl: false, 9168 zoomAnimation: this.options.zoomAnimation, 9169 autoToggleDisplay: this.options.autoToggleDisplay, 9170 touchZoom: !this.options.zoomLevelFixed, 9171 scrollWheelZoom: !this.options.zoomLevelFixed, 9172 doubleClickZoom: !this.options.zoomLevelFixed, 9173 boxZoom: !this.options.zoomLevelFixed 9174 });
9175 this._miniMap.addLayer(L.Util.clone(this._layer)); 9176 this._mainMapMoving = false; 9177 this._miniMapMoving = false; 9178 this._userToggledDisplay = false; 9179 this._minimized = false; 9180 if (this.options.toggleDisplay) { 9181 this._addToggleButton() 9182 } 9183 this._miniMap.whenReady(L.Util.bind(function() { 9184 this._aimingRect = L.rectangle(this._mainMap.getBounds(), { 9185 color: "#ff7800", 9186 weight: 1, 9187 clickable: false 9188 }).addTo(this._miniMap); 9189 this._mainMap.on('moveend', this._onMainMapMoved, this); 9190 this._mainMap.on('move', this._onMainMapMoving, this); 9191 this._miniMap.on('moveend', this._onMiniMapMoved, this) 9192 }, this)); 9193 return this._container 9194 }, 9195 addTo: function(map) { 9196 L.Control.prototype.addTo.call(this, map); 9197 this._miniMap.setView(this._mainMap.getCenter(), this._decideZoom(true)); 9198 this._setDisplay(true); 9199 return this 9200 }, 9201 onRemove: function(map) { 9202 this._mainMap.off('moveend', this._onMainMapMoved, this); 9203 this._mainMap.off('move', this._onMainMapMoving, this); 9204 this._miniMap.off('moveend', this._onMiniMapMoved, this) 9205 }, 9206 _addToggleButton: function() { 9207 this._toggleDisplayButton = this.options.toggleDisplay ? this._createButton('', 'Hide', 'leaflet-control-minimap-toggle-display', this._container, this._toggleDisplayButtonClicked, this) : undefined 9208 }, 9209 _createButton: function(html, title, className, container, fn, context) { 9210 var link = L.DomUtil.create('a', className, container); 9211 link.innerHTML = html; 9212 link.href = '#'; 9213 link.title = title; 9214 var stop = L.DomEvent.stopPropagation; 9215 L.DomEvent.on(link, 'click', stop).on(link, 'mousedown', stop).on(link, 'dblclick', stop).on(link, 'click', L.DomEvent.preventDefault).on(link, 'click', fn, context); 9216 return link 9217 }, 9218 _toggleDisplayButtonClicked: function() { 9219 this._userToggledDisplay = true; 9220 if (!this._minimized) { 9221 this._minimize() 9222 } else { 9223 this._restore() 9224 } 9225 }, 9226 _setDisplay: function(minimize) { 9227 if (minimize != this._minimized) { 9228 if (!this._minimized) { 9229 this._minimize() 9230 } else { 9231 this._restore() 9232 } 9233 } 9234 }, 9235 _minimize: function() { 9236 if (this.options.toggleDisplay) { 9237 this._container.style.width = '19px'; 9238 this._container.style.height = '19px'; 9239 this._toggleDisplayButton.className += ' minimized' 9240 } else { 9241 this._container.style.display = 'none' 9242 } 9243 this._minimized = true 9244 }, 9245 _restore: function() { 9246 if (this.options.toggleDisplay) { 9247 this._container.style.width = this.options.width + 'px'; 9248 this._container.style.height = this.options.height + 'px'; 9249 this._toggleDisplayButton.className = this._toggleDisplayButton.className.replace(/(?:^|\s)minimized(?!\S)/g, '') 9250 } else { 9251 this._container.style.display = 'block' 9252 } 9253 this._minimized = false 9254 }, 9255 _onMainMapMoved: function(e) { 9256 if (!this._miniMapMoving) { 9257 this._mainMapMoving = true; 9258 this._miniMap.setView(this._mainMap.getCenter(), this._decideZoom(true)); 9259 this._setDisplay(this._decideMinimized()) 9260 } else { 9261 this._miniMapMoving = false 9262 } 9263 this._aimingRect.setBounds(this._mainMap.getBounds()) 9264 }, 9265 _onMainMapMoving: function(e) { 9266 this._aimingRect.setBounds(this._mainMap.getBounds()) 9267 }, 9268 _onMiniMapMoved: function(e) { 9269 if (!this._mainMapMoving) { 9270 this._miniMapMoving = true; 9271 this._mainMap.setView(this._miniMap.getCenter(), this._decideZoom(false)) 9272 } else { 9273 this._mainMapMoving = false 9274 } 9275 }, 9276 _decideZoom: function(fromMaintoMini) { 9277 if (!this.options.zoomLevelFixed) { 9278 if (fromMaintoMini) return this._mainMap.getZoom() + this.options.zoomLevelOffset; 9279 else return this._miniMap.getZoom() - this.options.zoomLevelOffset 9280 } else { 9281 if (fromMaintoMini) return this.options.zoomLevelFixed; 9282 else return this._mainMap.getZoom() 9283 } 9284 }, 9285 _decideMinimized: function() { 9286 if (this._userToggledDisplay) { 9287 return this._minimized 9288 } 9289 if (this.options.autoToggleDisplay) { 9290 if (this._mainMap.getBounds().contains(this._miniMap.getBounds())) { 9291 return true 9292 } 9293 return false 9294 } 9295 return this._minimized 9296 } 9297}); 9298L.Util.clone = function(o) { 9299 if (o == null || typeof(o) != 'object') return o; 9300 var c = new o.constructor(); 9301 for (var k in o) c[k] = L.Util.clone(o[k]); 9302 return c 9303}; 9304E.Control.Layers = L.Control.Layers.extend({ 9305 initialize: function(options) { 9306 L.setOptions(this, options);
9307 this.options.autoZIndex = 0; 9308 this._layers = {}; 9309 this._lastZIndex = 0; 9310 this._handlingClick = false 9311 }, 9312 onAdd: function(map) { 9313 this._initLayout(); 9314 this._update(); 9315 map.eachLayer(function(layer) { 9316 this._addLayerObserver({ 9317 type: "layeraddswitcher", 9318 layer: layer 9319 }) 9320 }, this); 9321 map.on('layeradd', this._onLayerChange, this).on('layerremove', this._onLayerChange, this).on('layeraddswitcher', this._addLayerObserver, this).on('layerremoveswitcher', this._addLayerObserver, this); 9322 return this._container 9323 }, 9324 onRemove: function(map) { 9325 map.off('layeradd', this._onLayerChange).off('layerremove', this._onLayerChange).off('layeraddswitcher', this._addLayerObserver).off('layerremoveswitcher', this._addLayerObserver) 9326 }, 9327 removeLayer: function(layer) { 9328 var id = L.stamp(layer); 9329 delete this._layers[id]; 9330 this._update(); 9331 return this 9332 }, 9333 _addLayerObserver: function(e) { 9334 if ((e.layer instanceof L.TileLayer) || (e.layer instanceof E.VectorLayer)) 9335 if (!e.layer.options.system) { 9336 if (e.type == "layeraddswitcher") { 9337 this._addLayer(e.layer, e.layer.options.name, !e.layer.options.baseLayer); 9338 this._update() 9339 } else this.removeLayer(e.layer) 9340 } 9341 }, 9342 _onInputClick: function() { 9343 var i, input, obj, inputs = this._form.getElementsByTagName('input'), 9344 inputsLen = inputs.length; 9345 this._handlingClick = true; 9346 for (i = 0; i < inputsLen; i++) { 9347 input = inputs[i]; 9348 obj = this._layers[input.layerId]; 9349 if (input.checked && !this._map.hasLayer(obj.layer)) { 9350 this._map.addLayer(obj.layer); 9351 if (obj.layer.options.baseLayer) obj.layer.bringToBack() 9352 } else if (!input.checked && this._map.hasLayer(obj.layer)) { 9353 this._map.removeLayer(obj.layer) 9354 } 9355 } 9356 this._handlingClick = false 9357 } 9358}); 9359E.ArrayObjects = L.Class.extend({ 9360 _items: null, 9361 _objectType: null, 9362 initialize: function(objectType, options) { 9363 this._objectType = objectType; 9364 this._items = new Array(); 9365 E.extend(this, options) 9366 }, 9367 destroy: function() { 9368 this.removeItems(); 9369 this._items = null 9370 }, 9371 addItem: function(options) { 9372 var item = new this._objectType(options); 9373 this._items.push(item); 9374 return item 9375 }, 9376 insertItem: function(options, index) { 9377 if (this._inRange(index)) this._items.splice(index, 0, new this._objectType(options)); 9378 else this._items.push(new this._objectType(options)) 9379 }, 9380 setItem: function(options, index) { 9381 if (this._inRange(index)) { 9382 this._items[index] = null; 9383 this._items[index] = new this._objectType(options) 9384 } 9385 }, 9386 removeItem: function(index) { 9387 if ((index >= 0) && (index < this._items.length)) this._items.splice(index, 1) 9388 }, 9389 removeItems: function(destroy) { 9390 if (destroy != false) 9391 for (var i = 0; i < this._items.length; i++) 9392 if (this._items[i].destroy) this._items[i].destroy(); 9393 this._items.length = 0 9394 }, 9395 moveItem: function(from, to) { 9396 if (this._inRange(from) && this._inRange(to)) { 9397 this._items.splice(to, 0, this._items.splice(from, 1)[0]) 9398 } 9399 }, 9400 getObject: function(property, val) { 9401 for (var i = 0; i < this._items.length; i++) 9402 if (this._items[i][property] == val) return this._items[i]; 9403 return null 9404 }, 9405 findObject: function(property, val) { 9406 for (var i = 0; i < this._items.length; i++) 9407 if (this._items[i][property] == val) return i; 9408 return -1 9409 }, 9410 initializeItems: function(objects) { 9411 if (!(objects instanceof Array)) objects = [objects]; 9412 for (var i = 0; i < objects.length; i++) this.addItem(objects[i]) 9413 }, 9414 itemById: function(id) { 9415 return this.getObject("id", id) 9416 }, 9417 item: function(i) { 9418 return this._items[i] 9419 }, 9420 count: function() { 9421 return this._items.length 9422 }, 9423 _inRange: function(index) { 9424 return ((index >= 0) && (index < this.count())) 9425 }, 9426 toArray: function() { 9427 return this._items.slice(0) 9428 }, 9429 fromArray: function(a) { 9430 return this._items = a 9431 } 9432}); 9433L.DistanceGrid = function(cellSize) { 9434 this._cellSize = cellSize; 9435 this._sqCellSize = cellSize * cellSize; 9436 this._grid = {}; 9437 this._objectPoint = {} 9438}; 9439L.DistanceGrid.prototype = { 9440 addObject: function(obj, point) { 9441 var x = this._getCoord(point.x), 9442 y = this._getCoord(point.y), 9443 grid = this._grid, 9444 row = grid[y] = grid[y] || {}, 9445 cell = row[x] = row[x] || [], 9446 stamp = L.Util.stamp(obj); 9447 this._objectPoint[stamp] = point; 9448 cell.push(obj) 9449 }, 9450 updateObject: function(obj, point) { 9451 this.removeObject(obj); 9452 this.addObject(obj, point) 9453 }, 9454 removeObject: function(obj, point) { 9455 var x = this._getCoord(point.x), 9456 y = this._getCoord(point.y), 9457 grid = this._grid, 9458 row = grid[y] = grid[y] || {}, 9459 cell = row[x] = row[x] || [], 9460 i, len; 9461 delete this._objectPoint[L.Util.stamp(obj)]; 9462 for (i = 0, len = cell.length; i < len; i++) { 9463 if (cell[i] === obj) { 9464 cell.splice(i, 1); 9465 if (len === 1) { 9466 delete row[x] 9467 } 9468 return true 9469 } 9470 } 9471 }, 9472 eachObject: function(fn, context) { 9473 var i, j, k, len, row, cell, removed, grid = this._grid; 9474 for (i in grid) { 9475 row = grid[i]; 9476 for (j in row) { 9477 cell = row[j]; 9478 for (k = 0, len = cell.length; k < len; k++) {
9479 removed = fn.call(context, cell[k]); 9480 if (removed) { 9481 k--; 9482 len-- 9483 } 9484 } 9485 } 9486 } 9487 }, 9488 getNearObject: function(point) { 9489 var x = this._getCoord(point.x), 9490 y = this._getCoord(point.y), 9491 i, j, k, row, cell, len, obj, dist, objectPoint = this._objectPoint, 9492 closestDistSq = this._sqCellSize, 9493 closest = null; 9494 for (i = y - 1; i <= y + 1; i++) { 9495 row = this._grid[i]; 9496 if (row) { 9497 for (j = x - 1; j <= x + 1; j++) { 9498 cell = row[j]; 9499 if (cell) { 9500 for (k = 0, len = cell.length; k < len; k++) { 9501 obj = cell[k]; 9502 dist = this._sqDist(objectPoint[L.Util.stamp(obj)], point); 9503 if (dist < closestDistSq) { 9504 closestDistSq = dist; 9505 closest = obj 9506 } 9507 } 9508 } 9509 } 9510 } 9511 } 9512 return closest 9513 }, 9514 _getCoord: function(x) { 9515 return Math.floor(x / this._cellSize) 9516 }, 9517 _sqDist: function(p, p2) { 9518 var dx = p2.x - p.x, 9519 dy = p2.y - p.y; 9520 return dx * dx + dy * dy 9521 } 9522}; 9523L.MarkerClusterGroup = L.FeatureGroup.extend({ 9524 options: { 9525 maxClusterRadius: 80, 9526 iconCreateFunction: null, 9527 spiderfyOnMaxZoom: true, 9528 showCoverageOnHover: true, 9529 zoomToBoundsOnClick: true, 9530 singleMarkerMode: false, 9531 disableClusteringAtZoom: null, 9532 removeOutsideVisibleBounds: true, 9533 animateAddingMarkers: false, 9534 spiderfyDistanceMultiplier: 1, 9535 chunkedLoading: false, 9536 chunkInterval: 200, 9537 chunkDelay: 50, 9538 chunkProgress: null, 9539 polygonOptions: {} 9540 }, 9541 initialize: function(options) { 9542 L.Util.setOptions(this, options); 9543 if (!this.options.iconCreateFunction) { 9544 this.options.iconCreateFunction = this._defaultIconCreateFunction 9545 } 9546 this._featureGroup = L.featureGroup(); 9547 this._featureGroup.on(L.FeatureGroup.EVENTS, this._propagateEvent, this); 9548 this._nonPointGroup = L.featureGroup(); 9549 this._nonPointGroup.on(L.FeatureGroup.EVENTS, this._propagateEvent, this); 9550 this._inZoomAnimation = 0; 9551 this._needsClustering = []; 9552 this._needsRemoving = []; 9553 this._currentShownBounds = null; 9554 this._queue = [] 9555 }, 9556 addLayer: function(layer) { 9557 if (layer instanceof L.LayerGroup) { 9558 var array = []; 9559 for (var i in layer._layers) { 9560 array.push(layer._layers[i]) 9561 } 9562 return this.addLayers(array) 9563 } 9564 if (!layer.getLatLng) { 9565 this._nonPointGroup.addLayer(layer); 9566 return this 9567 } 9568 if (!this._map) { 9569 this._needsClustering.push(layer); 9570 return this 9571 } 9572 if (this.hasLayer(layer)) { 9573 return this 9574 } 9575 if (this._unspiderfy) { 9576 this._unspiderfy() 9577 } 9578 this._addLayer(layer, this._maxZoom); 9579 var visibleLayer = layer, 9580 currentZoom = this._map.getZoom(); 9581 if (layer.__parent) { 9582 while (visibleLayer.__parent._zoom >= currentZoom) { 9583 visibleLayer = visibleLayer.__parent 9584 } 9585 } 9586 if (this._currentShownBounds.contains(visibleLayer.getLatLng())) { 9587 if (this.options.animateAddingMarkers) { 9588 this._animationAddLayer(layer, visibleLayer) 9589 } else { 9590 this._animationAddLayerNonAnimated(layer, visibleLayer) 9591 } 9592 } 9593 return this 9594 }, 9595 removeLayer: function(layer) { 9596 if (layer instanceof L.LayerGroup) { 9597 var array = []; 9598 for (var i in layer._layers) { 9599 array.push(layer._layers[i]) 9600 } 9601 return this.removeLayers(array) 9602 } 9603 if (!layer.getLatLng) { 9604 this._nonPointGroup.removeLayer(layer); 9605 return this 9606 } 9607 if (!this._map) { 9608 if (!this._arraySplice(this._needsClustering, layer) && this.hasLayer(layer)) { 9609 this._needsRemoving.push(layer) 9610 } 9611 return this 9612 } 9613 if (!layer.__parent) { 9614 return this 9615 } 9616 if (this._unspiderfy) { 9617 this._unspiderfy(); 9618 this._unspiderfyLayer(layer) 9619 } 9620 this._removeLayer(layer, true); 9621 if (this._featureGroup.hasLayer(layer)) { 9622 this._featureGroup.removeLayer(layer); 9623 if (layer.setOpacity) { 9624 layer.setOpacity(1) 9625 } 9626 } 9627 return this 9628 }, 9629 addLayers: function(layersArray) { 9630 var fg = this._featureGroup, 9631 npg = this._nonPointGroup, 9632 chunked = this.options.chunkedLoading, 9633 chunkInterval = this.options.chunkInterval, 9634 chunkProgress = this.options.chunkProgress, 9635 newMarkers, i, l, m; 9636 if (this._map) { 9637 var offset = 0, 9638 started = (new Date()).getTime(); 9639 var process = L.bind(function() { 9640 var start = (new Date()).getTime(); 9641 for (; offset < layersArray.length; offset++) { 9642 if (chunked && offset % 200 === 0) {
9643 var elapsed = (new Date()).getTime() - start; 9644 if (elapsed > chunkInterval) { 9645 break 9646 } 9647 } 9648 m = layersArray[offset]; 9649 if (!m.getLatLng) { 9650 npg.addLayer(m); 9651 continue 9652 } 9653 if (this.hasLayer(m)) { 9654 continue 9655 } 9656 this._addLayer(m, this._maxZoom); 9657 if (m.__parent) { 9658 if (m.__parent.getChildCount() === 2) { 9659 var markers = m.__parent.getAllChildMarkers(), 9660 otherMarker = markers[0] === m ? markers[1] : markers[0]; 9661 fg.removeLayer(otherMarker) 9662 } 9663 } 9664 } 9665 if (chunkProgress) { 9666 chunkProgress(offset, layersArray.length, (new Date()).getTime() - started) 9667 } 9668 if (offset === layersArray.length) { 9669 this._featureGroup.eachLayer(function(c) { 9670 if (c instanceof L.MarkerCluster && c._iconNeedsUpdate) { 9671 c._updateIcon() 9672 } 9673 }); 9674 this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds) 9675 } else { 9676 setTimeout(process, this.options.chunkDelay) 9677 } 9678 }, this); 9679 process() 9680 } else { 9681 newMarkers = []; 9682 for (i = 0, l = layersArray.length; i < l; i++) { 9683 m = layersArray[i]; 9684 if (!m.getLatLng) { 9685 npg.addLayer(m); 9686 continue 9687 } 9688 if (this.hasLayer(m)) { 9689 continue 9690 } 9691 newMarkers.push(m) 9692 } 9693 this._needsClustering = this._needsClustering.concat(newMarkers) 9694 } 9695 return this 9696 }, 9697 removeLayers: function(layersArray) { 9698 var i, l, m, fg = this._featureGroup, 9699 npg = this._nonPointGroup; 9700 if (!this._map) { 9701 for (i = 0, l = layersArray.length; i < l; i++) { 9702 m = layersArray[i]; 9703 this._arraySplice(this._needsClustering, m); 9704 npg.removeLayer(m) 9705 } 9706 return this 9707 } 9708 for (i = 0, l = layersArray.length; i < l; i++) { 9709 m = layersArray[i]; 9710 if (!m.__parent) { 9711 npg.removeLayer(m); 9712 continue 9713 } 9714 this._removeLayer(m, true, true); 9715 if (fg.hasLayer(m)) { 9716 fg.removeLayer(m); 9717 if (m.setOpacity) { 9718 m.setOpacity(1) 9719 } 9720 } 9721 } 9722 this._topClusterLevel._recursivelyAddChildrenToMap(null, this._zoom, this._currentShownBounds); 9723 fg.eachLayer(function(c) { 9724 if (c instanceof L.MarkerCluster) { 9725 c._updateIcon() 9726 } 9727 }); 9728 return this 9729 }, 9730 clearLayers: function() { 9731 if (!this._map) { 9732 this._needsClustering = []; 9733 delete this._gridClusters; 9734 delete this._gridUnclustered 9735 } 9736 if (this._noanimationUnspiderfy) { 9737 this._noanimationUnspiderfy() 9738 } 9739 this._featureGroup.clearLayers(); 9740 this._nonPointGroup.clearLayers(); 9741 this.eachLayer(function(marker) { 9742 delete marker.__parent 9743 }); 9744 if (this._map) { 9745 this._generateInitialClusters() 9746 } 9747 return this 9748 }, 9749 getBounds: function() { 9750 var bounds = new L.LatLngBounds(); 9751 if (this._topClusterLevel) { 9752 bounds.extend(this._topClusterLevel._bounds) 9753 } 9754 for (var i = this._needsClustering.length - 1; i >= 0; i--) { 9755 bounds.extend(this._needsClustering[i].getLatLng()) 9756 } 9757 bounds.extend(this._nonPointGroup.getBounds()); 9758 return bounds 9759 }, 9760 eachLayer: function(method, context) { 9761 var markers = this._needsClustering.slice(), 9762 i; 9763 if (this._topClusterLevel) { 9764 this._topClusterLevel.getAllChildMarkers(markers) 9765 } 9766 for (i = markers.length - 1; i >= 0; i--) { 9767 method.call(context, markers[i]) 9768 } 9769 this._nonPointGroup.eachLayer(method, context) 9770 }, 9771 getLayers: function() { 9772 var layers = []; 9773 this.eachLayer(function(l) { 9774 layers.push(l) 9775 }); 9776 return layers 9777 }, 9778 getLayer: function(id) { 9779 var result = null; 9780 this.eachLayer(function(l) { 9781 if (L.stamp(l) === id) { 9782 result = l 9783 } 9784 });
9785 return result 9786 }, 9787 hasLayer: function(layer) { 9788 if (!layer) { 9789 return false 9790 } 9791 var i, anArray = this._needsClustering; 9792 for (i = anArray.length - 1; i >= 0; i--) { 9793 if (anArray[i] === layer) { 9794 return true 9795 } 9796 } 9797 anArray = this._needsRemoving; 9798 for (i = anArray.length - 1; i >= 0; i--) { 9799 if (anArray[i] === layer) { 9800 return false 9801 } 9802 } 9803 return !!(layer.__parent && layer.__parent._group === this) || this._nonPointGroup.hasLayer(layer) 9804 }, 9805 zoomToShowLayer: function(layer, callback) { 9806 var showMarker = function() { 9807 if ((layer._icon || layer.__parent._icon) && !this._inZoomAnimation) { 9808 this._map.off('moveend', showMarker, this); 9809 this.off('animationend', showMarker, this); 9810 if (layer._icon) { 9811 callback() 9812 } else if (layer.__parent._icon) { 9813 var afterSpiderfy = function() { 9814 this.off('spiderfied', afterSpiderfy, this); 9815 callback() 9816 }; 9817 this.on('spiderfied', afterSpiderfy, this); 9818 layer.__parent.spiderfy() 9819 } 9820 } 9821 }; 9822 if (layer._icon && this._map.getBounds().contains(layer.getLatLng())) { 9823 callback() 9824 } else if (layer.__parent._zoom < this._map.getZoom()) { 9825 this._map.on('moveend', showMarker, this); 9826 this._map.panTo(layer.getLatLng()) 9827 } else { 9828 this._map.on('moveend', showMarker, this); 9829 this.on('animationend', showMarker, this);
9830 this._map.setView(layer.getLatLng(), layer.__parent._zoom + 1); 9831 layer.__parent.zoomToBounds() 9832 } 9833 }, 9834 onAdd: function(map) { 9835 this._map = map; 9836 var i, l, layer; 9837 if (!isFinite(this._map.getMaxZoom())) { 9838 throw "Map has no maxZoom specified" 9839 } 9840 this._featureGroup.onAdd(map); 9841 this._nonPointGroup.onAdd(map); 9842 if (!this._gridClusters) { 9843 this._generateInitialClusters() 9844 } 9845 for (i = 0, l = this._needsRemoving.length; i < l; i++) { 9846 layer = this._needsRemoving[i]; 9847 this._removeLayer(layer, true) 9848 } 9849 this._needsRemoving = []; 9850 this._zoom = this._map.getZoom(); 9851 this._currentShownBounds = this._getExpandedVisibleBounds(); 9852 this._map.on('zoomend', this._zoomEnd, this); 9853 this._map.on('moveend', this._moveEnd, this); 9854 if (this._spiderfierOnAdd) { 9855 this._spiderfierOnAdd() 9856 } 9857 this._bindEvents(); 9858 l = this._needsClustering; 9859 this._needsClustering = []; 9860 this.addLayers(l) 9861 }, 9862 onRemove: function(map) { 9863 map.off('zoomend', this._zoomEnd, this); 9864 map.off('moveend', this._moveEnd, this); 9865 this._unbindEvents(); 9866 this._map._mapPane.className = this._map._mapPane.className.replace(' leaflet-cluster-anim', ''); 9867 if (this._spiderfierOnRemove) { 9868 this._spiderfierOnRemove() 9869 } 9870 this._hideCoverage(); 9871 this._featureGroup.onRemove(map); 9872 this._nonPointGroup.onRemove(map); 9873 this._featureGroup.clearLayers(); 9874 this._map = null 9875 }, 9876 getVisibleParent: function(marker) { 9877 var vMarker = marker; 9878 while (vMarker && !vMarker._icon) { 9879 vMarker = vMarker.__parent 9880 } 9881 return vMarker || null 9882 }, 9883 _arraySplice: function(anArray, obj) { 9884 for (var i = anArray.length - 1; i >= 0; i--) { 9885 if (anArray[i] === obj) { 9886 anArray.splice(i, 1); 9887 return true 9888 } 9889 } 9890 }, 9891 _removeLayer: function(marker, removeFromDistanceGrid, dontUpdateMap) { 9892 var gridClusters = this._gridClusters, 9893 gridUnclustered = this._gridUnclustered, 9894 fg = this._featureGroup, 9895 map = this._map; 9896 if (removeFromDistanceGrid) { 9897 for (var z = this._maxZoom; z >= 0; z--) { 9898 if (!gridUnclustered[z].removeObject(marker, map.project(marker.getLatLng(), z))) { 9899 break 9900 } 9901 } 9902 } 9903 var cluster = marker.__parent, 9904 markers = cluster._markers, 9905 otherMarker; 9906 this._arraySplice(markers, marker); 9907 while (cluster) { 9908 cluster._childCount--; 9909 if (cluster._zoom < 0) { 9910 break 9911 } else if (removeFromDistanceGrid && cluster._childCount <= 1) { 9912 otherMarker = cluster._markers[0] === marker ? cluster._markers[1] : cluster._markers[0]; 9913 gridClusters[cluster._zoom].removeObject(cluster, map.project(cluster._cLatLng, cluster._zoom)); 9914 gridUnclustered[cluster._zoom].addObject(otherMarker, map.project(otherMarker.getLatLng(), cluster._zoom)); 9915 this._arraySplice(cluster.__parent._childClusters, cluster); 9916 cluster.__parent._markers.push(otherMarker); 9917 otherMarker.__parent = cluster.__parent; 9918 if (cluster._icon) { 9919 fg.removeLayer(cluster); 9920 if (!dontUpdateMap) { 9921 fg.addLayer(otherMarker) 9922 } 9923 } 9924 } else { 9925 cluster._recalculateBounds(); 9926 if (!dontUpdateMap || !cluster._icon) { 9927 cluster._updateIcon() 9928 } 9929 } 9930 cluster = cluster.__parent 9931 } 9932 delete marker.__parent 9933 }, 9934 _isOrIsParent: function(el, oel) { 9935 while (oel) { 9936 if (el === oel) { 9937 return true 9938 } 9939 oel = oel.parentNode 9940 } 9941 return false 9942 }, 9943 _propagateEvent: function(e) { 9944 if (e.layer instanceof L.MarkerCluster) { 9945 if (e.originalEvent && this._isOrIsParent(e.layer._icon, e.originalEvent.relatedTarget)) { 9946 return 9947 } 9948 e.type = 'cluster' + e.type 9949 } 9950 this.fire(e.type, e) 9951 }, 9952 _defaultIconCreateFunction: function(cluster) { 9953 var childCount = cluster.getChildCount(); 9954 var c = ' marker-cluster-'; 9955 if (childCount < 10) { 9956 c += 'small' 9957 } else if (childCount < 100) { 9958 c += 'medium' 9959 } else { 9960 c += 'large' 9961 } 9962 return new L.DivIcon({ 9963 html: '<div><span>' + childCount + '</span></div>', 9964 className: 'marker-cluster' + c, 9965 iconSize: new L.Point(40, 40) 9966 }) 9967 }, 9968 _bindEvents: function() { 9969 var map = this._map, 9970 spiderfyOnMaxZoom = this.options.spiderfyOnMaxZoom, 9971 showCoverageOnHover = this.options.showCoverageOnHover, 9972 zoomToBoundsOnClick = this.options.zoomToBoundsOnClick; 9973 if (spiderfyOnMaxZoom || zoomToBoundsOnClick) { 9974 this.on('clusterclick', this._zoomOrSpiderfy, this) 9975 } 9976 if (showCoverageOnHover) { 9977 this.on('clustermouseover', this._showCoverage, this); 9978 this.on('clustermouseout', this._hideCoverage, this); 9979 map.on('zoomend', this._hideCoverage, this) 9980 } 9981 }, 9982 _zoomOrSpiderfy: function(e) { 9983 var map = this._map; 9984 if (map.getMaxZoom() === map.getZoom()) { 9985 if (this.options.spiderfyOnMaxZoom) { 9986 e.layer.spiderfy() 9987 } 9988 } else if (this.options.zoomToBoundsOnClick) { 9989 e.layer.zoomToBounds() 9990 } 9991 if (e.originalEvent && e.originalEvent.keyCode === 13) { 9992 map._container.focus() 9993 } 9994 }, 9995 _showCoverage: function(e) { 9996 var map = this._map; 9997 if (this._inZoomAnimation) { 9998 return 9999 } 10000 if (this._shownPolygon) { 10001 map.removeLayer(this._shownPolygon) 10002 } 10003 if (e.layer.getChildCount() > 2 && e.layer !== this._spiderfied) { 10004 this._shownPolygon = new L.Polygon(e.layer.getConvexHull(), this.options.polygonOptions); 10005 map.addLayer(this._shownPolygon) 10006 } 10007 }, 10008 _hideCoverage: function() { 10009 if (this._shownPolygon) { 10010 this._map.removeLayer(this._shownPolygon); 10011 this._shownPolygon = null 10012 } 10013 }, 10014 _unbindEvents: function() { 10015 var spiderfyOnMaxZoom = this.options.spiderfyOnMaxZoom, 10016 showCoverageOnHover = this.options.showCoverageOnHover, 10017 zoomToBoundsOnClick = this.options.zoomToBoundsOnClick, 10018 map = this._map; 10019 if (spiderfyOnMaxZoom || zoomToBoundsOnClick) { 10020 this.off('clusterclick', this._zoomOrSpiderfy, this) 10021 } 10022 if (showCoverageOnHover) { 10023 this.off('clustermouseover', this._showCoverage, this); 10024 this.off('clustermouseout', this._hideCoverage, this); 10025 map.off('zoomend', this._hideCoverage, this) 10026 } 10027 }, 10028 _zoomEnd: function() { 10029 if (!this._map) { 10030 return 10031 }
10032 this._mergeSplitClusters(); 10033 this._zoom = this._map._zoom; 10034 this._currentShownBounds = this._getExpandedVisibleBounds() 10035 }, 10036 _moveEnd: function() { 10037 if (this._inZoomAnimation) { 10038 return 10039 } 10040 var newBounds = this._getExpandedVisibleBounds(); 10041 this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, newBounds); 10042 this._topClusterLevel._recursivelyAddChildrenToMap(null, this._map._zoom, newBounds); 10043 this._currentShownBounds = newBounds; 10044 return 10045 }, 10046 _generateInitialClusters: function() { 10047 var maxZoom = this._map.getMaxZoom(), 10048 radius = this.options.maxClusterRadius, 10049 radiusFn = radius; 10050 if (typeof radius !== "function") { 10051 radiusFn = function() { 10052 return radius 10053 } 10054 } 10055 if (this.options.disableClusteringAtZoom) { 10056 maxZoom = this.options.disableClusteringAtZoom - 1 10057 } 10058 this._maxZoom = maxZoom; 10059 this._gridClusters = {}; 10060 this._gridUnclustered = {}; 10061 for (var zoom = maxZoom; zoom >= 0; zoom--) { 10062 this._gridClusters[zoom] = new L.DistanceGrid(radiusFn(zoom)); 10063 this._gridUnclustered[zoom] = new L.DistanceGrid(radiusFn(zoom)) 10064 } 10065 this._topClusterLevel = new L.MarkerCluster(this, -1) 10066 }, 10067 _addLayer: function(layer, zoom) { 10068 var gridClusters = this._gridClusters, 10069 gridUnclustered = this._gridUnclustered, 10070 markerPoint, z; 10071 if (this.options.singleMarkerMode) { 10072 layer.options.icon = this.options.iconCreateFunction({ 10073 getChildCount: function() { 10074 return 1 10075 }, 10076 getAllChildMarkers: function() { 10077 return [layer] 10078 } 10079 }) 10080 } 10081 for (; zoom >= 0; zoom--) { 10082 markerPoint = this._map.project(layer.getLatLng(), zoom); 10083 var closest = gridClusters[zoom].getNearObject(markerPoint); 10084 if (closest) { 10085 closest._addChild(layer); 10086 layer.__parent = closest; 10087 return 10088 } 10089 closest = gridUnclustered[zoom].getNearObject(markerPoint); 10090 if (closest) { 10091 var parent = closest.__parent; 10092 if (parent) { 10093 this._removeLayer(closest, false) 10094 } 10095 var newCluster = new L.MarkerCluster(this, zoom, closest, layer); 10096 gridClusters[zoom].addObject(newCluster, this._map.project(newCluster._cLatLng, zoom)); 10097 closest.__parent = newCluster; 10098 layer.__parent = newCluster; 10099 var lastParent = newCluster; 10100 for (z = zoom - 1; z > parent._zoom; z--) { 10101 lastParent = new L.MarkerCluster(this, z, lastParent); 10102 gridClusters[z].addObject(lastParent, this._map.project(closest.getLatLng(), z)) 10103 } 10104 parent._addChild(lastParent); 10105 for (z = zoom; z >= 0; z--) { 10106 if (!gridUnclustered[z].removeObject(closest, this._map.project(closest.getLatLng(), z))) { 10107 break 10108 } 10109 } 10110 return 10111 } 10112 gridUnclustered[zoom].addObject(layer, markerPoint) 10113 } 10114 this._topClusterLevel._addChild(layer); 10115 layer.__parent = this._topClusterLevel; 10116 return 10117 }, 10118 _enqueue: function(fn) { 10119 this._queue.push(fn); 10120 if (!this._queueTimeout) { 10121 this._queueTimeout = setTimeout(L.bind(this._processQueue, this), 300) 10122 } 10123 }, 10124 _processQueue: function() { 10125 for (var i = 0; i < this._queue.length; i++) { 10126 this._queue[i].call(this) 10127 } 10128 this._queue.length = 0; 10129 clearTimeout(this._queueTimeout); 10130 this._queueTimeout = null 10131 }, 10132 _mergeSplitClusters: function() { 10133 this._processQueue(); 10134 if (this._zoom < this._map._zoom && this._currentShownBounds.contains(this._getExpandedVisibleBounds())) { 10135 this._animationStart(); 10136 this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, this._zoom, this._getExpandedVisibleBounds()); 10137 this._animationZoomIn(this._zoom, this._map._zoom) 10138 } else if (this._zoom > this._map._zoom) { 10139 this._animationStart(); 10140 this._animationZoomOut(this._zoom, this._map._zoom) 10141 } else { 10142 this._moveEnd() 10143 } 10144 }, 10145 _getExpandedVisibleBounds: function() { 10146 if (!this.options.removeOutsideVisibleBounds) { 10147 return this.getBounds() 10148 } 10149 var map = this._map, 10150 bounds = map.getBounds(), 10151 sw = bounds._southWest, 10152 ne = bounds._northEast, 10153 latDiff = L.Browser.mobile ? 0 : Math.abs(sw.lat - ne.lat), 10154 lngDiff = L.Browser.mobile ? 0 : Math.abs(sw.lng - ne.lng); 10155 return new L.LatLngBounds(new L.LatLng(sw.lat - latDiff, sw.lng - lngDiff, true), new L.LatLng(ne.lat + latDiff, ne.lng + lngDiff, true)) 10156 }, 10157 _animationAddLayerNonAnimated: function(layer, newCluster) { 10158 if (newCluster === layer) { 10159 this._featureGroup.addLayer(layer) 10160 } else if (newCluster._childCount === 2) { 10161 newCluster._addToMap(); 10162 var markers = newCluster.getAllChildMarkers(); 10163 this._featureGroup.removeLayer(markers[0]); 10164 this._featureGroup.removeLayer(markers[1]) 10165 } else { 10166 newCluster._updateIcon() 10167 } 10168 } 10169}); 10170L.MarkerClusterGroup.include(!L.DomUtil.TRANSITION ? { 10171 _animationStart: function() {}, 10172 _animationZoomIn: function(previousZoomLevel, newZoomLevel) { 10173 this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel); 10174 this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); 10175 this.fire('animationend') 10176 }, 10177 _animationZoomOut: function(previousZoomLevel, newZoomLevel) { 10178 this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel); 10179 this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); 10180 this.fire('animationend') 10181 }, 10182 _animationAddLayer: function(layer, newCluster) { 10183 this._animationAddLayerNonAnimated(layer, newCluster) 10184 } 10185} : { 10186 _animationStart: function() { 10187 this._map._mapPane.className += ' leaflet-cluster-anim'; 10188 this._inZoomAnimation++ 10189 }, 10190 _animationEnd: function() { 10191 if (this._map) { 10192 this._map._mapPane.className = this._map._mapPane.className.replace(' leaflet-cluster-anim', '') 10193 } 10194 this._inZoomAnimation--; 10195 this.fire('animationend') 10196 }, 10197 _animationZoomIn: function(previousZoomLevel, newZoomLevel) { 10198 var bounds = this._getExpandedVisibleBounds(), 10199 fg = this._featureGroup, 10200 i; 10201 this._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function(c) { 10202 var startPos = c._latlng, 10203 markers = c._markers, 10204 m; 10205 if (!bounds.contains(startPos)) { 10206 startPos = null 10207 } 10208 if (c._isSingleParent() && previousZoomLevel + 1 === newZoomLevel) { 10209 fg.removeLayer(c); 10210 c._recursivelyAddChildrenToMap(null, newZoomLevel, bounds) 10211 } else { 10212 c.setOpacity(0); 10213 c._recursivelyAddChildrenToMap(startPos, newZoomLevel, bounds) 10214 } 10215 for (i = markers.length - 1; i >= 0; i--) { 10216 m = markers[i];
10217 if (!bounds.contains(m._latlng)) { 10218 fg.removeLayer(m) 10219 } 10220 } 10221 }); 10222 this._forceLayout(); 10223 this._topClusterLevel._recursivelyBecomeVisible(bounds, newZoomLevel); 10224 fg.eachLayer(function(n) { 10225 if (!(n instanceof L.MarkerCluster) && n._icon) { 10226 n.setOpacity(1) 10227 } 10228 }); 10229 this._topClusterLevel._recursively(bounds, previousZoomLevel, newZoomLevel, function(c) { 10230 c._recursivelyRestoreChildPositions(newZoomLevel) 10231 }); 10232 this._enqueue(function() { 10233 this._topClusterLevel._recursively(bounds, previousZoomLevel, 0, function(c) { 10234 fg.removeLayer(c); 10235 c.setOpacity(1) 10236 }); 10237 this._animationEnd() 10238 }) 10239 }, 10240 _animationZoomOut: function(previousZoomLevel, newZoomLevel) { 10241 this._animationZoomOutSingle(this._topClusterLevel, previousZoomLevel - 1, newZoomLevel); 10242 this._topClusterLevel._recursivelyAddChildrenToMap(null, newZoomLevel, this._getExpandedVisibleBounds()); 10243 this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds, previousZoomLevel, this._getExpandedVisibleBounds()) 10244 }, 10245 _animationZoomOutSingle: function(cluster, previousZoomLevel, newZoomLevel) { 10246 var bounds = this._getExpandedVisibleBounds(); 10247 cluster._recursivelyAnimateChildrenInAndAddSelfToMap(bounds, previousZoomLevel + 1, newZoomLevel); 10248 var me = this; 10249 this._forceLayout(); 10250 cluster._recursivelyBecomeVisible(bounds, newZoomLevel); 10251 this._enqueue(function() { 10252 if (cluster._childCount === 1) { 10253 var m = cluster._markers[0]; 10254 m.setLatLng(m.getLatLng()); 10255 if (m.setOpacity) { 10256 m.setOpacity(1) 10257 } 10258 } else { 10259 cluster._recursively(bounds, newZoomLevel, 0, function(c) { 10260 c._recursivelyRemoveChildrenFromMap(bounds, previousZoomLevel + 1) 10261 }) 10262 } 10263 me._animationEnd() 10264 }) 10265 }, 10266 _animationAddLayer: function(layer, newCluster) { 10267 var me = this, 10268 fg = this._featureGroup; 10269 fg.addLayer(layer); 10270 if (newCluster !== layer) { 10271 if (newCluster._childCount > 2) { 10272 newCluster._updateIcon(); 10273 this._forceLayout(); 10274 this._animationStart(); 10275 layer._setPos(this._map.latLngToLayerPoint(newCluster.getLatLng())); 10276 layer.setOpacity(0); 10277 this._enqueue(function() { 10278 fg.removeLayer(layer); 10279 layer.setOpacity(1); 10280 me._animationEnd() 10281 }) 10282 } else { 10283 this._forceLayout(); 10284 me._animationStart(); 10285 me._animationZoomOutSingle(newCluster, this._map.getMaxZoom(), this._map.getZoom()) 10286 } 10287 } 10288 }, 10289 _forceLayout: function() { 10290 L.Util.falseFn(document.body.offsetWidth) 10291 } 10292}); 10293L.markerClusterGroup = function(options) { 10294 return new L.MarkerClusterGroup(options) 10295}; 10296L.MarkerCluster = L.Marker.extend({ 10297 initialize: function(group, zoom, a, b) { 10298 L.Marker.prototype.initialize.call(this, a ? (a._cLatLng || a.getLatLng()) : new L.LatLng(0, 0), { 10299 icon: this 10300 }); 10301 this._group = group; 10302 this._zoom = zoom; 10303 this._markers = []; 10304 this._childClusters = []; 10305 this._childCount = 0; 10306 this._iconNeedsUpdate = true; 10307 this._bounds = new L.LatLngBounds(); 10308 if (a) { 10309 this._addChild(a) 10310 } 10311 if (b) { 10312 this._addChild(b) 10313 } 10314 }, 10315 getAllChildMarkers: function(storageArray) { 10316 storageArray = storageArray || []; 10317 for (var i = this._childClusters.length - 1; i >= 0; i--) { 10318 this._childClusters[i].getAllChildMarkers(storageArray) 10319 } 10320 for (var j = this._markers.length - 1; j >= 0; j--) { 10321 storageArray.push(this._markers[j]) 10322 } 10323 return storageArray 10324 }, 10325 getChildCount: function() { 10326 return this._childCount 10327 }, 10328 zoomToBounds: function() { 10329 var childClusters = this._childClusters.slice(), 10330 map = this._group._map, 10331 boundsZoom = map.getBoundsZoom(this._bounds), 10332 zoom = this._zoom + 1, 10333 mapZoom = map.getZoom(), 10334 i; 10335 while (childClusters.length > 0 && boundsZoom > zoom) { 10336 zoom++; 10337 var newClusters = []; 10338 for (i = 0; i < childClusters.length; i++) { 10339 newClusters = newClusters.concat(childClusters[i]._childClusters) 10340 } 10341 childClusters = newClusters 10342 } 10343 if (boundsZoom > zoom) {
10344 this._group._map.setView(this._latlng, zoom) 10345 } else if (boundsZoom <= mapZoom) { 10346 this._group._map.setView(this._latlng, mapZoom + 1) 10347 } else { 10348 this._group._map.fitBounds(this._bounds) 10349 } 10350 }, 10351 getBounds: function() { 10352 var bounds = new L.LatLngBounds(); 10353 bounds.extend(this._bounds); 10354 return bounds 10355 }, 10356 _updateIcon: function() { 10357 this._iconNeedsUpdate = true; 10358 if (this._icon) { 10359 this.setIcon(this) 10360 } 10361 }, 10362 createIcon: function() { 10363 if (this._iconNeedsUpdate) { 10364 this._iconObj = this._group.options.iconCreateFunction(this); 10365 this._iconNeedsUpdate = false 10366 } 10367 return this._iconObj.createIcon() 10368 }, 10369 createShadow: function() { 10370 return this._iconObj.createShadow() 10371 }, 10372 _addChild: function(new1, isNotificationFromChild) { 10373 this._iconNeedsUpdate = true; 10374 this._expandBounds(new1); 10375 if (new1 instanceof L.MarkerCluster) { 10376 if (!isNotificationFromChild) { 10377 this._childClusters.push(new1); 10378 new1.__parent = this 10379 } 10380 this._childCount += new1._childCount 10381 } else { 10382 if (!isNotificationFromChild) { 10383 this._markers.push(new1) 10384 } 10385 this._childCount++ 10386 } 10387 if (this.__parent) { 10388 this.__parent._addChild(new1, true) 10389 } 10390 }, 10391 _expandBounds: function(marker) { 10392 var addedCount, addedLatLng = marker._wLatLng || marker._latlng; 10393 if (marker instanceof L.MarkerCluster) { 10394 this._bounds.extend(marker._bounds); 10395 addedCount = marker._childCount 10396 } else { 10397 this._bounds.extend(addedLatLng); 10398 addedCount = 1 10399 } 10400 if (!this._cLatLng) { 10401 this._cLatLng = marker._cLatLng || addedLatLng 10402 } 10403 var totalCount = this._childCount + addedCount; 10404 if (!this._wLatLng) { 10405 this._latlng = this._wLatLng = new L.LatLng(addedLatLng.lat, addedLatLng.lng) 10406 } else { 10407 this._wLatLng.lat = (addedLatLng.lat * addedCount + this._wLatLng.lat * this._childCount) / totalCount; 10408 this._wLatLng.lng = (addedLatLng.lng * addedCount + this._wLatLng.lng * this._childCount) / totalCount 10409 } 10410 }, 10411 _addToMap: function(startPos) { 10412 if (startPos) { 10413 this._backupLatlng = this._latlng; 10414 this.setLatLng(startPos) 10415 } 10416 this._group._featureGroup.addLayer(this) 10417 }, 10418 _recursivelyAnimateChildrenIn: function(bounds, center, maxZoom) { 10419 this._recursively(bounds, 0, maxZoom - 1, function(c) { 10420 var markers = c._markers, 10421 i, m; 10422 for (i = markers.length - 1; i >= 0; i--) { 10423 m = markers[i]; 10424 if (m._icon) { 10425 m._setPos(center); 10426 m.setOpacity(0) 10427 } 10428 } 10429 }, function(c) { 10430 var childClusters = c._childClusters, 10431 j, cm; 10432 for (j = childClusters.length - 1; j >= 0; j--) { 10433 cm = childClusters[j]; 10434 if (cm._icon) { 10435 cm._setPos(center); 10436 cm.setOpacity(0) 10437 } 10438 } 10439 }) 10440 }, 10441 _recursivelyAnimateChildrenInAndAddSelfToMap: function(bounds, previousZoomLevel, newZoomLevel) { 10442 this._recursively(bounds, newZoomLevel, 0, function(c) { 10443 c._recursivelyAnimateChildrenIn(bounds, c._group._map.latLngToLayerPoint(c.getLatLng()).round(), previousZoomLevel); 10444 if (c._isSingleParent() && previousZoomLevel - 1 === newZoomLevel) { 10445 c.setOpacity(1); 10446 c._recursivelyRemoveChildrenFromMap(bounds, previousZoomLevel) 10447 } else { 10448 c.setOpacity(0) 10449 } 10450 c._addToMap() 10451 }) 10452 }, 10453 _recursivelyBecomeVisible: function(bounds, zoomLevel) { 10454 this._recursively(bounds, 0, zoomLevel, null, function(c) { 10455 c.setOpacity(1) 10456 }) 10457 }, 10458 _recursivelyAddChildrenToMap: function(startPos, zoomLevel, bounds) { 10459 this._recursively(bounds, -1, zoomLevel, function(c) { 10460 if (zoomLevel === c._zoom) { 10461 return 10462 } 10463 for (var i = c._markers.length - 1; i >= 0; i--) { 10464 var nm = c._markers[i]; 10465 if (!bounds.contains(nm._latlng)) { 10466 continue 10467 } 10468 if (startPos) { 10469 nm._backupLatlng = nm.getLatLng(); 10470 nm.setLatLng(startPos); 10471 if (nm.setOpacity) { 10472 nm.setOpacity(0) 10473 } 10474 } 10475 c._group._featureGroup.addLayer(nm) 10476 } 10477 }, function(c) { 10478 c._addToMap(startPos) 10479 }) 10480 }, 10481 _recursivelyRestoreChildPositions: function(zoomLevel) { 10482 for (var i = this._markers.length - 1; i >= 0; i--) { 10483 var nm = this._markers[i];
10484 if (nm._backupLatlng) { 10485 nm.setLatLng(nm._backupLatlng); 10486 delete nm._backupLatlng 10487 } 10488 } 10489 if (zoomLevel - 1 === this._zoom) { 10490 for (var j = this._childClusters.length - 1; j >= 0; j--) { 10491 this._childClusters[j]._restorePosition() 10492 } 10493 } else { 10494 for (var k = this._childClusters.length - 1; k >= 0; k--) { 10495 this._childClusters[k]._recursivelyRestoreChildPositions(zoomLevel) 10496 } 10497 } 10498 }, 10499 _restorePosition: function() { 10500 if (this._backupLatlng) { 10501 this.setLatLng(this._backupLatlng); 10502 delete this._backupLatlng 10503 } 10504 }, 10505 _recursivelyRemoveChildrenFromMap: function(previousBounds, zoomLevel, exceptBounds) { 10506 var m, i; 10507 this._recursively(previousBounds, -1, zoomLevel - 1, function(c) { 10508 for (i = c._markers.length - 1; i >= 0; i--) { 10509 m = c._markers[i]; 10510 if (!exceptBounds || !exceptBounds.contains(m._latlng)) { 10511 c._group._featureGroup.removeLayer(m); 10512 if (m.setOpacity) { 10513 m.setOpacity(1) 10514 } 10515 } 10516 } 10517 }, function(c) { 10518 for (i = c._childClusters.length - 1; i >= 0; i--) { 10519 m = c._childClusters[i]; 10520 if (!exceptBounds || !exceptBounds.contains(m._latlng)) { 10521 c._group._featureGroup.removeLayer(m); 10522 if (m.setOpacity) { 10523 m.setOpacity(1) 10524 } 10525 } 10526 } 10527 }) 10528 }, 10529 _recursively: function(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel) { 10530 var childClusters = this._childClusters, 10531 zoom = this._zoom, 10532 i, c; 10533 if (zoomLevelToStart > zoom) { 10534 for (i = childClusters.length - 1; i >= 0; i--) { 10535 c = childClusters[i]; 10536 if (boundsToApplyTo.intersects(c._bounds)) { 10537 c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel) 10538 } 10539 } 10540 } else { 10541 if (runAtEveryLevel) { 10542 runAtEveryLevel(this) 10543 } 10544 if (runAtBottomLevel && this._zoom === zoomLevelToStop) { 10545 runAtBottomLevel(this) 10546 } 10547 if (zoomLevelToStop > zoom) { 10548 for (i = childClusters.length - 1; i >= 0; i--) { 10549 c = childClusters[i]; 10550 if (boundsToApplyTo.intersects(c._bounds)) { 10551 c._recursively(boundsToApplyTo, zoomLevelToStart, zoomLevelToStop, runAtEveryLevel, runAtBottomLevel) 10552 } 10553 } 10554 } 10555 } 10556 }, 10557 _recalculateBounds: function() { 10558 var markers = this._markers, 10559 childClusters = this._childClusters, 10560 i; 10561 this._bounds = new L.LatLngBounds(); 10562 delete this._wLatLng; 10563 for (i = markers.length - 1; i >= 0; i--) { 10564 this._expandBounds(markers[i]) 10565 } 10566 for (i = childClusters.length - 1; i >= 0; i--) { 10567 this._expandBounds(childClusters[i]) 10568 } 10569 }, 10570 _isSingleParent: function() { 10571 return this._childClusters.length > 0 && this._childClusters[0]._childCount === this._childCount 10572 } 10573}); 10574L.MarkerCluster.include({ 10575 _2PI: Math.PI * 2, 10576 _circleFootSeparation: 25, 10577 _circleStartAngle: Math.PI / 6, 10578 _spiralFootSeparation: 28, 10579 _spiralLengthStart: 11, 10580 _spiralLengthFactor: 5, 10581 _circleSpiralSwitchover: 9, 10582 spiderfy: function() { 10583 if (this._group._spiderfied === this || this._group._inZoomAnimation) { 10584 return 10585 } 10586 var childMarkers = this.getAllChildMarkers(), 10587 group = this._group, 10588 map = group._map, 10589 center = map.latLngToLayerPoint(this._latlng), 10590 positions; 10591 this._group._unspiderfy(); 10592 this._group._spiderfied = this; 10593 if (childMarkers.length >= this._circleSpiralSwitchover) { 10594 positions = this._generatePointsSpiral(childMarkers.length, center) 10595 } else { 10596 center.y += 10; 10597 positions = this._generatePointsCircle(childMarkers.length, center) 10598 } 10599 this._animationSpiderfy(childMarkers, positions) 10600 }, 10601 unspiderfy: function(zoomDetails) { 10602 if (this._group._inZoomAnimation) { 10603 return 10604 } 10605 this._animationUnspiderfy(zoomDetails); 10606 this._group._spiderfied = null 10607 }, 10608 _generatePointsCircle: function(count, centerPt) { 10609 var circumference = this._group.options.spiderfyDistanceMultiplier * this._circleFootSeparation * (2 + count),
10610 legLength = circumference / this._2PI, 10611 angleStep = this._2PI / count, 10612 res = [], 10613 i, angle; 10614 res.length = count; 10615 for (i = count - 1; i >= 0; i--) { 10616 angle = this._circleStartAngle + i * angleStep; 10617 res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round() 10618 } 10619 return res 10620 }, 10621 _generatePointsSpiral: function(count, centerPt) { 10622 var legLength = this._group.options.spiderfyDistanceMultiplier * this._spiralLengthStart, 10623 separation = this._group.options.spiderfyDistanceMultiplier * this._spiralFootSeparation, 10624 lengthFactor = this._group.options.spiderfyDistanceMultiplier * this._spiralLengthFactor, 10625 angle = 0, 10626 res = [], 10627 i; 10628 res.length = count; 10629 for (i = count - 1; i >= 0; i--) { 10630 angle += separation / legLength + i * 0.0005; 10631 res[i] = new L.Point(centerPt.x + legLength * Math.cos(angle), centerPt.y + legLength * Math.sin(angle))._round(); 10632 legLength += this._2PI * lengthFactor / angle 10633 } 10634 return res 10635 }, 10636 _noanimationUnspiderfy: function() { 10637 var group = this._group, 10638 map = group._map, 10639 fg = group._featureGroup, 10640 childMarkers = this.getAllChildMarkers(), 10641 m, i; 10642 this.setOpacity(1); 10643 for (i = childMarkers.length - 1; i >= 0; i--) { 10644 m = childMarkers[i]; 10645 fg.removeLayer(m); 10646 if (m._preSpiderfyLatlng) { 10647 m.setLatLng(m._preSpiderfyLatlng); 10648 delete m._preSpiderfyLatlng 10649 } 10650 if (m.setZIndexOffset) { 10651 m.setZIndexOffset(0) 10652 } 10653 if (m._spiderLeg) { 10654 map.removeLayer(m._spiderLeg); 10655 delete m._spiderLeg 10656 } 10657 } 10658 group._spiderfied = null 10659 } 10660}); 10661L.MarkerCluster.include(!L.DomUtil.TRANSITION ? { 10662 _animationSpiderfy: function(childMarkers, positions) { 10663 var group = this._group, 10664 map = group._map, 10665 fg = group._featureGroup, 10666 i, m, leg, newPos; 10667 for (i = childMarkers.length - 1; i >= 0; i--) { 10668 newPos = map.layerPointToLatLng(positions[i]); 10669 m = childMarkers[i]; 10670 m._preSpiderfyLatlng = m._latlng; 10671 m.setLatLng(newPos); 10672 if (m.setZIndexOffset) { 10673 m.setZIndexOffset(1000000) 10674 } 10675 fg.addLayer(m); 10676 leg = new L.Polyline([this._latlng, newPos], { 10677 weight: 1.5, 10678 color: '#222' 10679 }); 10680 map.addLayer(leg); 10681 m._spiderLeg = leg 10682 } 10683 this.setOpacity(0.3); 10684 group.fire('spiderfied') 10685 }, 10686 _animationUnspiderfy: function() { 10687 this._noanimationUnspiderfy() 10688 } 10689} : { 10690 SVG_ANIMATION: (function() { 10691 return document.createElementNS('http://www.w3.org/2000/svg', 'animate').toString().indexOf('SVGAnimate') > -1 10692 }()), 10693 _animationSpiderfy: function(childMarkers, positions) { 10694 var me = this, 10695 group = this._group, 10696 map = group._map, 10697 fg = group._featureGroup, 10698 thisLayerPos = map.latLngToLayerPoint(this._latlng), 10699 i, m, leg, newPos; 10700 for (i = childMarkers.length - 1; i >= 0; i--) { 10701 m = childMarkers[i]; 10702 if (m.setOpacity) { 10703 m.setZIndexOffset(1000000); 10704 m.setOpacity(0); 10705 fg.addLayer(m); 10706 m._setPos(thisLayerPos) 10707 } else { 10708 fg.addLayer(m) 10709 } 10710 } 10711 group._forceLayout(); 10712 group._animationStart(); 10713 var initialLegOpacity = L.Path.SVG ? 0 : 0.3, 10714 xmlns = L.Path.SVG_NS; 10715 for (i = childMarkers.length - 1; i >= 0; i--) { 10716 newPos = map.layerPointToLatLng(positions[i]); 10717 m = childMarkers[i]; 10718 m._preSpiderfyLatlng = m._latlng; 10719 m.setLatLng(newPos); 10720 if (m.setOpacity) { 10721 m.setOpacity(1) 10722 } 10723 leg = new L.Polyline([me._latlng, newPos], { 10724 weight: 1.5, 10725 color: '#222', 10726 opacity: initialLegOpacity 10727 }); 10728 map.addLayer(leg); 10729 m._spiderLeg = leg; 10730 if (!L.Path.SVG || !this.SVG_ANIMATION) { 10731 continue 10732 } 10733 var length = leg._path.getTotalLength(); 10734 leg._path.setAttribute("stroke-dasharray", length + "," + length); 10735 var anim = document.createElementNS(xmlns, "animate"); 10736 anim.setAttribute("attributeName", "stroke-dashoffset"); 10737 anim.setAttribute("begin", "indefinite"); 10738 anim.setAttribute("from", length); 10739 anim.setAttribute("to", 0); 10740 anim.setAttribute("dur", 0.25); 10741 leg._path.appendChild(anim); 10742 anim.beginElement(); 10743 anim = document.createElementNS(xmlns, "animate"); 10744 anim.setAttribute("attributeName", "stroke-opacity"); 10745 anim.setAttribute("attributeName", "stroke-opacity"); 10746 anim.setAttribute("begin", "indefinite"); 10747 anim.setAttribute("from", 0); 10748 anim.setAttribute("to", 0.5); 10749 anim.setAttribute("dur", 0.25); 10750 leg._path.appendChild(anim); 10751 anim.beginElement() 10752 } 10753 me.setOpacity(0.3); 10754 if (L.Path.SVG) { 10755 this._group._forceLayout(); 10756 for (i = childMarkers.length - 1; i >= 0; i--) { 10757 m = childMarkers[i]._spiderLeg; 10758 m.options.opacity = 0.5; 10759 m._path.setAttribute('stroke-opacity', 0.5) 10760 } 10761 } 10762 setTimeout(function() { 10763 group._animationEnd(); 10764 group.fire('spiderfied') 10765 }, 200) 10766 }, 10767 _animationUnspiderfy: function(zoomDetails) { 10768 var group = this._group, 10769 map = group._map, 10770 fg = group._featureGroup, 10771 thisLayerPos = zoomDetails ? map._latLngToNewLayerPoint(this._latlng, zoomDetails.zoom, zoomDetails.center) : map.latLngToLayerPoint(this._latlng), 10772 childMarkers = this.getAllChildMarkers(), 10773 svg = L.Path.SVG && this.SVG_ANIMATION, 10774 m, i, a; 10775 group._animationStart(); 10776 this.setOpacity(1); 10777 for (i = childMarkers.length - 1; i >= 0; i--) { 10778 m = childMarkers[i];
10779 if (!m._preSpiderfyLatlng) { 10780 continue 10781 } 10782 m.setLatLng(m._preSpiderfyLatlng); 10783 delete m._preSpiderfyLatlng; 10784 if (m.setOpacity) { 10785 m._setPos(thisLayerPos); 10786 m.setOpacity(0) 10787 } else { 10788 fg.removeLayer(m) 10789 } 10790 if (svg) { 10791 a = m._spiderLeg._path.childNodes[0]; 10792 a.setAttribute('to', a.getAttribute('from')); 10793 a.setAttribute('from', 0); 10794 a.beginElement(); 10795 a = m._spiderLeg._path.childNodes[1]; 10796 a.setAttribute('from', 0.5); 10797 a.setAttribute('to', 0); 10798 a.setAttribute('stroke-opacity', 0); 10799 a.beginElement(); 10800 m._spiderLeg._path.setAttribute('stroke-opacity', 0) 10801 } 10802 } 10803 setTimeout(function() { 10804 var stillThereChildCount = 0; 10805 for (i = childMarkers.length - 1; i >= 0; i--) { 10806 m = childMarkers[i]; 10807 if (m._spiderLeg) { 10808 stillThereChildCount++ 10809 } 10810 } 10811 for (i = childMarkers.length - 1; i >= 0; i--) { 10812 m = childMarkers[i]; 10813 if (!m._spiderLeg) { 10814 continue 10815 } 10816 if (m.setOpacity) { 10817 m.setOpacity(1); 10818 m.setZIndexOffset(0) 10819 } 10820 if (stillThereChildCount > 1) { 10821 fg.removeLayer(m) 10822 } 10823 map.removeLayer(m._spiderLeg); 10824 delete m._spiderLeg 10825 } 10826 group._animationEnd() 10827 }, 200) 10828 } 10829}); 10830L.MarkerClusterGroup.include({ 10831 _spiderfied: null, 10832 _spiderfierOnAdd: function() { 10833 this._map.on('click', this._unspiderfyWrapper, this); 10834 if (this._map.options.zoomAnimation) { 10835 this._map.on('zoomstart', this._unspiderfyZoomStart, this) 10836 } 10837 this._map.on('zoomend', this._noanimationUnspiderfy, this); 10838 if (L.Path.SVG && !L.Browser.touch) { 10839 this._map._initPathRoot() 10840 } 10841 }, 10842 _spiderfierOnRemove: function() { 10843 this._map.off('click', this._unspiderfyWrapper, this); 10844 this._map.off('zoomstart', this._unspiderfyZoomStart, this); 10845 this._map.off('zoomanim', this._unspiderfyZoomAnim, this); 10846 this._unspiderfy() 10847 }, 10848 _unspiderfyZoomStart: function() { 10849 if (!this._map) { 10850 return 10851 } 10852 this._map.on('zoomanim', this._unspiderfyZoomAnim, this) 10853 }, 10854 _unspiderfyZoomAnim: function(zoomDetails) { 10855 if (L.DomUtil.hasClass(this._map._mapPane, 'leaflet-touching')) { 10856 return 10857 } 10858 this._map.off('zoomanim', this._unspiderfyZoomAnim, this); 10859 this._unspiderfy(zoomDetails) 10860 }, 10861 _unspiderfyWrapper: function() { 10862 this._unspiderfy() 10863 }, 10864 _unspiderfy: function(zoomDetails) { 10865 if (this._spiderfied) { 10866 this._spiderfied.unspiderfy(zoomDetails) 10867 } 10868 }, 10869 _noanimationUnspiderfy: function() { 10870 if (this._spiderfied) { 10871 this._spiderfied._noanimationUnspiderfy() 10872 } 10873 }, 10874 _unspiderfyLayer: function(layer) { 10875 if (layer._spiderLeg) { 10876 this._featureGroup.removeLayer(layer); 10877 layer.setOpacity(1); 10878 layer.setZIndexOffset(0); 10879 this._map.removeLayer(layer._spiderLeg); 10880 delete layer._spiderLeg 10881 } 10882 } 10883}); 10884(function() { 10885 L.QuickHull = { 10886 getDistant: function(cpt, bl) { 10887 var vY = bl[1].lat - bl[0].lat, 10888 vX = bl[0].lng - bl[1].lng; 10889 return (vX * (cpt.lat - bl[0].lat) + vY * (cpt.lng - bl[0].lng)) 10890 }, 10891 findMostDistantPointFromBaseLine: function(baseLine, latLngs) { 10892 var maxD = 0, 10893 maxPt = null, 10894 newPoints = [], 10895 i, pt, d; 10896 for (i = latLngs.length - 1; i >= 0; i--) { 10897 pt = latLngs[i]; 10898 d = this.getDistant(pt, baseLine); 10899 if (d > 0) { 10900 newPoints.push(pt) 10901 } else { 10902 continue 10903 } 10904 if (d > maxD) { 10905 maxD = d; 10906 maxPt = pt 10907 } 10908 } 10909 return { 10910 maxPoint: maxPt, 10911 newPoints: newPoints 10912 } 10913 }, 10914 buildConvexHull: function(baseLine, latLngs) { 10915 var convexHullBaseLines = [], 10916 t = this.findMostDistantPointFromBaseLine(baseLine, latLngs); 10917 if (t.maxPoint) { 10918 convexHullBaseLines = convexHullBaseLines.concat(this.buildConvexHull([baseLine[0], t.maxPoint], t.newPoints)); 10919 convexHullBaseLines = convexHullBaseLines.concat(this.buildConvexHull([t.maxPoint, baseLine[1]], t.newPoints)); 10920 return convexHullBaseLines 10921 } else { 10922 return [baseLine[0]] 10923 } 10924 }, 10925 getConvexHull: function(latLngs) { 10926 var maxLat = false, 10927 minLat = false, 10928 maxPt = null, 10929 minPt = null, 10930 i; 10931 for (i = latLngs.length - 1; i >= 0; i--) { 10932 var pt = latLngs[i]; 10933 if (maxLat === false || pt.lat > maxLat) { 10934 maxPt = pt; 10935 maxLat = pt.lat 10936 } 10937 if (minLat === false || pt.lat < minLat) { 10938 minPt = pt; 10939 minLat = pt.lat 10940 } 10941 } 10942 var ch = [].concat(this.buildConvexHull([minPt, maxPt], latLngs), this.buildConvexHull([maxPt, minPt], latLngs)); 10943 return ch 10944 } 10945 } 10946}()); 10947L.MarkerCluster.include({ 10948 getConvexHull: function() { 10949 var childMarkers = this.getAllChildMarkers(), 10950 points = [], 10951 p, i; 10952 for (i = childMarkers.length - 1; i >= 0; i--) { 10953 p = childMarkers[i].getLatLng(); 10954 points.push(p) 10955 } 10956 return L.QuickHull.getConvexHull(points) 10957 } 10958}); 10959L.Label = L.Class.extend({ 10960 includes: L.Mixin.Events, 10961 options: { 10962 className: '', 10963 clickable: false, 10964 direction: 'right', 10965 noHide: false, 10966 offset: [12, -15], 10967 opacity: 1, 10968 zoomAnimation: true 10969 }, 10970 initialize: function(options, source) { 10971 L.setOptions(this, options); 10972 this._source = source; 10973 this._animated = L.Browser.any3d && this.options.zoomAnimation; 10974 this._isOpen = false 10975 }, 10976 onAdd: function(map) { 10977 this._map = map; 10978 this._pane = this._source instanceof L.Marker ? map._panes.markerPane : map._panes.popupPane; 10979 if (!this._container) { 10980 this._initLayout() 10981 } 10982 this._pane.appendChild(this._container); 10983 this._initInteraction(); 10984 this._update(); 10985 this.setOpacity(this.options.opacity); 10986 map.on('moveend', this._onMoveEnd, this).on('viewreset', this._onViewReset, this); 10987 if (this._animated) { 10988 map.on('zoomanim', this._zoomAnimation, this) 10989 } 10990 if (L.Browser.touch && !this.options.noHide) { 10991 L.DomEvent.on(this._container, 'click', this.close, this) 10992 } 10993 }, 10994 onRemove: function(map) { 10995 this._pane.removeChild(this._container); 10996 map.off({ 10997 zoomanim: this._zoomAnimation, 10998 moveend: this._onMoveEnd, 10999 viewreset: this._onViewReset 11000 }, this); 11001 this._removeInteraction(); 11002 this._map = null 11003 }, 11004 setLatLng: function(latlng) { 11005 this._latlng = L.latLng(latlng); 11006 if (this._map) { 11007 this._updatePosition() 11008 } 11009 return this 11010 }, 11011 setContent: function(content) { 11012 this._previousContent = this._content; 11013 this._content = content; 11014 this._updateContent(); 11015 return this 11016 }, 11017 close: function() { 11018 var map = this._map; 11019 if (map) { 11020 if (L.Browser.touch && !this.options.noHide) { 11021 L.DomEvent.off(this._container, 'click', this.close) 11022 } 11023 map.removeLayer(this) 11024 } 11025 }, 11026 updateZIndex: function(zIndex) { 11027 this._zIndex = zIndex; 11028 if (this._container && this._zIndex) { 11029 this._container.style.zIndex = zIndex 11030 } 11031 }, 11032 setOpacity: function(opacity) { 11033 this.options.opacity = opacity; 11034 if (this._container) { 11035 L.DomUtil.setOpacity(this._container, opacity) 11036 } 11037 }, 11038 _initLayout: function() { 11039 this._container = L.DomUtil.create('div', 'leaflet-label-empty ' + this.options.className + ' leaflet-zoom-animated'); 11040 this.updateZIndex(this._zIndex) 11041 }, 11042 _update: function() { 11043 if (!this._map) { 11044 return 11045 } 11046 this._container.style.visibility = 'hidden'; 11047 this._updateContent(); 11048 this._updatePosition(); 11049 this._container.style.visibility = '' 11050 }, 11051 _updateContent: function() { 11052 if (!this._content || !this._map || this._prevContent === this._content) { 11053 return 11054 } 11055 if (typeof this._content === 'string') { 11056 this._container.innerHTML = this._content; 11057 this._prevContent = this._content; 11058 this._labelWidth = this._container.offsetWidth 11059 } 11060 }, 11061 _updatePosition: function() { 11062 var pos = this._map.latLngToLayerPoint(this._latlng); 11063 this._setPosition(pos) 11064 }, 11065 _setPosition: function(pos) { 11066 var map = this._map, 11067 container = this._container, 11068 centerPoint = map.latLngToContainerPoint(map.getCenter()), 11069 labelPoint = map.layerPointToContainerPoint(pos), 11070 direction = this.options.direction, 11071 labelWidth = this._labelWidth, 11072 offset = L.point(this.options.offset); 11073 if (direction === 'right' || direction === 'auto' && labelPoint.x < centerPoint.x) { 11074 L.DomUtil.addClass(container, 'leaflet-label-right'); 11075 L.DomUtil.removeClass(container, 'leaflet-label-left'); 11076 pos = pos.add(offset) 11077 } else { 11078 L.DomUtil.addClass(container, 'leaflet-label-left'); 11079 L.DomUtil.removeClass(container, 'leaflet-label-right'); 11080 pos = pos.add(L.point(-offset.x - labelWidth, offset.y)) 11081 } 11082 L.DomUtil.setPosition(container, pos) 11083 }, 11084 _zoomAnimation: function(opt) { 11085 var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round(); 11086 this._setPosition(pos) 11087 }, 11088 _onMoveEnd: function() { 11089 if (!this._animated || this.options.direction === 'auto') { 11090 this._updatePosition() 11091 } 11092 }, 11093 _onViewReset: function(e) { 11094 if (e && e.hard) { 11095 this._update() 11096 } 11097 }, 11098 _initInteraction: function() { 11099 if (!this.options.clickable) { 11100 return 11101 } 11102 var container = this._container, 11103 events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu']; 11104 L.DomUtil.addClass(container, 'leaflet-clickable'); 11105 L.DomEvent.on(container, 'click', this._onMouseClick, this); 11106 for (var i = 0; i < events.length; i++) { 11107 L.DomEvent.on(container, events[i], this._fireMouseEvent, this) 11108 } 11109 }, 11110 _removeInteraction: function() { 11111 if (!this.options.clickable) { 11112 return 11113 } 11114 var container = this._container, 11115 events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu']; 11116 L.DomUtil.removeClass(container, 'leaflet-clickable'); 11117 L.DomEvent.off(container, 'click', this._onMouseClick, this); 11118 for (var i = 0; i < events.length; i++) { 11119 L.DomEvent.off(container, events[i], this._fireMouseEvent, this) 11120 } 11121 }, 11122 _onMouseClick: function(e) { 11123 if (this.hasEventListeners(e.type)) { 11124 L.DomEvent.stopPropagation(e) 11125 } 11126 this.fire(e.type, { 11127 originalEvent: e 11128 }) 11129 }, 11130 _fireMouseEvent: function(e) { 11131 this.fire(e.type, { 11132 originalEvent: e 11133 });
11134 if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) { 11135 L.DomEvent.preventDefault(e) 11136 } 11137 if (e.type !== 'mousedown') { 11138 L.DomEvent.stopPropagation(e) 11139 } else { 11140 L.DomEvent.preventDefault(e) 11141 } 11142 } 11143}); 11144L.FeatureGroup.include({ 11145 clearLayers: function() { 11146 this.unbindLabel(); 11147 this.eachLayer(this.removeLayer, this); 11148 return this 11149 }, 11150 bindLabel: function(content, options) { 11151 return this.invoke('bindLabel', content, options) 11152 }, 11153 unbindLabel: function() { 11154 return this.invoke('unbindLabel') 11155 }, 11156 updateLabelContent: function(content) { 11157 this.invoke('updateLabelContent', content) 11158 } 11159}); 11160L.Map.include({ 11161 showLabel: function(label) { 11162 this._label = label; 11163 return this.addLayer(label) 11164 } 11165}); 11166L.Path.include({ 11167 bindLabel: function(content, options) { 11168 if (!this.label || this.label.options !== options) { 11169 this.label = new L.Label(options, this) 11170 } 11171 this.label.setContent(content); 11172 if (!this._showLabelAdded) { 11173 this.on('mouseover', this._showLabel, this).on('mousemove', this._moveLabel, this).on('mouseout remove', this._hideLabel, this); 11174 if (L.Browser.touch) { 11175 this.on('click', this._showLabel, this) 11176 } 11177 this._showLabelAdded = true 11178 } 11179 return this 11180 }, 11181 unbindLabel: function() { 11182 if (this.label) { 11183 this._hideLabel(); 11184 this.label = null; 11185 this._showLabelAdded = false; 11186 this.off('mouseover', this._showLabel, this).off('mousemove', this._moveLabel, this).off('mouseout remove', this._hideLabel, this) 11187 } 11188 return this 11189 }, 11190 updateLabelContent: function(content) { 11191 if (this.label) { 11192 this.label.setContent(content) 11193 } 11194 }, 11195 _showLabel: function(e) { 11196 this.label.setLatLng(e.latlng); 11197 this._map.showLabel(this.label) 11198 }, 11199 _moveLabel: function(e) { 11200 this.label.setLatLng(e.latlng) 11201 }, 11202 _hideLabel: function() { 11203 this.label.close() 11204 }, 11205 showLabel: function() { 11206 if (this._label && this._map) { 11207 this._label.setLatLng(this._latlngs[0]); 11208 this._map.showLabel(this._label) 11209 } 11210 return this 11211 } 11212}); 11213E.Polygon.prototype.addHook('onAdd', function() { 11214 if ((this._label) && (this._label.options.noHide)) this.showLabel() 11215}); 11216E.Polyline.prototype.addHook('onAdd', function() { 11217 if ((this._label) && (this._label.options.noHide)) this.showLabel() 11218}); 11219L.Icon.Default.mergeOptions({ 11220 labelAnchor: new L.Point(9, -20) 11221}); 11222L.Marker.mergeOptions({ 11223 icon: new L.Icon.Default() 11224}); 11225L.Marker.include(L.BaseMarkerMethods); 11226E.Marker.include({ 11227 _originalUpdateZIndex: L.Marker.prototype._updateZIndex, 11228 _updateZIndex: function(offset) { 11229 var zIndex = this._zIndex + offset; 11230 this._originalUpdateZIndex(offset); 11231 if (this.label) { 11232 this.label.updateZIndex(zIndex) 11233 } 11234 }, 11235 _originalSetOpacity: L.Marker.prototype.setOpacity, 11236 setOpacity: function(opacity, labelHasSemiTransparency) { 11237 this.options.labelHasSemiTransparency = labelHasSemiTransparency; 11238 this._originalSetOpacity(opacity) 11239 }, 11240 _originalUpdateOpacity: L.Marker.prototype._updateOpacity, 11241 _updateOpacity: function() { 11242 var absoluteOpacity = this.options.opacity === 0 ? 0 : 1; 11243 this._originalUpdateOpacity(); 11244 if (this.label) { 11245 this.label.setOpacity(this.options.labelHasSemiTransparency ? this.options.opacity : absoluteOpacity) 11246 } 11247 }, 11248 _originalSetLatLng: L.Marker.prototype.setLatLng, 11249 setLatLng: function(latlng) { 11250 if (this.label && !this._labelNoHide) { 11251 this.hideLabel() 11252 } 11253 return this._originalSetLatLng(latlng) 11254 } 11255}); 11256E.Marker.prototype.addHook('onAdd', function() { 11257 if ((this._label) && (this._label.options.noHide)) this.showLabel() 11258}); 11259E.Profile = L.Class.extend({ 11260 includes: L.Mixin.Events, 11261 _lC: null, 11262 _div: null, 11263 initialize: function(map) { 11264 this._map = map; 11265 this._lC = new E.Profile.LoginController(map, this); 11266 this._pW = new E.Profile.ProfileWindow(map, this, this._lC) 11267 }, 11268 login: function() { 11269 this._lC.login() 11270 }, 11271 showProfile: function() { 11272 this._pW.show() 11273 }, 11274 reportError: function(a) { 11275 this._pW.show(a) 11276 }, 11277 hide: function() { 11278 this._overlay.hide() 11279 }, 11280 isLogged: function() { 11281 return this._lC.isLogged() 11282 }, 11283 lC: function() { 11284 return this._lC 11285 } 11286}); 11287E.Map.addInitHook(function() { 11288 this.profile = new E.Profile(this) 11289}); 11290E.Profile.ReportErrorWindow = L.Class.extend({ 11291 _map: null, 11292 _layer: null, 11293 _parent: null, 11294 _user: '', 11295 _layer: null, 11296 initialize: function(map, pw, lc) { 11297 this._map = map; 11298 this._pw = pw; 11299 this._lc = lc; 11300 this._layer = new L.marker(L.LatLng(0, 0)) 11301 }, 11302 renderWindow: function(div, pos) { 11303 var html = '<form name="uwagi" id="RE_form" method="POST" action="https://szp.emapa.pl/PostError.aspx" target="_self" accept-charset="utf-8" enctype="multipart/form-data">' + '<p class="naglowek">' + E.lang('RE_NotifyError') + '</p><select id="uwagi" name="uwagi" class="reportErrorInput">'; 11304 for (var i = 0; i < 12; i++) html += '<option>' + E.lang('RE_Item_' + i) + '</option>'; 11305 html += '</select><input id="RE_X" name="x" type="hidden" value=""><input id="RE_Y" name="y" type="hidden" value=""><input name="tytul" id="RE_tytul" type="hidden" value="Blad ze strony internetowej">' + '<input name="uzytkownik" id="RE_uzytkownik" type="hidden" value=""><input name="pcompany" id="RE_pcompany" type="hidden"><input name="puser" id="puser" type="hidden"><p class="reportErrorInput">' + E.lang('RE_Describe') + '</p>
11305<textarea id="RE_komentarz" rows="5" name="komentarz" class="reportErrorInputTextArea"></textarea><input name="MAX_FILE_SIZE" value="5097152" type="hidden"><input name="error_file" type="file" class="reportErrorInput"><br>' + E.lang('RE_MAX_FILE_SIZE') + '<br><input name="NewSearch2" style="float:right" type="submit" id="RE_submit" value="' + E.lang('RE_Send') + '" class="reportErrorInput"><div style="clear:both"></div></form>'; 11306 div.text(html); 11307 E.$('RE_X').value(pos.lng); 11308 E.$('RE_Y').value(pos.lat); 11309 E.$('RE_uzytkownik').value(""); 11310 E.$('RE_pcompany').value(""); 11311 E.$('RE_submit').click(E.bind(this._onPreSubmitDone, this)); 11312 var form = E.$("RE_form").elem(); 11313 form.onsubmit = E.bind(this._onSubmitDone, { 11314 re: this, 11315 form: form 11316 }); 11317 this._layer.setLatLng(pos); 11318 this._map.addLayer(this._layer) 11319 }, 11320 hide: function() { 11321 this._map.removeLayer(this._layer) 11322 }, 11323 _onPreSubmitDone: function() { 11324 E.$('RE_uzytkownik').value(this._user); 11325 var lon = E.$('RE_X').value(), 11326 lat = E.$('RE_Y').value(); 11327 this._map.postError({ 11328 desc: E.$('RE_komentarz').value(), 11329 lon: E.$('RE_X').value(), 11330 lon: lon, 11331 lat: lat, 11332 user: this._user 11333 }); 11334 if (this._user.length > 0) try { 11335 var b = new Date(); 11336 var day = b.getDate() < 10 ? '0' + b.getDate() : b.getDate(); 11337 var month = (b.getMonth() + 1) < 10 ? '0' + (b.getMonth() + 1) : (b.getMonth() + 1); 11338 day = b.getFullYear() + '-' + month + '-' + day; 11339 this._lc.getService('ReportErrors').value.push({ 11340 description: E.$('RE_komentarz').value(), 11341 status: 0, 11342 release: '', 11343 submission_time: day, 11344 lon: lon, 11345 lat: lat 11346 }) 11347 } catch (e) {} 11348 return true 11349 }, 11350 _onSubmitDone: function(form) { 11351 if (!window.focus) return true; 11352 window.open('', 'join', 'height=200,width=600,location=0,menubar=0,status=0,toolbar=0,scrollbars=yes'); 11353 this.form.target = 'join'; 11354 setTimeout(E.bind(this.re._pw.hide, this.re._pw), 100); 11355 return true 11356 }, 11357 setUser: function(a) { 11358 this._user = a 11359 } 11360}); 11361E.Profile.LoginWindow = L.Class.extend({ 11362 _user: null, 11363 _pass: null, 11364 _warning: null, 11365 _imgClick: null, 11366 _overlay: null, 11367 _blocked: false, 11368 _onDoLogin: null, 11369 initialize: function(map, onDoLogin) { 11370 this._map = map; 11371 this._onDoLogin = onDoLogin; 11372 this.items = [] 11373 }, 11374 setBlockClick: function(block) { 11375 this.block = block; 11376 if (block) E.$('btn-login').att('disabled', block); 11377 else E.$('btn-login').delAtt('disabled') 11378 }, 11379 show: function() { 11380 this._overlay = new E.Overlay.Form(); 11381 this._overlay.showWindow(this.renderWindow()); 11382 E.$('btn-login').click(this._clickLogin, this); 11383 E.$('lw_close_window').click(E.bind(this.hide, this)); 11384 this._user = E.$('user_login'); 11385 this._pass = E.$('user_pass'); 11386 this._user.key(this._keyEvent, this); 11387 this._pass.key(this._keyEvent, this); 11388 this._warning = E.$('LoginWindow_warning'); 11389 this.setWarning = E.bind(this._warning.text, this._warning); 11390 try { 11391 this.inputUser.focus() 11392 } catch (e) {}; 11393 this._docked = false 11394 }, 11395 hide: function() { 11396 this._overlay.hide(); 11397 this._overlay = null 11398 }, 11399 renderWindow: function(div) { 11400 this._docked = true; 11401 this.items.length = 0; 11402 var ldiv = E.newElem("div"); 11403 ldiv.innerHTML = '<div class="login_window">' + ' <div class="close_window" id="lw_close_window"></div>' + ' <div class="content">' + ' <div class="LoginWindow_warning" id="LoginWindow_warning"> </div>' + ' <p>' + ' <label for="user_login">' + E.lang('LW_UserName') + '</label><br>' + ' <input name="log" class="mid" id="user_login" autocomplete="on" type="text">' + ' </p>' + ' <p>' + ' <label for="user_pass"></label>' + E.lang('LW_Pass') + '<br>' + ' <input name="pwd" class="mid" id="user_pass" autocomplete="on" type="password">' + ' </p>' + ' <p class="rememberme">' + ' <input name="rememberme" class="checkbox" id="rememberme" value="forever" type="checkbox"> ' + ' <label for="rememberme">' + E.lang('RememberMe') + '</label>' + ' </p>' + ' <p class="submit"><input type="submit" class="btn-login" id="btn-login" value="' + E.lang('LW_Login') + '"></p>' + ' <div class="account_params">' + ' <p><a href="http://auth.emapa.pl" rel="nofollow" target="_blank">' + E.lang('LW_Register') + '</a><br />' + ' <a href="https://auth.emapa.pl/RemindPassword.aspx" target="_blank" title="" rel="nofollow">' + E.lang('LW_ForgotPass') + '</a></p>
11403' + ' </div>' + ' </div>' + ' </div>'; 11404 if (div) div.append(ldiv); 11405 return ldiv 11406 }, 11407 _keyEvent: function(e) { 11408 if ((e.keyCode == 13) && (this._user.value() != "") && (this._pass.value() != "")) this._clickLogin() 11409 }, 11410 _clickLogin: function() { 11411 if (this._block) return; 11412 if (this._user.value().length == 0) { 11413 this.setWarning(E.lang('LW_UserEmpty')); 11414 return 11415 } 11416 if (this._pass.value().length == 0) { 11417 this.setWarning(E.lang('LW_PassEmpty')); 11418 return 11419 } 11420 this.setWarning(' '); 11421 this.setBlockClick(true); 11422 this._onDoLogin(this._user.value(), this._pass.value()) 11423 } 11424}); 11425E.Profile.ProfileWindow = L.Class.extend({ 11426 _anonymousTab: 're_report_error_form', 11427 _loginTab: 're_report_error_form', 11428 _reportTab: null, 11429 _headerTab: null, 11430 _lc: null, 11431 _mainTabItems: [], 11432 _itemsTabHeader: null, 11433 _itemsTab: null, 11434 _pos: null, 11435 _errorWindow: null, 11436 _marker: null, 11437 _isActive: false, 11438 initialize: function(map, pm, lc) { 11439 pm.on("onLogin", this._onLogin, this).on("onLogout", this.hide, this); 11440 this._lc = lc; 11441 this._map = map; 11442 this._errorWindow = new E.Profile.ReportErrorWindow(map, this, lc); 11443 this._marker = L.marker(); 11444 this._isActive = false 11445 }, 11446 show: function(pos) { 11447 var d; 11448 this._isActive = true; 11449 this._pos = pos; 11450 this._overlay = new E.Overlay.Form(); 11451 this._overlay.showWindow(d = this.renderWindow()); 11452 this._draggable = new L.Draggable(d = d.parentNode, E.$(d).getElem("re_belka").elem()).enable(); 11453 E.$("re_login").click(this._onLoginTab, this); 11454 E.$("re_report_anonymous").click(this._onAnonymousTab, this); 11455 E.$("re_close_window").click(this.hide, this); 11456 this._itemsTab = this._preareItems(["re_report_error_form", "re_reported_errors_form", "re_profile_form", "re_myto_form"]); 11457 this._mainTabItems = this._preareItems(["re_login", "re_report_anonymous"]); 11458 this._itemsTabHeader = this._preareItems(['re_myto', 're_profile', 're_reported_errors', 're_report_error'], true); 11459 for (var i = 0; i < this._itemsTabHeader.length; i++) this._itemsTabHeader[i].v.click(E.bind(this._loginTabClick, { 11460 pm: this, 11461 elem: this._itemsTabHeader[i].n 11462 })); 11463 this._headerTab = E.$("re_content_data_header"); 11464 this._onAnonymousTab(); 11465 this._processReportError(); 11466 this._onLogin(); 11467 this._overlay.updatePosition(); 11468 d = E.$(d).pos(0, 0); 11469 var w = E.windowSize(), 11470 e = d.size(); 11471 E.setPos(d.elem(), new L.Point(parseInt(((w[0] - e[0]) / 2)), parseInt(((w[1] - e[1]) / 2)))); 11472 this._overlay.activateDrag(E.$('re_belka')) 11473 }, 11474 _preareItems: function(a, p) { 11475 for (var i = 0; i < a.length; i++) a[i] = { 11476 n: a[i], 11477 v: p ? E.$(a[i]).parent() : E.$(a[i]) 11478 }; 11479 return a 11480 }, 11481 _setItemClass: function(items, elem, cname, show, cname2) { 11482 for (var i = 0; i < items.length; i++) 11483 if (items[i].n == elem) { 11484 if (show) items[i].v.show(); 11485 if (cname2) items[i].v.removeClass(cname2); 11486 if (cname) items[i].v.addClass(cname) 11487 } else { 11488 if (show) items[i].v.hide(); 11489 if (cname) items[i].v.removeClass(cname); 11490 if (cname2) items[i].v.addClass(cname2) 11491 } 11492 }, 11493 _loginTabClick: function() { 11494 this.pm._loginTabProcess(this.elem) 11495 }, 11496 _loginTabProcess: function(a) { 11497 this._loginTab = a + '_form'; 11498 this._setItemClass(this._itemsTabHeader, a, 'headerActive'); 11499 this._activateLoginTab(true) 11500 }, 11501 hide: function() { 11502 this._map.removeLayer(this._marker); 11503 if (this._overlay) this._overlay.hide(); 11504 this._overlay = null; 11505 this._errorWindow.hide(); 11506 this._isActive = false 11507 }, 11508 _onLogin: function() { 11509 if ((this._isActive) && (this._lc.isLogged())) { 11510 if (!this._pos) this._loginTab = 're_profile_form'; 11511 else this._loginTab = 're_report_error_form'; 11512 this._loginTabProcess(this._loginTab.replace("_form", "")); 11513 this._processReportedErrors(); 11514 this._processeMyto(); 11515 E.$('re_login').text(this._lc.loginUser()) 11516 } 11517 }, 11518 _onLoginTab: function() { 11519 if (!this._lc.isLogged()) { 11520 this._lc.login() 11521 } else this._activateLoginTab(true) 11522 }, 11523 _onAnonymousTab: function() { 11524 this._activateLoginTab(false) 11525 }, 11526 _activateLoginTab: function(a) { 11527 var b = ['activeTdElementHeader', 'inactiveTdElementHeader']; 11528 this._headerTab.visible(a); 11529 this._errorWindow.setUser(a ? this._lc.loginUser() : ''); 11530 if (a) { 11531 this._setItemClass(this._mainTabItems, 're_login', b[0], false, b[1]); 11532 this._setItemClass(this._itemsTab, this._loginTab, undefined, true) 11533 } else { 11534 this._setItemClass(this._mainTabItems, 're_report_anonymous', b[0], false, b[1]); 11535 this._setItemClass(this._itemsTab, this._anonymousTab, undefined, true) 11536 } 11537 }, 11538 _processReportError: function() { 11539 if (this._pos) this._errorWindow.renderWindow(E.$("re_report_error_form"), this._pos); 11540 else E.$("re_report_error_form").text(E.lang('PM_how_report')) 11541 }, 11542 _processeMyto: function() { 11543 if (this._lc.isService('viaToll')) E.$('re_myto_form').text(E.lang('PM_viatoll_acces') + this._lc.getService('viaToll').expiryDate) 11544 }, 11545 _processReportedErrors: function() { 11546 var value = this._lc.getService('ReportErrors'); 11547 if (value) { 11548 var result = '<table width="100%" class="re_reported_table" id="re_reported_table"><tr class="re_reported_table_dt_h"><td style="width:20px;text-align: center">Id</td><td style="width:150px">Opis</td><td style="width:80px">Data dodania</td><td style="width:90px">Status</td><td>Release</td></tr>'; 11549 var items = value.value; 11550 items.reverse(); 11551 for (var i = 0; i < items.length; i++) { 11552 var c = items[i].description; 11553 if (c.length > 50) { 11554 var a = c.replace("\"", "\\\"").replace(/<br>/g, " 
"); 11555 c = "<a title=\"" + a + "\" style=\"color:inherit\">" + c.substring(0, 47) + "...</a>" 11556 } 11557 result += '<tr class="re_reported_table_dt_' + i % 2 + '" lon="' + items[i].lon + '" lat="' + items[i].lat
11557+ '"><td style="text-align: center" >' + (i + 1) + '</td><td>' + c + '</td>'; 11558 result += '<td style="text-align: center">' + items[i].submission_time + '</td><td style="text-align: center">' + E.lang('PM_reported_errors_' + items[i].status) + '</td>'; 11559 result += '<td style="text-align: center">' + items[i].release + '</td>' + '</tr>' 11560 } 11561 result += '</table>'; 11562 items.reverse(); 11563 E.$('re_reported_errors_form').text(result); 11564 var a = E.$('re_reported_table').firstChild().childs(); 11565 for (i = 0; i < a.length; i++) a[i].click(E.bind(this._showPos, { 11566 c: this, 11567 e: a[i] 11568 })) 11569 } 11570 }, 11571 _showPos: function() { 11572 this.c._centerPoint.call(this.c, this.e) 11573 }, 11574 _centerPoint: function(a) { 11575 this._map.removeLayer(this._marker); 11576 this._marker.setLatLng(L.latLng(a.att("lat"), a.att("lon"))); 11577 this._map.addLayer(this._marker); 11578 this._map.panTo(L.latLng(a.att("lat"), a.att("lon"))) 11579 }, 11580 renderWindow: function() { 11581 var div = E.newElem('div', 're_window'); 11582 div.innerHTML = '<div class="re_belka" id="re_belka"></div>' + '<div class="close_window" id="re_close_window"></div>' + '<div class="re_content">' + ' <div class="content_header">' + '<table cellpadding="0" cellspacing="0" border="0">' + '<tr>' + '<td class="re_td1">' + ' <div class="re_anonymous activeTdElementHeader" id="re_report_anonymous">' + E.lang('PM_report_anonymous') + '</div> ' + '</td>' + '<td class="re_td2">' + ' <div class="re_anonymous inactiveTdElementHeader" id="re_login">' + E.lang('PM_login') + '</div>' + '</td>' + '<td class="re_td2" style="display:none">' + '</td>' + '</tr>' + '</table>' + ' </div>' + ' <div class="re_content_data" id="re_content_data">' + '<div class="re_content_data_header" id="re_content_data_header">' + ' <table cellpadding="0" cellspacing="0" border="0">' + ' <tr>' + ' <td class="re_td3">' + '<div class="re_anonymous1" id="re_profile">' + E.lang('PM_profil') + '</div>' + ' </td>' + ' <td class="re_td4">' + '<div class="re_anonymous1" id="re_report_error">' + E.lang('PM_report_error') + '</div>' + ' </td>' + ' <td class="re_td4">' + '<div class="re_anonymous1" id="re_reported_errors">' + E.lang('PM_reported_errors') + '</div>' + ' </td>' + ' <td class="re_td4">' + '<div class="re_anonymous1" id="re_myto">' + E.lang('PM_e-toll module') + '</div>' + ' </td>' + ' </tr>' + ' </table>' + '</div>' + '<div class="report_error" id="re_report_error_form">' + '</div>' + '<div class="report_error" id="re_reported_errors_form" style="height:300px;overflow-x:hidden;overflow-y:auto">' + E.lang('PM_reported_errors_empty') + '</div>' + '<div class="report_error" id="re_profile_form">' + '<div>' + E.lang('PM_login_privacy') + '</div>' + ' <iframe style="border:0px;width:100%;height:400px" src="https://auth.emapa.pl/EditProfile.aspx?idx=6xij7pog54k&lang=' + E.Lang.code() + '" style="width:100%;height:400px"></iframe>' + '</div>' + '<div class="report_error" id="re_myto_form">' + E.lang('PM_e_myto_info') + '</div>' + ' </div>'; 11583 return div 11584 } 11585}); 11586E.Profile.LoginController = L.Class.extend({ 11587 _logged: false, 11588 _loginUser: '', 11589 _services: [], 11590 _map: null, 11591 _loginWindow: null, 11592 initialize: function(map, pm) { 11593 this._map = map; 11594 this._pm = pm; 11595 this._loginWindow = new E.Profile.LoginWindow(map, E.bind(this._doLogin, this)) 11596 }, 11597 _doLogin: function(user, pass) { 11598 this._loginUser = user; 11599 this._map.login({ 11600 login: user, 11601 password: pass, 11602 services: 'viaToll;SZP' 11603 }, this._onGetServerData, this, {}) 11604 }, 11605 _onGetServerData: function(data, object) { 11606 with(this._loginWindow) { 11607 setBlockClick(false); 11608 if (data.result == -1) { 11609 setWarning(E.lang('LW_ConnectionError')) 11610 } else if (data.result == 0) { 11611 this._setSevices(data.services); 11612 hide(); 11613 this._onLogIn(data.SessionId) 11614 } else if (data.result == 1) setWarning(E.lang('LW_UnknownError')); 11615 else if (data.result == 2) setWarning(E.lang("LW_BadLoginOrPasswordError")); 11616 else setWarning(E.lang("LW_ServerSendUnknowResponse")) 11617 } 11618 }, 11619 loginUser: function() { 11620 return this._loginUser 11621 }, 11622 hasPaidServices: function() { 11623 for (var x in this._services) 11624 if (this._services[x].Free == 0) return true; 11625 return false 11626 }, 11627 isService: function(name) { 11628 return this._services[name] != null 11629 }, 11630 getService: function(name) { 11631 return this._services[name].Value 11632 }, 11633 login: function() { 11634 this._loginWindow.show() 11635 }, 11636 logout: function() { 11637 this._logged = false; 11638 this._pm.fire("onLogout"); 11639 this._map.logout({}) 11640 }, 11641 isLogged: function() { 11642 return this._logged 11643 }, 11644 _onLogIn: function(a) { 11645 this._logged = true; 11646 this._map.setSession(a); 11647 this._pm.fire("onLogin") 11648 }, 11649 _setSevices: function(a) { 11650 this._services = []; 11651 for (var i = 0; i < a.length; i++) { 11652 if (E.type(a[i].Value) == 's') eval("a[i].Value=" + a[i].Value); 11653 this._services[a[i].Name] = a[i] 11654 } 11655 } 11656}); 11657E.Router = L.Class.extend({ 11658 includes: [L.Mixin.Events, E.Hook], 11659 _queryList: null, 11660 _wayPoints: null, 11661 _drivers: null, 11662 _vehicles: null, 11663 _isMap: false, 11664 _map: null, 11665 _api: {}, 11666 _maxTracePoints: 5, 11667 _layer: null, 11668 _pointsLayer: null, 11669 _currentRouteID: 0, 11670 _lastVehicleId: -1, 11671 forceCalc: true, 11672 initialize: function(obj, options) { 11673 E.extend(this, options); 11674 this._isMap = obj instanceof E.Map; 11675 this._map = obj;
11676 this._layer = E.vectorLayer(); 11677 this._pointsLayer = E.vectorLayer(); 11678 this._drivers = new E.ArrayObjects(E.Router.DriverParams); 11679 this._vehicles = new E.ArrayObjects(E.Router.VehicleParams); 11680 this._vehicles.initializeItems(E.Router.RouteConsts.vehicles); 11681 this._drivers.initializeItems(E.Router.RouteConsts.drivers); 11682 this._routeRep = new E.ArrayObjects(E.Router.RouteRepresentation); 11683 this._activeRoute = 0; 11684 this._queryList = new E.QueryList(this); 11685 if (this._isMap) { 11686 this._initContext(); 11687 this._api = obj._map; 11688 this._map.addLayer(this._layer); 11689 this._map.addLayer(this._pointsLayer); 11690 this.on('beforeCalculateRoute', function() { 11691 this._map._map.fire('beforeCalculateRoute') 11692 }).on('afterCalculateRoute', function() { 11693 this._map._map.fire('afterCalculateRoute') 11694 }) 11695 } else { 11696 this._map = new L.Class(); 11697 new E.API(obj, this._api) 11698 } 11699 this._wayPoints = new E.Router.RoutePointsController(E.Router.WayPointEx, options, this, this._pointsLayer, this._api).on('activateRoute', function(a, b) { 11700 this.fire(a.type, { 11701 routeIndex: this._activeRoute = a.routeIndex 11702 }) 11703 }, this); 11704 this.executeHook('initialize') 11705 }, 11706 _initContext: function() { 11707 this._map.addMapAction(0, new E.Router.RouteContextAddFromPoint('AddFromPoint', this)); 11708 this._map.addMapAction(1, new E.Router.RouteContextAddViaPoint('AddViaPoint', this)); 11709 this._map.addMapAction(2, new E.Router.RouteContextAddToPoint('AddToPoint', this)); 11710 this._map.addMapAction(3, new E.Actions.Item.Context('Divider')) 11711 }, 11712 addWaypoint: function(lonLat, pointType, callback) { 11713 var index; 11714 with(this) { 11715 if ((pointType == 0) || (pointType == 2)) { 11716 index = _wayPoints.isPointSet(pointType); 11717 if (index > -1) { 11718 setWaypoint(index, lonLat, callback); 11719 return false 11720 } 11721 index = 0 11722 } 11723 if (_wayPoints.count() >= _maxTracePoints) { 11724 alert(E.lang('RR_MXR') + _maxTracePoints); 11725 return false 11726 } 11727 index = _wayPoints.getAddPointIndex(pointType); 11728 _wayPoints.addPoint(pointType, E.LLP(lonLat), ''); 11729 _getDesctiption(index, callback); 11730 _onPointsChange("addPoint", _wp(index)) 11731 } 11732 return true 11733 }, 11734 _getDesctiption: function(index, callback) { 11735 var item = this._wayPoints.item(index); 11736 this._api.addWaypoint({ 11737 'lon': item.lonLat.lng, 11738 'lat': item.lonLat.lat 11739 }, this._onResponse, this, { 11740 callback: callback, 11741 action: 'getDescription', 11742 id: item.key 11743 }) 11744 }, 11745 setWaypoint: function(index, lonLat, callback) { 11746 with(this) { 11747 _wayPoints.setPoint(index, E.LLP(lonLat), ''); 11748 _getDesctiption(index, callback); 11749 _onPointsChange("setPoint", _wp(index)) 11750 } 11751 }, 11752 removeWaypoints: function() { 11753 with(this) { 11754 _queryList.clear(); 11755 _wayPoints.clearPoints(); 11756 _onPointsChange("removePoints") 11757 } 11758 }, 11759 removeWaypoint: function(index) { 11760 with(this) { 11761 var a = _wp(index); 11762 _wayPoints.removePoint(index); 11763 _onPointsChange("removePoint", a) 11764 } 11765 }, 11766 swapWaypoint: function(firstPointIndex, secondPointIndex) { 11767 with(this) { 11768 this._wayPoints.swapPoints(firstPointIndex, secondPointIndex); 11769 this._onPointsChange("swapPoint", _wp(firstPointIndex), _wp(secondPointIndex)) 11770 } 11771 }, 11772 calculateRoute: function(vehicle, driver, roadType, routeOptions, callback, force, params) { 11773 if (vehicle && driver && (roadType !== null) && routeOptions) { 11774 if (routeOptions.optimize == 1) this._simpleOptimizer(); 11775 var lVehicle, lDriver, roadParams = '', 11776 i, item, obj, points, options = 0, 11777 a; 11778 with(vehicle) lVehicle = E.format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11};{12};{13};{14};{15};{16};{17}", [vehicleType, (vehicle.ignoreFuel ? '1' : '0'), fixedCost, costPerKilometer, costPerHour, tollRoadPerKilometer, tankCapacity, fuelCost, refuelTime, vehicleWeight, vehicleLength, vehicleHeight, vehicleWidth, vehicleCapacity, vehicleLoadCapacity, shippingTime, borderPassTime, vehicleWeightPerAxle]); 11779 with(driver) lDriver = E.format("{0};{1};{2};{3};{4};{5}", [routeOptions.useArchivalTraffic ? routeOptions.journeyStartTime : j
11779ourneyStartTime, dayWorkTime, continuousWorkTime, breakTime, costPerKilometer, costPerHour]); 11780 for (i = 0; i < vehicle.routeOptions.count(); i++) with(vehicle.routeOptions.item(i)) { 11781 if ((roadType == 'LocalRoad') || (roadType == 'Ferry')) try { 11782 se = (obj.roadType == 'LocalRoad') ? routeOptions.useGroundRoad : routeOptions.useFerry 11783 } catch (e) {} 11784 obj = '' + speed + ';' + combustion + ';' + (use ? '1' : '0') + ';' + toll; 11785 roadParams += (i > 0 ? ';' : '') + obj 11786 } 11787 if (params != undefined) { 11788 with(params) { 11789 lParams = E.format("{0};{1};{2};{3}", [params.currency ? currency : "PLN", params.vinettespanday ? vinettespanday : "7-14", params.returnMapaMapRoute ? returnMapaMapRoute : false, "6"]) 11790 } 11791 } else { 11792 lParams = "PLN;7-14;false;6" 11793 } 11794 points = this._wayPoints.getPointsLoLa(); 11795 if (points.length == 0) return; 11796 points[0] = this._encode(points[0], 5); 11797 for (i = 0, a = ['useDifficulties', 'useTrafficTI', 'viaToll', 'avoidToll', 'useLogistic', 'useVignette', 'useArchivalTraffic', 'avoidViaToll', 'useSoftRestrictions', 'avoidLowCategoryRoads', 'alternativeRoutes']; i < a.length; i++) options += (routeOptions[a[i]] ? 1 << i : 0); 11798 if (force) { 11799 this._calculateRoute({ 11800 json: [lVehicle, lDriver, roadParams, roadType, options, points[0], "", lParams], 11801 obj: { 11802 callback: callback, 11803 routeParams: { 11804 useDifficulties: routeOptions.useDifficulties, 11805 useTrafficTI: routeOptions.useTrafficTI, 11806 vehicle: vehicle.vehicleType 11807 }, 11808 action: 'afterCalculateRoute', 11809 points: points[1], 11810 optimizeRoute: routeOptions.optimize 11811 } 11812 }) 11813 } else { 11814 this._queryList.clear(); 11815 this._queryList.addQuery(this._calculateRoute, { 11816 json: [lVehicle, lDriver, roadParams, roadType, options, points[0], "", lParams], 11817 obj: { 11818 callback: callback, 11819 routeParams: { 11820 useDifficulties: routeOptions.useDifficulties, 11821 useTrafficTI: routeOptions.useTrafficTI 11822 }, 11823 action: 'afterCalculateRoute', 11824 points: points[1], 11825 optimizeRoute: routeOptions.optimize 11826 } 11827 }) 11828 } 11829 } 11830 }, 11831 doCalculateRoute: function() { 11832 if ((this.forceCalc) && (this._wayPoints.isPointSet(0) > -1) && (this._wayPoints.isPointSet(2) > -1)) { 11833 this.calculateRoute(this._vehicles.item(0), this._drivers.item(1), 0, { 11834 useGroundRoad: true, 11835 useFerry: true, 11836 useTollRoad: false, 11837 useVignetteRoads: false, 11838 useDifficulties: false 11839 }, null, true) 11840 } 11841 }, 11842 _simpleOptimizer: function() { 11843 var wp = this._wayPoints, 11844 i, j, t = [], 11845 s = [], 11846 dist, minDist, r = [], 11847 g, b; 11848 for (i = 0; i < wp.count(); i++) t.push({ 11849 x: wp.item(i).lonLat.lng, 11850 y: wp.item(i).lonLat.lat, 11851 id: i 11852 }), r.push(0); 11853 s.push({ 11854 from: t[0], 11855 to: t[t.length - 1] 11856 }); 11857 t.splice(0, 1); 11858 t.splice(t.length - 1, 1); 11859 while (t.length > 0) { 11860 for (var i = 0; i < s.length; i++) { 11861 for (var j = 0; j < t.length; j++) { 11862 dist2Segment = E.Util.distToSegment(t[j], s[i].from, s[i].to); 11863 dist2Point = E.Util.distToPoint(t[j], s[i].from); 11864 minDist = ((i == 0 && j == 0) || (dist2Segment < minDist.distSegment) || (dist2Point < minDist.distPoint)) ? { 11865 distSegment: dist2Segment, 11866 distPoint: dist2Point, 11867 point: j, 11868 segment: i 11869 } : minDist 11870 } 11871 } 11872 g = s[j = minDist.segment]; 11873 i = t[minDist.point]; 11874 with(this._wayPoints) { 11875 s.push({ 11876 from: i, 11877 to: s[j].to 11878 }); 11879 r[i.id] = s[j].to.id; 11880 r[s[j].from.id] = i.id; 11881 s[j].to = i 11882 } 11883 t.splice(minDist.point, 1) 11884 } 11885 for (i = 0, t = [], j = 0; i < r.length; i++) { 11886 t.push([j, i]); 11887 j = r[j] 11888 } 11889 this._pointsSet(null, { 11890 Points: t 11891 }) 11892 }, 11893 _wp: function(index) { 11894 return this._wayPoints.item(index) 11895 }, 11896 _pId: function(id) { 11897 return this._wayPoints.findObject('id', id) 11898 }, 11899 _pKey: function(key) { 11900 return this._wayPoints.findObject('key', key) 11901 }, 11902 _pIndex: function(obj) { 11903 for (var i = 0; i < obj.points.length; i++) { 11904 obj.points[i] = this._pId(obj.points[i]); 11905 if (obj.points[i] < 0) return [] 11906 } 11907 return obj.points 11908 }, 11909 _calculateRoute: function(p) { 11910 this.fire('beforeCalculateRoute'); 11911 this._api[p.obj.optimizeRoute ? "optimizeRoute" : "calculateRoute"](p.json, this._onResponse, this, p.obj, this._nextQuery) 11912 }, 11913 _nextQuery: function() { 11914 this._queryList.nextQuery() 11915 }, 11916 _onRouteCalc: function(obj, data) { 11917 this._pointsSet(obj, data); 11918 this.executeHook('onRouteCalc', obj, data); 11919 this.fire('afterCalculateRoute', data) 11920 }, 11921 _pointsSet: function(obj, data) { 11922 var wp = this._wayPoints, 11923 np, t = [], 11924 p, j, k; 11925 if (np = data.Points) { 11926 for (var i = 0, p; i < np.length; i++) t.push(i); 11927 for (var i = 0, p; i < np.length; i++) { 11928 if ((p = np[i])[0] != p[1] && t[p[1]] != p[0]) { 11929 j = t.indexOf(p[0]); 11930 this._wayPoints.swapPoints(j, p[1]); 11931 this._onPointsChange("swapPoint", this._wp(j), this._wp(p[1]), 1); 11932 k = t[j]; 11933 t[j] = t[p[1]];
11934 t[p[1]] = k 11935 } 11936 } 11937 } 11938 }, 11939 _onResponse: function(data, obj, nextQuery) { 11940 if (nextQuery) this._nextQuery(); 11941 with(this) { 11942 switch (obj.action) { 11943 case 'getDescription': 11944 if (data.result == 0) { 11945 var a = data.routePlanEntryDescription.split(';'); 11946 _wayPoints.setDescription(this._pKey(obj.id), a[1], a[0]); 11947 _onPointsChange("getDescription", _wp(_pKey(obj.id))) 11948 } 11949 break; 11950 case 'afterCalculateRoute': { 11951 _onRouteCalc(obj, data) 11952 } 11953 break 11954 } 11955 } 11956 this.fire(obj.type) 11957 }, 11958 _onPointsChange: function(action, first, second, block) { 11959 this.fire(action, { 11960 index: { 11961 first: first, 11962 second: second 11963 } 11964 }); 11965 if ((action != 'getDescription') && !block) this.doCalculateRoute(); 11966 this.fire('PointsChange', action, first, second); 11967 this.executeHook('PointsChange', action, first, second) 11968 }, 11969 refreshFullTrace: function() { 11970 this._layer.clearLayers(); 11971 this._wayPoints.refreshFullTrace() 11972 }, 11973 _decode: function(c, d) { 11974 d = Math.pow(10, -d); 11975 var f = c.length, 11976 e = 0, 11977 j = 0, 11978 k = 0, 11979 h = []; 11980 while (e < f) { 11981 var l, a = 0, 11982 m = 0; 11983 do { 11984 l = c.charCodeAt(e++) - 63; 11985 m |= (l & 31) << a; 11986 a += 5 11987 } while (l >= 32); 11988 var g = ((m & 1) ? ~(m >> 1) : (m >> 1)); 11989 j += g; 11990 a = 0; 11991 m = 0; 11992 do { 11993 l = c.charCodeAt(e++) - 63; 11994 m |= (l & 31) << a; 11995 a += 5 11996 } while (l >= 32); 11997 var i = ((m & 1) ? ~(m >> 1) : (m >> 1)); 11998 k += i; 11999 h.push([j * d, k * d]) 12000 } 12001 return h 12002 }, 12003 _encode: function(c, d) { 12004 d = Math.pow(10, d); 12005 var a, b, x = 0, 12006 y = 0, 12007 x1, y1, x2, y2 = 0; 12008 var res = ''; 12009 for (var i = 0; i < c.length; i++) { 12010 x2 = parseInt(c[i].lng * d); 12011 y2 = parseInt(c[i].lat * d); 12012 x1 = (x2 - x); 12013 x1 = (x1 < 0) ? ((~x1) << 1) + 1 : x1 << 1; 12014 y1 = (y2 - y); 12015 y1 = (y1 < 0) ? ((~y1) << 1) + 1 : y1 << 1; 12016 b = true; 12017 while ((y1 > 0) || (b)) { 12018 b = false; 12019 a = (y1 & 0x1F); 12020 y1 = y1 >> 5; 12021 a = (y1 > 0 ? a + 0x20 : a) + 63; 12022 res += String.fromCharCode(a) 12023 } 12024 b = true; 12025 while ((x1 > 0) || (b)) { 12026 b = false; 12027 a = (x1 & 0x1F); 12028 x1 = x1 >> 5; 12029 a = (x1 > 0 ? a + 0x20 : a) + 63; 12030 res += String.fromCharCode(a) 12031 } 12032 x = x2; 12033 y = y2 12034 } 12035 return res 12036 }, 12037 drivers: function() { 12038 return this._drivers 12039 }, 12040 vehicles: function() { 12041 return this._vehicles 12042 }, 12043 wayPoints: function() { 12044 return this._wayPoints 12045 }, 12046 routeRepresentation: function() { 12047 return this._routeRep.item(this._activeRoute) 12048 } 12049}); 12050E.Router.Fuel = { 12051 cost: 5.60 12052}; 12053E.Router.RouteConsts = { 12054 drivers: [{ 12055 id: 0, 12056 name: 'Experienced', 12057 journeyStartTime: 0.375, 12058 dayWorkTime: 0.375, 12059 continuousWorkTime: 0.1875, 12060 breakTime: 0.03125, 12061 costPerKilometer: 0, 12062 costPerHour: 0 12063 }, { 12064 id: 1, 12065 name: 'Unexperienced', 12066 journeyStartTime: 0.375, 12067 dayWorkTime: 0, 12068 continuousWorkTime: 0, 12069 breakTime: 0, 12070 costPerKilometer: 0, 12071 costPerHour: 0 12072 }], 12073 vehicles: [] 12074}; 12075(function init() { 12076 var vehicles = [ 12077 [ 12078 ['Passenger car', 0, false, 0, 0, 0, 0, 50, E.Router.Fuel.cost, 0.00694, 0, 0, 0, 0, 0, 0, 0, 0.02083, 0.003472], { 12079 use: 2047, 12080 speed: [115, 85, 70, 60, 45, 35, 10, 50, 45, 40, 30], 12081 combustion: [7.0, 7.0, 7.0, 7.0, 8.0, 8.0, 9.0, 8.0, 9.0, 10.0, 0.0] 12082 } 12083 ], 12084 [ 12085 ['Fast passenger car', 0, false, 0, 0, 0, 0, 50, E.Router.Fuel.cost, 0.00694, 0, 0, 0, 0, 0, 0, 0, 0.02083, 0.003472], { 12086 use: 2047, 12087 speed: [135, 110, 95, 85, 55, 45, 10, 50, 45, 40, 30], 12088 combustion: [9.0, 8.0, 8.0, 7.0, 9.0, 9.0, 9.0, 9.0, 10.0, 10.0, 0.0] 12089 } 12090 ], 12091 [ 12092 ['Transport truck 10t', 1, false, 0, 0, 0, 0, 600, E.Router.Fuel.cost, 0.017361, 10.0, 0, 3.4, 2.3, 0, 0, 0, 0.02083, 0.02083], { 12093 use: 2047, 12094 speed: [89, 85, 80, 75, 45, 35, 10, 50, 45, 40, 30], 12095 combustion: [20.0, 20.0, 22.0, 22.0, 25.0, 28.0, 30.0, 25.0, 25.0, 28.0, 0.0] 12096 } 12097 ], 12098 [ 12099 ['Transport truck 20t', 1, false, 0, 0, 0, 0, 600, E.Router.Fuel.cost, 0.017361, 20.0, 0, 3.2, 2.0, 0, 0, 0, 0.02083, 0.02083], { 12100 use: 2047, 12101 speed: [89, 85, 80, 75, 45, 35, 10, 50, 45, 40, 30], 12102 combustion: [22.0, 22.0, 24.0, 24.0, 26.0, 28.0, 30.0, 26.0, 26.0, 28.0, 0.0] 12103 } 12104 ], 12105 [ 12106 ['Delivery truck', 5, false, 0, 0, 0, 0, 100, E.Router.Fuel.cost, 0.0138, 10.0, 0, 3.4, 2.3, 0, 0, 0, 0.02083, 0.02083], { 12107 use: 2047, 12108 speed: [115, 100, 85, 75, 45, 35, 10, 50, 45, 40, 30], 12109 combustion: [12.0, 12.0, 14.0, 15.0, 15.0, 17.0, 17.0, 15.0, 15.0, 15.0, 0.0] 12110 } 12111 ], 12112 [ 12113 ['Motorcycle', 2, false, 0, 0, 0, 0, 15, E.Router.Fuel.cost, 0.00694, 0.0, 0, 0, 0, 0, 0, 0, 0.02083, 0.003472], { 12114 use: 2047, 12115 speed: [130, 110, 95, 85, 80, 40, 10, 80, 50, 30, 30], 12116 combustion: [7.5, 7.5, 7.5, 7.5, 7.5, 7.5, 8.0, 9.0, 10.
121160, 10.0, 0.0] 12117 } 12118 ], 12119 [ 12120 ['Bicycle', 4, true, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02083, 0.003472], { 12121 use: 2044, 12122 speed: [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 30], 12123 combustion: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 12124 } 12125 ], 12126 [ 12127 ['Pedestrian', 3, true, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.02083, 0.003472], { 12128 use: 2044, 12129 speed: [1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 30], 12130 combustion: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] 12131 } 12132 ] 12133 ], 12134 i, j, a = ['Highway', 'Speedway', 'NationalRoad', 'RegionalRoad', 'LocalRoad', 'OtherRoad', 'UnpavedRoad', 'VehicularStreet', 'MainStreet', 'OtherStreet', 'Ferry'], 12135 b, c, d = ["name", "vehicleType", "ignoreFuel", "fixedCost", "costPerKilometer", "costPerHour", "tollRoadPerKilometer", "tankCapacity", "fuelCost", "refuelTime", "vehicleWeight", "vehicleLength", "vehicleHeight", "vehicleWidth", "vehicleWeightPerAxle", "vehicleCapacity", "vehicleLoadCapacity", "shippingTime", "borderPassTime"], 12136 e = [ 12137 ['HighwayInBUA', 'Highway'], 12138 ['SpeedwayInBUA', 'Speedway'], 12139 ['NationalRoadInBUA', 'NationalRoad'], 12140 ['RegionalRoadInBUA', 'RegionalRoad'] 12141 ]; 12142 for (i = 0; i < vehicles.length; i++) { 12143 b = vehicles[i]; 12144 for (j = 0, c = { 12145 id: i, 12146 routeOptions: [] 12147 }; j < d.length; j++) c[d[j]] = b[0][j];
12148 for (j = 0; j < a.length; j++) c.routeOptions.push({ 12149 use: (b[1].use >> j) % 2 == 1, 12150 id: j, 12151 roadType: a[j], 12152 speed: b[1].speed[j], 12153 combustion: b[1].combustion[j], 12154 toll: 0 12155 }); 12156 for (j = 0; j < e.length; j++) b = c.routeOptions[a.indexOf(e[j][1])], c.routeOptions.push({ 12157 use: b.use, 12158 id: a.length + j, 12159 roadType: e[j][0], 12160 speed: b.speed, 12161 combustion: b.combustion, 12162 toll: b.toll 12163 }); 12164 E.Router.RouteConsts.vehicles.push(c) 12165 } 12166})(); 12167E.Router.DriverParams = L.Class.extend({ 12168 id: 0, 12169 name: 'driver', 12170 journeyStartTime: 0, 12171 dayWorkTime: 0, 12172 continuousWorkTime: 0, 12173 breakTime: 0, 12174 costPerKilometer: 0, 12175 costPerHour: 0, 12176 initialize: function(options) { 12177 E.extend(this, options) 12178 }, 12179 destroy: function() {} 12180}); 12181E.Router.RoadParams = L.Class.extend({ 12182 id: 0, 12183 roadType: '', 12184 use: true, 12185 speed: 0, 12186 combustion: 0, 12187 toll: 0, 12188 initialize: function(options) { 12189 E.extend(this, options) 12190 }, 12191 destroy: function() {} 12192}); 12193E.Router.VehicleParams = L.Class.extend({ 12194 id: 0, 12195 name: 'vehicle', 12196 vehicleType: 0, 12197 ignoreFuel: true, 12198 fixedCost: 0, 12199 costPerKilometer: 0, 12200 costPerHour: 0, 12201 tollRoadPerKilometer: 0, 12202 tankCapacity: 0, 12203 fuelCost: 0, 12204 refuelTime: 0, 12205 vehicleWeight: 0, 12206 vehicleLength: 0, 12207 vehicleHeight: 0, 12208 vehicleWidth: 0, 12209 vehicleCapacity: 0, 12210 vehicleLoadCapacity: 0, 12211 shippingTime: 0, 12212 borderPassTime: 0, 12213 routeOptions: null, 12214 vehicleWeightPerAxle: 0, 12215 initialize: function(options) { 12216 E.extend(this, options); 12217 this.routeOptions = new E.ArrayObjects(E.Router.RoadParams); 12218 this.routeOptions.initializeItems(options.routeOptions) 12219 }, 12220 destroy: function() { 12221 this.routeOptions.destroy(); 12222 this.routeOptions = null 12223 } 12224}); 12225E.Router.WayPoint = L.Class.extend({ 12226 id: 0, 12227 lonLat: null, 12228 description: '', 12229 initialize: function(options) { 12230 E.extend(this, options) 12231 }, 12232 destroy: function() { 12233 this.lonLat = null 12234 } 12235}); 12236E.Router.WayPointEx = L.Class.extend({ 12237 point: null, 12238 icon: null, 12239 initialize: function(options) { 12240 this.icon = options.icon; 12241 this.pointType = options.pointType; 12242 this.id = options.id; 12243 this.key = options.key; 12244 delete options['icon']; 12245 delete options['pointType']; 12246 this.point = new E.Router.WayPoint(options); 12247 this.routes = new E.ArrayObjects(E.Router.RouteParams) 12248 }, 12249 clearRoutes: function(a) { 12250 for (var i = 0; i < this.routes.count(); i++) this.routes.item(i).removeRoadsLayers(a); 12251 this.routes.removeItems() 12252 }, 12253 addRoute: function() { 12254 this.routes.addItem(); 12255 return this.routes.count() - 1 12256 }, 12257 setRouteRepresentation: function(index, a) { 12258 this.routes.item(index).addRoadsLayers((E.type(a) != 'a') ? [a] : a) 12259 }, 12260 setRouteSegment: function(index, a) { 12261 if (this.routes._inRange(index)) { 12262 var item = this.routes.item(index); 12263 L.Util.extend(item, a) 12264 } 12265 }, 12266 setRouteStyle: function(index, style) { 12267 if (this.routes._inRange(index)) this.routes.item(index).setStyle(style) 12268 }, 12269 routeItem: function(index) { 12270 return this.routes.item(index) 12271 }, 12272 popup: function() { 12273 this.icon.openPopup() 12274 } 12275}); 12276E.Router.RouteParams = L.Class.extend({ 12277 roadLayers: [], 12278 reportPos: null, 12279 itrep: null, 12280 routeRep: [], 12281 bounds: null, 12282 initialize: function(options) { 12283 this.roadLayers = []; 12284 this.reportPos = null; 12285 this.itrep = null; 12286 this.routeRep = []; 12287 this.bounds = null; 12288 E.extend(this, options) 12289 }, 12290 removeRoadsLayers: function(a) { 12291 for (var i = 0; i < this.roadLayers.length; i++) a.push(this.roadLayers[i]); 12292 this.roadLayers.length = 0; 12293 this.itrep = null 12294 }, 12295 addRoadsLayers: function(a) { 12296 a = (E.type(a) != 'a') ? [a] : a; 12297 for (var i = 0; i < a.length; i++) { 12298 this.roadLayers.push(a[i]); 12299 if (this.bounds == null) this.bounds = a[i].getBounds(); 12300 else this.bounds.extend(a[i].getBounds()) 12301 } 12302 }, 12303 setStyle: function(options) { 12304 for (var i = 0, val = {}, item; i < this.roadLayers.length; i++) { 12305 item = this.roadLayers[i];
12306 if (options.color) val.color = [E.isA(options.color) ? options.color[Math.min(item.options.roadType, 1)] : options.color]; 12307 if (options.opacity) val.opacity = options.opacity; 12308 if (options.weight) val.weight = options.weight; 12309 item.setStyle(val); 12310 if (options.bringToFront) item.bringToFront(); 12311 if (options.sendToBack) item.bringToBack() 12312 } 12313 }, 12314 getRepresentation: function() { 12315 for (var i = 0, a = []; i < this.roadLayers.length; i++) a = a.concat(this.roadLayers[i].getLatLngs()); 12316 return a 12317 }, 12318 destroy: function() {} 12319}); 12320E.Router.RoutePointsController = E.ArrayObjects.extend({ 12321 includes: [L.Mixin.Events, E.Hook], 12322 _drawMapPointStyle: 7, 12323 _layer: null, 12324 _observeElement: null, 12325 _reportPointsHandlerButtonsName: '', 12326 _reportPointsHandlerPointsName: '', 12327 _pointId: 0, 12328 _removeTrace: [], 12329 _addTrace: [], 12330 _forceCalc: true, 12331 _segments: [], 12332 initialize: function(objectType, options, router, layer, map) { 12333 this._reportPointsHandlerPointsName = options.reportPointsHandlerPointsName; 12334 this._reportPointsHandlerButtonsName = options.reportPointsHandlerButtonsName; 12335 this._router = router; 12336 this._layer = layer; 12337 E.ArrayObjects.prototype.initialize.apply(this, [objectType]); 12338 this._objectType = objectType; 12339 this._segments = [], this._pointId = 0; 12340 this._actionKey = map.regAction(this._pAction, router); 12341 this._item = this.item; 12342 this.item = function(a) { 12343 return this._item(a).point 12344 }; 12345 this._icons = []; 12346 for (var i = 0, a = ['Start', 'Via', 'Stop']; i < a.length; i++) this._icons.push(L.divIcon({ 12347 className: 'RR_' + a[i] + ' RR_Flag', 12348 html: "", 12349 iconSize: null 12350 })); 12351 this.executeHook('init'); 12352 router.on('beforeCalculateRoute', this._disableDrag, this).on('afterCalculateRoute', this._enableDrag, this) 12353 }, 12354 _nextQuery: function() { 12355 this._queryList.nextQuery() 12356 }, 12357 _onRouteCalc: function(obj, data) { 12358 this._pointsSet(obj, data); 12359 this.executeHook('onRouteCalc', obj, data); 12360 this.fire('afterCalculateRoute', data) 12361 }, 12362 clearPoints: function() { 12363 this.removeItems(); 12364 this._removeTrace.length = 0; 12365 this._addTrace.length = 0; 12366 this._layer.clearLayers(); 12367 this._segments = []; 12368 this.drawPoints(); 12369 this._pointId = 0; 12370 this.fire("clearPoints") 12371 }, 12372 _getId: function() { 12373 return this._pointId++ 12374 }, 12375 addPoint: function(pointType, lonLat, description, country, insertIndex) { 12376 var index = 0; 12377 var icon = 0; 12378 var id = this._getId(); 12379 if ((pointType == 0) || (pointType == 2)) { 12380 index = this.isPointSet(pointType); 12381 if (index > -1) this.setPoint(index, lonLat, description, country); 12382 else { 12383 icon = this.createMapObject(pointType, lonLat, description, id); 12384 if (pointType == 0) this.insertItem({ 12385 pointType: pointType, 12386 lonLat: lonLat, 12387 description: description, 12388 country: country, 12389 icon: icon, 12390 id: id, 12391 key: id 12392 }, 0); 12393 else this.addItem({ 12394 pointType: pointType, 12395 lonLat: lonLat, 12396 description: description, 12397 country: country, 12398 icon: icon, 12399 id: id, 12400 key: id 12401 }) 12402 } 12403 } else { 12404 index = E.isU(insertIndex) ? this.isPointSet(2) : insertIndex; 12405 icon = this.createMapObject(pointType, lonLat, description, id); 12406 if (index > -1) this.insertItem({ 12407 pointType: pointType, 12408 lonLat: lonLat, 12409 description: description, 12410 country: country, 12411 icon: icon, 12412 id: id, 12413 key: id 12414 }, index); 12415 else this.addItem({ 12416 pointType: pointType, 12417 lonLat: lonLat, 12418 description: description, 12419 country: country, 12420 icon: icon, 12421 id: id, 12422 key: id 12423 }); 12424 this._refreshTrace(index == -1 ? this.count() - 1 : index) 12425 } 12426 this.drawPoints(); 12427 return this.findObject("id", id) 12428 }, 12429 movePoint: function(a, b) { 12430 if ((this._inRange(a)) && (this._inRange(b))) { 12431 this.moveItem(a, b); 12432 this._refreshTrace(a); 12433 this._refreshTrace(b); 12434 this.drawPoints() 12435 } 12436 }, 12437 swapPoints: function(a, b) { 12438 if ((this._inRange(a)) && (this._inRange(b))) { 12439 with(this._item(a).point) var ia = [description, lonLat, country, key]; 12440 with(this._item(b).point) var ib = [description, lonLat, country, key]; 12441 this.setPoint(b, ia[1], ia[0], ia[2]); 12442 this.setPoint(a, ib[1], ib[0], ib[2]); 12443 with(this._item(a)) key = point.key = ib[3]; 12444 with(this._item(b)) key = point.key = ia[3]; 12445 this._refreshTrace(a); 12446 this._refreshTrace(b) 12447 } 12448 }, 12449 removePoint: function(index) { 12450 if (this._inRange(index)) { 12451 this._refreshTrace(index); 12452 this._layer.removeLayer(this._item(index).icon); 12453 this.removeItem(index); 12454 this.drawPoints() 12455 } 12456 }, 12457 createMapObject: function(pointType, lonLat, description, id) { 12458 var marker = L.marker(lonLat, { 12459 icon: this._icons[pointType], 12460 draggable: true 12461 });
12462 marker.bindPopup(description); 12463 marker.on('dragend', this._onDragPoint, this); 12464 marker.on('contextmenu', this._onMouseDown, this); 12465 marker._id = id; 12466 this._layer.addLayer(marker); 12467 return marker 12468 }, 12469 setPoint: function(index, lonLat, description, country) { 12470 if (this._inRange(index)) { 12471 with(this._item(index)) { 12472 point.lonLat = lonLat; 12473 point.description = description; 12474 point.country = country; 12475 icon.closePopup(); 12476 icon.bindPopup(description); 12477 icon.setLatLng(lonLat) 12478 } 12479 this._refreshTrace(index) 12480 } 12481 this.drawPoints() 12482 }, 12483 setPointType: function(index, type) { 12484 if (this._inRange(index)) with(this._item(index)) { 12485 pointType = type; 12486 point.pointType = type; 12487 icon.setIcon(this._icons[type]); 12488 this.drawPoints() 12489 } 12490 }, 12491 setDescription: function(index, description, country) { 12492 if (this._inRange(index)) { 12493 with(this._items[index]) { 12494 point.description = description; 12495 point.country = country; 12496 icon.closePopup(); 12497 icon.bindPopup(description) 12498 } 12499 } 12500 this.drawPoints() 12501 }, 12502 isPointSet: function(pointType) { 12503 return this.findObject('pointType', pointType) 12504 }, 12505 getAddPointIndex: function(pointType) { 12506 if (pointType == 1) { 12507 var index = this.isPointSet(2); 12508 if (index > -1) return index; 12509 else return this.count() 12510 } else if (pointType == 0) return 0; 12511 else return this.count() 12512 }, 12513 getPointsRange: function() { 12514 with(this) return [item(0).lonLat, item(count() - 1).lonLat] 12515 }, 12516 getPointsLoLa: function() { 12517 var ei, si = ei = -1, 12518 a = [], 12519 b = [], 12520 iset = false, 12521 i; 12522 with(this) { 12523 for (i = 0; i < count() - 1; i++) 12524 if (_item(i).routes.count() == 0) { 12525 if (si == -1) si = i; 12526 if (iset) { 12527 ei = count(); 12528 break 12529 } 12530 ei = i + 2 12531 } else if (ei != -1) iset = true; 12532 if (si == -1) return []; 12533 for (i = si; i < ei; i++) { 12534 a.push(item(i).lonLat); 12535 b.push(item(i).id) 12536 } 12537 } 12538 return [a, b] 12539 }, 12540 clearRoutes: function(index) { 12541 if (this._inRange(index)) { 12542 with(this._item(index)) clearRoutes(this._removeTrace) 12543 } 12544 }, 12545 _disableDrag: function() { 12546 this._disableDragging = 1; 12547 for (var i = 0; i < this.count(); i++) this._item(i).icon.dragging.disable() 12548 }, 12549 _enableDrag: function() { 12550 this._disableDragging = 0; 12551 for (var i = 0; i < this.count(); i++) this._item(i).icon.dragging.enable() 12552 }, 12553 _onDragPoint: function(a) { 12554 this._router.setWaypoint(this.findObject('id', a.target._id), a.target.getLatLng()) 12555 }, 12556 _onMouseDown: function(a) { 12557 if (!this._disableDragging) { 12558 L.DomEvent.stopPropagation(a.originalEvent); 12559 L.DomEvent.preventDefault(a.originalEvent); 12560 this._router.removeWaypoint(this.findObject('id', a.target._id)) 12561 } 12562 }, 12563 onDrawPoints: function() {}, 12564 drawPoints: function(name) { 12565 with(this) { 12566 var a = E.$(_reportPointsHandlerPointsName), 12567 i, res = '', 12568 index = 1; 12569 12570 function ap(id, type, name, a, index, fun) { 12571 return E.format("<table border='0'><tr class='RR_P'><td><div class='Index'>({0})</div></td><td><div class='Type Flag{1}'></div></td><td><div class='Description' {2}'center',{4})\">{3}</div></td><td><table border='0'><tbody><tr><td><div class='RR_PA {5}' {2}'up',{4})\"></div></td><td><div class='RR_PA {6}' {2}'down',{4})\" ></div></td><td><div class='RR_PA {7}' {2}'del',{4})\"'></div></td></tr></table></td></tr></table>", [id, type, 'onclick="' + fun + '(', name, index, a[0], a[1], a[2]]) 12572 } 12573 if (!a.elem()) return; 12574 if (isPointSet(0) == -1) res += ap(index++, 0, E.lang('RR_p_no1'), ['', '', ''], 0, ''); 12575 for (i = 0; i < count(); i++) with(_item(i)) res += ap(index++, pointType, point.description, [(i > 0) ? 'up' : '', (i + 1 < count()) ? 'down' : '', 'del'], i, _actionKey); 12576 if (isPointSet(2) == -1) res += ap(index++, 2, E.lang('RR_p_no2'), ['', '', ''], 0, ''); 12577 a.text(res); 12578 if ((a = E.$(_reportPointsHandlerButtonsName)).elem()) a.text(E.format("<div class='RR_PB'>{0}{1}</div >", [_layer.count() > 0 ? "<span class='RR_PC clear' {2}'clear')\"></span>" : '', (isPointSet(0) > -1) && (isPointSet(2) > -1) ? "<span class='RR_PC calc' {2}'calc')\"></span>
12578" : '', 'onclick="' + this._actionKey + '('])) 12579 } 12580 }, 12581 _pAction: function(act, id) { 12582 if (act == 'up') this.swapWaypoint(id, id - 1); 12583 else if (act == 'down') this.swapWaypoint(id, id + 1); 12584 else if (act == 'del') this.removeWaypoint(id); 12585 else if (act == 'calc') this.doCalculateRoute(); 12586 else if (act == 'clear') this.removeWaypoints(); 12587 else if (act == 'center') this._wayPoints._item(id).popup() 12588 } 12589}); 12590E.Router.RoutePointsController.include({ 12591 _activeRoute: -1, 12592 cssActive: { 12593 color: ["#0026bd", "#ff0000"], 12594 opacity: 1, 12595 weight: 8, 12596 bringToFront: 1 12597 }, 12598 cssInactive: [{ 12599 color: "#8900b2", 12600 opacity: 1, 12601 weight: 6 12602 }], 12603 _routes: [], 12604 _labels: [], 12605 init: function() { 12606 this.on("clearPoints", this._clearRoutes, this) 12607 }, 12608 _clearRoutes: function() { 12609 this._routes.length = 0; 12610 this._labels.length = 0 12611 }, 12612 addTrace: function(index) { 12613 if (this._inRange(index)) { 12614 with(this._item(index)) return addRoute() 12615 } 12616 }, 12617 traceItem: function(index, routeindex) { 12618 if (this._inRange(index)) { 12619 with(this._item(index)) return routeItem(routeindex) 12620 } 12621 }, 12622 setTraceRepresentation: function(index, routeIndex, points, chargeType) { 12623 if (this._inRange(index)) { 12624 with(this._item(index)) { 12625 var o = [], 12626 i, j, p; 12627 routeRep = []; 12628 for (var i = 0; i < points.length; i++) { 12629 p = points[i][0]; 12630 for (j = (i > 0 ? 1 : 0); j < p.length; j++) routeRep.push(new E.LonLat(p[j][0], p[j][1])); 12631 o.push(j = L.polyline(points[i][0], E.extend(this.cssInactive[0], { 12632 roadType: points[i][1] 12633 }))); 12634 j.on("mouseover", function() { 12635 this.hoverInRoute(routeIndex) 12636 }, this).on("mouseout", function() { 12637 this.hoverOutRoute(routeIndex) 12638 }, this).on("click", function() { 12639 this.activateRoute(routeIndex) 12640 }, this); 12641 this._addTrace.push(j) 12642 } 12643 setRouteRepresentation(routeIndex, o) 12644 } 12645 } 12646 }, 12647 addRoute: function(index, viatoll, paid) { 12648 this._routes.push({ 12649 index: index, 12650 viatoll: viatoll, 12651 paid: paid 12652 }) 12653 }, 12654 activateRoute: function(routeIndex) { 12655 if (this._activeRoute > -1) this.deactivateRoute(this._activeRoute); 12656 var route = this._routes[routeIndex]; 12657 for (var i = 0; i < this.count() - 1; i++) this._item(i).setRouteStyle(route.index[i], this.cssActive); 12658 this._activeRoute = routeIndex; 12659 if (route.label) E.$(route.label._container).addClass("routeActive"); 12660 this.fire('activateRoute', { 12661 routeIndex: routeIndex 12662 }) 12663 }, 12664 deactivateRoute: function(routeIndex) { 12665 var css = this.cssInactive[0]; 12666 var route = this._routes[routeIndex]; 12667 for (var i = 0; i < this.count() - 1; i++) this._item(i).setRouteStyle(route.index[i], E.extend(css, { 12668 sendToBack: 1 12669 })); 12670 if (route.label) E.$(route.label._container).removeClass("routeActive"); 12671 this.fire('deactivateRoute', routeIndex) 12672 }, 12673 hoverInRoute: function(routeIndex) { 12674 for (var i = 0; i < this.count() - 1; i++) this._item(i).setRouteStyle(routeIndex, { 12675 bringToFront: 1 12676 }) 12677 }, 12678 hoverOutRoute: function(routeIndex) { 12679 for (var i = 0; i < this.count() - 1; i++) this._item(i).setRouteStyle(routeIndex, { 12680 sendToBack: this._activeRoute == routeIndex ? 0 : 1 12681 }) 12682 }, 12683 getRouteSegment: function(index) { 12684 return this._item(index) 12685 }, 12686 setRouteSegment: function(index, routeIndex, b) { 12687 if (this._inRange(index)) this._item(index).setRouteSegment(routeIndex, b) 12688 }, 12689 refreshFullTrace: function() { 12690 with(this) for (var i = 0; i < count() - 1; i++) _item(i).clearRoutes(_removeTrace); 12691 this._removeTrace = this._removeTrace.concat(this._labels); 12692 this._labels.length = 0; 12693 this._routes.length = 0 12694 }, 12695 _refreshTrace: function(index, prev) { 12696 this._activeRoute = -1; 12697 if (index > 0 && prev != false) with(this._item(index - 1)) clearRoutes(this._removeTrace); 12698 with(this._item(index)) clearRoutes(this._removeTrace); 12699 this._removeTrace = this._removeTrace.concat(this._labels); 12700 this._clearRoutes() 12701 }, 12702 processTrace: function() { 12703 for (var i = 0; i < this._removeTrace.length; i++) this._layer.removeLayer(this._removeTrace[i]); 12704 this._removeTrace.length = 0; 12705 for (i = 0; i < this._addTrace.length; i++) this._layer.addLayer(this._addTrace[i]); 12706 this._addTrace.length = 0; 12707 if (this._routes.length > 0) { 12708 if (this._routes.length > 1) this.processLabel(); 12709 this.activateRoute(0) 12710 } 12711 }, 12712 getRepresentaion: function(routeIndex) { 12713 for (var i = 0, a = []; i < this.count() - 1; i++) { 12714 a = a.concat(this._item(i).routeItem(this._routes[routeIndex].index[i]).getRepresentation()) 12715 }; 12716 return a 12717 }, 12718 getRouteBounds: function(routeIndex) { 12719 for (var i = 0, b = new L.LatLngBounds(); i < this.count() - 1; i++) b.extend(this._item(i).routeItem(this._routes[routeIndex].index[i]).bounds); 12720 return b 12721 }, 12722 getMaxRouteCount: function() { 12723 var result = 0; 12724 for (var i = 0; i < this.count() - 1; i++) result = Math.max(this._item(i).routes.count(), result); 12725 return result 12726 }, 12727 processLabel: function() { 12728 function canAddLabeLOffset(map, x, y, val, offsetX, offsetY) { 12729 var a, b; 12730 for (var i = x - offsetX; i < x + offsetX; i++) 12731 for (var j = y - offsetY; j < y + offsetY; j++) { 12732 if ((a = map[i]) && (b = a[j])) { 12733 if ((b[0] == 0) || (b[0] != val)) return false 12734 } 12735 } 12736 return true 12737 }
12738 var routeCount = this._routes.length; 12739 var bounds = new L.LatLngBounds(); 12740 for (var i = 0, routeRep = []; i < routeCount; i++) { 12741 routeRep.push(this.getRepresentaion(i)); 12742 bounds.extend(this.getRouteBounds(i)); 12743 this._routes[i].label = new L.Label({ 12744 className: 'leaflet-label-route', 12745 clickable: 1, 12746 routeId: i 12747 }).setContent("Trasa " + (i + 1).toString() + "").on("click", function(a) { 12748 this.activateRoute(a.target.options.routeId) 12749 }, this); 12750 this._labels.push(this._routes[i].label) 12751 }; 12752 var map = {}; 12753 var dividerX = Math.abs((bounds.getWest() - bounds.getEast()) / 100); 12754 var dividerY = Math.abs((bounds.getSouth() - bounds.getNorth()) / 100); 12755 for (var i = 0; i < routeRep.length; i++) { 12756 for (var j = 0, a = routeRep[i], x, y; j < a.length; j++) { 12757 x = Math.round((a[j].lng - bounds.getWest()) / dividerX); 12758 y = Math.round((a[j].lat - bounds.getSouth()) / dividerY); 12759 if (!map[x]) map[x] = {}; 12760 if (!map[x][y]) map[x][y] = [i + 1, a[j]]; 12761 else if (map[x][y][0] != i + 1) map[x][y] = [0] 12762 } 12763 } 12764 var layer; 12765 var added = {}; 12766 for (var i = 0; i < routeRep.length; i++) { 12767 xoffset = 20; 12768 yoffset = 20; 12769 while (!added[i + 1] && xoffset >= 0) { 12770 for (var x in map) { 12771 for (var y in map[x]) { 12772 if (map[x][y][0] !== 0 && !added[map[x][y][0]] && map[x][y][0] == i + 1) { 12773 if (canAddLabeLOffset(map, parseInt(x), parseInt(y), map[x][y][0], xoffset, yoffset)) { 12774 this._routes[map[x][y][0] - 1].label.setLatLng(map[x][y][1]); 12775 added[map[x][y][0]] = 1 12776 } 12777 } 12778 } 12779 } 12780 xoffset -= 2; 12781 yoffset -= 2 12782 } 12783 } 12784 for (var i = 0; i < routeCount; i++) { 12785 if (!added[i + 1]) this._routes[i].label.setLatLng(routeRep[i][i == 0 ? 0 : (i == 1 ? parseInt(routeRep[i].length / 2) : routeRep[i].length - 1)]); 12786 this._layer.addLayer(this._routes[i].label) 12787 } 12788 } 12789}); 12790E.Router.RoutePointsController.prototype.addHook('init', E.Router.RoutePointsController.prototype.init); 12791E.Router.RouteRepresentation = L.Class.extend({ 12792 routeFrom: '', 12793 routeTo: '', 12794 routeDescription: '', 12795 routeItems: null, 12796 tollRoadLength: 0, 12797 tollRoadTime: 0, 12798 totalFuelCost: 0, 12799 totalRouteCost: 0, 12800 totalRouteLength: 0, 12801 totalRouteTime: 0, 12802 unreachableEntry: -1, 12803 initialize: function(options) { 12804 E.extend(this, options); 12805 this.routeItems = new Array() 12806 }, 12807 destroy: function() { 12808 this.clear(); 12809 this.routeItems.length = 0; 12810 this.routeItems = null 12811 }, 12812 findObject: function(property, val) { 12813 var lRes = -1; 12814 for (var i = 0; i < this.routeItems.length; i++) { 12815 lRes = this.routeItems[i].findObject(property, val); 12816 if (lRes) return lRes 12817 } 12818 return null 12819 }, 12820 clear: function() { 12821 for (var i = 0; i < this.routeItems.length; i++) { 12822 this.routeItems[i].destroy() 12823 } 12824 this.routeItems.length = 0 12825 } 12826}); 12827E.Router.RouteRepresentationItem = L.Class.extend({ 12828 entryCost: 0, 12829 entryDistance: 0, 12830 entryPosition: null, 12831 entryTime: 0, 12832 entryDescription: '', 12833 entryType: 0, 12834 entryId: 0, 12835 _mapObject: null, 12836 browserReportObject: null, 12837 initialize: function(options) { 12838 L.Util.extend(this, options) 12839 }, 12840 destroy: function() { 12841 this._mapObject = null; 12842 this.entryPosition = null 12843 }, 12844 _entryCost: 0, 12845 _entryDistance: 0, 12846 _entryTime: 0 12847}); 12848E.Router.RouteRepresentationSection = L.Class.extend({ 12849 sectionFrom: '', 12850 sectionTo: '', 12851 sectionCost: 0, 12852 sectionDistance: 0, 12853 sectionTime: 0, 12854 routeItems: null, 12855 representationPath: null, 12856 initialize: function(options) { 12857 L.Util.extend(this, options); 12858 this.routeItems = new Array() 12859 }, 12860 destroy: function() { 12861 this.clear() 12862 }, 12863 findObject: function(property, val) { 12864 for (var i = 0; i < this.routeItems.length; i++) { 12865 if (this.routeItems[i][property] == val) { 12866 return this.routeItems[i] 12867 } 12868 } 12869 return null 12870 }, 12871 clear: function() { 12872 for (var i = 0; i < this.routeItems.length; i++) { 12873 this.routeItems[i].destroy() 12874 } 12875 this.routeItems.length = 0 12876 }, 12877 _additionalRouteCost: 0, 12878 _tollRoad: { 12879 set: false, 12880 length: 0, 12881 time: 0, 12882 cost: 0 12883 }, 12884 _viaToll: { 12885 set: false, 12886 cost: 0, 12887 length: 0, 12888 time: 0 12889 } 12890}); 12891E.Router.include({ 12892 _messageType: { 12893 0: 1, 12894 1: 2, 12895 2: 2, 12896 3: 3, 12897 4: 3, 12898 5: 0, 12899 6: 0, 12900 7: 4, 12901 8: 3, 12902 9: 3, 12903 10: 5, 12904 11: 0, 12905 12: 1, 12906 13: 3, 12907 14: 3, 12908 15: 3, 12909 16: 3, 12910 17: 3, 12911 18: 3, 12912 19: 3, 12913 20: 3, 12914 21: 3, 12915 22: 3, 12916 23: 3, 12917 24: 3, 12918 25: 3, 12919 26: 3, 12920 27: 3, 12921 28: 0, 12922 29: 0, 12923 30: 0, 12924 31: 0, 12925 32: 0, 12926 33: 0, 12927 34: 0, 12928 35: 0, 12929 36: 0, 12930 37: 0, 12931 38: 0 12932 }, 12933 _messageType2: { 12934 3: 0, 12935 4: 0, 12936 8: 1, 12937 9: 2, 12938 13: 3, 12939 14: 2, 12940 15: 2, 12941 16: 2, 12942 17: 2, 12943 18: 2, 12944 19: 2, 12945 20: 2, 12946 21: 2, 12947 22: 2, 12948 23: 2, 12949 24: 4, 12950 25: 5, 12951 26: 6, 12952 27: 7 12953 }, 12954 _initializeRP: function() {
12955 this._repActKey = this._api.regAction(this._infoOver, this) 12956 }, 12957 _parseReport: function(obj, data) { 12958 if (data.result == 0) { 12959 this._routeRep.removeItems(false); 12960 var routes = [data].concat(data.AlternativeRoutes), 12961 par = [], 12962 pidx = this._pIndex(obj); 12963 if (pidx.length == 0) return; 12964 for (var i = 0; i < pidx.length - 1; i++) this._wayPoints._refreshTrace(pidx[i], false); 12965 for (var i = 0; i < routes.length; i++) { 12966 var representationPrecision = routes[i].RepresentationPrecision; 12967 if (representationPrecision == undefined) { 12968 representationPrecision = 5 12969 } 12970 var points = this._decode(routes[i].Representation, representationPrecision), 12971 seg = routes[i].Segment, 12972 routeIndices = [], 12973 routeIndex; 12974 for (var j = 0; j < seg.length; j++) { 12975 routeIndices.push(routeIndex = this._wayPoints.addTrace(pidx[j])); 12976 this._wayPoints.setTraceRepresentation(pidx[j], routeIndex, this._splitSections(points.slice(seg[j].Pos[0], seg[j].Pos[1] + 1), seg[j].Index, seg[j].Pos[0], obj.routeParams.vehicle)) 12977 } 12978 this._pSections(routes[i], pidx, obj, routeIndices) 12979 } 12980 this._prepareReportData2(pidx, routes); 12981 this._pReportHTML(obj); 12982 this._wayPoints.processTrace(); 12983 this._pCallback(obj.callback, data, []) 12984 } else this._pCallback(obj.callback, data, []) 12985 }, 12986 _splitSections: function(p, s, r, v) { 12987 var i, j, k, a, b, c = [ 12988 [0, p.length, 0] 12989 ], 12990 d; 12991 for (j = 0; j < s.length; j++) 12992 for (i = 0; i < s[j].length; i++) { 12993 if ((v == 0) && (j == 0)) continue; 12994 a = s[j][i]; 12995 a[0] = a[0] - r; 12996 a[1] = a[1] - r; 12997 for (k = c.length - 1; k >= 0; k--) 12998 if ((c[k][0] < a[1]) && (c[k][1] > a[0])) { 12999 d = c[k].slice(); 13000 if (d[0] <= a[0]) { 13001 if (d[0] < a[0]) c.push([d[0], a[0], d[2]]); 13002 c.push([Math.max(a[0] - 1, 0), a[1], Math.pow(2, i) + d[2]]) 13003 } 13004 if (d[1] > a[1]) c.push([a[1] - 1, d[1], d[2]]); 13005 c.splice(k, 1) 13006 } 13007 } 13008 a = []; 13009 for (j = 0; j < c.length; j++) { 13010 b = c[j]; 13011 a.push([p.slice(b[0], b[1]), b[2]]) 13012 } 13013 return a 13014 }, 13015 _tTime: function(time) { 13016 time = Math.floor(parseFloat(time) * 24 * 60 * 60); 13017 var S = time % 60; 13018 if (S < 10) S = '' + S; 13019 time = Math.floor(time / 60); 13020 var M = time % 60; 13021 time = Math.floor(time / 60); 13022 var H = time % 24; 13023 H = (H > 0) ? H + 'h ' : ''; 13024 time = Math.floor(time / 24); 13025 return ((time > 0) ? time + 'd ' : '') + H + M + 'min' 13026 }, 13027 _tLength: function(length, a) { 13028 return (Math.round(parseFloat(length) / 100) / 10).toString() + (a ? '' : ' km') 13029 }, 13030 _tCost: function(cost, a) { 13031 return (Math.round(parseFloat(cost) * 100) / 100).toString() + (a ? '' : E.lang('RR_hzl')) 13032 }, 13033 _tMessage: function(a, b, c) { 13034 var res = E.lang('RR_i' + a); 13035 switch (this._messageType[a]) { 13036 case 1: 13037 return res + b; 13038 case 2: 13039 return res + ' ' + b + ': ' + c; 13040 case 3: 13041 return res + ((c != '') ? ' ' + E.lang('RR_ic' + this._messageType2[a]) + c : ''); 13042 case 4: 13043 return res + ((c != '') ? ' ' + c : ''); 13044 case 5: 13045 return res + (b != '' ? ' ' + b : '') + (c != '' ? E.lang('RR_ic8') + c : ''); 13046 default: 13047 return res 13048 } 13049 }, 13050 _pViaToll: function(params) { 13051 var res = []; 13052 var summary = [0, 0]; 13053 if (params instanceof Array) { 13054 for (var i = 0; i < params.length; i++) { 13055 var item = params[i].split(","); 13056 summary[0] += (item[1] = parseFloat(item[1])); 13057 summary[1] += (item[2] = parseFloat(item[2])); 13058 if ((item[1] > 0) || (item[2] > 0)) { 13059 item[0] = item[0].replace("InBUA", ""); 13060 var found = false; 13061 for (var j = 0; j < res.length; j++) 13062 if (res[j].Name == item[0]) { 13063 res[j].ViaTollCos += item[1]; 13064 res[j].ViaTollLength += item[2]; 13065 found = true; 13066 break 13067 } if (!found) res.push({ 13068 Name: item[0], 13069 ViaTollCost: item[1], 13070 ViaTollLength: item[2] 13071 }) 13072 } 13073 } 13074 for (i = res.length - 1; i >= 0; i--) 13075 if (res[i][2] > 0) { 13076 res[i].ViaTollCost = Math.round(res[i][1] * 100) / 100; 13077 res[i].ViaTollLength = Math.round(res[i][2] * 10) / 10 13078 } else res.splice(i, 1) 13079 } 13080 return [summary, res] 13081 }, 13082 _buildHTMLReport: function(data) {}, 13083 _pReportError: function() { 13084 var d; 13085 if (d = E.$$(this.reportResultHandlerName)) d.clear().append(E.newElem$('div', 'RouteCalculateError').text(E.lang('TTrasowanieCalculateError'))); 13086 if (d = E.$$(this.reportReportStatsHandlerName)) d.clear().append(E.newElem$('div', 'RouteCalculateError').text(E.lang('TTrasowanieCalculateError'))) 13087 }, 13088 _reportSectionClick: function(evt, obj) { 13089 var next = (obj = E.$(obj)).nextSibling(); 13090 if (!next.visible()) obj.parent().getElem(".reportData").hide();
13091 next.toggle(); 13092 this._activeRoute = obj.att("routeId") 13093 }, 13094 _pReportHTML: function(obj) { 13095 var d, e; 13096 if (d = E.$$(this.reportResultHandlerName)) d.clear(); 13097 d.append(E.newElem$('div', 'RouteReport').text(this._pHeaderReportSummary(this._routeRep.item(0)))); 13098 d.append(e = E.newElem$('div', 'RouteReportItems')); 13099 for (var i = 0; i < this._routeRep.count(); i++) { 13100 var route = this._wayPoints._routes[i]; 13101 e.append(d = E.newElem$('div', 'RouteReportItem')); 13102 d.append(E.newElem$('div', 'RouteReport').text(this._pReportHeader('data', route.viatoll, route.paid, obj, i)).att("routeId", i)); 13103 d.append(E.newElem$('div', 'reportData').text(this._pReportSummary(route.viatoll, route.paid, obj, i) + this._gTableItem('RR_H', [{ 13104 items: ['', '', 'RR_hkm', 'RR_hzl', 'RR_htime'], 13105 css: [] 13106 }]) + this._pReportSections(route.viatoll, obj, i))) 13107 } 13108 this._setActions() 13109 }, 13110 _pHeaderReportSummary: function(b) { 13111 var s = "", 13112 e = [ 13113 ['From', 'RR_hfm', b.routeFrom], 13114 ['To', 'RR_hto', b.routeTo] 13115 ]; 13116 for (var i in e) s += E.format("<div><span class='{0}_Description'><span class='{0}_{1}'>{2}</span><span class='{1} value'>{3}</span></span></div>", ["RR_TE", e[i][0], E.lang(e[i][1]), E.lang(e[i][2])]); 13117 return s 13118 }, 13119 _pReportHeader: function(data, vt, add, obj, routeIndex) { 13120 function dr(a, b, c, d, e) { 13121 return E.format("<div class='{0}_div_hr'><hr class='{0}_hr3'></div><div class='rr_pt{4}'></div><table class='{0}' border='0'><tr><td><div class='Dist Img'></div></td><td><div class='Dv val'>{1}</div></td><td><div class='Cost Img'></div></td><td><div class='Cv val'>{2}</div></td><td><div class='Time Img'></div></td><td><div class='Tv val'>{3}</div></td></tr></table>", [d, a, b, c, e]) 13122 } 13123 var b = this._routeRep.item(routeIndex); 13124 var a = E.format("<div href='http://emapi.pl/emapi_opis/pl/?page=funkcje' target='blank' class='{0}' alt='{1}' title='{1}'>{2}</div>", ['RouteReportTotalElem', E.lang('RT_Koszt'), dr(b.totalRouteLength + ' km', b.totalRouteCost + ' zÅ', b.totalRouteTime, 'RR_TE', '')]); 13125 return a 13126 }, 13127 _pReportSummary: function(vt, add, obj, routeIndex) { 13128 function dr(a, b, c, d, e) { 13129 var s = ''; 13130 for (var i in e) s += E.format("<div><span class='{0}_Description'><span class='{0}_{1}'>{2}</span><span class='{1} value'>{3}</span></span></div>", ['RR_TE', e[i][0], E.lang(e[i][1]), E.lang(e[i][2])]); 13131 return s + E.format("<div class='{0}_div_hr'><hr class='{0}_hr3'></div><div class='rr_pt{4}'></div><table class='{0}' border='0'><tr><td><div class='Dist Img'></div></td><td><div class='Dv val'>{1}</div></td><td><div class='Cost Img'></div></td><td><div class='Cv val'>{2}</div></td><td><div class='Time Img'></div></td><td><div class='Tv val'>{3}</div></td></tr></table>", [d, a, b, c, e]) 13132 } 13133 var c = 'RR_TE'; 13134 var b = this._routeRep.item(routeIndex); 13135 var a = ''; 13136 if ((vt.sum[1] >
13136 0) && (obj.routeParams.vehicle != 0)) a += dr(this._tLength(vt.sum[1]), this._tCost(vt.sum[0]), '', c, [ 13137 ['myto', 'RR_hin', 'RR_hVT'] 13138 ], '_'); 13139 if (add.cost > 0) a += dr(this._tLength(add.dist), this._tCost(add.cost), add.time, c, [ 13140 ['additional', 'RR_hin', 'RR_hTR'] 13141 ], '_'); 13142 return a 13143 }, 13144 _gTableItem: function(cn, e, type) { 13145 var i, j, r = '', 13146 res = '', 13147 a = ['Type', 'Description', 'Dist', 'Cost', 'Time']; 13148 for (i = 0; i < e.length; i++) { 13149 for (j = 0; j < e[i].items.length; j++) r += E.format('<td class="{0}_{1}_td"><div class="{0}_{1}{3}">{2}</div></td>', [cn, a[j], E.lang(e[i].items[j]), e[i].css[j] ? e[i].css[j] : '']); 13150 res += (type == 1) ? E.format("<tr onmouseover='{0}({1},{2},0)' onclick='{0}({1},{2},1);' >{3}</tr>", [this._repActKey, e[i].id[0], e[i].id[1], r]) : ((type == 2) ? E.format("<tr>{0}</tr>", [r]) : E.format("<tr><td><table><tr>{0}</tr></table></td></tr>", [r])); 13151 res += e[i].value ? E.format("<tr><td>{0}</td></tr>", [e[i].value]) : ''; 13152 r = '' 13153 } 13154 return E.format('<table class="{0}_table">{1}</table>', [cn, res]) 13155 }, 13156 _pReportSections: function(vt, obj, routeIndex) { 13157 var i, j, b = [], 13158 a = this._routeRep.item(routeIndex).routeItems, 13159 res = [], 13160 r; 13161 if (obj.routeParams.vehicle != 0) 13162 for (i in vt) 13163 if ((i != 'sum') && (E.isA(vt[i]))) b.push({ 13164 items: ['', E.lang("RT_" + vt[i][0]), this._tLength(vt[i][2], 1), this._tCost(vt[i][1], 1), ''], 13165 css: [] 13166 }); 13167 r = b.length > 0 ? this._gTableItem('RR_SE', [{ 13168 items: ['', E.lang('RT_RM'), '', '', ''], 13169 css: [], 13170 value: this._gTableItem('RR_EE', b, 2) 13171 }], 0) : ''; 13172 for (i = 0; i < a.length; i++) with(a[i]) { 13173 b = []; 13174 for (j = 0; j < routeItems.length; j++) with(routeItems[j]) b.push({ 13175 items: ['', entryDescription, entryDistance, entryCost, entryTime], 13176 css: [entryType], 13177 id: [i, j] 13178 }); 13179 res.push({ 13180 items: ['', sectionFrom + ' - ' + sectionTo, sectionDistance, sectionCost, sectionTime], 13181 value: this._gTableItem('RR_EE', b, 1), 13182 css: [] 13183 }) 13184 } 13185 return r + this._gTableItem('RR_SE', res, 0) 13186 }, 13187 _pReportViaToll: function(vt) { 13188 var i, j, res = []; 13189 for (i in vt[1]) with(vt[1][i]) if ((ViaTollCost > 0) || (ViaTollLength > 0)) res.push({ 13190 items: ['', Name, ViaTollLength, ViaTollCost, ''], 13191 css: [] 13192 }); 13193 return this._gTableItem('RR_VT', res) 13194 }, 13195 _pSections: function(d, p, o, index) { 13196 function decToll(a, b) { 13197 if (o.routeParams.vehicle != 0) a[9] -= b * 1000; 13198 return a 13199 } 13200 var it = this._pItinerary(d, o), 13201 i, j, u, s = it[1], 13202 it = it[0]; 13203 for (i = 0; i < d.Segment.length; i++) { 13204 var v = [], 13205 r = []; 13206 for (j = 0, u = d.Segment[i].Roads; j < u.length; j++) r.push(u[j].split(',')); 13207 for (j = 0, u = d.Segment[i].ViaToll; j < u.length; j++) v.push(u[j].split(',')); 13208 this._wayPoints.setRouteSegment(p[i], index[i], { 13209 summary: decToll(d.Segment[i].Summary.split(','), s[i]), 13210 roads: r, 13211 viaToll: v, 13212 itrep: it[0][i], 13213 itdata: it[1][i] 13214 }) 13215 } 13216 }, 13217 _pItinerary: function(data, obj) { 13218 var i = 0, 13219 it = data.Itinerary.split(','), 13220 lastNameIndex = -1, 13221 lastDoneIndex = -1, 13222 viaTollIndex = 0, 13223 lCost = 0, 13224 lTime = 0, 13225 lDistance = 0, 13226 pi = parseInt, 13227 pf = parseFloat, 13228 res = [ 13229 [], 13230 [] 13231 ], 13232 routeSection, rs1, vts = new E.Router.ViaTollLength(), 13233 vtsa = []; 13234 obj = obj.routeParams.vehicle == 0; 13235 while (i < it.length) { 13236 switch (pi(it[i])) { 13237 case 1: { 13238 res[0].push(routeSection = new E.Router.RouteRepresentationSection()); 13239 res[1].push(rs1 = { 13240 items: [] 13241 }); 13242 with(routeSection) { 13243 sectionFrom = it[i + 2] != '' ? it[i + 2] : it[i + 1];
13244 lCost = pf(it[i + 3]); 13245 lTime = pf(it[i + 7]); 13246 lDistance = pf(it[i + 4]) 13247 } 13248 break 13249 } 13250 case 2: { 13251 vtsa.push(vts.endSection(pf(it[i + 4]))); 13252 if ((i + 8 == it.length) && (it[i + 2] == '')) { 13253 it[i + 2] = it[i + 1]; 13254 it[i + 1] = E.lang() 13255 } 13256 with(routeSection) { 13257 sectionTo = it[i + 2] != '' ? it[i + 2] : it[i + 1]; 13258 rs1.sum = [pf(it[i + 3]) - lCost, pf(it[i + 7]) - lTime, pf(it[i + 4]) - lDistance]; 13259 sectionCost = this._tCost(pf(it[i + 3]) - lCost, 1); 13260 sectionTime = this._tTime(pf(it[i + 7]) - lTime); 13261 sectionDistance = this._tLength(pf(it[i + 4]) - lDistance, 1) 13262 } 13263 break 13264 } 13265 case 13: { 13266 var it1 = it[i + 2]; 13267 var it0 = it[i + 1]; 13268 var skip = (it1 == ''); 13269 if ((!skip) && (it0.length > it1.length) && (it0.search(it1) == 0)) { 13270 for (var j = it1.length; j < it0.length; j++) 13271 if (it0.charAt(j) == ',') { 13272 skip = true; 13273 break 13274 } else if (it0.charAt(j) == ' ') continue; 13275 else break 13276 } else break; 13277 if ((!skip) && (lastNameIndex > 0) && (lastDoneIndex == lastNameIndex) && (it[lastNameIndex] == 13)) skip = (it[lastNameIndex + 1] == it[i + 1]) && ((it[lastNameIndex + 2] == it[i + 2])); 13278 if (skip) { 13279 i += 8; 13280 continue 13281 } 13282 lastNameIndex = i 13283 } 13284 case 28: 13285 case 29: 13286 vts.setToll(pi(it[i]) == 28, pf(it[i + 3])); 13287 break; 13288 case 11: 13289 case 35: 13290 case 36: 13291 i += 8; 13292 continue; 13293 case 37: { 13294 vts.setViaToll(1, pf(it[i + 3])); 13295 if (obj) { 13296 i += 8; 13297 continue 13298 } 13299 viaTollIndex = i; 13300 break 13301 } 13302 case 38: { 13303 vts.setViaToll(0, pf(it[i + 3])); 13304 if (obj) { 13305 i += 8; 13306 continue 13307 } 13308 viaTollIndex = (viaTollIndex == -1) ? 0 : viaTollIndex; 13309 break 13310 } 13311 } 13312 var routeItem = new E.Router.RouteRepresentationItem(); 13313 with(routeItem) { 13314 entryDescription = this._tMessage(it[i], it[i + 1], it[i + 2]); 13315 entryPosition = new E.LonLat(it[i + 5], it[i + 6]); 13316 entryType = it[i] 13317 } 13318 rs1.items.push([pf(it[i + 3]) - lCost, pf(it[i + 7]) - lTime, pf(it[i + 4]) - lDistance]); 13319 routeSection.routeItems.push(routeItem); 13320 i += 8 13321 } 13322 return [res, vtsa] 13323 }, 13324 _prepareReportData2: function(idx, routes) { 13325 var rep, i, j, k, l, m, pi = parseInt, 13326 pf = parseFloat, 13327 s, p, li = 0, 13328 lc = 0, 13329 ld = 0, 13330 lt = 0, 13331 si, vt = { 13332 sum: [0, 0] 13333 }, 13334 wp = this._wayPoints, 13335 routeIndex; 13336 for (m = 0; m < this._wayPoints.getMaxRouteCount(); m++) { 13337 li = 0, lc = 0, ld = 0, lt = 0, si, vt = { 13338 sum: [0, 0] 13339 }; 13340 rep = this._routeRep.addItem(); 13341 routeIndex = []; 13342 for (i = 0; i < wp.count() - 1; i++) routeIndex.push(wp.traceItem(i, m) ? m : 0); 13343 for (i = 0; i < wp.count() - 1; i++) rep.routeItems.push(wp.traceItem(i, routeIndex[i]).itrep); 13344 si = idx[0]; 13345 if (si > 0) { 13346 i = wp.traceItem(si, routeIndex[0]).itdata; 13347 li = 0; 13348 lc = i.sum[0]; 13349 lt = i.sum[1]; 13350 ld = i.sum[2] 13351 } 13352 i = 0; 13353 for (i = si; i < wp.count() - 1; i++) { 13354 s = wp.traceItem(i, routeIndex[i]).itdata.items; 13355 p = rep.routeItems[i].routeItems; 13356 for (var k = 0; k < p.length; k++) with(p[k]) { 13357 si = s[k]; 13358 entryCost = this._tCost(si[0] + lc, 1); 13359 entryTime = this._tTime(si[1] + lt); 13360 entryDistance = this._tLength(si[2] + ld, 1) 13361 } 13362 lc += si[0]; 13363 lt += si[1]; 13364 ld += si[2] 13365 } 13366 for (j = 0, i = [ 13367 ['totalRouteLength', 1, 2], 13368 ['totalRouteTime', 2, 3], 13369 ['totalRouteCost', 0, 4], 13370 ['totalFuelCost', 0, 5], 13371 ['totalViaTollLength', 1, 6], 13372 ['totalViaTollCost', 0, 7], 13373 ['totalChargeRoadLength', 1, 8], 13374 ['tollRoadLength', 1, 9], 13375 ['tollRoadTime', 2, 10], 13376 ['additionalRouteCost', 0, 11] 13377 ]; j < i.length; j++) rep[i[j][0]] = 0; 13378 var bound = new L.LatLngBounds(); 13379 for (j = 0;
13379 j < wp.count() - 1; j++) { 13380 si = wp.traceItem(j, routeIndex[j]); 13381 bound.extend(si.bounds); 13382 s = si.summary; 13383 for (k = 0; k < i.length; k++) rep[i[k][0]] += pf(s[i[k][2]]); 13384 for (k = 0, s = si.viaToll; k < s.length; k++) { 13385 p = s[k][0].replace("InBUA", ""); 13386 if (!vt[p]) vt[p] = [p, 0, 0]; 13387 (l = vt[p])[1] += pf(s[k][1]); 13388 l[2] += pf(s[k][2]) 13389 } 13390 } 13391 for (k in vt) 13392 if (k != 'sum') { 13393 vt.sum[0] += vt[k][1], vt.sum[1] += vt[k][2] 13394 } for (k = 0, j = ['_tCost', '_tLength', '_tTime']; k < i.length; k++) rep[i[k][0]] = this[j[i[k][1]]](rep[i[k][0]], 1); 13395 with(rep) { 13396 with(routeItems[routeItems.length - 1]) with(routeItems[routeItems.length - 1]) { 13397 unreachableEntry = routes[0].UEntry; 13398 routeFrom = rep.routeItems[0].sectionFrom; 13399 routeTo = sectionTo 13400 } 13401 p = { 13402 dist: (pi(totalChargeRoadLength) + pi(tollRoadLength)) * 1000, 13403 time: tollRoadTime, 13404 cost: pf(additionalRouteCost) 13405 } 13406 } 13407 this._wayPoints.addRoute(routeIndex, vt, p) 13408 } 13409 if (this._isMap && !this.preserveViewport) this._map.setBounds(bound) 13410 }, 13411 _prepareReportData: function(idx, d, index) { 13412 var rep = this._routeRep.addItem(), 13413 i, j, l, pi = parseInt, 13414 pf = parseFloat, 13415 s, p, li = 0, 13416 lc = 0, 13417 ld = 0, 13418 lt = 0, 13419 si, vt = { 13420 sum: [0, 0] 13421 }, 13422 wp = this._wayPoints; 13423 rep.routeItems.length = 0; 13424 for (i = 0; i < wp.count() - 1; i++) rep.routeItems.push(wp.traceItem(i, index).itrep); 13425 si = idx[0]; 13426 if (si > 0) { 13427 i = wp.traceItem(si, index).itdata; 13428 li = 0; 13429 lc = i.sum[0]; 13430 lt = i.sum[1]; 13431 ld = i.sum[2] 13432 } 13433 i = 0; 13434 for (i = si; i < wp.count() - 1; i++) { 13435 s = wp.traceItem(i, index).itdata.items; 13436 p = rep.routeItems[i].routeItems; 13437 for (var k = 0; k < p.length; k++) with(p[k]) { 13438 si = s[k]; 13439 entryCost = this._tCost(si[0] + lc, 1); 13440 entryTime = this._tTime(si[1] + lt); 13441 entryDistance = this._tLength(si[2] + ld, 1) 13442 } 13443 lc += si[0]; 13444 lt += si[1]; 13445 ld += si[2] 13446 } 13447 for (j = 0, i = [ 13448 ['totalRouteLength', 1, 2], 13449 ['totalRouteTime', 2, 3], 13450 ['totalRouteCost', 0, 4], 13451 ['totalFuelCost', 0, 5], 13452 ['totalViaTollLength', 1, 6], 13453 ['totalViaTollCost', 0, 7], 13454 ['totalChargeRoadLength', 1, 8], 13455 ['tollRoadLength', 1, 9], 13456 ['tollRoadTime', 2, 10], 13457 ['additionalRouteCost', 0, 11] 13458 ]; j < i.length; j++) rep[i[j][0]] = 0; 13459 var bound = new L.LatLngBounds(); 13460 for (j = 0; j < wp.count() - 1; j++) { 13461 si = wp.traceItem(j, index); 13462 bound.extend(si.bounds); 13463 s = si.summary; 13464 for (k = 0; k < i.length; k++) rep[i[k][0]] += pf(s[i[k][2]]); 13465 for (k = 0, s = si.viaToll; k < s.length; k++) { 13466 p = s[k][0].replace("InBUA", ""); 13467 if (!vt[p]) vt[p] = [p, 0, 0]; 13468 (l = vt[p])[1] += pf(s[k][1]); 13469 l[2] += pf(s[k][2]) 13470 } 13471 } 13472 for (k in vt) 13473 if (k != 'sum') { 13474 vt.sum[0] += vt[k][1], vt.sum[1] += vt[k][2] 13475 } for (k = 0, j = ['_tCost', '_tLength', '_tTime']; k < i.length; k++) rep[i[k][0]] = this[j[i[k][1]]](rep[i[k][0]], 1); 13476 with(rep) { 13477 with(routeItems[routeItems.length - 1]) with(routeItems[routeItems.length - 1]) { 13478 unreachableEntry = d.UEntry; 13479 routeFrom = rep.routeItems[0].sectionFrom; 13480 routeTo = sectionTo 13481 } 13482 p = { 13483 dist: (pi(totalChargeRoadLength) + pi(tollRoadLength)) * 1000, 13484 time: tollRoadTime, 13485 cost: pf(additionalRouteCost) 13486 } 13487 } 13488 if (this._isMap && !this.preserveViewport) this._map.setBounds(bound); 13489 return [vt, p] 13490 }, 13491 _pCallback: function(call, data, toll) { 13492 if (!call) return; 13493 var r = {}, 13494 i, j, k, p, l, t, n, s, wp = this._wayPoints; 13495 t = [ 13496 ['Length', 0], 13497 ['Time', 1], 13498 ['FuelCost', 2], 13499 ['VehicleKilometerCost', 2], 13500 ['VehicleHourCost', 2], 13501 ['DriverKilometerCost', 2], 13502 ['DriverHourCost', 2] 13503 ]; 13504 for (j = 0;
13504 j < wp.count() - 1; j++) { 13505 s = wp._item(j).roads; 13506 for (i = 0; i < s.length; i++) { 13507 l = s[i]; 13508 p = l[0].replace("inBUA", ''); 13509 if (!r[p]) { 13510 n = r[p] = { 13511 'RoadType': p 13512 }; 13513 for (k = 0; k < t.length; k++) n[t[k][0]] = 0 13514 } 13515 n = r[p]; 13516 for (k = 0; k < t.length; k++) n[t[k][0]] += l[k + 1] 13517 } 13518 } 13519 j = []; 13520 for (i in r) { 13521 for (k = 0, p = ['_tLength', '_tTime', '_tCost']; k < t.length; k++) r[i][t[k][0]] = this[p[t[k][1]]](r[i][t[k][0]], 1); 13522 j.push(r[i]) 13523 } 13524 p = []; 13525 for (i in toll[0]) 13526 if (i != 'sum') p.push({ 13527 Cost: this._tCost(toll[0][i][1]), 13528 RoadType: i, 13529 Length: this._tLength(toll[0][i][2]) 13530 }); 13531 call({ 13532 'routeRepresentation': this._routeRep, 13533 'roadResults': j, 13534 'tollResults': p, 13535 'result': data.result 13536 }) 13537 }, 13538 _setActions: function() { 13539 E.$('.RR_EE_table').hide(); 13540 E.$('.RR_SE_Type').addClass('expand'); 13541 E.$('.RR_SE_Type').click(this._expandCoolapse) 13542 }, 13543 _expandCoolapse: function() { 13544 var a = E.$(this); 13545 var b = a.parent(['td', 'td', 'tr']).nextSibling().getElem('.RR_EE_table'); 13546 b.visible(a.hasClass('expand', 'hide')) 13547 }, 13548 _infoOver: function(b, c, a) { 13549 var d = this.routeRepresentation(), 13550 e = (c == 0) ? ((b > 0) ? d.routeItems[b - 1].routeItems.length - 1 : -1) : c - 1, 13551 f; 13552 with(d.routeItems[b]) with(routeItems[c]) { 13553 f = (c == routeItems.length - 1) ? ((b < d.routeItems.length - 1) ? 0 : -1) : c + 1; 13554 var s = '<div><table><tr>' + ((e != -1) ? E.format("<td><div class='RR_EP' onclick='{0}({1},{2});'></div></a></td>", [this._repActKey, (e == c - 1) ? b : b - 1, e]) : '') + ((f != -1) ? E.format("<td><div class='RR_EN' onclick='{0}({1},{2});'></div></a></td>", [this._repActKey, (f == c + 1) ? b : b + 1, f]) : '') + '</tr></table></div>'; 13555 this._map.showPopup(entryPosition, E.format("<div class='{0}S'>{1} {2} - {3}</div><table class='{0}DT'><tr><td><div class='{0}D'>{13}: </div></td><td class='{10}_td'><div class='{10}{11}'></div></td><td><div class='{0}D'>{12}</div></td></tr></table><div class='{0}T'>{4}: {5}</div><div class='{0}L'>{6}: {7}</div><div class='{0}C'>{8}: {9}</div>", ['RR_EI_', E.lang('RR_lo'), sectionFrom, sectionTo, E.lang('RR_htime'), entryTime, E.lang('RR_hcost'), entryCost, E.lang('RR_hdist'), entryDistance, 'RR_EE_Type', entryType, entryDescription, E.lang('RR_ld')]) + s); 13556 if (a == 1) this._map.setCenterPos(entryPosition) 13557 } 13558 } 13559}); 13560E.Router.ViaTollLength = L.Class.extend({ 13561 summary: 0, 13562 start: 0, 13563 type: 0, 13564 setValue: function(begin, km, type) { 13565 if (begin) { 13566 this.type |= type; 13567 this.start = km 13568 } else { 13569 if (this.type == 3) this.summary += km - this.start; 13570 this.type &= ~type 13571 } 13572 }, 13573 setViaToll: function(begin, km) { 13574 this.setValue(begin, km, 1) 13575 }, 13576 setToll: function(begin, km) { 13577 this.setValue(begin, km, 2) 13578 }, 13579 endSection: function(km) { 13580 var km1 = 0; 13581 if (this.type == 3) { 13582 km1 = km - this.start; 13583 this.start = km 13584 } 13585 return km1 + this.summary 13586 } 13587}); 13588E.Router.prototype.addHook('onRouteCalc', E.Router.prototype._parseReport); 13589E.Router.prototype.addHook('initialize', E.Router.prototype._initializeRP); 13590E.Router.RouteContext = E.Actions.Item.Context.extend({ 13591 _router: null, 13592 initialize: function(name, router) { 13593 this._name = name; 13594 this._router = router 13595 } 13596}); 13597E.Router.RouteContextCalculateRoute = E.Router.RouteContext.extend({ 13598 onContext: function(pos) { 13599 var router = this._router; 13600 router.calculateRoute(router._vehicles.item(0), { 13601 journeyStartTime: 1 / 24 13602 }, 0, { 13603 useGroundRoad: true, 13604 useFerry: true, 13605 useTollRoad: true, 13606 useVignetteRoads: true, 13607 useDifficulties: true 13608 }, function(pos) { 13609 alert("Trasa zostaÅa obliczona") 13610 }) 13611 } 13612}); 13613E.Router.RouteContextAddFromPoint = E.Router.RouteContext.extend({ 13614 onContext: function(pos) { 13615 this._router.addWaypoint(pos, 0, null) 13616 } 13617}); 13618E.Router.RouteContextAddViaPoint = E.Router.RouteContext.extend({ 13619 onContext: function(pos) { 13620 this._router.addWaypoint(pos, 1, null) 13621 } 13622}); 13623E.Router.RouteContextAddToPoint = E.Router.RouteContext.extend({ 13624 onContext: function(pos) { 13625 this._router.addWaypoint(pos, 2, null) 13626 } 13627}); 13628E.Control.Timetable = L.Class.extend({ 13629 _div: null, 13630 _closeBox: null, 13631 _map: '', 13632 initialize: function(map) { 13633 this._map = map; 13634 this._div = E.newElem$("div", "etrTimetable_div", document.body); 13635 this._map = map.on("ETR_ShowTimeTable", this.doShowTimeTable, this) 13636 }, 13637 _buildTimetable: function(timesArray, lineName, lineDirectionName, lineType, glossary) { 13638 function buildTable(array, title, skip) { 13639 function td(no) { 13640 return (no < 10 ? "0" : '') + no 13641 }; 13642 13643 function c(a, b) { 13644 return E.format("<tr><td class='Time'>{0}</td><td class='Min'>{1}</td></tr>", [a, b]) 13645 } 13646 var i, j, k, b, res = ''; 13647 for (i = 0; i <= 23; i++) { 13648 k = ""; 13649 if (i in skip) { 13650 if (i in array) 13651 for (j = 0; j < array[i].length; j++) { 13652 b = array[i][j][1]; 13653 k += E.format("<span class='Min'style='{1}'>{0}</span>", [td(array[i][j][0]) + b.replace('_', ''), b.indexOf('_') > -1 ? "text-decoration=underline" : '']) 13654 } 13655 res += c(i, k) 13656 } 13657 } 13658 return E.format("<table><tr><td style='width:25px'></td><td style='margin-left:30%;font-style:italic'>{0}</td></tr>{1}{2}</table>", [title, c(E.lang("ET_G"), E.lang("ET_M")), res]) 13659 } 13660 var i, a = ['WE', 'SA', 'SU'], 13661 skip = [], 13662 items = []; 13663 for (i = 0; i <= 23; i++) 13664 if (timesArray["WE"][i] || timesArray["SA"][i] || timesArray["SU"][i]) skip[i] = true; 13665 for (i = 0; i < a.length; i++) items.push(buildTable(timesArray[a[i]], E.lang("ET_" + a[i]), skip)); 13666 for (var i = 0, a = ''; i < glossary.length; i++) a += '<div>' + glossary[i] + '</div>'; 13667 return E.newElem$('div', 'ETRTT').text(E.format("<div class='Border Top'></div><div class='data'><div class='Number'>{0}</div><div class='Title'>{1} {2}</div><div class='close' onclick='E.$(this).parent().parent().hide().clear();'></div><br/>'<table><tr><td width='40%'>{3}</td><td width='30%'>{4}</td><td width='30%'>{5}</td></table><div class='Glossary'>{6}</div><div class='Logo Logo{7}' onclick='window.open(\"http://www.emapi.pl/css/etr/loga/redirect.php?cid={7}\", \"MPK\");'></div></div><div class='Border Bottom'></div>", [lineName, (lineType == '0' ? E.lang("ET_T") : (lineType == '3') ? E.lang("ET_B") : "???"), E.lang("ET_D") + lineDirectionName, items[0], items[1], items[2], a, timesArray["STOP_ID"].substr(0, 3)])) 13668 }, 13669 parseTimesArray: function(data) { 13670 var result = [], 13671 add = function(time, attribute, type) { 13672 for (var i = 0, tmp = time.split(":"); i < tmp.length; i++) tmp[i] = parseInt(tmp[i], 10); 13673 if (!((time = tmp)[0] in result[type])) result[type][time[0]] = []; 13674 var t = result[type][time[0]]; 13675 for (var i = 0; i < t.length; i++) 13676 if (t[i][0] == time[1] && t[i][1] == attribute) return; 13677 t.push([time[1], attribute]) 13678 }, 13679 i, j, k, tmp, wkd, a = { 13680 'ALL': ['WE', 'SA', 'SU'], 13681 'WEE': ['SA', 'SU'], 13682 'SAT': ['SA'], 13683 'SUN': ['SU'] 13684 }; 13685 result["WE"] = []; 13686 result["SA"] = []; 13687 result["SU"] = []; 13688 for (i = 0; i < data.length; i++) { 13689 tmp = data[i].split("|"); 13690 for (j = 0, wkd = tmp[0].split(","); j < wkd.length; j++) { 13691 if (a[wkd[j]]) 13692 for (k = 0; k < a[wkd[j]].length; k++) add(tmp[1], tmp[2], a[wkd[j]][k]); 13693 else add(tmp[1], tmp[2], 'WE') 13694 } 13695 } 13696 return result 13697 }, 13698 close: function() { 13699 this._div.hide().clear() 13700 }, 13701 doShowTimeTable: function(e) { 13702 var b = e.param; 13703 this._map.eTR_Timetable({ 13704 StopId: b[0], 13705 LineId: b[1], 13706 LineDirection: b[2] 13707 }, this._onShowTimeTable, this, { 13708 lineName: b[3], 13709 lineDirectionName: b[4], 13710 lineType: b[5], 13711 stopId: b[0], 13712 lineId: b[1] 13713 }) 13714 }, 13715 _onShowTimeTable: function(data, obj) { 13716 with(obj) { 13717 var timesArray = this.parseTimesArray(data.Timetable); 13718 timesArray["STOP_ID"] = obj.stopId; 13719 this._div.hide().clear().append(this._buildTimetable(timesArray, lineName, lineDirectionName, lineType, data.Glossary)).show() 13720 } 13721 } 13722}); 13723E.Map.addInitHook(function() { 13724 new E.Control.Timetable(this) 13725}); 13726E.Router.include({ 13727 _etr: null, 13728 _initETR: function() { 13729 this._etr = { 13730 reports: [], 13731 headerClick: this._api.regAction(this._eHeaderC, this), 13732 stopsClick: this._api.regAction(this._eStopsClick, this), 13733 markerMove: this._api.regAction(this._eStopsMove, this), 13734 timeTable: this._api.regAction(function(a) { 13735 this._map._map.fire('ETR_ShowTimeTable', { 13736 param: a 13737 }) 13738 }, this), 13739 markers: [], 13740 iconStop: { 13741 icon: L.icon({ 13742 className: 'ETR_IconStop', 13743 iconUrl: E.blank 13744 }) 13745 }, 13746 markerActive: L.marker([0, 0], { 13747 icon: L.icon({ 13748 className: 'ETR_IconStopA', 13749 iconUrl: E.blank 13750 }) 13751 }) 13752 } 13753 }, 13754 calculateETRRoute: function(p, callback) { 13755 with(this) { 13756 var wp = this._wayPoints.getPointsRange(), 13757 a, i, params = E.format("routespriority={0}|minmovetime={1}|maxwalkdistance={2}", [p.routesPriority, p.minMoveTime, p.maxWalkDistance]); 13758 if (wp.length != 2) return; 13759 for (i = 0, a = ['avoidTrams', 'avoidBuses', 'avoidSubway', 'avoidRail']; i < a.length; i++) 13760 if (p[a[i]]) params += '|' + a[i].toLowerCase() + '=true'; 13761 this.calculateProgress = true; 13762 this.fire('beforeCalculateRoute'); 13763 this._api.eTR_FindRoute({ 13764 StartLat: wp[0].lat, 13765 StartLon: wp[0].lng, 13766 FinishLat: wp[1].lat, 13767 FinishLon: wp[1].lng, 13768 DateTimeStart: p.dateTimeStart, 13769 DateTimeFinish: p.dateTimeFinish, 13770 Params: params, 13771 DateTimeStart: p.DateTimeStart, 13772 DateTimeFinish: p.DateTimeFinish 13773 }, this._onETRRoute, this, { 13774 callback: callback 13775 }) 13776 } 13777 }, 13778 _onETRRoute: function(data, scope) { 13779 if (this._isMap) { 13780 with(this._etr) this._layer.clearObjects(), reports = []; 13781 if (data.length <= 0) { 13782 E.Overlay.showMessage(E.lang("ETR_BR")); 13783 return 13784 } 13785 var rs = '', 13786 a = E.$(this.reportResultHandlerName).text(""), 13787 i, res; 13788 for (var i = 0; i < data.length; i++) res = this.parseETRReport(data[i], i), rs += res[0], this._etr.reports.push(res[1]); 13789 a.text(rs); 13790 for (i = 0, a = E.$(".ETR_ShowStops").elem(); i < a.length; i++) E.Tooltip.makeTooltip(a[i], E.lang("ET_RSS"), 2); 13791 for (i = 0, a = E.$(".ETR_HideStops").elem(); i < a.length; i++) E.Tooltip.makeTooltip(a[i], E.lang("ET_RHS"), 2); 13792 E.$("content_itc").childs()[0].click() 13793 } 13794 if (scope.callback) scope.callback(data); 13795 this.fire("afterCalculateRoute", { 13796 elem: 'etr' 13797 }) 13798 }, 13799 parseETRReport: function(data, j) { 13800 function getStop(stop, k, i) { 13801 with(stop) return E.format("<a href='#' onclick=\"{2},2);\" onmouseOver=\"{2},1);\" onmouseOut=\"{2},0);\"><div>[{0}]{1}</div></a>", [DepartureTime, Name.replace(/\(\d+\)/, ""), i]) 13802 }; 13803 var route = data.Route, 13804 i, k, res = '', 13805 rd = '', 13806 a, b; 13807 with(route) { 13808 for (i = 1; i < RouteItems.length - 1; i++) with(RouteItems[i]) res += E.format("<div class='ETR_IR' style='display:inline'><img class='ic_{0}' src='{2}'/><span class='desc'>{1}</span></div>", [LineType, LineName.split("|")[0], E.blank]); 13809 res = E.format("<div class='ETR_RH ETR_RH_I' onclick='{6}({7})'><div {5}<div class='ETR_RHD'>{0}-{1}</b>(<b>{2} min.</b> +{3} min. {4})</div></div>", [TripStartTime.substr(0, 5), TripFinishTime.substr(0, 5), TotalRideTime <= 0 ? 1 : TotalRideTime, TotalWalkTime <= 0 ? 1 : TotalWalkTime, E.lang("ET_ROF"), res, this._etr.headerClick, j]); 13810 for (i = 0; i < RouteItems.length; i++) { 13811 with(RouteItems[i]) { 13812 rd += E.format("<div class='ETR_IR'><img class='ic_{0}' src='{4}'/><span class='desc'>{1} ({2} {3})</span></div>", LineType < 4 ? [LineType, (d = LineName.split("|"))[0], E.lang('ET_D'), d[1], E.blank] : [LineType, E.lang('ET_OFA') + " " + (d = Cost.split('|'))[0] + " min.", d[1] + " m.", E.lang("ET_RISL"), E.blank]); 13813 if (LineType < 4) { 13814 b = this._etr.markerMove + '(' + j + ',' + i + ','; 13815 a = Stops.length; 13816 rd += "<div class='stops'>"; 13817 rd += getStop(Stops[0], 0, b + '0'); 13818 if (a > 2) { 13819 rd += E.format("<div class='aStops' id='ETRR{3}_{4}'><a href='#' onclick=\"{2}('ETRR{3}_{4}',1);\"><div class='ETR_ShowStops'>... {0} {1}</div></a><a href='#' style='display:none' onclick=\"{2}('ETRR{3}_{4}',0);\"><div class='hide ETR_HideStops' ><</div></a>", [E.lang("ET_RNOS"), a - 2, this._etr.stopsClick, j, i]); 13820 rd += "<div style='display:none'>"; 13821 for (k = 1; k < a - 1; k++) rd += getStop(Stops[k], a, b + k); 13822 rd += "</div></div>" 13823 } 13824 rd += getStop(Stops[a - 1], a - 1, b + (a - 1)); 13825 rd += "</div>" 13826 } 13827 } 13828 } 13829 } 13830 res += "<div class='ETR_RD'>" + rd + "</div>"; 13831 return [res, { 13832 data: data 13833 }] 13834 }, 13835 _eHeaderC: function(a) { 13836 with(this._etr) { 13837 E.$(".ETR_RD").hide(); 13838 E.$(".ETR_RH").replaceClass("ETR_RH_A", "ETR_RH_I"); 13839 with(E.$("content_itc").childs()[a * 2]) if (!hasClass("ETR_RH_A", "ETR_RH_I")) { 13840 nextSibling().show(); 13841 this._eShowTrack(reports[a].data) 13842 } 13843 } 13844 }, 13845 _eStopsClick: function(a, b) { 13846 a = E.$(a).childs(); 13847 a[0].visible(!b); 13848 a[1].visible(b); 13849 a[2].visible(b) 13850 }, 13851 _eShowTrack: function(d) { 13852 var a, i, b, j, c, e = new L.LatLngBounds(); 13853 with(d.Route) { 13854 this._layer.clearLayers(); 13855 for (i = 0; i < RouteItems.length; i++) with(RouteItems[i]) { 13856 a = []; 13857 for (j = 0, b = (d.Trips[i].length > 0) ? d.Trips[i] : Stops; j < b.length; j++) a.push([b[j].Latitude, b[j].Longitude]); 13858 e.extend(a); 13859 this._layer.addLayer(L.polyline(a, { 13860 opacity: 0.8, 13861 color: ["#B200FF", "#E6E163", "#50B376", "#3977E3", "#7F0037"][LineType > 3 ? 4 : LineType] 13862 })); 13863 if ((i > 0) && (i < RouteItems.length - 1)) 13864 for (j = 0, b = Stops; j < b.length - 1 + (i < RouteItems.length - 2 ? 0 : 1); j++) this._layer.addLayer(b[j]._icon = this._ePerpareMarker([b[j].Latitude, b[j].Longitude], this._etr.iconStop, [b[j].Id, LineId, b[j].DepartureTime, LineName, LineType])); 13865 if ((LineType < 4) && (b.length > 0)) this._layer.addLayer(this._ePerpareMarker([b[0].Latitude, b[0].Longitude], { 13866 icon: L.icon({ 13867 iconUrl: "csse/u/etr/mapIcon/?i=" + LineType + "&t=" + LineName.split("|")[0], 13868 className: 'ETR_IconLine' 13869 }) 13870 }, [b[0].Id, LineId, b[0].DepartureTime, LineName, LineType])) 13871 } 13872 } 13873 this._map.setBounds(e) 13874 }, 13875 _ePerpareMarker: function(a, b, c) { 13876 a = L.marker(a, b); 13877 a.on('click', this._eMarkerClick, this); 13878 a.etr = c; 13879 return a 13880 }, 13881 _eStopsMove: function(a, b, c, d) { 13882 with(this._etr) { 13883 this._layer.removeLayer(markerActive); 13884 if (d) { 13885 with(reports[a].data.Route.RouteItems[b].Stops[c]) if (d == 1) { 13886 markerActive.setLatLng([Latitude, Longitude]); 13887 this._layer.addLayer(markerActive) 13888 } else _icon.fire('click') 13889 } 13890 } 13891 }, 13892 _eMarkerClick: function(a) { 13893 a = a.target; 13894 var b, stopId = a.etr[0].split("|")[0], 13895 lineId = (b = a.etr[1].split("|"))[0], 13896 lineDirection = b[1]; 13897 this._api.eTR_Timetable({ 13898 StopId: stopId, 13899 LineId: lineId, 13900 LineDirection: lineDirection 13901 }, this._eShowStopDepartures, this, a); 13902 this._api.eTR_StopLines(stopId, this._eShowStopLines, this, a) 13903 }, 13904 _eTim
13904esArray: E.Control.Timetable.prototype.parseTimesArray, 13905 _eShowStopDepartures: function(data, obj) { 13906 var timesArray = this._eTimesArray(data.Timetable), 13907 tmp = obj.etr[2].split(":"), 13908 days = ["SU", "WE", "WE", "WE", "WE", "WE", "SA", "SU"], 13909 day = days[(new Date()).getDay()], 13910 i, twoDigits = function(no) { 13911 return (no < 10) ? "0" + no : no 13912 }; 13913 for (i = 0; i < tmp.length; i++) tmp[i] = parseInt(tmp[i]); 13914 var prevHour = tmp[0], 13915 prevMin = tmp[1], 13916 nextHour = tmp[0], 13917 nextMin = tmp[1]; 13918 for (var i = tmp[0]; i >= 0; i--) 13919 if (i in timesArray[day]) { 13920 prevHour = i; 13921 if (prevHour < tmp[0]) { 13922 prevMin = timesArray[day][i][timesArray[day][i].length - 1][0]; 13923 break 13924 } 13925 for (var j = 0; j < timesArray[day][i].length; j++) 13926 if (timesArray[day][i][j] < tmp[1]) prevMin = timesArray[day][i][j][0]; 13927 else break; 13928 if (prevHour != tmp[0] || prevMin != tmp[1]) break 13929 } for (var i = tmp[0]; i <= 23; i++) 13930 if (i in timesArray[day]) { 13931 nextHour = i; 13932 if (nextHour > tmp[0]) { 13933 nextMin = timesArray[day][i][0][0]; 13934 break 13935 } 13936 for (var j = timesArray[day][i].length - 1; j >= 0; j--) 13937 if (timesArray[day][i][j] > tmp[1]) nextMin = timesArray[day][i][j][0]; 13938 else break; 13939 if (nextHour != tmp[0] || nextMin != tmp[1]) break 13940 } with(obj) { 13941 var timesDiv = E.format("<div onMouseOver=\"this.style.color='#FF0000';\" onMouseOut=\"this.style.color='#000000';\" style='cursor:pointer' onClick=\"{0}(['{1}','{2}','{3}','{4}','{5}','{6}']);\">", [this._etr.timeTable, etr[0], (i = etr[1].split("|"))[0], i[1], (i = etr[3].split("|")[0]), i[1], etr[4]]); 13942 if (prevHour != tmp[0] || prevMin != tmp[1]) timesDiv += twoDigits(prevHour) + ":" + twoDigits(prevMin) + ":00 "; 13943 timesDiv += "<b style=\"color: #FF0000\">" + etr[2] + "</b>"; 13944 if (nextHour != tmp[0] || nextMin != tmp[1]) timesDiv += " " + twoDigits(nextHour) + ":" + twoDigits(nextMin) + ":00"; 13945 timesDiv += "</div>"; 13946 obj.times = timesDiv; 13947 if ((obj.times) && (obj.lines)) obj.bindPopup(obj.times + "<br/>" + obj.lines).off('click', this._eMarkerClick).openPopup() 13948 } 13949 }, 13950 _eShowStopLines: function(data, obj) { 13951 var res = '', 13952 i, j; 13953 data = data.Lines; 13954 for (i = 0; i < data.length; i++) 13955 for (j = 0; j < data[i].Directions.length; j++) { 13956 res += E.format("<div onMouseOver=\"this.style.color='#FF0000';\" onMouseOut=\"this.style.color='#000000';\" style='cursor:pointer' onClick=\"{0}(['{1}','{2}','{3}','{4}','{5}','{6}']);\")><b>{7}</b>({5})</div>", [this._etr.timeTable, obj.etr[0], data[i].Id, data[i].Directions[j].split("|")[0], data[i].Name.split("|")[0], data[i].Directions[j].split("|")[1], data[i].Type, data[i].Name]) 13957 } 13958 obj.lines = res; 13959 if ((obj.times) && (obj.lines)) obj.bindPopup(obj.times + "<br/>" + obj.lines).off('click', this._eMarkerClick).openPopup() 13960 } 13961}); 13962E.Router.prototype.addHook('initialize', E.Router.prototype._initETR); 13963E.POI = {}; 13964E.POI.Categories = L.Class.extend({ 13965 _map: null, 13966 _layer: null, 13967 _poiCategory: [], 13968 _userCategory: [], 13969 _customCategory: [], 13970 initialize: function(map) { 13971 this._map = map; 13972 map.on("MapInitialized", this._initialize, this) 13973 }, 13974 getPOICategory: function() { 13975 for (var i = 0; i < this._poiCategory.length; i++) { 13976 this._poiCategory[i].visible = this._layer._layer(this._poiCategory[i].id).visible; 13977 this._poiCategory[i].name = this._layer.localizeName(this._poiCategory[i].id, this._poiCategory[i].name) 13978 } 13979 return this._poiCategory 13980 }, 13981 getUserCategory: function() { 13982 for (var i = 0; i < this._userCategory.length; i++) { 13983 this._userCategory[i].visible = this._layer._layer(this._userCategory[i].id).visible; 13984 this._userCategory[i].name = this._layer.localizeName(this._userCategory[i].id, this._userCategory[i].name) 13985 } 13986 return this._userCategory 13987 }, 13988 getCustomCategory: function() { 13989 return this._customCategory 13990 }, 13991 removeCategory: function(id) { 13992 this._layer.removeLayer.add(id) 13993 }, 13994 showCategory: function(id) { 13995 this._layer.setCetegoryVisible(id, true) 13996 }, 13997 hideCategory: function(id) { 13998 this._layer.setCetegoryVisible(id, false) 13999 }, 14000 _initialize: function() { 14001 this._layer = new E.POI.Layer(E.server.POI + this._map.token(), { 14002 minZoom: 1, 14003 maxZoom: 19, 14004 attribution: '', 14005 subdomains: '1234' 14006 });
14007 this._layer._owner = this; 14008 this._map.addLayer(this._layer); 14009 this._layer.initParsers(); 14010 this._map.getObjectCategories({}, this._onGetCategory, this, { 14011 type: "u" 14012 }); 14013 this._map.getPOICategories({}, this._onGetCategory, this, { 14014 type: "p" 14015 }) 14016 }, 14017 _initLayerParsers: function() { 14018 var c = E.POI.Layer.Parser; 14019 this._layer.addConfigAction(c.POI); 14020 this._layer.addConfigAction(c.Wikipedia); 14021 this._layer.addConfigAction(c.D3); 14022 this._layer.addConfigAction(c.GDDKiA); 14023 this._layer.addConfigAction(c.NewRoads); 14024 this._layer.addConfigAction(c.Turist); 14025 this._layer.addConfigAction(c.TMC); 14026 this._layer.addConfigAction(c.ETR); 14027 this._layer.addConfigAction(c.Cams); 14028 this._layer.addConfigAction(c.BaseLayers) 14029 }, 14030 _onGetCategory: function(res, obj) { 14031 if (res.result == 0) { 14032 var cat = res.objectCategoryInfoArray; 14033 var layers = new Array(); 14034 var cats = new Array(); 14035 if (cat) 14036 for (var i = 0; i < cat.length; i++) 14037 if (cat[i].oneTile) { 14038 layers.push(this._calcCategory(cat[i], true, obj.type)); 14039 cats.push(this._parseCategory(cat[i], true)) 14040 } else 14041 for (var j = 0; j < cat[i].objectSubcategoryInfoArray.length; j++) { 14042 layers.push(this._calcCategory(cat[i].objectSubcategoryInfoArray[j], false, obj.type)); 14043 cats.push(this._parseCategory(cat[i].objectSubcategoryInfoArray[j], false)) 14044 } 14045 if (obj.type == 'p') this._poiCategory = cats; 14046 else this._userCategory = cats; 14047 this._layer.addCategories(layers); 14048 this._map.fire('onCategoriesChange', { 14049 categories: cats 14050 }); 14051 this._layer.updateVisibility(layers); 14052 this._map.fire('onCategoriesDone', { 14053 categories: cats 14054 }) 14055 } 14056 }, 14057 _parseCategory: function(category, oneTile) { 14058 if (oneTile == true) { 14059 var cat = { 14060 id: category.id, 14061 name: category.categoryName, 14062 subCat: [] 14063 }; 14064 for (var i = 0; i < category.objectSubcategoryInfoArray.length; i++) cat.subCat.push({ 14065 zoomMin: category.objectSubcategoryInfoArray[i].zoomMin, 14066 zoomMax: category.objectSubcategoryInfoArray[i].zoomMax, 14067 id: category.objectSubcategoryInfoArray[i].id, 14068 name: category.objectSubcategoryInfoArray[i].name 14069 }); 14070 return cat 14071 } else return { 14072 id: category.id, 14073 name: category.name, 14074 subCat: [{ 14075 zoomMin: category.zoomMin, 14076 zoomMax: category.zoomMax, 14077 id: category.id, 14078 name: category.name 14079 }] 14080 } 14081 }, 14082 _calcCategory: function(category, oneTile, type) { 14083 if (oneTile == true) { 14084 var cat = { 14085 minZoom: 17, 14086 maxZoom: 0, 14087 id: category.id, 14088 name: category.categoryName, 14089 categoryId: 2, 14090 visible: true, 14091 subCat: [], 14092 type: type 14093 }; 14094 for (var i = 0; i < category.objectSubcategoryInfoArray.length; i++) { 14095 var sCat = category.objectSubcategoryInfoArray[i]; 14096 cat.minZoom = Math.min(cat.minZoom, sCat.zoomMin); 14097 cat.maxZoom = Math.max(cat.maxZoom, sCat.zoomMax); 14098 cat.subCat.push(sCat) 14099 } 14100 return cat 14101 } else return { 14102 id: category.id, 14103 name: category.name, 14104 subCat: [category], 14105 minZoom: category.zoomMin, 14106 maxZoom: category.zoomMax, 14107 visible: true, 14108 categoryId: 2, 14109 type: type 14110 } 14111 }, 14112 getVisibleLayers: function() { 14113 var a = '', 14114 i; 14115 with(this._layer) for (i = 0; i < _layers.length; i++) with(_layers[i]) if (visible) a += a.length > 0 ? '|' + id : id; 14116 return a 14117 } 14118}); 14119E.Map.addInitHook(function() { 14120 this._poi = new E.POI.Categories(this); 14121 this.getCategoryObjects = function() { 14122 return this._poi 14123 } 14124}); 14125E.POI.Object = L.Class.extend({ 14126 _objectsArray: [], 14127 _map: null, 14128 _layer: null, 14129 initialize: function(layer, map) { 14130 this._map = map; 14131 this._layer = layer; 14132 this.setObjects(0, 0, 0, 'layers', []) 14133 }, 14134 setObjects: function(tileX, tileY, zoom, category, object) { 14135 var id = 'x' + tileX + 'y' + tileY + 'z' + zoom + 'c' + category; 14136 this._objectsArray[id] = object 14137 }, 14138 getObjects: function(tileX, tileY, zoom, category) { 14139 var id = 'x' + tileX + 'y' + tileY + 'z' + zoom + 'c' + category; 14140 return this._objectsArray[id] || [] 14141 }, 14142 initObjects: function(b, z, cats) { 14143 var y1 = Math.floor(b.getSouth() * 10);
14144 var y2 = Math.ceil(b.getNorth() * 10); 14145 var x1 = Math.floor(b.getWest() * 10); 14146 var x2 = Math.ceil(b.getEast() * 10); 14147 for (var x = x1; x <= x2; x += 3) 14148 for (var y = y1; y <= y2; y += 3) { 14149 var c = this._prepareCatURL(x, y, 0, cats); 14150 if (c.length > 0) { 14151 var b = { 14152 'lon': x / 10, 14153 'lat': y / 10, 14154 'zoom': z, 14155 'categories': c 14156 }; 14157 this._map.getObjectsData(b, this._onGetObjectsData, this, b, null, 1) 14158 } 14159 } 14160 }, 14161 initData: function(x, y, z, cats) { 14162 x -= x % 16; 14163 y -= y % 16; 14164 var c = this._prepareCatURL(x, y, z, cats); 14165 if (c.length > 0) { 14166 var b = { 14167 'tileX': x, 14168 'tileY': y, 14169 'zoom': z, 14170 'categories': c 14171 }; 14172 this._map.getObjectData(b, this._onGetObjectData, this, b, null, 1) 14173 } 14174 }, 14175 getObjectsFromPoint: function(pos, cats, first) { 14176 var result = new Array(), 14177 z = this._map.getZoom(), 14178 p1 = E.LL2XY(pos.lng, pos.lat, z), 14179 elems = this.getObjects(p1[0], p1[2], z, 'layers'), 14180 elem, i; 14181 if (elems != null) 14182 for (i = 0; i < cats.length; i++) { 14183 elem = elems[cats[i].id]; 14184 if (elem) { 14185 result = result.concat(this._getCategoryObjectsFromPoint(elem, cats[i].id, first, p1)); 14186 if ((first) && (result.length > 0)) break 14187 } 14188 } 14189 return result 14190 }, 14191 _prepareCatURL: function(x, y, z, cats) { 14192 var obj = this.getObjects(x, y, z, 'cat'), 14193 res = '', 14194 first = 1; 14195 if (E.type(obj) == 'u') obj = []; 14196 for (var i = 0; i < cats.length; i++) 14197 if (E.type(obj[cats[i].id]) == 'u') { 14198 obj[cats[i].id] = true; 14199 res += (first-- == 1 ? '' : ';') + cats[i].id.toString() 14200 } this.setObjects(x, y, z, 'cat', obj); 14201 return res 14202 }, 14203 _onGetObjectData: function(response, obj) { 14204 function _define(table, pos) { 14205 if ((table[pos] == undefined) || (table[pos] == null)) table[pos] = new Array() 14206 } 14207 response = eval(response.Data); 14208 var x = obj.tileX, 14209 y = obj.tileY, 14210 i, j, k, tile, cat, res; 14211 for (i = 0; i < response.length; i++) { 14212 res = response[i]; 14213 for (k = 0; k < res.length; k++) { 14214 tile = res[k]; 14215 cat = this.getObjects(tile.x, tile.y, obj.zoom, 'layers'); 14216 if (E.type(cat) == 'u') cat = []; 14217 for (j = 0; j < tile.data.length; j++) with(this._layer.category(tile.data[j].id_cat)) { 14218 _define(cat, main_cat); 14219 cat[main_cat].push(tile.data[j]) 14220 } 14221 this.setObjects(tile.x, tile.y, obj.zoom, 'layers', cat) 14222 } 14223 } 14224 response = null 14225 }, 14226 _onGetObjectsData: function(response, obj) { 14227 function _define(table, pos) { 14228 if ((table[pos] == undefined) || (table[pos] == null)) table[pos] = new Array() 14229 } 14230 response = response.Data; 14231 var i, res, cat = this.getObjects(0, 0, 0, 'layers'), 14232 markers = []; 14233 for (i = 0; i < response.length; i++) { 14234 res = response[i]; 14235 if (E.type(cat) == 'u') cat = []; 14236 try { 14237 with(this._layer.category(res.cat)) { 14238 _define(cat, main_cat); 14239 cat[main_cat].push(res); 14240 markers.push(L.marker(L.latLng(res.lat, res.lon), {})) 14241 } 14242 } catch (e) {} 14243 this._layer._clayer.addLayers(markers) 14244 } 14245 response = null 14246 }, 14247 _getCategoryObjectsFromPoint: function(catObjects, catId, first, pos) { 14248 var result = [], 14249 objects = catObjects, 14250 i, cwm, cw, chm, ch; 14251 for (i = objects.length - 1; i >= 0; i--) { 14252 var obj = objects[i]; 14253 var oPos = new Array(); 14254 oPos = oPos.concat(obj.pos); 14255 if (((pos[1] + 5 > oPos[0]) && (pos[1] - 5 < oPos[2])) && ((pos[3] + 5 > oPos[1]) && (pos[3] - 5 < oPos[3]))) { 14256 obj.layer = this; 14257 obj.back = new Array(); 14258 obj.back.tileX = pos[0]; 14259 obj.back.tileY = pos[2]; 14260 obj.back.posX = '[' + oPos[0] + ':' + oPos[2] + ']'; 14261 obj.back.posY = '[' + oPos[1] + ':' + oPos[3] + ']'; 14262 obj.tileX = pos[0]; 14263 obj.tileY = pos[2]; 14264 var cat = this._layer.category(obj.id_cat); 14265 obj.nameLabel = '<img src="' + cat.iconUrl + '" style="border:0;width:16px;height:16px">' + '<b> ' + cat.name + '</b>'; 14266 cwm = cat.width % 2; 14267 cw = Math.floor(cat.width / 2); 14268 chm = cat.height % 2; 14269 ch = Math.floor(cat.height / 2); 14270 if (oPos[2] < cw) { 14271 obj.tileX--; 14272 oPos[0] = 256 + oPos[2] - cw 14273 } else if (oPos[0] + cw > 255) { 14274 obj.tileX++; 14275 oPos[0] = (oPos[0] + cw + cwm) % 256 14276 } else { 14277 if (oPos[0] + cat.width > 255) oPos[0] = oPos[0] + cw + cwm; 14278 else oPos[0] = oPos[2] - cw 14279 } 14280 if (oPos[3] < ch) { 14281 obj.tileY--; 14282 oPos[1] = 256 + oPos[3] - ch 14283 } else if (oPos[1] + ch > 255) { 14284 obj.tileY++; 14285 oPos[1] = (oPos[1] + ch + chm) % 256 14286 } else { 14287 if (oPos[1] + cat.height > 255) oPos[1] = oPos[1] + ch + chm; 14288 else oPos[1] = oPos[3] - ch 14289 } 14290 obj.posX = oPos[0]; 14291 obj.posY = oPos[1]; 14292 result.push(obj); 14293 if (first) break 14294 } 14295 } 14296 return result 14297 } 14298}); 14299E.POI.Layer = L.TileLayer.extend({ 14300 action: [], 14301 _layersId: [], 14302 _layers: [], 14303 _categories: [], 14304 _categoriesPriority: [], 14305 _catsUrl: "", 14306 _catsArray: [], 14307 _refreshTimer: null, 14308 _needRefresh: false, 14309 _objects: null, 14310 _zoom: -1, 14311 _mc: [], 14312 _collision: null, 14313 initialize: function(url, options) { 14314 L.TileLayer.prototype.initialize.call(this, url, options); 14315 with(this) { 14316 _layersId = []; 14317 _layers = []; 14318 _categories = []; 14319 _categoriesPriority = []; 14320 _catsUrl = ""; 14321 _catsArray = []; 14322 _mc = [] 14323 } 14324 }, 14325 getTileUrl: function(tilePoint) { 14326 this._adjustTilePoint(tilePoint); 14327 if (this._catsUrl.length == 0) return E.blank; 14328 this._objects.initData(tilePoint.x, tilePoint.y, this._getZoomForUrl(), this._categoriesPriority); 14329 return L.Util.template(this._url, L.Util.extend({ 14330 s: this._getSubdomain(tilePoint), 14331 z: this._getZoomForUrl(), 14332 x: tilePoint.x, 14333 y: tilePoint.y, 14334 c: this._catsUrl 14335 }, this.options)) 14336 }, 14337 addCategories: function(cats) { 14338 for (var i = 0; i < cats.length; i++) { 14339 cats[i].layerType = this._getConfigAction("getLayerType", cats[i].id, [], 0); 14340 cats[i].visible = false; 14341 cats[i].name = this._getConfigAction("getLocalizeValue", cats[i].id, cats[i].id, cats[i].name); 14342 this._layersId[cats[i].id] = this._layers.length; 14343 this._layers.push(cats[i]); 14344 for (var j = 0; j < cats[i].subCat.length; j++) { 14345 var cat = cats[i].subCat[j]; 14346 cat.main_cat = cats[i].id; 14347 cat.type = cats[i].type; 14348 cat.rankValue = cats[i].rankValue; 14349 this._categories[cat.id] = cat 14350 } 14351 } 14352 }, 14353 updateVisibility: function(cats) { 14354 for (var i = 0; i < cats.length; i++) this.setCetegoryVisible(cats[i].id, this._getConfigAction("getVisibleStart", cats[i].id, [], false)) 14355 }, 14356 onAdd: function(map) { 14357 L.TileLayer.prototype.onAdd.call(this, map); 14358 this._objects = new E.POI.Object(this, this._map); 14359 map.on('clickMapInfo', this._clickMapInfo, this); 14360 this._clayer = new E.ClusterLayer("", { 14361 minZoom: 10 14362 }).addTo(map) 14363 }, 14364 _update: function() { 14365 if (this._zoom != this._map.getZoom()) { 14366 this._zoom = this._map.getZoom(); 14367 this._updateURL() 14368 } 14369 L.TileLayer.prototype._update.call(this) 14370 }, 14371 _layer: function(id) { 14372 return this._layers[this._layersId[id]] 14373 }, 14374 category: function(id) { 14375 return this._categories[id] 14376 }, 14377 setCetegoryVisible: function(layerId, visible) { 14378 var v = this._layer(layerId); 14379 if (v && v.visible != visible) { 14380 v.visible = visible; 14381 this._getConfigAction('onVisibleChange', layerId, [layerId, visible], false); 14382 this.fire('onVisibleChange', { 14383 layer: { 14384 id: layerId, 14385 visible: visible 14386 } 14387 }); 14388 this._map.fire('onVisibleChange', { 14389 layer: { 14390 id: layerId, 14391 visible: visible 14392 } 14393 }); 14394 this._pauseRefresh();
14395 this._resumeRefresh(this._isLayerVisible(layerId)) 14396 } 14397 return 0 14398 }, 14399 _isLayerVisible: function(id) { 14400 var l = this._layer(id); 14401 var z = this._map.getZoom(); 14402 return l.visible && ((l.minZoom <= z) && (l.maxZoom >= z)) 14403 }, 14404 _updateURL: function() { 14405 var cats = []; 14406 this._catsUrl = ''; 14407 var i = 0; 14408 for (i = 0; i < this._layers.length; i++) 14409 if ((this._isLayerVisible(this._layers[i].id) == true) && (this._layers[i].layerType == 0)) cats.push(this._layers[i]); 14410 cats.sort(function(a, b) { 14411 return a.rankValue - b.rankValue 14412 }); 14413 this._categoriesPriority = cats; 14414 var first = true; 14415 for (i = 0; i < cats.length; i++) { 14416 if (!first) this._catsUrl = this._catsUrl + ';'; 14417 else first = false; 14418 this._catsUrl = this._catsUrl + cats[i].id 14419 } 14420 this._zoom = this._map.getZoom(); 14421 return !first 14422 }, 14423 _pauseRefresh: function() { 14424 this._needRefresh = this._needRefresh || (this._refreshTimer != null); 14425 clearTimeout(this._refreshTimer) 14426 }, 14427 _resumeRefresh: function(force) { 14428 if ((this._needRefresh) || (force)) { 14429 this._needRefresh = false; 14430 this._updateURL(); 14431 this._refreshTimer = setTimeout(E.bind(this.redraw, this), 500) 14432 } 14433 }, 14434 _clickMapInfo: function(e) { 14435 var obj = this._objects.getObjectsFromPoint(e.latlng, this._categoriesPriority, true)[0]; 14436 if (this._mc.length > 0) obj = this._getConfigAction('getObjectsFromPoint', this._mc[0], [e.latlng, obj])[0]; 14437 this.showInfo(obj) 14438 }, 14439 _onGetObjectInfo: function(res, obj) { 14440 var a = this._getConfigAction("parseObjectInfo", obj.id_cat, [obj, res], ""); 14441 if (a.length > 0) { 14442 var z = this._map.getZoom(), 14443 pos = E.XY2LL(obj.tileX, obj.posX, obj.tileY, obj.posY, z); 14444 this._map.showPopup(L.latLng(pos[1], pos[0]), a, { 14445 offset: [0, 0] 14446 }) 14447 } 14448 }, 14449 showInfo: function(obj) { 14450 if (obj) this._getConfigAction('getObjectInfo', obj.id_cat, [obj, this._onGetObjectInfo], false) 14451 }, 14452 _getConfigAction: function() {}, 14453 localizeName: function(id, name) { 14454 return this._getConfigAction("getLocalizeValue", id, id, name) 14455 } 14456}); 14457E.POI.Layer.include({ 14458 _itemsLC: null, 14459 _types: null, 14460 addLayersCollision: function(type, layer) { 14461 with(this) { 14462 if (!_types) _types = []; 14463 if (_types.indexOf(type) == -1) _types.push(type); 14464 if (E.type(_itemsLC[type]) != 'a') _itemsLC[type] = []; 14465 _itemsLC[type].push(layer) 14466 } 14467 }, 14468 _onVisibleChangeLC: function(e) { 14469 var a = 0, 14470 layerId = e.layer.id, 14471 visible = e.layer.visible, 14472 c, i, s, j, l, m; 14473 if (visible) 14474 for (s = 0; s < this._types.length; s++) { 14475 i = this._itemsLC[this._types[s]]; 14476 for (j = 0; j < i.length; j++) 14477 for (var k = 0; k < i[j].length; k++) 14478 if (i[j][k] == layerId) { 14479 for (l = 0; l < i.length; l++) 14480 if (l != j) 14481 for (m = 0; m < i[l].length; m++) { 14482 c = this._layer(i[l][m]); 14483 if ((c) && (c.visible)) { 14484 this.setCetegoryVisible(i[l][m], false); 14485 a = 1 14486 } 14487 } 14488 break 14489 } 14490 } 14491 if (a) { 14492 E.Overlay.showMessage(E.lang("LC_info")) 14493 } 14494 } 14495}); 14496E.POI.Layer.addInitHook(function() { 14497 this._types = []; 14498 this._itemsLC = []; 14499 this.on('onVisibleChange', this._onVisibleChangeLC) 14500}); 14501E.POI.Layer.include({ 14502 _aItems: [], 14503 iactions: [], 14504 _getConfigAction: function(action, id, params, defval) { 14505 var result = null, 14506 adone = { 14507 result: false 14508 }; 14509 for (var i = 0; i < this._aItems.length; i++) 14510 if (this._aItems[i].isValidId(id)) { 14511 result = this._aItems[i][action](params, adone); 14512 if ((adone.result) || ((result != null) && (!adone.blokEnd))) { 14513 adone.result = true; 14514 break 14515 } 14516 } if (adone.result == false) return defval; 14517 else return result 14518 }, 14519 initParsers: function() { 14520 for (var i = 0; i < this.iactions.length; i++) this._aItems.push(new this.iactions[i](this, this._map)) 14521 } 14522}); 14523E.POI.Layer.addInitAction = function(a) { 14524 this.prototype.iactions.push(a) 14525}; 14526E.POI.Layer.Parser = L.Class.extend({ 14527 _priorityValue: 0, 14528 _categoryRank: 0, 14529 _layerType: 0, 14530 _catPositionIndex: 1, 14531 _visibleStart: false, 14532 _ids: [], 14533 _layer: null, 14534 _map: null, 14535 initialize: function(layer, map) { 14536 this._layer = layer; 14537 this._map = map; 14538 this._legend = map.legend; 14539 this.init() 14540 }, 14541 init: function() {},
14542 setParams: function(id, categoryRank, catPositionIndex, visibleStart) { 14543 this._ids = id; 14544 this._categoryRank = categoryRank; 14545 this._catPositionIndex = catPositionIndex; 14546 this._visibleStart = visibleStart 14547 }, 14548 isValidId: function(a) { 14549 a = this._layer.category(a) ? this._layer.category(a).main_cat : a; 14550 for (var i = 0; i < this._ids.length; i++) 14551 if (a == this._ids[i]) return true; 14552 return false 14553 }, 14554 getPriorityValue: function(id) { 14555 return this._priorityValue 14556 }, 14557 setParentParams: function(layer, map) { 14558 this._layer = layer; 14559 this._map = map 14560 }, 14561 getCategoryHover: function(id) { 14562 return null 14563 }, 14564 getLayerType: function(id) { 14565 return this._layerType 14566 }, 14567 getCategoryRank: function(id) { 14568 return this.categoryRank 14569 }, 14570 getCategoryPositionIndex: function(id) { 14571 return this._catPositionIndex 14572 }, 14573 getVisibleStart: function(id) { 14574 return this._visibleStart 14575 }, 14576 onVisibleChange: function(id) {}, 14577 parseObjectInfo: function(objects) {}, 14578 getObjectInfo: function(obj) { 14579 with(this._layer.category(obj[0].id_cat)) this._map['search' + (type == 'u' ? 'Objects' : 'POI')]({ 14580 categoryNames: id, 14581 searchText: "", 14582 lon: "0", 14583 lat: "0", 14584 objectCount: "1", 14585 queryRadius: "0", 14586 objectIDs: obj[0].id 14587 }, obj[1], this._layer, obj[0]); 14588 return 1 14589 }, 14590 getObjectsFromPoint: function(objects) { 14591 return false 14592 }, 14593 getLocalizeValue: function(id) { 14594 if (E.Lang.code() !== 'pl') return (id = E.lang('LP_PLN' + id)).indexOf('LP_PLN') > -1 ? null : id; 14595 return null 14596 } 14597}); 14598E.POI.Layer.addInitAction(E.POI.Layer.Parser.extend({ 14599 init: function() { 14600 this._ids = [101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 11, 12, 21, 113, 115, 116] 14601 }, 14602 parseObjectInfo: function(obj, result) { 14603 function generatePOIDiv(cn, val) { 14604 return ((E.type(val) == 'u') || (val.length == 0) || (val == '0')) ? '' : '<div class="POIItem' + cn + '">' + val + '</div>' 14605 } 14606 14607 function generateMailPOIDiv(cn, val) { 14608 return ((E.type(val) == 'u') || (val.length == 0) || (val == '0')) ? '' : generatePOIDiv(cn, '<a href="mailto:' + val + '">' + val + '</a>') 14609 } 14610 14611 function generateHTMLPOIDiv(cn, val) { 14612 if ((E.type(val) == 'u') || (val.length == 0)) return ''; 14613 var v = val.toLowerCase(); 14614 v = ((v.search('http://') == -1) && (v.search('https://') == -1)) ? "http://" : ""; 14615 return generatePOIDiv(cn, '<a href="' + v + val + '" target="_poi">' + val + '</a>') 14616 } 14617 var info = obj[0].nameLabel, 14618 res = obj[1].searchObjectArray[0]; 14619 var items = [ 14620 ["name", 0], 14621 ["city", 0], 14622 ["street", 0], 14623 ["zip", 0], 14624 ["tel", 0], 14625 ["email", 1], 14626 ["description", 0], 14627 ["http", 2] 14628 ]; 14629 for (var i = 0; i < items.length; i++) info += (items[i][1] == 0 ? generatePOIDiv : (items[i][1] == 1 ? generateMailPOIDiv : generateHTMLPOIDiv))(items[i][0], res[items[i][0]]); 14630 result.result = true; 14631 return info 14632 }, 14633 getCategoryPositionIndex: function(id) { 14634 id = { 14635 11: 3, 14636 12: 3, 14637 21: 3, 14638 113: 5, 14639 115: 5 14640 } [id]; 14641 return id ? id : 2 14642 } 14643})); 14644E.POI.Layer.addInitAction(E.POI.Layer.Parser.extend({ 14645 init: function() { 14646 this.setParams([14], 1, 3, false) 14647 }, 14648 parseObjectInfo: function(obj) { 14649 var res = obj[1].searchObjectArray[0]; 14650 return E.format('{0}<div>{1}</div></b></i></u></a><p><a href="http://pl.wikipedia.org/wiki/{2}" target="wikipedia"> <small>{3}</small> </a> </p><p><small><span style="color: gray; font-size: 85%;">{4}</span></small></p><a target="wikipedia" href="http://www.wikipedia.org"> <img class="wikipedia_info" src="' + E.blank + '" style="border: medium none ;" height="22" width="126"> </a>', [obj[0].nameLabel, res['description'], res['name'], E.lang('LP_WFA'), E.lang('LP_WA')]) 14651 } 14652})); 14653E.POI.Layer.addInitAction(E.POI.Layer.Parser.extend({ 14654 _key: '', 14655 init: function() { 14656 this.setParams([22], 2, 3, true); 14657 this._key = this._map.regAction(this.showTimeTable, this) 14658 }, 14659 getObjectInfo: function(obj) { 14660 with(this._layer.category(obj[0].id_cat)) this._map.eTR_StopLines(obj[0].id, obj[1], this._layer, obj[0]); 14661 return 1 14662 }, 14663 parseObjectInfo: function(obj) { 14664 var res = obj[1], 14665 t, sld = (res["StopName"] + "<br />").replace(/\(\d+\)/, ""), 14666 rl = res["Lines"], 14667 i, j, lineDiv = ''; 14668 for (i = 0; i < rl.length; i++) { 14669 t = rl[i]; 14670 for (j = 0; j < t.Directions.length; j++) lineDiv += E.format("<div onMouseOver=\"this.style.color='#FF0000';\" onMouseOut=\"this.style.color='#000000';\" onClick=\"{0}('{1}', '{2}','{3}','{4}', '{5}','{6}');\" style='cursor:pointer'><b>{7}</b>({8})</div>", [this._key, obj[0].id, t.Id, t.Directions[j].split("|")[0], t.Name.split("|")[0], t.Directions[j].split("|")[1], t.Type, t.Name, t.Directions[j].split("|")[1]]) 14671 } 14672 return sld + "<div>" + lineDiv + "</div>" 14673 }, 14674 showTimeTable: function() { 14675 this._map.fire("ETR_ShowTimeTable", { 14676 param: arguments 14677 }) 14678 } 14679})); 14680E.Finder = L.Class.extend({ 14681 _country: "pl", 14682 _api: {}, 14683 _items: [], 14684 initialize: function(obj, options) { 14685 if (obj instanceof E.Map) this._api = obj._map; 14686 else new E.API(obj, this._api); 14687 L.Util.extend(this, options) 14688 }, 14689 destroy: function() {}, 14690 setCountry: function(country) { 14691 if (country != null) this._country = country.toLowerCase() 14692 }, 14693 getCountry: function() { 14694 return this._country 14695 }, 14696 search: function(address, callback) { 14697 this._api.addressSearch({ 14698 cctld: this._country, 14699 address: address 14700 }, this.searchResponse, this, { 14701 callback: callback 14702 }) 14703 },
14704 geocode: function(country, city, zip, street, streetnumber, callback) { 14705 this._api.geocodeExt({ 14706 Country: country, 14707 City: city, 14708 Street: street, 14709 Zip: zip, 14710 Number: streetnumber 14711 }, callback, this) 14712 }, 14713 getCoordinates: function(index, callback) { 14714 with(this) index = { 14715 "result": 0, 14716 middlePoint: _items[index].middlePoint, 14717 "boundingRect": _items[index].boundingRect 14718 }; 14719 if (callback) callback(index); 14720 return index 14721 }, 14722 degeocode: function(points, zoom, callback) { 14723 if (points instanceof Array) { 14724 var pos = [], 14725 i, cPos = this._api.getCenterPos ? this._api.getCenterPos : { 14726 lon: 0, 14727 lat: 0 14728 }; 14729 for (i = 0; i < points.length; i++) pos.push({ 14730 Longitude: points[i].lon, 14731 Latitude: points[i].lat 14732 }); 14733 this._api.multiDegeocode({ 14734 'lon': cPos.lon, 14735 'lat': cPos.lat, 14736 'zoom': zoom, 14737 'points': pos 14738 }, callback, this) 14739 } else this._api.degeocode({ 14740 'lon': points.lon, 14741 'lat': points.lat, 14742 zoom: zoom 14743 }, callback, this) 14744 }, 14745 searchResponse: function(a, b) { 14746 this._items = a.geocodeInfoArray; 14747 if (b.callback) b.callback(a) 14748 }, 14749 getObjectCategories: function(callback) { 14750 this._api.getObjectCategories({}, callback, this) 14751 }, 14752 getPOICategories: function(callback) { 14753 this._api.getPOICategories({}, callback, this) 14754 }, 14755 searchObjects: function(categoryNames, searchText, lonLat, objectCount, queryRadius, objectIDs, callback) { 14756 this._api.searchObjects({ 14757 categoryNames: categoryNames, 14758 searchText: searchText, 14759 lon: lonLat.lon, 14760 lat: lonLat.lat, 14761 objectCount: objectCount, 14762 queryRadius: queryRadius, 14763 objectIDs: objectIDs 14764 }, callback, this) 14765 }, 14766 searchPOI: function(categoryNames, searchText, lonLat, objectCount, queryRadius, objectIDs, callback) { 14767 this._api.searchPOI({ 14768 categoryNames: categoryNames, 14769 searchText: searchText, 14770 lon: lonLat.lon, 14771 lat: lonLat.lat, 14772 objectCount: objectCount, 14773 queryRadius: queryRadius, 14774 objectIDs: objectIDs 14775 }, callback, this) 14776 } 14777}); 14778E.LonLat = L.Class.extend({ 14779 lon: 0, 14780 lat: 0, 14781 _lola: null, 14782 initialize: function(lon, lat) { 14783 if (lon.Latitude) lat = lon.Latitude; 14784 if (lon.Longitude) lon = lon.Longitude; 14785 this._lola = L.latLng(!lat ? lon : lat, !lat ? lat : lon); 14786 this.lon = this._lola.lng; 14787 this.lat = this._lola.lat 14788 }, 14789 toString: function() {
14790 return "lon=" + this.lon + ",lat=" + this.lat 14791 }, 14792 toShortString: function() { 14793 return this.lon + ", " + this.lat 14794 }, 14795 clone: function() { 14796 return new E.LonLat(this.lon, this.lat) 14797 }, 14798 add: function(lon, lat) { 14799 return new E.LonLat(this.lon + lon, this.lat + lat) 14800 }, 14801 equals: function(obj) { 14802 if (!obj) { 14803 return false 14804 } 14805 obj = L.latLng(obj); 14806 var margin = Math.max(Math.abs(this.lat - obj.lat), Math.abs(this.lon - obj.lng)); 14807 return margin <= L.LatLng.MAX_MARGIN 14808 }, 14809 fromString: function(str) { 14810 var pair = str.split(","); 14811 return new E.LonLat(parseFloat(pair[0]), parseFloat(pair[1])) 14812 }, 14813 getLatLng: function() { 14814 return this._lola 14815 } 14816}); 14817L.LatLng.prototype.getLonLat = function() { 14818 return new E.LonLat(this.lng, this.lat) 14819}; 14820E.LLP = function(a) { 14821 if (a instanceof L.LatLng) return a; 14822 if (!(a instanceof E.LonLat)) a = new E.LonLat(a); 14823 return a.getLatLng() 14824}; 14825E.Bounds = L.Class.extend({ 14826 left: null, 14827 bottom: null, 14828 right: null, 14829 top: null, 14830 initialize: function(left, bottom, right, top) { 14831 if (E.type(left) == 'a') { 14832 if (left.length == 4) { 14833 bottom = left[1]; 14834 right = left[2]; 14835 top = left[3]; 14836 left = left[0] 14837 } else if (left.length == 2) { 14838 bottom = left[0][1]; 14839 right = left[1][0]; 14840 top = left[1][1]; 14841 left = left[0][0] 14842 } 14843 } else if (left) { 14844 if (left.BottomRight) with(left.BottomRight) { 14845 right = Longitude; 14846 bottom = Latitude 14847 } 14848 if (left.TopLeft) with(left.TopLeft) { 14849 left = Longitude; 14850 top = Latitude 14851 } 14852 if (left.bottom) bottom = left.bottom; 14853 if (left.top) top = left.top; 14854 if (left.right) right = left.right; 14855 if (left.left) left = left.left 14856 } 14857 if (left != null) { 14858 this.left = parseFloat(left) 14859 } 14860 if (bottom != null) { 14861 this.bottom = parseFloat(bottom) 14862 } 14863 if (right != null) { 14864 this.right = parseFloat(right) 14865 } 14866 if (top != null) { 14867 this.top = parseFloat(top) 14868 } 14869 }, 14870 clone: function() { 14871 return new E.Bounds(this.left, this.bottom, this.right, this.top) 14872 }, 14873 equals: function(bounds) { 14874 var equals = false; 14875 if (bounds != null) { 14876 equals = ((this.left == bounds.left) && (this.right == bounds.right) && (this.top == bounds.top) && (this.bottom == bounds.bottom)) 14877 } 14878 return equals 14879 }, 14880 toString: function() { 14881 return ("left-bottom=(" + this.left + "," + this.bottom + ")" + " right-top=(" + this.right + "," + this.top + ")") 14882 }, 14883 toArray: function() { 14884 return [this.left, this.bottom, this.right, this.top] 14885 }, 14886 toBBOX: function(decimal) { 14887 if (decimal == null) { 14888 decimal = 10 14889 } 14890 var mult = Math.pow(10, decimal); 14891 var bbox = Math.round(this.left * mult) / mult + "," + Math.round(this.bottom * mult) / mult + "," + Math.round(this.right * mult) / mult + "," + Math.round(this.top * mult) / mult; 14892 return bbox 14893 }, 14894 getWidth: function() { 14895 return (this.right - this.left) 14896 }, 14897 getHeight: function() { 14898 return (this.top - this.bottom) 14899 }, 14900 getSize: function() { 14901 return new E.Size(this.getWidth(), this.getHeight()) 14902 }, 14903 getCenterPixel: function() { 14904 return new E.Pixel((this.left + this.right) / 2, (this.bottom + this.top) / 2) 14905 }, 14906 getCenterLonLat: function() { 14907 return new E.LonLat((this.left + this.right) / 2, (this.bottom + this.top) / 2) 14908 }, 14909 scale: function(ratio, origin) { 14910 if (origin == null) { 14911 origin = this.getCenterLonLat() 14912 } 14913 var bounds = []; 14914 var origx, origy; 14915 if (origin instanceof E.LonLat) { 14916 origx = origin.lon; 14917 origy = origin.lat 14918 } else { 14919 origx = origin.x; 14920 origy = origin.y 14921 } 14922 var left = (this.left - origx) * ratio + origx; 14923 var bottom = (this.bottom - origy) * ratio + origy; 14924 var right = (this.right - origx) * ratio + origx; 14925 var top = (this.top - origy) * ratio + origy; 14926 return new E.Bounds(left, bottom, right, top) 14927 }, 14928 add: function(x, y) { 14929 if ((x == null) || (y == null)) { 14930 return null 14931 } 14932 return new E.Bounds(this.left + x, this.bottom + y, this.right + x, this.top + y) 14933 }, 14934 extend: function(object) { 14935 var bounds = null; 14936 if (object) { 14937 if (object instanceof E.LonLat) bounds = new E.Bounds(object.lon, object.lat, object.lon, object.lat); 14938 else if (object instanceof E.Bounds) bounds = object 14939 } 14940 if (bounds) { 14941 if ((this.left == null) || (bounds.left < this.left)) { 14942 this.left = bounds.left 14943 } 14944 if ((this.bottom == null) || (bounds.bottom < this.bottom)) { 14945 this.bottom = bounds.bottom 14946 } 14947 if ((this.right == null) || (bounds.right > this.right)) { 14948 this.right = bounds.right 14949 } 14950 if ((this.top == null) || (bounds.top > this.top)) { 14951 this.top = bounds.top 14952 } 14953 } 14954 }, 14955 containsLonLat: function(ll, inclusive) { 14956 return this.contains(ll.lon, ll.lat, inclusive) 14957 }, 14958 containsPixel: function(px, inclusive) { 14959 return this.contains(px.x, px.y, inclusive) 14960 }, 14961 contains: function(x, y, inclusive) { 14962 if (inclusive == null) { 14963 inclusive = true 14964 } 14965 var contains = false; 14966 if (inclusive) { 14967 contains = ((x >= this.left) && (x <= this.right) && (y >= this.bottom) && (y <= this.top)) 14968 } else { 14969 contains = ((x > this.left) && (x < this.right) && (y > this.bottom) && (y < this.top)) 14970 } 14971 return contains 14972 },
14973 intersectsBounds: function(bounds, inclusive) { 14974 if (inclusive == null) { 14975 inclusive = true 14976 } 14977 var inBottom = (bounds.bottom == this.bottom && bounds.top == this.top) ? true : (((bounds.bottom > this.bottom) && (bounds.bottom < this.top)) || ((this.bottom > bounds.bottom) && (this.bottom < bounds.top))); 14978 var inTop = (bounds.bottom == this.bottom && bounds.top == this.top) ? true : (((bounds.top > this.bottom) && (bounds.top < this.top)) || ((this.top > bounds.bottom) && (this.top < bounds.top))); 14979 var inRight = (bounds.right == this.right && bounds.left == this.left) ? true : (((bounds.right > this.left) && (bounds.right < this.right)) || ((this.right > bounds.left) && (this.right < bounds.right))); 14980 var inLeft = (bounds.right == this.right && bounds.left == this.left) ? true : (((bounds.left > this.left) && (bounds.left < this.right)) || ((this.left > bounds.left) && (this.left < bounds.right))); 14981 return (this.containsBounds(bounds, true, inclusive) || bounds.containsBounds(this, true, inclusive) || ((inTop || inBottom) && (inLeft || inRight))) 14982 }, 14983 containsBounds: function(bounds, partial, inclusive) { 14984 if (partial == null) { 14985 partial = false 14986 } 14987 if (inclusive == null) { 14988 inclusive = true 14989 } 14990 var inLeft; 14991 var inTop; 14992 var inRight; 14993 var inBottom; 14994 if (inclusive) { 14995 inLeft = (bounds.left >= this.left) && (bounds.left <= this.right); 14996 inTop = (bounds.top >= this.bottom) && (bounds.top <= this.top); 14997 inRight = (bounds.right >= this.left) && (bounds.right <= this.right); 14998 inBottom = (bounds.bottom >= this.bottom) && (bounds.bottom <= this.top) 14999 } else { 15000 inLeft = (bounds.left > this.left) && (bounds.left < this.right); 15001 inTop = (bounds.top > this.bottom) && (bounds.top < this.top); 15002 inRight = (bounds.right > this.left) && (bounds.right < this.right); 15003 inBottom = (bounds.bottom > this.bottom) && (bounds.bottom < this.top) 15004 } 15005 return (partial) ? (inTop || inBottom) && (inLeft || inRight) : (inTo
15005p && inLeft && inBottom && inRight) 15006 }, 15007 determineQuadrant: function(lonlat) { 15008 var quadrant = ""; 15009 var center = this.getCenterLonLat(); 15010 quadrant += (lonlat.lat < center.lat) ? "b" : "t"; 15011 quadrant += (lonlat.lon < center.lon) ? "l" : "r"; 15012 return quadrant 15013 }, 15014 wrapDateLine: function(maxExtent, options) { 15015 options = options || {}; 15016 var leftTolerance = options.leftTolerance || 0; 15017 var rightTolerance = options.rightTolerance || 0; 15018 var newBounds = this.clone(); 15019 if (maxExtent) { 15020 while (newBounds.left < maxExtent.left && (newBounds.right - rightTolerance) <= maxExtent.left) { 15021 newBounds = newBounds.add(maxExtent.getWidth(), 0) 15022 } 15023 while ((newBounds.left + leftTolerance) >= maxExtent.right && newBounds.right > maxExtent.right) { 15024 newBounds = newBounds.add(-maxExtent.getWidth(), 0) 15025 } 15026 } 15027 return newBounds 15028 }, 15029 getTopLeft: function() { 15030 return new E.LonLat(this.left, this.top) 15031 } 15032}); 15033E.Bounds.fromString = function(str) { 15034 var bounds = str.split(","); 15035 return E.Bounds.fromArray(bounds) 15036}; 15037E.Bounds.fromArray = function(bbox) { 15038 return new E.Bounds(parseFloat(bbox[0]), parseFloat(bbox[1]), parseFloat(bbox[2]), parseFloat(bbox[3])) 15039}; 15040E.Bounds.fromSize = function(size) { 15041 return new E.Bounds(0, size.h, size.w, 0) 15042}; 15043E.Bounds.oppositeQuadrant = function(quadrant) { 15044 var opp = ""; 15045 opp += (quadrant.charAt(0) == 't') ? 'b' : 't'; 15046 opp += (quadrant.charAt(1) == 'l') ? 'r' : 'l'; 15047 return opp 15048}; 15049E.Pixel = L.Class.extend({ 15050 x: 0.0, 15051 y: 0.0, 15052 initialize: function(x, y) { 15053 this.x = parseFloat(x); 15054 this.y = parseFloat(y) 15055 }, 15056 toString: function() { 15057 return ("x=" + this.x + ",y=" + this.y) 15058 }, 15059 clone: function() { 15060 return new EMAPI.Pixel(this.x, this.y) 15061 }, 15062 equals: function(px) { 15063 var equals = false; 15064 if (px != null) { 15065 equals = ((this.x == px.x && this.y == px.y) || (isNaN(this.x) && isNaN(this.y) && isNaN(px.x) && isNaN(px.y))) 15066 } 15067 return equals 15068 }, 15069 add: function(x, y) { 15070 if ((x == null) || (y == null)) { 15071 return null 15072 } 15073 return new EMAPI.Pixel(this.x + x, this.y + y) 15074 }, 15075 offset: function(px) { 15076 var newPx = this.clone(); 15077 if (px) { 15078 newPx = this.add(px.x, px.y) 15079 } 15080 return newPx 15081 } 15082}); 15083E.Size = L.Class.extend({ 15084 w: 0.0, 15085 h: 0.0, 15086 initialize: function(w, h) { 15087 this.w = parseFloat(w); 15088 this.h = parseFloat(h); 15089 this.x = parseFloat(w); 15090 this.y = parseFloat(h) 15091 }, 15092 toString: function() { 15093 return ("w=" + this.w + ",h=" + this.h) 15094 }, 15095 clone: function() { 15096 return new E.Size(this.w, this.h) 15097 }, 15098 equals: function(sz) { 15099 var equals = false; 15100 if (sz != null) { 15101 equals = ((this.w == sz.w && this.h == sz.h) || (isNaN(this.w) && isNaN(this.h) && isNaN(sz.w) && isNaN(sz.h))) 15102 } 15103 return equals 15104 } 15105}); 15106E.Icon = L.DivIcon.extend({ 15107 initialize: function(options) { 15108 L.setOptions(this, options) 15109 } 15110}); 15111E.VectorLayer = L.FeatureGroup.extend({ 15112 visibilityZoomMin: 0, 15113 visibilityZoomMax: 0, 15114 _layer: null, 15115 _zIndex: 10, 15116 name: '', 15117 _count: 0, 15118 init: function(a, b) { 15119 L.FeatureGroup.prototype[a].call(this, b) 15120 }, 15121 initialize: function(name, options) { 15122 this.name = name; 15123 L.setOptions(this, L.extend({ 15124 name: name 15125 }, options)); 15126 this.init('initialize', options) 15127 }, 15128 onAdd: function(a) { 15129 this._zIndex = (E.VectorLayer._zIndex += 1000); 15130 this._mp = this._map = a; 15131 var t = []; 15132 this.eachLayer(function(a) { 15133 t.push(a) 15134 }, this); 15135 t.sort(function(a, b) { 15136 return a.options.zIndex - b.options.zIndex 15137 }); 15138 for (var i = 0; i < t.length; i++) t[i].options.zIndex = this._zIndex++, a.addLayer(t[i]) 15139 }, 15140 addObjects: function(objects) { 15141 if (E.type(objects) != 'a') objects = [objects]; 15142 for (var i = 0; i < objects.length; i++) this.addLayer(objects[i].onAdd(this).getFeature()) 15143 }, 15144 addLayer: function(a) { 15145 a.options.zIndex = this._zIndex++; 15146 a._layer = this; 15147 this.init('addLayer', a); 15148 this._count++ 15149 }, 15150 removeLayer: function(a) { 15151 this.init('removeLayer', a); 15152 this._count-- 15153 }, 15154 clearLayers: function() { 15155 this.init('clearLayers'); 15156 this._count = 0 15157 }, 15158 bringToFront: function() { 15159 this._zIndex = (E.VectorLayer._zIndex += 1000); 15160 this.init('bringToFront') 15161 }, 15162 removeObjects: function(objects) { 15163 if (E.type(objects) != 'a') objects = [objects];
15164 for (var i = 0; i < objects.length; i++) this.removeLayer(objects[i]._feature) 15165 }, 15166 clearObjects: function() { 15167 this.clearLayers() 15168 }, 15169 setMap: function(map) { 15170 map.addLayer(this) 15171 }, 15172 showInfoObject: function(obj) { 15173 obj._feature.openPopup() 15174 }, 15175 setVisibility: function(visibility) { 15176 if (visibility) this._mp.addLayer(this); 15177 else this._mp.removeLayer(this) 15178 }, 15179 count: function() { 15180 return this._count 15181 }, 15182 getBounds: function() { 15183 return this.init('getBounds') 15184 }, 15185 destroy: function() { 15186 this._mp.removeLayer(this) 15187 } 15188}); 15189E.vectorLayer = function(a) { 15190 return new E.VectorLayer(a) 15191}; 15192E.VectorLayer._zIndex = 1; 15193E.ClusterLayer = L.MarkerClusterGroup.extend({ 15194 name: '', 15195 _count: 0, 15196 init: function(a, b) { 15197 if (b && b.iconCreateFunction) { 15198 var d = b.iconCreateFunction; 15199 b.iconCreateFunction = function(c) { 15200 return d(c.getChildCount()) 15201 } 15202 } 15203 L.MarkerClusterGroup.prototype[a].call(this, b) 15204 }, 15205 initialize: function(name, options) { 15206 this.name = name; 15207 this.init('initialize', options) 15208 }, 15209 onAdd: function(a) { 15210 this.init('onAdd', a); 15211 this._mp = a 15212 }, 15213 addObjects: function(a) { 15214 if (E.type(a) != 'a') a = [a]; 15215 for (var i = 0; i < a.length; i++) this.addLayer(a[i].onAdd(this).getFeature()) 15216 }, 15217 removeObjects: function(a) { 15218 if (E.type(a) != 'a') a = [a]; 15219 for (var i = 0; i < a.length; i++) a[i]._layer = null, this.removeLayer(a[i]._feature) 15220 }, 15221 addLayer: function(a) { 15222 this.init('addLayer', a); 15223 this._count++ 15224 }, 15225 removeLayer: function(a) { 15226 this.init('removeLayer', a); 15227 this._count-- 15228 }, 15229 clearObjects: function() { 15230 this.clearLayers() 15231 }, 15232 setMap: function(map) { 15233 map.addLayer(this) 15234 }, 15235 setVisibility: function(visibility) { 15236 if (visibility) this._mp.addLayer(this); 15237 else this._mp.removeLayer(this) 15238 }, 15239 count: function() { 15240 return this._count 15241 }, 15242 getBounds: function() { 15243 return this.init('getBounds') 15244 }, 15245 destroy: function() { 15246 this._mp.removeLayer(this) 15247 }, 15248 _GetIcon: function(cluster) {} 15249}); 15250E.Object = L.Class.extend({ 15251 name: '', 15252 lonLat: null, 15253 attributes: null, 15254 fontColor: "red", 15255 fontSize: "12px", 15256 fontFamily: "Courier New, monospace", 15257 fontWeight: "bold", 15258 labelVisible: false, 15259 label: '', 15260 labelType: 'border', 15261 labelXOffset: 0, 15262 labelYOffset: 15, 15263 innerHTML: '', 15264 moveable: true, 15265 visible: true, 15266 clickable: true, 15267 autoInfo: false, 15268 popupXOffset: 0, 15269 popupYOffset: 0, 15270 _feature: null, 15271 icon: null, 15272 labelStyle: null, 15273 popupStyle: null, 15274 layer: null, 15275 initialize: function(options) { 15276 L.Util.extend(this, options) 15277 }, 15278 destroy: function() { 15279 if (this.lonLat instanceof Array) { 15280 this.lonLat.length = 0; 15281 this.lonLat = null 15282 } 15283 if (this.transLonLat instanceof Array) { 15284 this.transLonLat.length = 0; 15285 this.transLonLat = null 15286 } 15287 }, 15288 setVisibility: function(visible) { 15289 if (((visible == false) || (visible == true)) && (this.visible != visible)) { 15290 this.visible = visible; 15291 if (this.layer) 15292 if (this.visible) this.layer.addObjects(this); 15293 else this.layer.removeObjects(this) 15294 } 15295 }, 15296 setPosition: function(lonLat) { 15297 this.lonLat = lonLat.clone(); 15298 this.redraw() 15299 }, 15300 redraw: function() { 15301 with(this) { 15302 if (_feature) _feature.closePopup(); 15303 var l = layer; 15304 if (l) { 15305 l.removeObjects(this); 15306 _feature = null; 15307 l.addObjects(this) 15308 } 15309 } 15310 }, 15311 bringToFront: function() { 15312 if (_feature) _feature.bringToFront() 15313 }, 15314 setProperties: function(properties) { 15315 L.Util.extend(this, properties); 15316 this.redraw() 15317 }, 15318 showInfo: function() { 15319 if (this.layer) this.layer.showInfoObject(this) 15320 }, 15321 onAdd: function(layer) { 15322 this.layer = layer; 15323 return this 15324 } 15325}); 15326E.Object.PointObject = E.Object.extend({ 15327 externalGraphic: 'default/img2/marker-gold.png', 15328 graphicXOffset: 0, 15329 graphicYOffset: 0, 15330 graphicWidth: 10, 15331 graphicHeight: 10, 15332 backgroundGraphic: "", 15333 backgroundWidth: 10, 15334 backgroundHeight: 10, 15335 backgroundXOffset: 0, 15336 backgroundYOffset: -7, 15337 graphicZIndex: 11, 15338 backgroundGraphicZIndex: 1, 15339 riseOnInfo: false, 15340 initialize: function(options, attributes) { 15341 E.Object.prototype.initialize.apply(this, [options]); 15342 this.attributes = attributes 15343 }, 15344 destroy: function() { 15345 E.Object.prototype.destroy.apply(this, arguments) 15346 }, 15347 getFeature: function() { 15348 with(this) { 15349 if (_feature) return _feature; 15350 var a = icon ? icon : L.icon({ 15351 iconUrl: externalGraphic, 15352 iconSize: [graphicWidth, graphicHeight], 15353 iconAnchor: [-graphicXOffset, -graphicYOffset], 15354 shadowUrl: backgroundGraphic, 15355 shadowSize: [backgroundWidth, backgroundHeight], 15356 shadowAnchor: [-backgroundXOffset, -backgroundYOffset] 15357 }), 15358 l = labelStyle ? labelStyle : { 15359 fontColor: fontColor, 15360 fontSize: fontSize, 15361 fontFamily: fontFamily, 15362 fontWeight: fontWeight, 15363 offset: [-labelXOffset, -labelYOffset], 15364 noHide: labelVisible, 15365 className: 'leaflet-label-' + labelType 15366 }, 15367 p = popupStyle ? popupStyle : { 15368 offset: [-popupXOffset, -popupYOffset], 15369 maxHeight: 200 15370 }; 15371 _feature = new E.Marker(lonLat.getLatLng(), { 15372 icon: a, 15373 raiseOnHover: autoInfo, 15374 riseOnInfo: riseOnInfo, 15375 clickable: clickable 15376 }); 15377 if (label) _feature.bindLabel(label, l); 15378 if (innerHTML) _feature.bindPopup((name.length > 0 ? "<div style='font-weight:bold'>" + name + "</div>" : '') + innerHTML, p); 15379 _feature._mainObj = this; 15380 return _feature 15381 } 15382 }, 15383 setPosition: function(ll) { 15384 with(this) { 15385 lonLat = ll.clone(); 15386 if (_feature) _feature.setLatLng(ll.getLatLng()) 15387 } 15388 } 15389}); 15390EMAPI.Object.PolylineObject = EMAPI.Object.extend({ 15391 _class: E.Polyline, 15392 lonLat: null, 15393 stroke: true, 15394 strokeColor: "#339933", 15395 strokeOpacity: 1, 15396 strokeWidth: 3, 15397 strokeLinecap: "round", 15398 strokeDashstyle: "solid", 15399 fillOpacity: 0.9, 15400 fillColor: '', 15401 initialize: function(options, attributes) { 15402 EMAPI.Object.prototype.initialize.apply(this, [options]); 15403 this.attributes = attributes 15404 }, 15405 destroy: function() { 15406 EMAPI.Object.prototype.destroy.apply(this, arguments) 15407 }, 15408 setGeometry: function(geometry) { 15409 this.lonLat = geometry; 15410 this.redraw() 15411 }, 15412 _getStyle: function(a) { 15413 return { 15414 dot: '1, 5', 15415 dash: '5,5', 15416 dashdot: '5,5,1,5', 15417 longdash: '10,5', 15418 longdashdot: '15,10,5,10', 15419 solid: '1' 15420 } [a] 15421 }, 15422 getFeature: function() { 15423 with(this) { 15424 var l = labelStyle ? labelStyle : { 15425 fontColor: fontColor, 15426 fontSize: fontSize, 15427 fontFamily: fontFamily, 15428 fontWeight: fontWeight, 15429 offset: [-labelXOffset, -labelYOffset], 15430 noHide: labelVisible, 15431 className: 'leaflet-label-' + labelType 15432 }; 15433 var p = [], 15434 i; 15435 for (i = 0; i < lonLat.length; i++) p.push(lonLat[i].getLatLng()); 15436 _feature = new this._class(p, { 15437 fillOpacity: fillOpacity, 15438 fillColor: fillColor, 15439 color: strokeColor, 15440 stroke: stroke, 15441 opacity: strokeOpacity, 15442 weight: strokeWidth, 15443 dashArray: _getStyle(strokeDashstyle), 15444 raiseOnHover: autoInfo, 15445 clickable: clickable 15446 }); 15447 p = popupStyle ? popupStyle : { 15448 offset: [-popupXOffset, -popupYOffset], 15449 maxHeight: 200 15450 }; 15451 if (label) _feature.bindLabel(label, l); 15452 if (innerHTML) _feature.bindPopup((name.length > 0 ? "<div style='font-weight:bold'>" + name + "</div>" : '') + innerHTML, p); 15453 _feature._mainObj = this; 15454 return _feature 15455 } 15456 } 15457}); 15458E.Object.PolygonObject = E.Object.PolylineObject.extend({ 15459 _class: E.Polygon 15460}); 15461(E.Cookie = { 15462 _cookie: null, 15463 initialize: function() { 15464 this._cookie = document.cookie.split("; "); 15465 for (var i = 0, elem; i < this._cookie.length; i++) 15466 if (this._cookie[i].length > 0) { 15467 elem = this._cookie[i].split("="); 15468 elem[1] = elem[1].replace(/@/g, "="); 15469 this._cookie[i] = { 15470 name: elem[0], 15471 val: elem[1] 15472 } 15473 } 15474 }, 15475 getCookie: function(name) { 15476 for (var i = 0; i < this._cookie.length; i++) 15477 if (this._cookie[i].name == name) return this._cookie[i].val 15478 }, 15479 setCookie: function(name, val) { 15480 var d1 = new Date(), 15481 data = new Date(), 15482 val1 = val, 15483 i, f = false; 15484 data.setDate(d1.getDate() + 30); 15485 val = val.replace(/@/g, "="); 15486 var cookie = name + "=" + val + ';expires=' + (data).toGMTString(); 15487 document.cookie = cookie; 15488 for (i = 0; i < this._cookie.length; i++) 15489 if (this._cookie[i].name == name) { 15490 this._cookie[i].val = val1; 15491 f = true; 15492 break 15493 } if (!f) this._cookie.push({ 15494 name: name, 15495 val: val1 15496 }) 15497 } 15498}).initialize(); 15499E.Control.Legend = E.Control.extend({ 15500 options: { 15501 position: 'bottomright' 15502 }, 15503 _barHiden: true, 15504 _container: null, 15505 _belka: null, 15506 _hidden: true, 15507 _status: true, 15508 _activeId: -1, 15509 _className: 'emapi-control-legend', 15510 _legends: [], 15511 _items: [], 15512 hiden: true, 15513 addLegend: function(ids, type, style) { 15514 var i, a = this._legends.length; 15515 this._legends.push({ 15516 ids: ids, 15517 body: '', 15518 style: style 15519 });
15520 for (i = 0; i < ids.length; i++) this._items[ids[i]] = { 15521 v: false, 15522 id: a 15523 }; 15524 this._loadLegend(type, a) 15525 }, 15526 onVisibleChange: function(e) { 15527 var id = e.layer.id, 15528 visible = e.layer.visible; 15529 if ((this._items[id]) && (this._items[id].v != visible)) { 15530 this._items[id].v = visible; 15531 var i, a = this._legends[this._items[id].id], 15532 c = false; 15533 for (i = 0; i < a.ids.length; i++) c = c || this._items[a.ids[i]].v; 15534 if (c) this.showLegend(this._items[id].id); 15535 else this.hideLegend() 15536 } 15537 }, 15538 deactivate: function() { 15539 this.activeId = -1; 15540 this._hidden = true; 15541 this._belka.hide() 15542 }, 15543 activate: function(index) { 15544 var ai = 0; 15545 if (this.activeId != index) { 15546 ai = 1; 15547 this.activeId = index; 15548 this._content.text(this._legends[index].body) 15549 } 15550 this._belka.Class(E.format('{0}-belka belka_{1}_{2}', [this._className, this._legends[index].style, this._status ? 'show' : 'hide'])); 15551 if (ai) { 15552 this._hidden = false; 15553 this._belka.show() 15554 } 15555 return ai 15556 }, 15557 hideLegend: function(id) { 15558 this.deactivate(); 15559 if (!this._status) this._onClick() 15560 }, 15561 showLegend: function(id) { 15562 if (this.activate(id)) 15563 if (this._status) this._onClick() 15564 }, 15565 onAdd: function(map) { 15566 this._map = map; 15567 this._container = E.newElem$('div', this._className); 15568 this._belka = E.newElem$('div', this._className + '-belka belka_blue_show').click(this._onClick, this).hide(); 15569 this._content = E.newElem$('div', this._className + '-content').hide(); 15570 map.on('onVisibleChange', E.bind(this.onVisibleChange, this)); 15571 return this._container.append([this._belka, this._content]).elem() 15572 }, 15573 _onClick: function() { 15574 this._status = !this._status; 15575 if (!this._status) { 15576 this._belka.Class(this._belka.Class().replace('show', 'hide')); 15577 this._content.show(); 15578 this._belka.right(this._content.width()) 15579 } else { 15580 this._belka.Class(this._belka.Class().replace('hide', 'show')); 15581 this._content.hide(); 15582 this._belka.right(0) 15583 } 15584 }, 15585 _onGetData: function(res, obj) { 15586 this._legends[obj.id].body = res.data; 15587 if (obj.id == this.activeId) this._content.text(res.data) 15588 }, 15589 _loadLegend: function(type, id) { 15590 this._map.url('poi/Legends/Legends.php', { 15591 'lang': E.Lang.code(), 15592 'type': type 15593 }, this._onGetData, this, { 15594 id: id 15595 }) 15596 } 15597}); 15598E.Map.addInitHook(function() { 15599 this.legend = new E.Control.Legend(); 15600 this.legend.addTo(this) 15601}); 15602E.POI.Layer.addInitAction(E.POI.Layer.Parser.extend({ 15603 init: function() { 15604 this._priorityValue = 0; 15605 this.setParams(['P', 'H', 'M'], 1, 0, false); 15606 this._previusLayer = "M"; 15607 this._currentLayer = "M"; 15608 this._layerType = 1; 15609 var c = [{ 15610 id: 'M', 15611 name: E.lang("LP_PLNM"), 15612 subCat: [], 15613 minZoom: 19, 15614 maxZoom: 0, 15615 visible: true, 15616 categoryId: 1, 15617 type: 1 15618 }, { 15619 id: 'P', 15620 name: E.lang("LP_PLNP"), 15621 subCat: [], 15622 minZoom: 19, 15623 maxZoom: 0, 15624 visible: false, 15625 categoryId: 1, 15626 type: 1 15627 }, { 15628 id: 'H', 15629 name: E.lang("LP_PLNH"), 15630 subCat: [], 15631 minZoom: 19, 15632 maxZoom: 0, 15633 visible: false, 15634 categoryId: 1, 15635 type: 1 15636 }]; 15637 this._layer.addCategories(c); 15638 this._layer._owner._customCategory.push(c[0]); 15639 this._layer._owner._customCategory.push(c[1]); 15640 this._layer._owner._customCategory.push(c[2]); 15641 this._layer.setCetegoryVisible('M', true); 15642 this._errorTile = "data:image/png;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAA8AAD/7gAOQWRvYmUAZMAAAAAB/9sAhAAGBAQEBQQGBQUGCQYFBgkLCAYGCAsMCgoLCgoMEAwMDAwMDBAMDg8QDw4MExMUFBMTHBsbGxwfHx8fHx8fHx8fAQcHBw0MDRgQEBgaFREVGh8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx//wAARCAEAAQADAREAAhEBAxEB/8QAnAABAAICAwEAAAAAAAAAAAAAAAQFAwYBAgcIAQEBAAMBAAAAAAAAAAAAAAAAAQIDBQQQAAEEAQEDBA8IAQIEBgMAAAEAAgMEBREhEgYxQRMUUWFxsdEicpKyU3OTNFQVgZGhMkJSYjUjwSThgsIH8aLSM0MWoyUXEQEAAgIBAwQDAQEAAAAAAAAAAQIRAxIhMQRBYXEyUSIUE0L/2gAMAwEAAhEDEQA/APo6eecTyASOADjoNT2UHTrFj1r/ADigdYsetf5xQOsWPWv84oHWLHrX+cUDrFj1r/OKB1ix61/nFA6xY9a/zigdYsetf5xQOsWPWv8AOKB1ix61/nFA6xY9a/zigdYsetf5xQOsWPWv84oHWLHrX+cUDrFj1r/OKB1ix61/nFA6xY9a/wA4o
15642HWLHrX+cUDrFj1r/OKB1ix61/nFA6xY9a/zigdYsetf5xQOsWPWv84oHWLHrX+cUDrFj1r/ADigdYsetf5xQOsWPWv84oHWLHrX+cUDrFj1r/OKB1ix61/nFBGyNq0zH2XNme1zYnlrg4gghp0IOqCTY+Il8t3fQY0BAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQRsn/W2/YyeiUE2x8RL5bu+gxoCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgjZP+tt+xk9EoJtj4iXy3d9BjQEBAQEBAQEBAQEBAQdXPa0auIA7JOiDGblQcs8Y/5m+FBy21Wd+WZh7jggyAgjUbQg5QEBAQEBAQEBAQEBAQRsn/W2/YyeiUE2x8RL5bu+gxoCAgICAgICAgIOks0UTC+RwY0c5QVdnPsBIrs3v5u2D7uVXCZYo2cQX9sTJAw8hH+NvnHTVBIj4RyUh3ppY2E8upLj3v8AVMmGdvBTv1XAO5Hr/wBQTJhw7guUfkttJ7bCP9SmTCO/hfMwauge1/s3lp/HdTJhHdbzNEhtmN27zdI3Ye44cv3oJlXOVpdGyjondk7W/emDKxBBAIOoPIQorlAQEBAQEBAQEBBGyf8AW2/YyeiUE2x8RL5bu+gxoCAgICAgICAgrshl46+scWkk3P8Atb3VcJlGpYbJ5V4nmcY4TySP5x/BqDZaGBxtMAtjEko/+WTxj9nMFFWKAgICAg4c1rmlrgHNPKDtBQU2Q4WoWAXQf7eX+P5D3W+BXKYa9JHlcNNuyD/ETs5TG7uHmKC2pX4LbNWHR4/NGeUKKkoCAgICAgICAgjZP+tt+xk9EoJtj4iXy3d9BjQEBAQEBAQEFRlcqWk1q58fke8c3aCqTKdg+GWtDbN9u887WQHkHbf2+0mTDZANNg5FFcoCAgICAgICDHNBDPE6KZgfG7Y5p2hBqGYwc+Nk61UcTXB11/Uzu9pVErG5Fltm67xZm/mb2e2FFTUBAQEBAQEBBGyf9bb9jJ6JQTbHxEvlu76DGgICAgICAgrsvkOrx9FGf80g5f2t7KsJKRwzgw1rb9lur3bYGHmH7j2+wkkNlUUQcEgDU7AOUoKe7xdgKji11kSvHK2IF/4jxfxW2um0+jTbyKR6oH/9Cwm9p0VjTs7jNPTWf81mv+unun0uLsBbcGtsiJ55Gygs/E+L+KwtptHo2V8ik+q4BBAIOoPIVqbnKAgICDhzWuaWuAc1w0IO0EFBpmbxUmLtts1tRXcdWH9rv2ntKosadtlqASt2Hkc3sHsKKzoCAgICAgII2T/rbfsZPRKCbY+Il8t3fQY0BAQEBAQdJpWRROkedGsGpQVGGpPyuTdNONYYzvyDmP7WKo3UDTYORRXKCLkcjVx9R9qy7djZyDnceZrRzkrKtZtOIY3vFYzLzbOcUZDKvc0uMNTXxa7Ts0/kf1Fe/Xqivy5m3fa/wxY7hnNX2h8FciI8kkh3G/Zry/YrbbWvdjTRa3aFkf8At9nA3XpK5P7Q92vo6LX/AE1bf5L+ypyOAy2O22q7ms9Y3xmfeFtrsrbs031Wr3hIwfFGQxT2tDjNU18au47NP4n9JWOzVFvlnq32p8PSsdkauRqMtVnb0b+Uc7TztcOyF4LVms4l06Xi0ZhKWLIQEBBht1YrVd9eUaskGh7XYI7iDSqplxmTfVm2NJ3H9j+LlUX6iiAgICAgII2T/rbfsZPRKCbY+Il8t3fQY0BAQEBAQVGfs6MZXafzeM/uDk/FWElsWBoCnjY2kaSyf5Je67m+wKKsUBB5hxfm3ZHJujY7/aViWRAchI2Of9vN2l0NOvjHu5fkbeVvaF1wfwpE6JmRvsDi7xq8LuTTmc4d5at+70hu8fR/1LdAABoNgHIF5HucoOr2Me0se0Oa7YWkaghB5/xhwsyj/vqTdKrjpLGP0E8hH8V7dO3PSe7neRo49Y7IXCGbfjsm2N7v9pZIZKDyAnY1/wBnP2lnu18o92Hj7eNvaXp657qCAgICDWuMKAMcd1g2t/xy9w/lP3qwkuuMs9YpscTq9viv7o/4KKloCAgICAgjZP8ArbfsZPRKCbY+Il8t3fQY0BAQEBAQUbI+v8QMiO1gk0I/jHtd9+iqN4UUQQM7bdUw9uw06PZG7cPYc7xWn7ys9dc2iGvbbFZl5dhqYu5SrVP5ZZAH+SNrvwC6F7YiZcrXXlaIevta1rQ1o0a0aADmAXMdlygICDDbrRWqsteUaxytLHfaFazicpauYw8cnidDPJC780biw91p0XUicuLMYnD1rBW3W8PUsOOr3xt3z2XN8Vx+8Lm7K4tMOvqtmsSnrBsEBAQR8hWFqlNXP/yMIb5XK38UGocPykSSwnnG8B2xsPfVlIXaiiAgICAgjZP+tt+xk9EoJtj4iXy3d9BjQEBAQEHV7g1pceRoJP2IK3hGPpMlLM7aWRk69txH
15642/FWUhuCiiCl4xa48N3QOXRh+wSNJW3R94aPI+ktF4Qe1nEdIu5C5zftcxwH4lezd9JeDx5/eHqi5zrPOspwnxBPk7k8VXeilnkfG7pIxq1zyQdC7XkXupurER1c6+i82mcIv/wBN4k+T/wDyRf8ArWX+9Pyw/mv+Fpwzwzm6WbrWbNbo4I9/ffvxu03o3NGxrieUrXt21msxEtunTatomYb2vG97x7LPbJlbr2/ldPK5vcLyV1KfWHG2T+0/L0fg5pHDdIHl0efsMjiF4N/3l0vH+kLpam8QEBAQaO1vV+IpYxsb0r2gdp2pCqLxRRAQEBAQRsn/AFtv2MnolBNsfES+W7voMaAgICAgw3DpUnPYjd3igwcFN8a47sCMffveBWUhtKiiCNkaguULFU7OmjcwHsEjYfsKyrOJyxvXMTDyKKSencbIAWT15AdDsIcw8n4LpzGYceJms/D1zG5CDIUorcJ1ZINSOw7nB7i5lq8Zw7FLxaMwlLFkICCr4iy0eMxksxOkzgWQN5y8j/TlWzVTlLVu2ca5eUsZJLI1jQXSPIDRzkk6LouTHV7Djqgp0K9UbehjawnskDaftK5lrZnLs0rxiISViyEBAQEGlZUbvE7tPWR/i1qqLlRRAQEBAQRsn/W2/YyeiUE2x8RL5bu+gxoCAgICDFabvVpm9ljh+CCNwW7SW2zstYfuJ8KspDalFEBBoPHPD74Z3ZSu3WGU/wC5aP0v/d3Hd9ezx9mYxLn+VpxPKFRw/wAR2sPMd0dJWef8sJOn2jsFbdmqLNOndNJ9noGO4mw19gMVhrJDyxSEMcPv5fsXitqtDo03Vt6rIyxhu+XgN/cSNPvWvDZlUZTi3DUGuHTCxMOSKIh23tkbAttNNpab+RWrzzM5q5lrXT2Do0bI4h+Vo7S91NcVjo52zZN5zK/4G4ffNO3KWG6QxH/bNP6n/u7je+tHkbMRiHo8XTmeUtqo8R4u5fmowyf54iQ3XTdfpy7h59F57apiMvXXdW04haLW2iAgICDSckek4ndpzSs/8oHgVRdKKICAgICCNk/6237GT0Sgm2PiJfLd30GNAQEBAQcEAjQ8hQVXC7+gzL4Hfra+P7WnX/pVlIbkoogIOr2MkY5j2hzHAhzSNQQeUEITDSM7wHIHunxXjMO01XHQjyHHl7hXr1+R6WeDb4vrVqNirZrSGOxE+GQfpe0tP4r1RMT2eOazHdiVRlr1bNmQR14nzSH9LGlx/BSZiO6xWZ7NtwfAj9RZy5DI2+N1YHafLcNgHcXm2eR6VezV4vrZk4m4ugZAcbiSN3TcknZsa1vJux6d/wC5TVpnvZd3kRjjVpcckkUjZI3FkjCHNc06EEchC9Uw8UTh6PwrxTHk4xVtEMvsHcEgHOO32QvDu08esdnS0b+XSe7Y1oekQEBBo1N3Ws5LONrS6ST7CSB31UXqiiAgICAgjZP+tt+xk9EoJtj4iXy3d9BjQEBAQEBBQ23Gjmo7IHi7zZO6ORw+3aqjeWua5oc06tcNQeyCorlAQEBB0kiilbuSsa9v7XAEfcVYlJjKN9Gw+u91Gvr2eiZr3ledvyx/zr+ISY4oom7kTGsb+1oAH3BSZZRGEbLY5mRx81N7iwSjQPbygg6g9varS3GcsdlOUYeVZPGW8bbdWst3Xt2tcPyubzOaewujS8WjMOTek1nEoizYu0ckkUjZI3FkjCHNc06EEc4UmCJw9I4V4pjycYrWSGX2DuCQD9Te32QvDu08esdnS0b+XSe7YloekQQc1bFXGTy66OLdxnlO2D7uVBrPD8GjJZiOUhjfs2lWUhcKKICAgICCNk/6237GT0Sgm2PiJfLd30GNAQEBAQEFbnKvS1hK0eNFtPknlVhJWnC2QFih0Dj/AJa/i91n6T/okkLpRRAQEBAQEBBXZvCVMtUMMw3ZG7YZh+ZjvB2Qs9eyay17dUXjEvL8njLeNturWW7r27WuH5XN5nNPYXRraLRmHKvSaziUeGGSaZkMY3pJHBjG7Bq5x0A2qzOGMRmcMs8FzH3Ojk1htQlrvFcCWkgOBBaT2VImLR7Mpiaz7vV8Lant4mrZnGkssbXP5tT2ft5VztkYtMQ62u0zWJlNWDNqXFl4z2o6MW0RHV4HO93IPsCsJKXTrivWjiHK0eMe2dpUVmQEBAQEBBGyf9bb9jJ6JQTbHxEvlu76DGgICAgICDggEEEag7CEFDHJLhsqJG6mLsfujPKO6FUbvBNFPCyaJ29G8atcOwVFZEBAQEBAQEBBXZvCVMtUMMw3ZG6mGYDxmO8HZCz17JrLXt1ReMS8wv4+9irphmBjmjIdHI0ka6HY5jl0K2i0OXek0nEtg4Z4ZsZSYZLJl76+oLRISXSkbBqTt3QtO3bFekPRp0zeeVuzf2ta1oa0ANA0AGwABeJ0ELL5OPH03SnQyu8WFnZd4Ag1XD1nz2HXJvG0JIJ53nlKspC8UUQEBAQEBBGyf9bb9jJ6JQTbHxEvlu76DGgICAgICAgjX6TLcBYdjxtjd2Cgg4PMSY2c1LWork7deVjuz3FUbk1zXNDmkOa4agjaCCorlAQEBAQEBAQY5a8EwAmjbIG7W77Q7Q9rVWJmEmInu7gADQciisNy5Xp13Tzu3WN+8nsDtoNLmmtZrIb7vFibsA5mM8JVReRRMijbGwaMaNAFFd0BAQEBAQEEbJ/1tv2MnolBNsfES+W7voMaAgICAgICAghZHGsts3m6Nmb+V3Z7RQRMXm7eLk6tZaXVwdrD+Zvbb2lUbdVt17UQlrvEjDzjm7RHMorMgICAgICAgIIOTy9PHx6yu3pSPEhb+Y+AdtBqU02QzVref4sTeQfoYP8AUqouatWKtEI4xs5zzk9kqKzICAgICAgICCNk/wCtt+xk9EoJtj4iXy3d9BjQEBAQEBAQEBBgt04LTN2UbR+Vw5R3EFOauTxkpmqvJaP1M7H8mqotqHGEZAZdj3T62PaPtbypgyva2QpWhrXmZJ/EHxvNO1RUhAQEBBBt5rGVQelnaXD9DPGd9w5PtQUF7iy1OeioxmIO2B58Z57g5ArhMolbD2J39NccRvbSCdXnulMmFzFFHEwMjaGsHIAorugICAgICAgICCNk/wCtt+xk9EoJtj4iXy3d9BjQEBAQEBAQEBAQEESzjKdgkuZuvP627D4EFfLw/IDrDKD2A7YfvGquUw4a3iKvsjll3RyBr94fcSg7jK8Tt2b0nu2n/pQcHJcTybN6Uf8AIG/6BB0dTzlr/wB+VxB5pJCR9wJQZYOH2DbNKT/Fg0/Epkwsq9OtXGkUYaed3KfvKisyAgICAgICAgICAgjZP+tt+xk9EoJtj4iXy3d9BjQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBBGyf9bb9jJ6JQTbHxEvlu76DGgICAgICAgICAgICAgICAgICAgICAgICAgICAgICCNk/wCtt+xk9EoJtj4iXy3d9BjQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBBGyf8AW2/YyeiUE2x8RL5bu+gxoCAgICAgp+MJHx8K5Z8bix7aspa5p0IIYdoIQeeT3MJHw3jn4e/Zj4pmZWDP89kMfM7c6UP6V3Q7v5u0gv8Ai80n8XYWtlbfVaD60xncJ3V2F7fy6vDmc/IgkcFyFvEGVrY25Le4eiZGYZpZHTMbOfzMildrvDTl0KCst5vJDiiTiRszhgaNxmJli1IYWEFssxHJo2Vw2oLnjvKxYu5gbc8zoasdt7rBbrtaIidCBy7eZB34XZczthvE9+QtheC3FUI5CY449SC+Td2Old+HeDJ/3Lmmh4JyUkL3RyN6HdewlrhrPGNhCCHl+GG0MJJlMJas08hUhNhv+eaaOXcbvOY+OV72kOH4oJOY4mm/+jxZOBpbfycMUVSJvL09kAAN8nUkdxBxwJLcqC/w7kJjPcxUoMcziSZIJxvsdq7l0Oo7XIg1zB5rJYniLK37czpcFay9nHz7xJFaRr96KTb+Vh6TdP8A4IL5tV2T4o4nx0k0jYZKtRsZa4jo3OY4h7NDsIIBQU7c/mMhjq/B++6LiEzGnkbDddWVodC6wHfzZoB2dvaQWmRrWMrxNFwzHPNVw2OpsntCF5bJM4ndZG6QeNu6DU9nagtIuFsVhq92zj+niLq0jTEZ5ZI9d3Xe3Xud42zlQUPBvHnDVXhmhXyOTa27GxwmEgkc7Xfcdp0PMgsv+2dmSzwz0z5HSl1mfde4lx3d/ZyoNsQEBAQEBBGyf9bb9jJ6JQTbHxEvlu76DGgICAgICCr4oqWLnDmSq1mdJYnrSRxRggbznNIA26BBqtqDiK/wfX4bbgpI5+rQVpLVmSAQsMTWh0g3Xvefy7NmqCytcP238U4KZ8PWqVKnLBZnfukb+7o0lrjrq4oI8NDiDh+TNUsVUdZx1iN1nE7jmAQ2JPFdFo5w8UHxhzadtB1r/wDa7AHANq2InHJPg0lsdNNp07m6l+5v7mx/8UBmMz12pwqb9Mixj5z9QDixwDWMLGyHQkHe0B2IJuLxGRwGffBQhM3DuRLpTG0tHVJ+fQEj/G/sDk74SOP8beyfCV+lRiM1qXoujiBAJ3ZmOO1xA5GlBAyc3FWXxjsRUxL8e2zH0Fm9bki0ZG4br9yOJz3OJbrog63uETeyWIxM8L3cO4irqXl+4ZpwBGwasIeC0De1GiDs3hNuD4lx2QwVZ/VZhJVyjDK6QhjtCyTWVzj4rht0QZcFw2+ShxFQy1fSvksnbmjaSDvQy7u5INCdDqNRzhBF4EwXEGMzGVdlgZI9yCvUtktPSxwbzWkgEnXd011QWFTE3I+Pr2TdBpTmpRxMn8XbI1w1Gmu9yBBhzeOzVDiWPiLE1heZJX6rkKQcGSFodvNkjLtmo7HhQTq+UyeTr3IX4ixRZ0DxHJYdGC95GgYGtc48/Kg54JoXMfwtj6dyMw2YWOEkZIJBL3HlBI5CgwcBYy/jcCa16Iwz9YmfuEg+K9+rT4pPKEGxoCAgICAgjZP+tt+xk9EoJtj4iXy3d9BjQEBAQEBAQEBAQEBAQEBAQEBAQEBBxqNdNdvLpz6IOUBAQEBAQEBBGyf9bb9jJ6JQTbHxEvlu76DGgICDBchtSxBtax1d4dqX7gfqNDs0KDXamUzTmZm22y2xj6MMkdWUxtaZLMQJkcN0/kYRuds69hBI4f4m6zww/J5Etjnpsf18N2AFjd8ED+bC1w7qCpg4o4jk4XZdMcTcq7I9T6u4aM16bo+jJ5ify7yC3scRmWvhLNLxY8hdbWsMkHjsHRyl8ZH6XtfHoUEO3xFkmYu/O2RkckGVbRjkLQQ2F00cepBOhIDygsnWrMGOv2W5GO6+CvJJG1rWANc1pcCdwnsIIsuVvT5KjQ643HssU22WzbjS+aVx0dHH0mrRuDRxGhO0ILSStkxVjByIZJEHGafoWaPGuoJBOjd0cqCJwtbyl2vPctSiWnNJ/wDrTuCN7
15642oW7OldpzSHa3+OnZQdJrWXs8RW8dVttqw1qsEzCYhJq+V0jTrqW7P8AGEEJnEGVt0sMY3x1571yapYlYzfYRAJhvxhx5HGEEIJtG5lZshksRJZjdLUZBLFdjjAIExdrHJGXObvAR8uzYeRBggnz9jM2KVW+yStTicLNh0LdBZkbrFG3Q7dwHff9g50CHiO3drUKldrY8xYldFej03hX6sR1lxHY5AzX9zSghjP5J1PK3DlK1eSlatQwVZY2kObBI5rGnRzZCXaabEFtWy92XO0qcjBFFYxr7csJHjtlEkTd3U9gSEIM+QyFmDOYmnGR0NzrHTAjU/4ow5uh5tqCpzTMtWv1BUuMly9wmCvvQM8SuHB8z3kHXcboO67QIMzsndlzuSpOyUVKGmIOiDmMJd0se846uI50HTLcR3MXmKMLy2fHdVM2QlA0c1oeyPpxps3WueC4dg68yCXZy9pmbu1Iy014May5Fs1PSOklbrr2NGBBXjPZGZnDbTbjqfVKL7NqZzGkdI2OFwDd4gDbIUGxY8vNfV9ptwlx0mYGtGnY8UkIJSAgII2T/rbfsZPRKCbY+Il8t3fQY0BAQVHE0mUGO6HGxSPlsvEUs0O5vwxO/PI0Pc0F2mxvb2oMG65+Ds4upjbFRjKckVdsoiDSdzda0Fr3neOvOgqxw3kzZxsLWBuPtwVfrTSRq2Si0Fg0HL0visdpzNQd/ouU6h0fQHf+v9d3dW/D9c6TpOX9m3soMmV4fvt4hx9qi3fx8l1tu9ECB0UzInx9K0Hmka/RwHOAeygw3MNkjiMjF1V0r5cw22yEFhL4GzxvJGpA/K07CUFjfnrjBZZwxz8e1tSYufIyJgd/jds/xucg7yyV3YyvTuYqa9A6vGTpFHLGTu6bujnahw7YHdQVBpZ5uGqYuapYfTszzPtsjeySWKp0hdFVLnPG9vNIa4h2xuoQbTQtOma5nU5qbYg0MbKIwCNuxoY5/JogqZeH47nE921drCWm+pXiic4+KXNfKXtLQduxw5Qg7Z3BstTYSCKqx9CpZLpoQGhjIhBIxvi7Nm8QNAgiR08rga+Vq4ij08ch6xjXN3BuvmdpIyTeLS7o3eOOy3xeZBPwH+zrw0G0LbB4zprc4i8eR2rnySFsjjvPd2vwQcY7FPg4rzGQdAGR2oarYp9mrnMEgk5Nv7EFPDjpo6mVq2MC+5PauW5IJCINxzZpXOjcZHPDmjQ68moQS4qeVx+WxdmavLf6vijTszwlhJn34iXHpHMPjdGTqgmWIrl3NYa62rLDDWNoTiXcDm78Ya0kNc78x7CCJiZ8iy3ayd/FWzesno42N6BzYa7Cejiael5/zPPOT2gg56tJBxDlLVjEyXIbQr9Xka2F+nRx7rx472kbUEo4+WfiSvbfWLaDsZLXkY/d0a6SWJwic0E/paeTYgrMdgMtTymTjeDNSbjxUxs5cC4sD5Hsidrt3o+k3decaIOGYu7A3hV8+OfaZj8fJBchaInlkrooGgEPc0Hax3Ig2fHvY6vqyo6m0OI6F7WNPd0jLhtQSkBAQRsn/W2/YyeiUE2x8RL5bu+gxoCAgICAgICAgi3cVjbxjN2rFZMJJi6Vgfu6kE6a9to+5BKQEBAQEBAQEBAQEBAQEBAQEBAQEEbJ/wBbb9jJ6JQd58pjDPIRbhILjoekZ2e6g6fU8b83D7xvhQPqeN+bh943woH1PG/Nw+8b4UD6njfm4feN8KB9TxvzcPvG+FA+p435uH3jfCgfU8b83D7xvhQPqeN+bh943woH1PG/Nw+8b4UD6njfm4feN8KB9TxvzcPvG+FA+p435uH3jfCgfU8b83D7xvhQPqeN+bh943woH1PG/Nw+8b4UD6njfm4feN8KB9TxvzcPvG+FA+p435uH3jfCgfU8b83D7xvhQPqeN+bh943woH1PG/Nw+8b4UD6njfm4feN8KB9TxvzcPvG+FA+p435uH3jfCgfU8b83D7xvhQPqeN+bh943woH1PG/Nw+8b4UD6njfm4feN8KB9TxvzcPvG+FA+p435uH3jfCgjZHI49+PstbZic50Tw1oe0kktOgA1Qf/Z"; 15643 this._hybrid = new L.tileLayer.wmts((window.location.protocol != 'https:' ? 'http:' : 'https:') + '//mapy.geoportal.gov.pl/wss/service/PZGIK/ORTO/WMTS/StandardResolution', { 15644 maxZoom: 19, 15645 layer: 'ORTOFOTOMAPA', 15646 tilematrixSet: "EPSG:3857", 15647 errorTileUrl: this._errorTile 15648 }) 15649 }, 15650 onVisibleChange: function(a) { 15651 var b = this._map._layers, 15652 i; 15653 if (!a[1] && a[0] == 'P') { 15654 a[1] = 1; 15655 a[0] = this._previusLayer 15656 } 15657 if (a[1] && a[0] != this._currentLayer) { 15658 for (i in b) 15659 if (b[i].options.baseLayer) { 15660 this._currentLayer = a[0]; 15661 if (a[0] != 'P') this._previusLayer = a[0]; 15662 var l = a[0] == 'M' ? 'std' : (a[0] == 'P' ? 'hipso' : 'hybrid'); 15663 if (l == 'hybrid') { 15664 this._map.addLayer(this._hybrid); 15665 this._hybrid.bringToBack() 15666 } else this._map.removeLayer(this._hybrid); 15667 b[i].setLayerType(l); 15668 break 15669 } 15670 } 15671 }, 15672 getPriorityValue: function(id) { 15673 return id == 'M' ? 7 : 0 15674 }, 15675 getCategoryPositionIndex: function(id) { 15676 return id == 'P' ? 5 : 0 15677 } 15678})); 15679E.POI.Layer.addInitAction(E.POI.Layer.Parser.extend({ 15680 init: function() { 15681 this.setParams([17], 1, 3, false) 15682 }, 15683 parseObjectInfo: function(obj) { 15684 var res = obj[1].searchObjectArray[0]['description'].split("$$"); 15685 return E.format('{0}</b></i></u></a><p><p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" ><param name="src" value="http://emapi.pl/poi/cache/3D/{1}.swf"><embed type="application/x-shockwave-flash" src="http://emapi.pl/poi/cache/3d/{1}.swf" ></object></p>{2}<br>{3}', [obj[0].nameLabel, res[2].toLowerCase(), res[0], res[1]]) 15686 } 15687})); 15688E.POI.Layer.addInitAction(E.POI.Layer.Parser.extend({ 15689 init: function() { 15690 this.setParams([13], 1, 3, false) 15691 }, 15692 parseObjectInfo: function(obj) { 15693 function fO1(val) { 15694 return (val < 10) ? '0' + val : val 15695 } 15696 15697 function fO2(val) { 15698 for (var i = 0; i < val.length; i++) 15699 if (val[i] != '0') return parseInt(val.substr(i)); 15700 return parseInt(val) 15701 }; 15702 15703 function l(a) { 15704 return E.lang('LP_PU' + a) 15705 }; 15706 15707 function bo(v, d) { 15708 return (v != 'True') ? '' : l(d) 15709 }; 15710 15711 function bp(v, d, t, s) { 15712 return (v != '0') ? s + (s.length > 0 ? ', ' : '') + l(d) + v + t : s 15713 }; 15714 15715 function bs(v, d, s) { 15716 return (v != '1899-12-30') ? s + (s.length > 0 ? ', ' : '') + l(d) + fd(v) : s 15717 }; 15718 15719 function br(v) { 15720 for (var i = 1; i < v.length; i++) v[0] += (v[i] != '' ? '<br/>' + v[i] : ''); 15721 return v[0] 15722 }; 15723 15724 function fd(dateElem) { 15725 var dt = dateElem.split(" "), 15726 d = dt[0].split("-"), 15727 t = dt[1].split(":"); 15728 d = (new Date(Date.UTC(d[0], fO2(d[1]) - 1, d[2], t[0], t[1], t[2]))); 15729 return d.getFullYear() + '-' + fO1(d.getMonth() + 1) + '-' + fO1(d.getDate()) + ' ' + fO1(d.getHours()) + ':' + fO1(d.getMinutes()) + ':' + fO1(d.getSeconds()) 15730 } 15731 var res = obj[1].searchObjectArray[0]['description'].split("$$$"); 15732 try { 15733 var oe3 = bo(res[2], '1') || bo(res[3], '1') ? E.format("{0}{1}{2}{3}", [l('UW'), bo(res[2], 'RDK'), res[2] == res[3] ? ', ' : '', bo(res[3], 'DZ')]) : '', 15734 oe4 = '', 15735 oe5 = bp(bs(res[10], 'OD', bs(res[11], 'DO', '')), 'OB', '', ''), 15736 a = [ 15737 ['PD', ' km'], 15738 ['ND', ' T'], 15739 ['SD', ' m'], 15740 ['WD', ' m'] 15741 ], 15742 i; 15743 for (i = 0; i < a.length; i++) oe4 = bp(res[4 + i], a[i][0], a[i][1], oe4); 15744 return br([l('WR') + res[0], res[1], oe3, (oe4 != '' ? l('OG') : '') + oe4, oe5]) 15745 } catch (e) { 15746 return null 15747 } 15748 } 15749})); 15750E.POI.Layer.Parser.MCLayer = E.POI.Layer.Parser.extend({ 15751 getObjectsFromPoint: function(obj) { 15752 return ([{ 15753 layer: this.poiLayer, 15754 pos: obj[0], 15755 id_cat: this._ids[0], 15756 obj: obj[1] 15757 }]) 15758 }, 15759 getObjectInfo: function(obj) { 15760 with(obj[0].pos) this._map.degeocode({ 15761 lon: lng, 15762 lat: lat, 15763 zoom: this._map.getZoom() 15764 }, obj[1], this._layer, obj[0]); 15765 return 1 15766 }, 15767 addLegend: function(url, style) { 15768 this._legend.addLegend(this._ids, url, style) 15769 }, 15770 _getPDiv: function(v1, v2, cn) { 15771 return E.format('<div class="{0}">{1}</div>', [cn, v1 + (v1.length > 0 ? ' ' : '') + v2]) 15772 }, 15773 onVisibleChange: function(a) { 15774 with(this._layer) { 15775 var b = _mc.indexOf(a[0]); 15776 if (a[1] && (b == -1)) _mc.push(a[0]); 15777 else if (!a[1] && (b > -1)) _mc.splice(b, 1) 15778 } 15779 } 15780}); 15781E.POI.Layer.addInitAction(E.POI.Layer.Parser.MCLayer.extend({ 15782 init: function() { 15783 this._priorityValue = 7; 15784 this.setParams([25], 1, 1, false); 15785 this._layer.addLayersCollision('S', this._ids); 15786 this.addLegend('NewRoads', 'blue') 15787 }, 15788 parseObjectInfo: function(obj) { 15789 function parseItems(response) { 15790 var data = response.split("\n"), 15791 result = [], 15792 a, i; 15793 for (i = 0; i < data.length; i++) { 15794 a = data[i].indexOf('='); 15795 result.push({ 15796 cat: data[i].substring(0, a), 15797 value: data[i].substring(a + 1, data[i].length) 15798 }) 15799 } 15800 var getDataCat = function(cat) { 15801 for (var i = 0; i < this.data.length; i++) 15802 if (this.data[i].cat == cat) return this.data[i].value; 15803 return '' 15804 }; 15805 return { 15806 data: result, 15807 getDataCat: getDataCat 15808 } 15809 } 15810 15811 function ItemValue(val) { 15812 return val.split('=')[1] 15813 } 15814 15815 function cv(val) { 15816 return val.substring(0, 2) 15817 } 15818 15819 function getRTN(val) { 15820 val = parseInt(cv(val)); 15821 return E.lang('LP_NR_' + ((val < 7) ? 'AS' : (val < 13) ? 'DE' : 'D')) 15822 } 15823 15824 function getDiv(v1, v2, cn) { 15825 return (v2.length > 0) ? E.format('<div class="{0}">{1}</div>', [cn, v1 + (v1.length > 0 ? ' ' : '') + v2]) : '' 15826 } 15827 15828 function getEtap(val) { 15829 return E.lang('LP_NR_' + [0, 4, 0, 0, 1, 2, 3, 4, 0, 0, 1, 2, 3, 0, 0, 1, 2, 3][parseInt(cv(val))]) 15830 } 15831 var res = obj[1].SpatialDataViewer; 15832 obj = obj[0]; 15833 if ((res != null) && (res.length > 0)) { 15834 for (var i = 0; i < res.length; i++) { 15835 var cats = new parseItems(res[i].name), 15836 info = '';
15837 if (cats.getDataCat('type') != "planowane") continue; 15838 var catID = cv(cats.getDataCat('KATEGORIA')); 15839 if ((catID == '01') || (catID == '07')) { 15840 info = getDiv('', getRTN(cats.getDataCat('KATEGORIA')) + ' ' + cats.getDataCat('NUMER_DROG'), 'info_construction_roads_type') 15841 } else { 15842 info = getDiv('', getRTN(cats.getDataCat('KATEGORIA')) + ' ' + cats.getDataCat('NUMER_DROG'), 'info_construction_roads_type'); 15843 info += getDiv('', cats.getDataCat('NAZWA'), 'info_construction_roads_name'); 15844 info += getDiv(E.lang('LP_NR_RL'), getEtap(cats.getDataCat('KATEGORIA')), 'info_construction_roads_level'); 15845 info += getDiv(E.lang('LP_NR_CRS'), cats.getDataCat('OPIS'), 'info_construction_roads_describe'); 15846 info += getDiv(E.lang('LP_NR_CRE'), cats.getDataCat('TERMIN_ZAK'), 'info_construction_roads_end') 15847 } 15848 this._map.showPopup(obj.pos, info); 15849 return 15850 } 15851 } 15852 this._layer.showInfo(obj.obj) 15853 } 15854})); 15855E.POI.Layer.addInitAction(E.POI.Layer.Parser.MCLayer.extend({ 15856 init: function() { 15857 this._priorityValue = 7; 15858 this.setParams([26, -26], 1, 5, false); 15859 this._layer.addLayersCollision('S', this._ids); 15860 this.addLegend('TouristMap', 'blue') 15861 }, 15862 parseObjectInfo: function(obj) { 15863 function ParseDatai18n(v) { 15864 return v ? (E.lang('LP_TR' + v) == 'LP_TR' + v) ? v : E.lang('LP_TR' + v) : '' 15865 } 15866 var res = obj[1].SpatialDataViewer, 15867 info = ''; 15868 obj = obj[0]; 15869 if ((res != null) && (res.length > 0)) { 15870 for (var i = 0; i < res.length; i++) { 15871 var data = res[i].name.split('\n'); 15872 if ((data.length > 0) && (data[0] == 'type=TuristInfo')) { 15873 data = data[1].split(':'); 15874 for (var j = 0; j < data.length; j++) data[j] = data[j].replace(/^\s+|\s+$/g, ''); 15875 info = info + this._getPDiv(ParseDatai18n(data[0]), ParseDatai18n(data[1]), 'MapInformationTuristView') 15876 } 15877 } 15878 if (info.length > 0) { 15879 this._map.showPopup(obj.pos, info); 15880 return 15881 } 15882 } 15883 this._layer.showInfo(obj.obj) 15884 }, 15885 getObjectInfo: function(obj) { 15886 var a = E.POI.Layer.Parser; 15887 return (obj[0].id_cat != 26 ? a : a.MCLayer).prototype.getObjectInfo.call(this, obj) 15888 }, 15889 onVisibleChange: function(a) { 15890 if (a[0] != -26) E.POI.Layer.Parser.MCLayer.prototype.onVisibleChange.call(this, a) 15891 } 15892})); 15893E.POI.Layer.addInitAction(E.POI.Layer.Parser.MCLayer.extend({ 15894 init: function() { 15895 this._priorityValue = 7; 15896 this.setParams([201, 202], 3, 4, false); 15897 this._layer.addLayersCollision('S', this._ids); 15898 this.addLegend('Traffic', 'red') 15899 }, 15900 parseObjectInfo: function(obj) { 15901 function parseDelay(adelay) { 15902 return adelay > 0 ? ((adelay > 60) ? parseInt(adelay / 60) + 'm' : '') + ' ' + ((adelay % 60 > 0) ? adelay % 60 + 's' : '0') : '0s' 15903 } 15904 var tmc = obj[1].TMC; 15905 if (tmc) { 15906 var elems, value, i; 15907 if (this._layer._isLayerVisible(202)) 15908 for (i = 0; i < tmc.length; i++) { 15909 elems = tmc[i]['name'].split("\n"); 15910 if (elems.length > 10) { 15911 if (elems[1].indexOf('Current Speed:') == -1) return this._map.showPopup(obj[0].pos, elems[1]) 15912 } 15913 } 15914 if (this._layer._isLayerVisible(201)) 15915 for (i = 0; i < tmc.length; i++) { 15916 elems = tmc[i]['name'].split("\n"); 15917 if (elems.length > 10) { 15918 if (elems[1].indexOf('Current Speed:') != -1) { 15919 elems[1] = elems[1].replace('Current Speed:', ''); 15920 elems[1] = elems[1].replace('Delay:', ''); 15921 elems[1] = elems[1].split(';'); 15922 value = E.lang('LP_TMCCS') + elems[1][0] + ' km/h' + '<br>' + E.lang('LP_TMCTD') + parseDelay(parseInt(elems[1][1])); 15923 this._map.showPopup(obj[0].pos, value); 15924 return 15925 } 15926 } 15927 } 15928 } 15929 this._layer.showInfo(obj[0].obj) 15930 }, 15931 onVisibleChange: function(a) { 15932 E.POI.Layer.Parser.MCLayer.prototype.onVisibleChange.call(this, a) 15933 }, 15934 getLocalizeValue: function(id) { 15935 if (E.Lang.code() !== 'pl') return (id = E.lang('LP_PLN' + id)).indexOf('LP_PLN') > -1 ? null : id; 15936 return null 15937 } 15938})); 15939E.POI.Layer.addInitAction(E.POI.Layer.Parser.extend({ 15940 init: function(layer) { 15941 this.setParams([19, 21], 4, 3, false) 15942 }, 15943 getCategoryHover: function(id) { 15944 return [ 15945 [60, 66, "http://emapi.pl/poi/poi/cams/big_o.png"], 15946 [44, 46, "http://emapi.pl/poi/poi/cams/small_o.png"], 15947 [44, 42, "http://emapi.pl/poi/poi/cams/small_c_o.png"] 15948 ][{ 15949 191: 1, 15950 192: 0, 15951 193: 0, 15952 194: 1, 15953 195: 2 15954 } [id]] 15955 }, 15956 parseStreamData: function(a) { 15957 return (a.toLowerCase().indexOf('mms://') == 0) ? E.format('<object id="MediaPlayer" width="380" height="260" CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"><param name="uiMode" value="none"><param name="src" value="{0}" /><param name="url" value="{0}" /><param name="width" value="380" /><param name="height" value="260" /><embed type="application/x-mplayer2" src="{0}" width="480" height="360" pluginspage="http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&" name="MediaPlayer" autostart=1></embed></object>', [a]) : a 15958 }, 15959 parseObjectInfo: function(obj) { 15960 var r = obj[1].searchObjectArray[0], 15961 d = r['description'].split("$$$"), 15962 info = '<div class="webcams_div"><div class="webcams_image_div"><a href="{0}" target="webcams">' + '<img class="webcams_image" src="{1}" alt="{2}"></a></div>' + '<div class="webcams_break"></div><div class="webcams_logo">' + '<a href="http://{3}" target="webcams"><img class="{4}" src="{5}" alt="{6}"></a>{7}' + '</div>' + '<div class="webcams_user"></div>{8}<div class="webcams_lastupdate"> To zdj\u0119cie przedstawia widok z kamery zarejestrowany w ciÄ gu ostatnich 60 minut. </div></div></div>', 15963 gddk = '<div class="webcams_logo"><a href="http://www.gddkia.gov.pl/" target="webcams"><img class="webcams-gddkia-logo" src="http://emapi.pl/poi/poi/cams/GDDKiA-logo.png" alt="Generalna Dyrekcja Dróg Krajowych i Autostrad"></a></div>'; 15964 switch (obj[0].id_cat) { 15965 case 191: 15966 return E.format(info, [r['http'], d[0], r['city'], 'www.webcams.travel', 'webcams-travel-logo', E.blank, 'Webcams.travel', '', E.format('<a href="http://www.webcams.travel/user/{0}" target="webcams"> Autor: {1} </a>', [d[1], d[2]]), '']); 15967 case 192: 15968 return E.format(info, ['http://www.traxelektronik.pl/pogoda/kamery/kamera.php?pkamnum=' + d[1], d[0], r['city'], 'www.traxelektronik.pl/', 'webcams-trax-logo', E.blank, 'TRAX elektronik', gddk, '', '']); 15969 case 193: 15970 return E.format(info, ['http://www.meteoinfo.info/dane-ogolnodostepne.php?m=dz-kamery-lodz', d[0], r['city'], 'www.mark.krakow.pl/', 'webcams-mark-logo', E.blank, 'MARK ELECTRONICS', gddk, '', '']); 15971 case 194: 15972 return E.format(info, [d[1], d[0], r['name'], 'www.mark.krakow.pl/', '', '', '', '', '<div class="webcams_describe">' + d[2] + '</div>']); 15973 case 195: 15974 return E.format('<div class="webcams_div"><div class="webcams_image_div"><a href="{0}" target="webcams">{1}</a></div><div class="webcams_break"></div><div class="webcams_describe">{2}</div><div class="webcams_lastupdate"> To zdj\u0119cie przedstawia widok z kamery zarejestrowany w ci�gu ostatnich 60 minut. </div></div></div>', [d[1], this.parseStreamData(d[0]), d[2]]) 15975 } 15976 return null 15977 } 15978})); 15979E.Profile.Shapes = L.Class.extend({ 15980 _decode: E.Util.decodeRepresentation, 15981 _encode: E.Util.encodeRepresentation, 15982 initialize: function(profile) { 15983 this._pf = profile; 15984 this._layer = new E.VectorLayer("", { 15985 system: 1 15986 });
15987 this._map = profile._map; 15988 this._map.addLayer(this._layer); 15989 this._map.on("MapInitializedA", function() {}, this); 15990 this._dc = new L.Control.Draw({ 15991 edit: { 15992 featureGroup: this._layer 15993 } 15994 }); 15995 this._pf.on("onLogin", function() { 15996 this._dc.addTo(this._map); 15997 this._map.shapeGet({}, this._onGetShapes, this) 15998 }, this); 15999 this._pf.on("onLogout", function() { 16000 this._dc.removeFrom(this._map); 16001 this._layer.clearObjects() 16002 }, this); 16003 this._map.on('draw:created', this._newShape, this); 16004 this._map.on('draw:edited', this._editedShape, this); 16005 this._map.on('draw:deleted', this._removeShape, this) 16006 }, 16007 _newShape: function(e) { 16008 var type = this.shapeType(e.layerType), 16009 layer = e.layer; 16010 this._layer.addLayer(layer); 16011 this._map.shapeAdd({ 16012 Type: type, 16013 Id: -1, 16014 Representation: this._encode(layer.getLatLng ? layer.getLatLng() : layer.getLatLngs(), 5), 16015 Radius: layer.getRadius ? layer.getRadius() : 0 16016 }, this._onDoneAdd, this, layer) 16017 }, 16018 _onDoneAdd: function(a, b) { 16019 b.shapeId = a.id 16020 }, 16021 _editedShape: function(e) { 16022 var layers = e.layers, 16023 l = []; 16024 layers.eachLayer(function(layer) { 16025 l.push({ 16026 Type: -1, 16027 Id: layer.shapeId, 16028 Representation: this._encode(layer.getLatLng ? layer.getLatLng() : layer.getLatLngs(), 5), 16029 Radius: layer.getRadius ? layer.getRadius() : 0 16030 }) 16031 }, this); 16032 this._map.shapeSet({ 16033 Items: l 16034 }) 16035 }, 16036 _removeShape: function(e) { 16037 var layers = e.layers; 16038 var ids = []; 16039 layers.eachLayer(function(layer) { 16040 ids.push(layer.shapeId) 16041 }); 16042 if (ids.length > 0) this._map.shapeRemove({ 16043 Id: ids 16044 }) 16045 }, 16046 _onGetShapes: function(a) { 16047 this._layer.clearObjects(); 16048 for (var i = 0; i < a.Items.length; i++) { 16049 var b = a.Items[i], 16050 pos = this._decode(b.Representation, 5), 16051 c; 16052 switch (b.Type) { 16053 case 0: 16054 c = new L.Marker(pos[0], { 16055 color: '#f06eaa' 16056 }); 16057 break; 16058 case 1: 16059 c = new E.Circle(pos[0], b.Radius, { 16060 shapeId: b.Id, 16061 color: '#f06eaa' 16062 }); 16063 break; 16064 case 2: 16065 c = new L.Rectangle(pos, { 16066 color: '#f06eaa' 16067 }); 16068 break; 16069 case 3: 16070 c = new L.Polygon(pos, { 16071 color: '#f06eaa' 16072 }); 16073 break; 16074 case 4: 16075 c = new L.Polyline(pos, { 16076 color: '#f06eaa' 16077 }); 16078 break 16079 } 16080 c.shapeId = b.Id; 16081 this._layer.addLayer(c) 16082 } 16083 }, 16084 shapeType: function(type) { 16085 a = { 16086 'marker': 0, 16087 'circle': 1, 16088 'rectangle': 2, 16089 'polygon': 3, 16090 'polyline': 4 16091 }; 16092 return a[type] 16093 } 16094}); 16095E.Profile.addInitHook(function() { 16096 this.shapes = new E.Profile.Shapes(this) 16097}); 16098var calCanBeOpen = false; 16099var turnOffYearSpan = true; 16100var weekStartsOnSunday = false; 16101var showWeekNumber = true; 16102var calendar_display_time = true; 16103var todayStringFormat = '[todayString][UCFdayString], [day]. [monthString]. [year] r.'; 16104var pathToImages = 'csse/u/calendar/'; 16105var speedOfSelectBoxSliding = 200; 16106var intervalSelectBox_minutes = 5; 16107var calendar_offsetTop = 0; 16108var calendar_offsetLeft = 0; 16109var calendarDiv = false; 16110var languageCode = E.Lang.code(); 16111var MSIE = false; 16112var Opera = false; 16113if (navigator.userAgent.indexOf('MSIE') >= 0 && navigator.userAgent.indexOf('Opera') < 0) MSIE = true; 16114if (navigator.userAgent.indexOf('Opera') >= 0) Opera = true; 16115switch (languageCode) { 16116 case "pl": 16117 var monthArray = ['StyczeÅ', 'Luty', 'Marzec', 'KwiecieÅ', 'Maj', 'Czerwiec', 'Lipiec', 'SierpieÅ', 'WrzesieÅ', 'Październik', 'Listopad', 'GrudzieÅ']; 16118 var monthArrayShort = ['Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru']; 16119 var dayArray = ['Pn', 'Wt', 'År', 'Cz', 'Pt', 'So', 'Nd']; 16120 var fullDayArray = ['PoniedziaÅek', 'Wtorek', 'Åroda', 'Czwartek', 'PiÄ tek', 'Sobota', 'Niedziela']; 16121 var weekString = 'TydzieÅ'; 16122 var todayString = ''; 16123 break; 16124 case "en": 16125 var monthArray = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; 16126 var monthArrayShort = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; 16127 var dayArray = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']; 16128 var fullDayArray = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']; 16129 var weekString = 'Week'; 16130 var todayString = ''; 16131 break; 16132 case "ge": 16133 var monthArray = ['Januar', 'Februar', 'M�rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember']; 16134 var monthArrayShort = ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']; 16135 var dayArray = ['Mon', 'Die', 'Mit', 'Don', 'Fre', 'Sam', 'Son']; 16136 var weekString = 'Woche'; 16137 var todayString = 'Heute'; 16138 break; 16139 case "no": 16140 var monthArray = ['Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember']; 16141 var monthArrayShort = ['Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des']; 16142 var dayArray = ['Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør', 'Søn']; 16143 var weekString = 'Uke'; 16144 var todayString = 'Dagen i dag er'; 16145 break; 16146 case "nl": 16147 var monthArray = ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December']; 16148 var monthArrayShort = ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec']; 16149 var dayArray = ['Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za', 'Zo']; 16150 var weekString = 'Week'; 16151 var todayString = 'Vandaag'; 16152 break; 16153 case "es": 16154 var monthArray = ['Enero', 'Febrero', 'Marzo', 'April', 'Mayo', 'Junio', 'Julio', 'Agosto', '
16154Septiembre', 'Octubre', 'Noviembre', 'Diciembre']; 16155 var monthArrayShort = ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic']; 16156 var dayArray = ['Lun', 'Mar', 'Mie', 'Jue', 'Vie', 'Sab', 'Dom']; 16157 var weekString = 'Semana'; 16158 var todayString = 'Hoy es'; 16159 break; 16160 case "pt-br": 16161 var monthArray = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']; 16162 var monthArrayShort = ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']; 16163 var dayArray = ['Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom']; 16164 var weekString = 'Sem.'; 16165 var todayString = 'Hoje é'; 16166 break; 16167 case "fr": 16168 var monthArray = ['Janvier', 'F�vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao�t', 'Septembre', 'Octobre', 'Novembre', 'D�cembre']; 16169 var monthArrayShort = ['Jan', 'Fev', 'Mar', 'Avr', 'Mai', 'Jun', 'Jul', 'Aou', 'Sep', 'Oct', 'Nov', 'Dec']; 16170 var dayArray = ['Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam', 'Dim']; 16171 var weekString = 'Sem'; 16172 var todayString = "Aujourd'hui"; 16173 break; 16174 case "da": 16175 var monthArray = ['januar', 'februar', 'marts', 'april', 'maj', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'december']; 16176 var monthArrayShort = ['jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec']; 16177 var dayArray = ['man', 'tirs', 'ons', 'tors', 'fre', 'lør', 'søn']; 16178 var weekString = 'Uge'; 16179 var todayString = 'I dag er den'; 16180 break; 16181 case "hu": 16182 var monthArray = ['Január', 'Február', 'Március', '�?prilis', 'Május', 'Június', 'Július', 'Augusztus', 'Szeptember', 'Október', 'November', 'December']; 16183 var monthArrayShort = ['Jan', 'Feb', 'Márc', '�?pr', 'Máj', 'Jún', 'Júl', 'Aug', 'Szep', 'Okt', 'Nov', 'Dec']; 16184 var dayArray = ['Hé', 'Ke', 'Sze', 'Cs', 'Pé', 'Szo', 'Vas']; 16185 var weekString = 'Hét'; 16186 var todayString = 'Mai nap'; 16187 break; 16188 case "it": 16189 var monthArray = ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre']; 16190 var monthArrayShort = ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lugl', 'Ago', 'Set', 'Ott', 'Nov', 'Dic']; 16191 var dayArray = ['Lun', ';Mar', 'Mer', 'Gio', 'Ven', 'Sab', 'Dom']; 16192 var weekString = 'Settimana'; 16193 var todayString = 'Oggi è il'; 16194 break; 16195 case "sv": 16196 var monthArray = ['Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December']; 16197 var monthArrayShort = ['Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec']; 16198 var dayArray = ['Mån', 'Tis', 'Ons', 'Tor', 'Fre', 'Lör', 'Sön']; 16199 var weekString = 'Vecka'; 16200 var todayString = 'Idag är det den'; 16201 break; 16202 case "cz": 16203 var monthArray = ['leden', 'únor', 'březen', 'duben', 'květen', 'červen', 'červenec', 'srpen', 'září', 'říjen', 'listopad', 'prosinec']; 16204 var monthArrayShort = ['led', 'ún', 'bř', 'dub', 'kvě', 'čer', 'čer-ec', 'srp', 'zář', 'říj', 'list', 'pros']; 16205 var dayArray = ['Pon', 'Út', 'St', 'Čt', 'Pá', 'So', 'Ne']; 16206 var weekString = 'týden'; 16207 var todayString = ''; 16208 break 16209} 16210if (weekStartsOnSunday) { 16211 var tempDayName = dayArray[6]; 16212 for (var theIx = 6; theIx > 0; theIx--) { 16213 dayArray[theIx] = dayArray[theIx - 1] 16214 } 16215 dayArray[0] = tempDayName 16216} 16217var daysInMonthArray = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 16218var currentMonth; 16219var currentYear; 16220var currentHour; 16221var currentMinute; 16222var calendarContentDiv; 16223var returnDateTo; 16224var returnFormat; 16225var activeSelectBoxMonth; 16226var activeSelectBoxYear; 16227var activeSelectBoxHour; 16228var activeSelectBoxMinute; 16229var iframeObj = false; 16230var iframeObj2 = false; 16231 16232function EIS_FIX_EI1(where2fixit) { 16233 if (!iframeObj2) return; 16234 iframeObj2.style.display = 'block'; 16235 iframeObj2.style.height = document.getElementById(where2fixit).offsetHeight + 1; 16236 iframeObj2.style.width = document.getElementById(where2fixit).offsetWidth; 16237 iframeObj2.style.left = getleftPos(document.getElementById(where2fixit)) + 1 - calendar_offsetLeft; 16238 iframeObj2.style.top = getTopPos(document.getElementById(where2fixit)) - document.getElementById(where2fixit).offsetHeight - calendar_offsetTop 16239} 16240 16241function EIS_Hide_Frame() { 16242 if (iframeObj2) iframeObj2.style.display = 'none' 16243} 16244var returnDateToYear; 16245var returnDateToMonth; 16246var returnDateToDay; 16247var returnDateToHour; 16248var returnDateToMinute; 16249var inputYear; 16250var inputMonth; 16251var inputDay; 16252var inputHour; 16253var inputMinute; 16254var calendarDisplayTime = false; 16255var selectBoxHighlightColor = '#D60808'; 16256var selectBoxRolloverBgColor = '#E2EBED'; 16257var selectBoxMovementInProgress = false; 16258var activeSelectBox = false; 16259 16260function cancelCalendarEvent() { 16261 return false 16262} 16263 16264function isLeapYear(inputYear) { 16265 if (inputYear % 400 == 0 || (inputYear % 4 == 0 && inputYear % 100 != 0)) return true; 16266 return false 16267} 16268var activeSelectBoxMonth = false; 16269var activeSelectBoxDirection = false; 16270 16271function highlightMonthYear() { 16272 if (activeSelectBoxMonth) activeSelectBoxMonth.className = ''; 16273 activeSelectBox = this; 16274 if (this.className == 'monthYearActive') { 16275 this.className = '' 16276 } else { 16277 this.className = 'monthYearActive'; 16278 activeSelectBoxMonth = this 16279 } 16280 if (this.innerHTML.indexOf('-') >= 0 || this.innerHTML.indexOf('+') >= 0) { 16281 if (this.className == 'monthYearActive') selectBoxMovementInProgress = true; 16282 else selectBoxMovementInProgress = false; 16283 if (this.innerHTML.indexOf('-') >= 0) activeSelectBoxDirection = -1; 16284 else activeSelectBoxDirection = 1 16285 } else selectBoxMovementInProgress = false 16286} 16287 16288function showMonthDropDown() { 16289 if (document.getElementById('monthDropDown').style.display == 'block') { 16290 document.getElementById('monthDropDown').style.display = 'none'; 16291 EIS_Hide_Frame() 16292 } else { 16293 document.getElementById('monthDropDown').style.display = 'block'; 16294 document.getElementById('yearDropDown').style.display = 'none'; 16295 document.getElementById('hourDropDown').style.display = 'none'; 16296 document.getElementById('minuteDropDown').style.display = 'none'; 16297 if (MSIE) { 16298 EIS_FIX_EI1('monthDropDown') 16299 } 16300 } 16301} 16302 16303function showYearDropDown() { 16304 if (document.getElementById('yearDropDown').style.display == 'block') { 16305 document.getElementById('yearDropDown').style.display = 'none'; 16306 EIS_Hide_Frame() 16307 } else { 16308 document.getElementById('yearDropDown').style.display = 'block'; 16309 document.getElementById('monthDropDown').style.display = 'none'; 16310 document.getElementById('hourDropDown').style.display = 'none'; 16311 document.getElementById('minuteDropDown').style.display = 'none'; 16312 if (MSIE) { 16313 EIS_FIX_EI1('yearDropDown') 16314 } 16315 } 16316} 16317 16318function showHourDropDown() { 16319 if (document.getElementById('hourDropDown').style.display == 'block') { 16320 document.getElementById('hourDropDown').style.display = 'none'; 16321 EIS_Hide_Frame() 16322 } else { 16323 document.getElementById('hourDropDown').style.display = 'block'; 16324 document.getElementById('monthDropDown').style.display = 'none'; 16325 document.getElementById('yearDropDown').style.display = 'none'; 16326 document.getElementById('minuteDropDown').style.display = 'none'; 16327 if (MSIE) { 16328 EIS_FIX_EI1('hourDropDown') 16329 } 16330 } 16331} 16332 16333function showMinuteDropDown() { 16334 if (document.getElementById('minuteDropDown').style.display == 'block') { 16335 document.getElementById('minuteDropDown').style.display = 'none'; 16336 EIS_Hide_Frame() 16337 } else { 16338 document.getElementById('minuteDropDown').style.display = 'block'; 16339 document.getElementById('monthDropDown').style.display = 'none'; 16340 document.getElementById('yearDropDown').style.display = 'none'; 16341 document.getElementById('hourDropDown').style.display = 'none'; 16342 if (MSIE) { 16343 EIS_FIX_EI1('minuteDropDown') 16344 } 16345 } 16346} 16347 16348function selectMonth() { 16349 document.getElementById('calendar_month_txt').innerHTML = this.innerHTML; 16350 currentMonth = this.id.replace(/[^\d]/g, ''); 16351 document.getElementById('monthDropDown').style.display = 'none'; 16352 EIS_Hide_Frame(); 16353 for (var no = 0; no < monthArray.length; no++) { 16354 document.getElementById('monthDiv_' + no).style.color = '' 16355 } 16356 this.style.color = selectBoxHighlightColor; 16357 activeSelectBoxMonth = this; 16358 writeCalendarContent() 16359} 16360 16361function selectHour() { 16362 document.getElementById('calendar_hour_txt').innerHTML = this.innerHTML; 16363 currentHour = this.innerHTML.replace(/[^\d]/g, ''); 16364 document.getElementById('hourDropDown').style.display = 'none'; 16365 EIS_Hide_Frame(); 16366 if (activeSelectBoxHour) { 16367 activeSelectBoxHour.style.color = '' 16368 } 16369 activeSelectBoxHour = this; 16370 this.style.color = selectBoxHighlightColor 16371} 16372 16373function selectMinute() { 16374 document.getElementById('calendar_minute_txt').innerHTML = this.innerHTML; 16375 currentMinute = this.innerHTML.replace(/[^\d]/g, ''); 16376 document.getElementById('minuteDropDown').style.display = 'none'; 16377 EIS_Hide_Frame(); 16378 if (activeSelectBoxMinute) { 16379 activeSelectBoxMinute.style.color = '' 16380 } 16381 activeSelectBoxMinute = this; 16382 this.style.color = selectBoxHighlightColor 16383} 16384 16385function selectYear() { 16386 document.getElementById('calendar_year_txt').innerHTML = this.innerHTML; 16387 currentYear = this.innerHTML.replace(/[^\d]/g, ''); 16388 document.getElementById('yearDropDown').style.display = 'none'; 16389 EIS_Hide_Frame(); 16390 if (activeSelectBoxYear) { 16391 activeSelectBoxYear.style.color = '' 16392 } 16393 activeSelectBoxYear = this; 16394 this.style.color = selectBoxHighlightColor; 16395 writeCalendarContent() 16396} 16397 16398function switchMonth() { 16399 if (this.src.indexOf('left') >= 0) { 16400 currentMonth = currentMonth - 1; 16401 if (currentMonth < 0) { 16402 currentMonth = 11; 16403 if (currentYear > 2010) currentYear = currentYear - 1 16404 } 16405 } else { 16406 currentMonth = currentMonth + 1; 16407 if (currentMonth > 11) { 16408 currentMonth = 0; 16409 if (currentYear < 2011) currentYear = currentYear / 1 + 1 16410 } 16411 } 16412 writeCalendarContent() 16413} 16414 16415function createMonthDiv() { 16416 var div = document.createElement('DIV'); 16417 div.className = 'monthYearPicker'; 16418 div.id = 'monthPicker'; 16419 for (var no = 0; no < monthArray.length; no++) { 16420 var subDiv = document.createElement('DIV'); 16421 subDiv.innerHTML = monthArray[no]; 16422 subDiv.onmouseover = highlightMonthYear; 16423 subDiv.onmouseout = highlightMonthYear; 16424 subDiv.onclick = selectMonth; 16425 subDiv.id = 'monthDiv_' + no; 16426 subDiv.style.width = '56px'; 16427 subDiv.onselectstart = cancelCalendarEvent; 16428 div.appendChild(subDiv); 16429 if (currentMonth && currentMonth == no) { 16430 subDiv.style.color = selectBoxHighlightColor; 16431 activeSelectBoxMonth = subDiv 16432 } 16433 } 16434 return div 16435} 16436 16437function changeSelectBoxYear(e, inputObj) { 16438 if (!inputObj) inputObj = this; 16439 var yearItems = inputObj.parentNode.getElementsByTagName('DIV'); 16440 if (inputObj.innerHTML.indexOf('-') >= 0) { 16441 var startYear = yearItems[1].innerHTML / 1 - 1; 16442 if (activeSelectBoxYear) { 16443 activeSelectBoxYear.style.color = '' 16444 } 16445 } else { 16446 var startYear = yearItems[1].innerHTML / 1 + 1; 16447 if (activeSelectBoxYear) { 16448 activeSelectBoxYear.style.color = '' 16449 } 16450 } 16451 for (var no = 1; no < yearItems.length - 1; no++) { 16452 yearItems[no].innerHTML = startYear + no - 1; 16453 yearItems[no].id = 'yearDiv' + (startYear / 1 + no / 1 - 1) 16454 } 16455 if (activeSelectBoxYear) { 16456 activeSelectBoxYear.style.color = ''; 16457 if (document.getElementById('yearDiv' + currentYear)) { 16458 activeSelectBoxYear = document.getElementById('yearDiv' + currentYear); 16459 activeSelectBoxYear.style.color = selectBoxHighlightColor 16460 } 16461 } 16462} 16463 16464function changeSelectBoxHour(e, inputObj) { 16465 if (!inputObj) inputObj = this; 16466 var hourItems = inputObj.parentNode.getElementsByTagName('DIV'); 16467 if (inputObj.innerHTML.indexOf('-') >= 0) { 16468 var startHour = hourItems[1].innerHTML / 1 - 1; 16469 if (startHour < 0) startHour = 0; 16470 if (activeSelectBoxHour) { 16471 activeSelectBoxHour.style.color = '' 16472 } 16473 } else { 16474 var startHour = hourItems[1].innerHTML / 1 + 1; 16475 if (startHour > 14) startHour = 14; 16476 if (activeSelectBoxHour) { 16477 activeSelectBoxHour.style.color = '' 16478 } 16479 } 16480 var prefix = ''; 16481 for (var no = 1; no < hourItems.length - 1; no++) { 16482 if ((startHour / 1 + no / 1) < 11) prefix = '0'; 16483 else prefix = ''; 16484 hourItems[no].innerHTML = prefix + (startHour + no - 1); 16485 hourItems[no].id = 'hourDiv' + (startHour / 1 + no / 1 - 1) 16486 } 16487 if (activeSelectBoxHour) { 16488 activeSelectBoxHour.style.color = ''; 16489 if (document.getElementById('hourDiv' + currentHour)) { 16490 activeSelectBoxHour = document.getElementById('hourDiv' + currentHour); 16491 activeSelectBoxHour.style.color = selectBoxHighlightColor 16492 } 16493 } 16494} 16495 16496function updateYearDiv() { 16497 var yearSpan = 5; 16498 if (turnOffYearSpan) { 16499 yearSpan = 0 16500 } 16501 var div = document.getElementById('yearDropDown'); 16502 var yearItems = div.getElementsByTagName('DIV'); 16503 for (var no = 1; no < yearItems.length - 1; no++) { 16504 yearItems[no].innerHTML = currentYear / 1 - yearSpan + no; 16505 if (currentYear == (currentYear / 1 - yearSpan + no)) { 16506 yearItems[no].style.color = selectBoxHighlightColor; 16507 activeSelectBoxYear = yearItems[no] 16508 } else { 16509 yearItems[no].style.color = '' 16510 } 16511 } 16512} 16513 16514function updateMonthDiv() { 16515 for (no = 0; no < 12; no++) { 16516 document.getElementById('monthDiv_' + no).style.color = '' 16517 } 16518 document.getElementById('monthDiv_' + currentMonth).style.color = selectBoxHighlightColor; 16519 activeSelectBoxMonth = document.getElementById('monthDiv_' + currentMonth) 16520} 16521 16522function updateHourDiv() { 16523 var div = document.getElementById('hourDropDown'); 16524 var hourItems = div.getElementsByTagName('DIV'); 16525 var addHours = 0; 16526 if ((currentHour / 1 - 6 + 1) < 0) { 16527 addHours = (currentHour / 1 - 6 + 1) * -1 16528 } 16529 for (var no = 1; no < hourItems.length - 1; no++) { 16530 var prefix = ''; 16531 if ((currentHour / 1 - 6 + no + addHours) < 10) prefix = '0'; 16532 hourItems[no].innerHTML = prefix + (currentHour / 1 - 6 + no + addHours); 16533 if (currentHour == (currentHour / 1 - 6 + no)) { 16534 hourItems[no].style.color = selectBoxHighlightColor; 16535 activeSelectBoxHour = hourItems[no] 16536 } else { 16537 hourItems[no].style.color = '' 16538 } 16539 } 16540} 16541 16542function updateMinuteDiv() { 16543 for (no = 0; no < 60; no += intervalSelectBox_minutes) { 16544 var prefix = ''; 16545 if (no < 10) prefix = '0';
16546 document.getElementById('minuteDiv_' + prefix + no).style.color = '' 16547 } 16548 if (document.getElementById('minuteDiv_' + currentMinute)) { 16549 document.getElementById('minuteDiv_' + currentMinute).style.color = selectBoxHighlightColor; 16550 activeSelectBoxMinute = document.getElementById('minuteDiv_' + currentMinute) 16551 } 16552} 16553 16554function createYearDiv() { 16555 if (!document.getElementById('yearDropDown')) { 16556 var div = document.createElement('DIV'); 16557 div.className = 'monthYearPicker' 16558 } else { 16559 var div = document.getElementById('yearDropDown'); 16560 var subDivs = div.getElementsByTagName('DIV'); 16561 for (var no = 0; no < subDivs.length; no++) { 16562 subDivs[no].parentNode.removeChild(subDivs[no]) 16563 } 16564 } 16565 var d = new Date(); 16566 if (currentYear) { 16567 d.setFullYear(currentYear) 16568 } 16569 var startYear = d.getFullYear() / 1 - 5; 16570 var yearSpan = 10; 16571 if (!turnOffYearSpan) { 16572 var subDiv = document.createElement('DIV'); 16573 subDiv.innerHTML = ' - '; 16574 subDiv.onclick = changeSelectBoxYear; 16575 subDiv.onmouseover = highlightMonthYear; 16576 subDiv.onmouseout = function() { 16577 selectBoxMovementInProgress = false 16578 }; 16579 subDiv.onselectstart = cancelCalendarEvent; 16580 div.appendChild(subDiv) 16581 } else { 16582 startYear = d.getFullYear() / 1 - 0; 16583 yearSpan = 2 16584 } 16585 for (var no = currentYear; no <= currentYear + 1; no++) { 16586 var subDiv = document.createElement('DIV'); 16587 subDiv.innerHTML = no; 16588 subDiv.onmouseover = highlightMonthYear; 16589 subDiv.onmouseout = highlightMonthYear; 16590 subDiv.onclick = selectYear; 16591 subDiv.id = 'yearDiv' + no; 16592 subDiv.onselectstart = cancelCalendarEvent; 16593 div.appendChild(subDiv) 16594 } 16595 if (!turnOffYearSpan) { 16596 var subDiv = document.createElement('DIV'); 16597 subDiv.innerHTML = ' + '; 16598 subDiv.onclick = changeSelectBoxYear; 16599 subDiv.onmouseover = highlightMonthYear; 16600 subDiv.onmouseout = function() { 16601 selectBoxMovementInProgress = false 16602 }; 16603 subDiv.onselectstart = cancelCalendarEvent; 16604 div.appendChild(subDiv) 16605 } 16606 return div 16607} 16608 16609function slideCalendarSelectBox() { 16610 if (selectBoxMovementInProgress) { 16611 if (activeSelectBox.parentNode.id == 'hourDropDown') { 16612 changeSelectBoxHour(false, activeSelectBox) 16613 } 16614 if (activeSelectBox.parentNode.id == 'yearDropDown') { 16615 changeSelectBoxYear(false, activeSelectBox) 16616 } 16617 } 16618 setTimeout('slideCalendarSelectBox()', speedOfSelectBoxSliding) 16619} 16620 16621function createHourDiv() { 16622 if (!document.getElementById('hourDropDown')) { 16623 var div = document.createElement('DIV'); 16624 div.className = 'monthYearPicker' 16625 } else { 16626 var div = document.getElementById('hourDropDown'); 16627 var subDivs = div.getElementsByTagName('DIV'); 16628 for (var no = 0; no < subDivs.length; no++) { 16629 subDivs[no].parentNode.removeChild(subDivs[no]) 16630 } 16631 } 16632 if (!currentHour) currentHour = 0; 16633 var startHour = currentHour / 1; 16634 if (startHour > 14) startHour = 14; 16635 var subDiv = document.createElement('DIV'); 16636 subDiv.innerHTML = ' - '; 16637 subDiv.onclick = changeSelectBoxHour; 16638 subDiv.onmouseover = highlightMonthYear; 16639 subDiv.onmouseout = function() { 16640 selectBoxMovementInProgress = false 16641 }; 16642 subDiv.onselectstart = cancelCalendarEvent; 16643 div.appendChild(subDiv); 16644 for (var no = startHour; no < startHour + 10; no++) { 16645 var prefix = ''; 16646 if (no / 1 < 10) prefix = '0'; 16647 var subDiv = document.createElement('DIV'); 16648 subDiv.innerHTML = prefix + no; 16649 subDiv.onmouseover = highlightMonthYear; 16650 subDiv.onmouseout = highlightMonthYear; 16651 subDiv.onclick = selectHour; 16652 subDiv.id = 'hourDiv' + no; 16653 subDiv.onselectstart = cancelCalendarEvent; 16654 div.appendChild(subDiv); 16655 if (currentYear && currentYear == no) { 16656 subDiv.style.color = selectBoxHighlightColor; 16657 activeSelectBoxYear = subDiv 16658 } 16659 } 16660 var subDiv = document.createElement('DIV'); 16661 subDiv.innerHTML = ' + '; 16662 subDiv.onclick = changeSelectBoxHour; 16663 subDiv.onmouseover = highlightMonthYear; 16664 subDiv.onmouseout = function() { 16665 selectBoxMovementInProgress = false 16666 }; 16667 subDiv.onselectstart = cancelCalendarEvent; 16668 div.appendChild(subDiv); 16669 return div 16670} 16671 16672function createMinuteDiv() { 16673 if (!document.getElementById('minuteDropDown')) { 16674 var div = document.createElement('DIV'); 16675 div.className = 'monthYearPicker' 16676 } else { 16677 var div = document.getElementById('minuteDropDown'); 16678 var subDivs = div.getElementsByTagName('DIV'); 16679 for (var no = 0; no < subDivs.length; no++) { 16680 subDivs[no].parentNode.removeChild(subDivs[no]) 16681 } 16682 } 16683 var startMinute = 0; 16684 var prefix = ''; 16685 for (var no = startMinute; no < 60; no += intervalSelectBox_minutes) { 16686 if (no < 10) prefix = '0'; 16687 else prefix = ''; 16688 var subDiv = document.createElement('DIV');
16689 subDiv.innerHTML = prefix + no; 16690 subDiv.onmouseover = highlightMonthYear; 16691 subDiv.onmouseout = highlightMonthYear; 16692 subDiv.onclick = selectMinute; 16693 subDiv.id = 'minuteDiv_' + prefix + no; 16694 subDiv.onselectstart = cancelCalendarEvent; 16695 div.appendChild(subDiv); 16696 if (currentYear && currentYear == no) { 16697 subDiv.style.color = selectBoxHighlightColor; 16698 activeSelectBoxYear = subDiv 16699 } 16700 } 16701 return div 16702} 16703 16704function highlightSelect() { 16705 if (this.className == 'selectBoxTime') { 16706 this.className = 'selectBoxTimeOver'; 16707 this.getElementsByTagName('IMG')[0].src = pathToImages + 'down_over.png' 16708 } else if (this.className == 'selectBoxTimeOver') { 16709 this.className = 'selectBoxTime'; 16710 this.getElementsByTagName('IMG')[0].src = pathToImages + 'down.png' 16711 } 16712 if (this.className == 'selectBox') { 16713 this.className = 'selectBoxOver'; 16714 this.getElementsByTagName('IMG')[0].src = pathToImages + 'down_over.png' 16715 } else if (this.className == 'selectBoxOver') { 16716 this.className = 'selectBox'; 16717 this.getElementsByTagName('IMG')[0].src = pathToImages + 'down.png' 16718 } 16719} 16720 16721function highlightArrow() { 16722 if (this.src.indexOf('over') >= 0) { 16723 if (this.src.indexOf('left') >= 0) this.src = pathToImages + 'left.gif'; 16724 if (this.src.indexOf('right') >= 0) this.src = pathToImages + 'right.gif' 16725 } else { 16726 if (this.src.indexOf('left') >= 0) this.src = pathToImages + 'left_over.gif'; 16727 if (this.src.indexOf('right') >= 0) this.src = pathToImages + 'right_over.gif' 16728 } 16729} 16730 16731function highlightClose() { 16732 if (this.src.indexOf('over') >= 0) { 16733 this.src = pathToImages + 'close.png' 16734 } else { 16735 this.src = pathToImages + 'close.png' 16736 } 16737} 16738 16739function closeCalendar() { 16740 if (calCanBeOpen) return; 16741 document.getElementById('yearDropDown').style.display = 'none'; 16742 document.getElementById('monthDropDown').style.display = 'none'; 16743 document.getElementById('hourDropDown').style.display = 'none'; 16744 document.getElementById('minuteDropDown').style.display = 'none'; 16745 calendarDiv.style.display = 'none'; 16746 if (iframeObj) { 16747 iframeObj.style.display = 'none'; 16748 EIS_Hide_Frame() 16749 } 16750 if (activeSelectBoxMonth) activeSelectBoxMonth.className = ''; 16751 if (activeSelectBoxYear) activeSelectBoxYear.className = '' 16752} 16753 16754function writeTopBar() { 16755 var topBar = document.createElement('DIV'); 16756 topBar.className = 'topBar'; 16757 topBar.id = 'topBar'; 16758 calendarDiv.appendChild(topBar); 16759 var monthDiv = document.createElement('DIV'); 16760 monthDiv.id = 'monthSelect'; 16761 monthDiv.onmouseover = highlightSelect; 16762 monthDiv.onmouseout = highlightSelect; 16763 monthDiv.onclick = showMonthDropDown; 16764 var span = document.createElement('SPAN'); 16765 span.innerHTML = monthArray[currentMonth]; 16766 span.id = 'calendar_month_txt'; 16767 monthDiv.appendChild(span); 16768 var img = document.createElement('IMG'); 16769 img.src = pathToImages + 'down.png'; 16770 img.style.position = 'absolute'; 16771 img.style.right = '0px'; 16772 monthDiv.appendChild(img); 16773 monthDiv.className = 'selectBox'; 16774 if (Opera) { 16775 img.style.cssText = 'float:right;position:relative'; 16776 img.style.position = 'relative'; 16777 img.style.styleFloat = 'right' 16778 } 16779 topBar.appendChild(monthDiv); 16780 var monthPicker = createMonthDiv(); 16781 monthPicker.style.left = '3px'; 16782 monthPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px'; 16783 monthPicker.style.width = '60px'; 16784 monthPicker.id = 'monthDropDown'; 16785 calendarDiv.appendChild(monthPicker); 16786 var yearDiv = document.createElement('DIV'); 16787 yearDiv.onmouseover = highlightSelect; 16788 yearDiv.onmouseout = highlightSelect; 16789 yearDiv.onclick = showYearDropDown; 16790 var span = document.createElement('SPAN'); 16791 span.innerHTML = currentYear; 16792 span.id = 'calendar_year_txt'; 16793 yearDiv.appendChild(span); 16794 topBar.appendChild(yearDiv); 16795 var img = document.createElement('IMG'); 16796 img.src = pathToImages + 'down.png'; 16797 yearDiv.appendChild(img); 16798 yearDiv.className = 'selectBox'; 16799 if (Opera) { 16800 yearDiv.style.width = '50px'; 16801 img.style.cssText = 'float:right'; 16802 img.style.position = 'relative'; 16803 img.style.styleFloat = 'right' 16804 } 16805 var yearPicker = createYearDiv(); 16806 yearPicker.style.left = '80px'; 16807 yearPicker.style.top = monthDiv.offsetTop + monthDiv.offsetHeight + 1 + 'px'; 16808 yearPicker.style.width = '35px'; 16809 yearPicker.id = 'yearDropDown'; 16810 calendarDiv.appendChild(yearPicker); 16811 var img = document.createElement('IMG'); 16812 img.src = pathToImages + 'close.png'; 16813 img.style.styleFloat = 'right'; 16814 img.onmouseover = highlightClose; 16815 img.onmouseout = highlightClose;
16816 img.onclick = forceCloseCalendar; 16817 topBar.appendChild(img); 16818 if (!document.all) { 16819 img.style.position = 'absolute'; 16820 img.style.right = '2px' 16821 } 16822} 16823 16824function forceCloseCalendar() { 16825 calCanBeOpen = false; 16826 closeCalendar() 16827} 16828 16829function writeCalendarContent() { 16830 var calendarContentDivExists = true; 16831 if (!calendarContentDiv) { 16832 calendarContentDiv = document.createElement('DIV'); 16833 calendarDiv.appendChild(calendarContentDiv); 16834 calendarContentDivExists = false 16835 } 16836 currentMonth = currentMonth / 1; 16837 var d = new Date(); 16838 d.setFullYear(currentYear); 16839 d.setDate(1); 16840 d.setMonth(currentMonth); 16841 var dayStartOfMonth = d.getDay(); 16842 if (!weekStartsOnSunday) { 16843 if (dayStartOfMonth == 0) dayStartOfMonth = 7; 16844 dayStartOfMonth-- 16845 } 16846 document.getElementById('calendar_year_txt').innerHTML = currentYear; 16847 document.getElementById('calendar_month_txt').innerHTML = monthArray[currentMonth]; 16848 document.getElementById('calendar_hour_txt').innerHTML = currentHour / 1 > 9 ? currentHour : '0' + currentHour; 16849 document.getElementById('calendar_minute_txt').innerHTML = currentMinute / 1 > 9 ? currentMinute : '0' + currentMinute; 16850 var existingTable = calendarContentDiv.getElementsByTagName('TABLE'); 16851 if (existingTable.length > 0) { 16852 calendarContentDiv.removeChild(existingTable[0]) 16853 } 16854 var calTable = document.createElement('TABLE'); 16855 calTable.width = '100%'; 16856 calTable.cellSpacing = '0'; 16857 calendarContentDiv.appendChild(calTable); 16858 var calTBody = document.createElement('TBODY'); 16859 calTable.appendChild(calTBody); 16860 var row = calTBody.insertRow(-1); 16861 row.className = 'calendar_week_row'; 16862 if (showWeekNumber) { 16863 var cell = row.insertCell(-1); 16864 cell.innerHTML = weekString; 16865 cell.className = 'calendar_week_column'; 16866 cell.style.backgroundColor = selectBoxRolloverBgColor 16867 } 16868 for (var no = 0; no < dayArray.length; no++) { 16869 var cell = row.insertCell(-1); 16870 cell.innerHTML = dayArray[no] 16871 } 16872 var row = calTBody.insertRow(-1); 16873 if (showWeekNumber) { 16874 var cell = row.insertCell(-1); 16875 cell.className = 'calendar_week_column'; 16876 cell.style.backgroundColor = selectBoxRolloverBgColor; 16877 var week = getWeek(currentYear, currentMonth, 1); 16878 cell.innerHTML = week 16879 } 16880 for (var no = 0; no < dayStartOfMonth; no++) { 16881 var cell = row.insertCell(-1); 16882 cell.innerHTML = ' ' 16883 } 16884 var colCounter = dayStartOfMonth; 16885 var daysInMonth = daysInMonthArray[currentMonth]; 16886 if (daysInMonth == 28) { 16887 if (isLeapYear(currentYear)) daysInMonth = 29 16888 } 16889 for (var no = 1; no <= daysInMonth; no++) { 16890 d.setDate(no - 1); 16891 if (colCounter > 0 && colCounter % 7 == 0) { 16892 var row = calTBody.insertRow(-1); 16893 if (showWeekNumber) { 16894 var cell = row.insertCell(-1); 16895 cell.className = 'calendar_week_column'; 16896 var week = getWeek(currentYear, currentMonth, no); 16897 cell.innerHTML = week; 16898 cell.style.backgroundColor = selectBoxRolloverBgColor 16899 } 16900 } 16901 var cell = row.insertCell(-1); 16902 if (currentYear == inputYear && currentMonth == inputMonth && no == inputDay) { 16903 cell.className = 'activeDay' 16904 } 16905 cell.innerHTML = no; 16906 cell.onclick = pickDate; 16907 colCounter++ 16908 } 16909 if (!document.all) { 16910 if (calendarContentDiv.offsetHeight) document.getElementById('topBar').style.top = calendarContentDiv.offsetHeight + document.getElementById('timeBar').offsetHeight + document.getElementById('topBar').offsetHeight - 1 + 'px'; 16911 else { 16912 document.getElementById('topBar').style.top = ''; 16913 document.getElementById('topBar').style.bottom = '0px' 16914 } 16915 } 16916 if (iframeObj) { 16917 if (!calendarContentDivExists) setTimeout('resizeIframe()', 350); 16918 else setTimeout('resizeIframe()', 10) 16919 } 16920} 16921 16922function resizeIframe() { 16923 iframeObj.style.width = calendarDiv.offsetWidth + 'px'; 16924 iframeObj.style.height = calendarDiv.offsetHeight + 'px' 16925} 16926 16927function pickTodaysDate() { 16928 var d = new Date(); 16929 currentMonth = d.getMonth(); 16930 currentYear = d.getFullYear(); 16931 pickDate(false, d.getDate()) 16932} 16933 16934function pickDate(e, inputDay) {
16935 var month = currentMonth / 1 + 1; 16936 if (month < 10) month = '0' + month; 16937 var day; 16938 if (!inputDay && this) day = this.innerHTML; 16939 else day = inputDay; 16940 if (day / 1 < 10) day = '0' + day; 16941 if (returnFormat) { 16942 returnFormat = returnFormat.replace('dd', day); 16943 returnFormat = returnFormat.replace('mm', month); 16944 returnFormat = returnFormat.replace('yyyy', currentYear); 16945 returnFormat = returnFormat.replace('hh', currentHour); 16946 returnFormat = returnFormat.replace('ii', currentMinute); 16947 returnFormat = returnFormat.replace('d', day / 1); 16948 returnFormat = returnFormat.replace('m', month / 1); 16949 returnDateTo.value = returnFormat; 16950 try { 16951 if ("fireEvent" in returnDateTo) returnDateTo.fireEvent("onchange"); 16952 else { 16953 var evt = document.createEvent("HTMLEvents"); 16954 evt.initEvent("change", false, true); 16955 returnDateTo.dispatchEvent(evt) 16956 } 16957 } catch (e) {} 16958 } else { 16959 for (var no = 0; no < returnDateToYear.options.length; no++) { 16960 if (returnDateToYear.options[no].value == currentYear) { 16961 returnDateToYear.selectedIndex = no; 16962 break 16963 } 16964 } 16965 for (var no = 0; no < returnDateToMonth.options.length; no++) { 16966 if (returnDateToMonth.options[no].value == parseFloat(month)) { 16967 returnDateToMonth.selectedIndex = no; 16968 break 16969 } 16970 } 16971 for (var no = 0; no < returnDateToDay.options.length; no++) { 16972 if (returnDateToDay.options[no].value == parseFloat(day)) { 16973 returnDateToDay.selectedIndex = no; 16974 break 16975 } 16976 } 16977 if (calendarDisplayTime) { 16978 for (var no = 0; no < returnDateToHour.options.length; no++) { 16979 if (returnDateToHour.options[no].value == parseFloat(currentHour)) { 16980 returnDateToHour.selectedIndex = no; 16981 break 16982 } 16983 } 16984 for (var no = 0; no < returnDateToMinute.options.length; no++) { 16985 if (returnDateToMinute.options[no].value == parseFloat(currentMinute)) { 16986 returnDateToMinute.selectedIndex = no; 16987 break 16988 } 16989 } 16990 } 16991 } 16992 calCanBeOpen = false; 16993 closeCalendar() 16994} 16995 16996function getWeek(year, month, day) { 16997 if (!weekStartsOnSunday) { 16998 day = (day / 1) 16999 } else { 17000 day = (day / 1) + 1 17001 } 17002 year = year / 1; 17003 month = month / 1 + 1; 17004 var a = Math.floor((14 - (month)) / 12); 17005 var y = year + 4800 - a; 17006 var m = (month) + (12 * a) - 3; 17007 var jd = day + Math.floor(((153 * m) + 2) / 5) + (365 * y) + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400) - 32045; 17008 var d4 = (jd + 31741 - (jd % 7)) % 146097 % 36524 % 1461; 17009 var L = Math.floor(d4 / 1460); 17010 var d1 = ((d4 - L) % 365) + L; 17011 NumberOfWeek = Math.floor(d1 / 7) + 1; 17012 return NumberOfWeek 17013} 17014 17015function writeTimeBar() { 17016 var timeBar = document.createElement('DIV'); 17017 timeBar.id = 'timeBar'; 17018 timeBar.className = 'timeBar'; 17019 var subDiv = document.createElement('DIV'); 17020 subDiv.innerHTML = 'Time:'; 17021 var hourDiv = document.createElement('DIV'); 17022 hourDiv.onmouseover = highlightSelect; 17023 hourDiv.onmouseout = highlightSelect; 17024 hourDiv.onclick = showHourDropDown; 17025 hourDiv.style.width = '30px'; 17026 var span = document.createElement('SPAN'); 17027 span.innerHTML = currentHour; 17028 span.id = 'calendar_hour_txt'; 17029 hourDiv.appendChild(span); 17030 timeBar.appendChild(hourDiv); 17031 var img = document.createElement('IMG'); 17032 img.src = pathToImages + 'down_time.png'; 17033 hourDiv.appendChild(img); 17034 hourDiv.className = 'selectBoxTime'; 17035 if (Opera) { 17036 hourDiv.style.width = '30px'; 17037 img.style.cssText = 'float:right'; 17038 img.style.position = 'relative'; 17039 img.style.styleFloat = 'right' 17040 } 17041 var hourPicker = createHourDiv(); 17042 hourPicker.style.left = '130px'; 17043 hourPicker.style.width = '35px'; 17044 hourPicker.id = 'hourDropDown'; 17045 calendarDiv.appendChild(hourPicker); 17046 var minuteDiv = document.createElement('DIV'); 17047 minuteDiv.onmouseover = highlightSelect; 17048 minuteDiv.onmouseout = highlightSelect; 17049 minuteDiv.onclick = showMinuteDropDown; 17050 minuteDiv.style.width = '30px'; 17051 var span = document.createElement('SPAN'); 17052 span.innerHTML = currentMinute; 17053 span.id = 'calendar_minute_txt'; 17054 minuteDiv.appendChild(span); 17055 timeBar.appendChild(minuteDiv); 17056 var img = document.createElement('IMG'); 17057 img.src = pathToImages + 'down_time.png'; 17058 minuteDiv.appendChild(img); 17059 minuteDiv.className = 'selectBoxTime'; 17060 if (Opera) { 17061 minuteDiv.style.width = '30px'; 17062 img.style.cssText = 'float:right'; 17063 img.style.position = 'relative'; 17064 img.style.styleFloat = 'right' 17065 } 17066 var minutePicker = createMinuteDiv(); 17067 minutePicker.style.left = '167px'; 17068 minutePicker.style.width = '35px'; 17069 minutePicker.id = 'minuteDropDown'; 17070 calendarDiv.appendChild(minutePicker); 17071 return timeBar 17072} 17073 17074function writeBottomBar() { 17075 var d = new Date(); 17076 var bottomBar = document.createElement('DIV'); 17077 bottomBar.id = 'bottomBar'; 17078 bottomBar.style.cursor = 'pointer'; 17079 bottomBar.className = 'todaysDate'; 17080 var subDiv = document.createElement('DIV'); 17081 subDiv.onclick = pickTodaysDate; 17082 subDiv.id = 'todaysDateString'; 17083 subDiv.style.width = (calendarDiv.offsetWidth - 95) + 'px'; 17084 var day = d.getDay(); 17085 if (!weekStartsOnSunday) { 17086 if (day == 0) day = 7; 17087 day-- 17088 } 17089 var bottomString = todayStringFormat; 17090 bottomString = bottomString.replace('[monthString]', monthArrayShort[d.getMonth()]); 17091 bottomString = bottomString.replace('[day]', d.getDate()); 17092 bottomString = bottomString.replace('[year]', d.getFullYear()); 17093 bottomString = bottomString.replace('[dayString]', dayArray[day].toLowerCase()); 17094 bottomString = bottomString.replace('[UCFdayString]', fullDayArray[day]); 17095 bottomString = bottomString.replace('[todayString]', todayString); 17096 subDiv.innerHTML = todayString + ': ' + d.getDate() + '. ' + monthArrayShort[d.getMonth()] + ', ' + d.getFullYear(); 17097 subDiv.innerHTML = bottomString; 17098 bottomBar.appendChild(subDiv); 17099 var timeDiv = writeTimeBar(); 17100 bottomBar.appendChild(timeDiv); 17101 calendarDiv.appendChild(bottomBar) 17102} 17103 17104function getTopPos(inputObj) { 17105 var returnValue = inputObj.offsetTop + inputObj.offsetHeight; 17106 while ((inputObj = inputObj.offsetParent) != null) returnValue += inputObj.offsetTop; 17107 return returnValue + calendar_offsetTop 17108} 17109 17110function getleftPos(inputObj) { 17111 var returnValue = inputObj.offsetLeft; 17112 while ((inputObj = inputObj.offsetParent) != null) returnValue += inputObj.offsetLeft; 17113 return returnValue + calendar_offsetLeft 17114} 17115 17116function positionCalendar(inputObj) { 17117 calendarDiv.style.left = getleftPos(inputObj) + 'px'; 17118 calendarDiv.style.top = getTopPos(inputObj) + 'px'; 17119 if (iframeObj) { 17120 iframeObj.style.left = calendarDiv.style.left; 17121 iframeObj.style.top = calendarDiv.style.top; 17122 iframeObj2.style.left = calendarDiv.style.left; 17123 iframeObj2.style.top = calendarDiv.style.top 17124 } 17125} 17126 17127function calendarOver() { 17128 calCanBeOpen = true 17129} 17130 17131function calendarOut() { 17132 calCanBeOpen = false 17133} 17134
17135function initCalendar() { 17136 calendarDiv = document.createElement('DIV'); 17137 calendarDiv.id = 'calendarDiv'; 17138 calendarDiv.style.zIndex = 30000; 17139 calendarDiv.onmouseover = calendarOver; 17140 calendarDiv.onmouseout = calendarOut; 17141 slideCalendarSelectBox(); 17142 document.body.appendChild(calendarDiv); 17143 writeBottomBar(); 17144 writeTopBar(); 17145 if (!currentYear) { 17146 var d = new Date(); 17147 currentMonth = d.getMonth(); 17148 currentYear = d.getFullYear() 17149 } 17150 writeCalendarContent() 17151} 17152 17153function setTimeProperties() { 17154 if (!calendarDisplayTime) { 17155 document.getElementById('timeBar').style.display = 'none'; 17156 document.getElementById('timeBar').style.visibility = 'hidden'; 17157 document.getElementById('todaysDateString').style.width = '100%' 17158 } else { 17159 document.getElementById('timeBar').style.display = 'block'; 17160 document.getElementById('timeBar').style.visibility = 'visible'; 17161 document.getElementById('hourDropDown').style.top = document.getElementById('calendar_minute_txt').parentNode.offsetHeight + calendarContentDiv.offsetHeight + document.getElementById('topBar').offsetHeight + 'px'; 17162 document.getElementById('minuteDropDown').style.top = document.getElementById('calendar_minute_txt').parentNode.offsetHeight + calendarContentDiv.offsetHeight + document.getElementById('topBar').offsetHeight + 'px'; 17163 document.getElementById('minuteDropDown').style.right = '50px'; 17164 document.getElementById('hourDropDown').style.right = '50px'; 17165 document.getElementById('todaysDateString').style.width = '115px' 17166 } 17167} 17168 17169function calendarSortItems(a, b) { 17170 return a / 1 - b / 1 17171} 17172 17173function displayCalendar(inputField, format, buttonObj, displayTime, timeInput) { 17174 if (displayTime) calendarDisplayTime = true; 17175 else calendarDisplayTime = false; 17176 if (inputField.value.length > 6) { 17177 if (!inputField.value.match(/^[0-9]*?$/gi)) { 17178 var items = inputField.value.split(/[^0-9]/gi); 17179 var positionArray = new Object(); 17180 positionArray.m = format.indexOf('mm'); 17181 if (positionArray.m == -1) positionArray.m = format.indexOf('m'); 17182 positionArray.d = format.indexOf('dd'); 17183 if (positionArray.d == -1) positionArray.d = format.indexOf('d'); 17184 positionArray.y = format.indexOf('yyyy'); 17185 positionArray.h = format.indexOf('hh'); 17186 positionArray.i = format.indexOf('ii'); 17187 this.initialHour = '00'; 17188 this.initialMinute = '00'; 17189 var elements = ['y', 'm', 'd', 'h', 'i']; 17190 var properties = ['currentYear', 'currentMonth', 'inputDay', 'currentHour', 'currentMinute']; 17191 var propertyLength = [4, 2, 2, 2, 2]; 17192 for (var i = 0; i < elements.length; i++) { 17193 if (positionArray[elements[i]] >= 0) { 17194 window[properties[i]] = inputField.value.substr(positionArray[elements[i]], propertyLength[i]) / 1 17195 } 17196 } 17197 currentMonth-- 17198 } else { 17199 var monthPos = format.indexOf('mm'); 17200 currentMonth = inputField.value.substr(monthPos, 2) / 1 - 1; 17201 var yearPos = format.indexOf('yyyy'); 17202 currentYear = inputField.value.substr(yearPos, 4); 17203 var dayPos = format.indexOf('dd'); 17204 tmpDay = inputField.value.substr(dayPos, 2); 17205 var hourPos = format.indexOf('hh'); 17206 if (hourPos >= 0) { 17207 tmpHour = inputField.value.substr(hourPos, 2); 17208 currentHour = tmpHour; 17209 if (currentHour.length == 1) currentHour = '0' 17210 } else { 17211 currentHour = '00' 17212 } 17213 var minutePos = format.indexOf('ii'); 17214 if (minutePos >= 0) { 17215 tmpMinute = inputField.value.substr(minutePos, 2); 17216 currentMinute = tmpMinute 17217 } else { 17218 currentMinute = '00' 17219 } 17220 } 17221 } else { 17222 var d = new Date(); 17223 currentMonth = d.getMonth(); 17224 currentYear = d.getFullYear(); 17225 currentHour = '08'; 17226 currentMinute = '00'; 17227 inputDay = d.getDate() / 1 17228 } 17229 inputYear = currentYear; 17230 inputMonth = currentMonth; 17231 if (!calendarDiv) { 17232 initCalendar() 17233 } else { 17234 if (calendarDiv.style.display == 'block') { 17235 calCanBeOpen = false;
17236 closeCalendar(); 17237 return false 17238 } 17239 writeCalendarContent() 17240 } 17241 returnFormat = format; 17242 returnDateTo = inputField; 17243 positionCalendar(buttonObj); 17244 calendarDiv.style.visibility = 'visible'; 17245 calendarDiv.style.display = 'block'; 17246 calendarDiv.style.marginTop = '-180px'; 17247 if (iframeObj) { 17248 iframeObj.style.display = ''; 17249 iframeObj.style.height = '140px'; 17250 iframeObj.style.width = '195px'; 17251 iframeObj.style.marginTop = '-140px'; 17252 iframeObj2.style.display = ''; 17253 iframeObj2.style.height = '140px'; 17254 iframeObj2.style.width = '195px' 17255 } 17256 setTimeProperties(); 17257 updateYearDiv(); 17258 updateMonthDiv(); 17259 updateMinuteDiv(); 17260 updateHourDiv() 17261} 17262 17263function displayCalendarSelectBox(yearInput, monthInput, dayInput, hourInput, minuteInput, buttonObj) { 17264 if (!hourInput) calendarDisplayTime = false; 17265 else calendarDisplayTime = true; 17266 currentMonth = monthInput.options[monthInput.selectedIndex].value / 1 - 1; 17267 currentYear = yearInput.options[yearInput.selectedIndex].value; 17268 if (hourInput) { 17269 currentHour = hourInput.options[hourInput.selectedIndex].value; 17270 inputHour = currentHour / 1 17271 } 17272 if (minuteInput) { 17273 currentMinute = minuteInput.options[minuteInput.selectedIndex].value; 17274 inputMinute = currentMinute / 1 17275 } 17276 inputYear = yearInput.options[yearInput.selectedIndex].value; 17277 inputMonth = monthInput.options[monthInput.selectedIndex].value / 1 - 1; 17278 inputDay = dayInput.options[dayInput.selectedIndex].value / 1; 17279 if (!calendarDiv) { 17280 initCalendar() 17281 } else { 17282 writeCalendarContent() 17283 } 17284 returnDateToYear = yearInput; 17285 returnDateToMonth = monthInput; 17286 returnDateToDay = dayInput; 17287 returnDateToHour = hourInput; 17288 returnDateToMinute = minuteInput; 17289 returnFormat = false; 17290 returnDateTo = false; 17291 positionCalendar(buttonObj); 17292 calendarDiv.style.visibility = 'visible'; 17293 calendarDiv.style.display = 'block'; 17294 if (iframeObj) { 17295 iframeObj.style.display = ''; 17296 iframeObj.style.height = calendarDiv.offsetHeight + 'px'; 17297 iframeObj.style.width = calendarDiv.offsetWidth + 'px'; 17298 iframeObj2.style.display = ''; 17299 iframeObj2.style.height = calendarDiv.offsetHeight + 'px'; 17300 iframeObj2.style.width = calendarDiv.offsetWidth + 'px' 17301 } 17302 setTimeProperties(); 17303 updateYearDiv(); 17304 updateMonthDiv(); 17305 updateHourDiv(); 17306 updateMinuteDiv() 17307} 17308 17309function parseDateTime(d, t) { 17310 var date = d.value(), 17311 time = t.value(), 17312 dateRegex = new RegExp("\\d{4}-\\d{2}-\\d{2}"), 17313 timeRegex = new RegExp("\\d{2}:\\d{2}"), 17314 i, e = new Date(); 17315 if (!date.match(dateRegex)) date = e.getFullYear() + '-' + ((i = e.getMonth()) < 10 ? '0' + i : i) + '-' + ((i = e.getDate()) < 10 ? '0' + i : i); 17316 if (!time.match(timeRegex)) time = ((i = e.getHours()) < 10 ? '0' + i : i) + ':' + ((i = e.getMinutes()) < 10 ? '0' + i : i); 17317 var dateYear = date.substr(0, date.indexOf("-")); 17318 date = date.substr(date.indexOf("-") + 1, date.length); 17319 var dateMonth = date.substr(0, date.indexOf("-")); 17320 date = date.substr(date.indexOf("-") + 1, date.length); 17321 var dateDay = date; 17322 var timeHour = time.substr(0, time.indexOf(":")); 17323 var timeMin = time.substr(time.indexOf(":") + 1, time.length); 17324 dateYear = (dateYear < 2013 ? 2013 : (dateYear > 2014 ? 2014 : dateYear)); 17325 dateMonth = (dateMonth < 1 ? '01' : (dateMonth > 12 ? 12 : dateMonth)); 17326 dateDay = (dateDay < 1 ? '01' : (dateDay > 31 ? 31 : dateDay)); 17327 timeHour = (timeHour < 1 ? '01' : (timeHour > 24 ? 24 : timeHour)); 17328 timeMin = (timeMin < 1 ? '01' : (timeMin > 59 ? 59 : timeMin)); 17329 d.value(dateYear + "-" + dateMonth + "-" + dateDay); 17330 t.value(timeHour + ":" + timeMin); 17331 return d.value() + ' ' + t.value() 17332} 17333E.ListInput = L.Class.extend({ 17334 _div: '', 17335 _input: [], 17336 _as: [], 17337 _ac: [], 17338 _type: '', 17339 id: -1, 17340 _class: '', 17341 _alert: '', 17342 _alerti: '', 17343 _func: 0, 17344 _pos: 0, 17345 _desc: 0, 17346 _country: 0, 17347 initialize: function(div, f, p) { 17348 with(this) { 17349 _type = p.id; 17350 E.$(div).append((_div = E.newElem$('div', '')).text(drawPoint(p, f)).obj('ct', this)); 17351 _input = _div.getElem('.li_i').focus(function() { 17352 with(this) _country.hide(), _input.width(_input.parent().width() - 5) 17353 }, this).blur(function() { 17354 with(this) _input.width(_input.parent().width() - 5 - _country.show().width()) 17355 }, this); 17356 _ac = _pAc(_div.getElem('.li_ctd').childs()); 17357 _as = _pAc(_div.getElem('.li_as').childs()[0].childs()); 17358 _alert = _div.getElem('.alert').hide(); 17359 _alerti = _div.getElem('.li_im_a'); 17360 _pos = p.pos; 17361 _desc = _div.getElem('.desc'); 17362 _country = _div.getElem('.country') 17363 } 17364 }, 17365 _getAc: function(p, f) { 17366 var i, j, k, r, c = '', 17367 a = p.actions, 17368 s = { 17369 'm': ['mouseover', 'mouseout'], 17370 'c': ['click'] 17371 }; 17372 for (i = 0; i < a.length; i++) with(a[i]) { 17373 for (j = 0, r = ''; j < ac.length; j++) 17374 for (k = 0; k < s[ac[j]].length; k++) r += E.format(" on{0}=\"{1}('{2}','{3}','{0}')\"", [s[ac[j]][k], f, name, p.id]); 17375 c += E.format("<img src='{0}' class='li_im_{1}' {2}>", [E.blank, a[i].name, r]) 17376 } 17377 return c 17378 }, 17379 _getAs: function(p, f) { 17380 var i, j, k, r, c = '', 17381 a = p.as ? ['search', 'up', 'down', 'del'] : ['search']; 17382 for (i = 0; i < a.length; i++) c += E.format("<img src='{0}' class='RR_PA {1}' onclick=\"{3}('{1}','{2}')\">", [E.blank, a[i], p.id, f]); 17383 return "<span class='RR_P'>" + c + '</span>' 17384 }, 17385 _getDesc: function(p) { 17386 return p.desc ? E.format("<span class='desc' style='margin-right:5px'></span><img src='{0}' class='RT {1}'>", [E.blank, p.desc, E.lang('LI_' + p.desc)]) : "" 17387 }, 17388 _pAc: function(a) { 17389 var i, b = {}; 17390 for (i = 0; i < a.length; i++) b[a[i].Class().replace('li_im_', '').replace('RR_PA ', '')] = a[i]; 17391 return b 17392 }, 17393 drawPoint: function(p, f) { 17394 with(this) return E.format("<table {5}t{0}'><tr><td>{3}</td><td {5}btd{0}' {1}></td><td {5}itd{0}'><span class='country'></span><input {5}i{0}{9}' {1} spellcheck='false' onclick=\"{7}('input','{8}','0')\" ondblclick=\"{7}('input','{8}','1')\"></td><td {5}ctd{0}' {1}>{2}</td>" + "<td {5}as{0}'>{4}</td></tr></table><div class='alert'><div class='t'>{6}</div></div>", [_class, '', _getAc(p, f), _getDesc(p), _getAs(p, f), "class='li_", E.lang(p.alert), f, p.id, p.iclass ? " " + p.iclass : ""]) 17395 }, 17396 showAction: function(a, b) { 17397 if (E.type(a) != 'a') a = [a]; 17398 with(this) for (var i = 0; i < a.length; i++) { 17399 if (_as[a[i]]) _as[a[i]].visibility(b); 17400 if (_ac[a[i]]) _ac[a[i]].visibility(b) 17401 } 17402 return this 17403 }, 17404 hideAlert: function() { 17405 this.showAlert(0) 17406 }, 17407 showAlert: function(v, t) { 17408 with(this) { 17409 var a = E.pos(_alerti.elem(), 1); 17410 _alert.visible(v).pos(a.left - _alert.width() / 2 + 17, a.top - _alert.height()); 17411 if (t && v) setTimeout(E.bind(this.hideAlert, this), 3000); 17412 return this 17413 } 17414 }, 17415 setLonLat: function(a, b) { 17416 with(this) if (_pos) E.$(_pos).text(a ? E.format(this._func, [b.Latitude, b.Longitude]) : '') 17417 }, 17418 setDescription: function(a) { 17419 this._desc.text(a) 17420 }, 17421 setCountry: function(a) { 17422 with(this) { 17423 var b = _country.visible(); 17424 _country.hide().text(a ? '[' + a + ']' : '').att('val', a), _input.width(_input.parent().width() - 5 - _country.visible(b).width()) 17425 } 17426 return this 17427 }, 17428 getCountry: function(a) { 17429 return this._country.att('val') 17430 }, 17431 clear: function() { 17432 with(this) { 17433 _input.value(""); 17434 id = -1; 17435 setCountry() 17436 } 17437 }, 17438 actionX: function() { 17439 this._input.value('').focus(); 17440 this.setCountry() 17441 } 17442}); 17443L.Map.include({ 17444 offsets: [400, 60], 17445 _offset: function(ll, z) { 17446 var l = L.latLng((ll instanceof L.LatLng) ? [ll.lat, ll.lng] : ll); 17447 with(this) var a = unproject([offsets[0] / 2, offsets[1] / 2], z), 17448 b = this.unproject([0, 0], z); 17449 l.lng += (b.lng - a.lng); 17450 l.lat += (b.lat - a.lat); 17451 return l 17452 },
17453 fitBounds: function(bounds) { 17454 var zoom = this.getBoundsZoom(bounds); 17455 return this.setView(this._offset(L.latLngBounds(bounds).getCenter(), zoom), zoom) 17456 }, 17457 getBoundsZoom: function(bounds, inside) { 17458 bounds = L.latLngBounds(bounds); 17459 var size = this.getSize().subtract(this.offsets), 17460 zoom = this.options.minZoom || 0, 17461 maxZoom = this.getMaxZoom(), 17462 ne = bounds.getNorthEast(), 17463 sw = bounds.getSouthWest(), 17464 boundsSize, nePoint, swPoint, zoomNotFound = true; 17465 if (inside) { 17466 zoom-- 17467 } 17468 do { 17469 zoom++; 17470 nePoint = this.project(ne, zoom); 17471 swPoint = this.project(sw, zoom); 17472 boundsSize = new L.Point(Math.abs(nePoint.x - swPoint.x), Math.abs(swPoint.y - nePoint.y)); 17473 if (!inside) { 17474 zoomNotFound = boundsSize.x <= size.x && boundsSize.y <= size.y 17475 } else { 17476 zoomNotFound = boundsSize.x < size.x || boundsSize.y < size.y 17477 } 17478 } while (zoomNotFound && zoom <= maxZoom); 17479 if (zoomNotFound && inside) { 17480 return null 17481 } 17482 return inside ? zoom : zoom - 1 17483 } 17484}); 17485E.Map.include({ 17486 setView: function(center, zoom) {
17487 this._map.setView(this._map._offset(center instanceof E.LonLat ? [center.lat, center.lon] : center, zoom = (zoom ? zoom : this.getZoom())), zoom) 17488 } 17489}); 17490E.MC = L.Class.extend({ 17491 includes: E.Hook, 17492 _ppPosition: 'l', 17493 _offset: { 17494 r: 0, 17495 l: 10 17496 }, 17497 _div: '', 17498 _actP: 'search', 17499 _actPT: 'search', 17500 _Panels: ['search', 'route', 'routeReport'], 17501 _finder: { 17502 Zip: '', 17503 Name: '', 17504 key: '', 17505 c: '', 17506 a: null, 17507 p: '', 17508 items: 0, 17509 layer: new E.VectorLayer(), 17510 objects: [] 17511 }, 17512 _router: { 17513 c: '', 17514 key: '', 17515 activeRP: 'vehicle', 17516 lastVehicle: -1, 17517 lastDriver: -1, 17518 lastRouteType: -1, 17519 lastVehicleType: -1, 17520 lastEuroType: -1, 17521 time: 0, 17522 doCalc: 0 17523 }, 17524 _searchAdditional: '', 17525 _lastVehicleId: -1, 17526 _select: '', 17527 _countries: {}, 17528 _routeReports: [], 17529 initialize: function(div, token, options) { 17530 this._map = new E.Map(div, token, options); 17531 this._map._map.on('onVisibleChange', this._layerVisibleChange, this); 17532 this._profile = this._map._map.profile.on("onLogin", this._onLogin, this).on('onLogout', this._onLogout, this).lC(); 17533 this._profile._setVehicle = false; 17534 this._poi = this._map._map._poi; 17535 with(this._finder) { 17536 key = this._map._map.regAction(this._clickShowRect, this); 17537 c = new E.Finder(this._map); 17538 p = L.marker([0, 0], { 17539 icon: L.icon({ 17540 className: 'Finder_Point', 17541 iconUrl: E.blank 17542 }) 17543 }); 17544 this._map.addLayer(layer); 17545 this._map._map.on('objPopup', this._onShowPopup, this) 17546 } 17547 with(this._router) { 17548 key = this._map._map.regAction(this._addRoutePoint, this); 17549 c = new E.Router(this._map, { 17550 reportResultHandlerName: 'content_itc', 17551 reportPointsHandlerButtonsName: 'content_ist_pb' 17552 }); 17553 c.on('activateRoute', this._onActivateRoute, this); 17554 with(c) c._onRouteCalc1 = _onRouteCalc, _onRouteCalc = E.bind(function(a, b) { 17555 if (this.activeRP != 'transport') { 17556 if (this.activeRP == 'walk' || this.activeRP == 'bicycle') { 17557 this.c, _map.categoryObjects().showCategory(26) 17558 } 17559 if (b.result != 0) alert("Nie można wyznaczyÄ trasy"); 17560 this.c._onRouteCalc1(a, b) 17561 } 17562 }, this._router), c._onETRRoute1 = _onETRRoute, _onETRRoute = E.bind(function(a, b) { 17563 if (this.activeRP == 'transport') this.c._onETRRoute1(a, b) 17564 }, this._router); 17565 doCalc = E.bind(this._doCalculateRoute, this); 17566 E.$("clearRoute").click(c.removeWaypoints, c) 17567 }; 17568 this._layerVisibleChange({ 17569 layer: { 17570 id: 'H', 17571 visible: this._poi.getVisibleLayers().indexOf('H') > -1 17572 } 17573 }); 17574 this._select = this._map._map.regAction(this._selectFun, this); 17575 this._myto = new E.MC.MytoEuroController(); 17576 this._truckEditor = new E.MC.TruckSettingsEditor(E.bind(function(p) { 17577 this._myto.setRoadsParam(parseInt(E.$('select_truckVehicle').selected()) + 1, E.$('select_EuroEmission').selected(), p); 17578 this._doCalculateRoute(1) 17579 }, this)); 17580 this._div = E.$(div); 17581 this._initPanels(); 17582 this._initializeSuggest(); 17583 this._initRoute(); 17584 E.$('emapi_login_id').click(function() { 17585 with(this._profile) if (isLogged()) logout(); 17586 else login() 17587 }, this); 17588 this._ppbarAction(); 17589 this._initPopup(); 17590 this.executeHook('initialize'); 17591 E.$('emapi_login_id_user').click(this._map._map.profile.showProfile, this._map._map.profile); 17592 this._initTest(); 17593 try { 17594 new E.RouterArgParser(this._router.c) 17595 } catch (e) {} 17596 }, 17597 _initTest: function() {}, 17598 _initPopup: function() { 17599 var i, a = 'FVT', 17600 l = '', 17601 r = this._map._map.regAction(function(a, b, c) { 17602 this.addWaypoint(new E.LonLat(c, b), a); 17603 this._map._map._activePopup._close() 17604 }, this._router.c); 17605 for (i = 0; i < a.length; i++) l += E.format('<a href="#" onclick=\'{0}({2},{3});\'><img src="{4}" class="Type1 Flag{2}">{1}</a>', [r, E.lang("TT_" + a[i]), i, '{0},{1}', E.blank]); 17606 L.Popup.prototype._driveFunc = E.format('<div class="PopupRoute">{0}<div>', [l]) 17607 }, 17608 _initPanels: function() { 17609 E.$('pp_bar').clickP(this._ppbarAction, this); 17610 E.$('.leaflet-left').left(320); 17611 E.$('.leaflet-control-zoom-EMAPI').top(40); 17612 L.DomUtil.setPosition(E.$('.emapi-control-actionPanel').elem(), new L.Point(17, 270)); 17613 var a = this._Panels, 17614 i, b = ''; 17615 for (i = 0; i < a.length; i++) E.$('bar_item_' + a[i] + '_div').clickP(this.showPanel, this); 17616 this._actP = E.$('bar_item_' + this._actP + '_div'); 17617 a = [ 17618 ['country', ''], 17619 ['category', ''], 17620 ['country', '_route'] 17621 ]; 17622 for (i = 0; i < a.length; i++) { 17623 E.$(a[i][0] + 'Selected' + a[i][1]).click(this._selectListVisible, this, [true, a[i][0], a[i][1]]); 17624 E.$(a[i][0] + 'SelectListClose' + a[i][1]).click(this._selectListVisible, this, [false, a[i][0], a[i][1]]) 17625 } 17626 a = ['vehicle', 'walk', 'transport', 'bicycle']; 17627 for (i = 0; i < a.length; i++) E.$('content_route_select_' + a[i]).clickP(this._clickRouteItems, { 17628 i: i, 17629 e: a, 17630 c: this 17631 });
17632 E.$('content_ith_h1').clickP(a = function(a, b) { 17633 (b = E.$(b)).nextSibling().visible(b.childs()[0].hasClass('show', 'hide')) 17634 }); 17635 E.$('content_ith_h2').clickP(a); 17636 E.$('euroTruckEdit').click(function() { 17637 this._truckEditor.showEditor(this._myto.getRoadsParam(1 + parseInt(E.$('select_truckVehicle').selected()), E.$('select_EuroEmission').selected())) 17638 }, this).width(100); 17639 E.resize(this._updateSize, this, 1); 17640 this._updateSize(); 17641 for (i = 2, a = E.langa("TT_Country"); i < a.length; i += 2) b += E.format("<{0} value='{1}' {2}>{3}</{0}>", ['option', a[i], i == 0 ? 'selected="selected"' : '', a[i + 1]]), this._countries[a[i + 1]] = a[i]; 17642 this._makeSelect('csec_s', [a.slice(0, 2)], b).id('csec'); 17643 this._makeSelect('csec_rs', [a.slice(0, 2)], b).id('csec_r'); 17644 a = this._makeSelect('cats_sel_s', [E.lang('TT_cats')]).id('cats_sel'); 17645 new E.MC.ObjectsSearcher('addressIdSet_POI', a, 'content_item_searchRes_POI', this._map); 17646 for (i = 0, b = []; i < 6; i++) b.push("Euro " + i); 17647 this._makeSelect('cir_me', b).id('select_EuroEmission').width(45); 17648 this._makeSelect('cir_mv', [E.lang("TT_v1"), E.lang("TT_v2"), E.lang("TT_v3")]).id('select_truckVehicle').width(100) 17649 }, 17650 _updateSize: function() { 17651 var a = E.$('content_panel'), 17652 b = a.parent().height() - 30, 17653 i, c = a.childs(); 17654 for (i = 0; i < c.length; i++) c[i].height(b - 5) 17655 }, 17656 _clickRouteItems: function(a, b) { 17657 with(this) { 17658 for (var j = 0; j < e.length; j++) { 17659 E.$('content_route_select_' + e[j]).replaceClass("_a", ''); 17660 E.$('content_route_' + e[j]).visible(i == j) 17661 }(b = E.$(b)).Class(b.Class() + '_a'); 17662 with(c._router) { 17663 if ((activeRP = b.id().replace('content_route_select_', '')) == 'transport' && c._wayPoints.isPointSet(1) != -1) E.Overlay.showMessage(E.lang("LI_B")); 17664 c.doCalculateRoute() 17665 } 17666 } 17667 }, 17668 initRoutePanel: function() {}, 17669 _ppbarAction: function(a, b, c) { 17670 b = E.$('pp_bar'), a = b.hasClass('pp_show'), c = E.$("pp_bg").visible(a); 17671 b.left(a ? c.width() + c.left() : 0); 17672 E.$('.leaflet-left').left(a ? 320 : 0); 17673 this._map._map.offsets[0] = a ? 400 : 0; 17674 E.$("pp").visible(a); 17675 b.hasClass(a ? 'pp_show' : 'pp_hide', a ? 'pp_hide' : 'pp_show') 17676 }, 17677 showPanel: function(a, b) { 17678 a = E.type(a) == 's' ? a : E.$(b).id().split("_")[2]; 17679 this._actP.replaceClass('_a', '_i'); 17680 E.$('content_' + this._actP.id().split("_")[2]).hide(); 17681 this._actP = E.$('bar_item_' + a + '_div').replaceClass('_i', '_a'); 17682 this._actPT = this._actP.id().split("_")[2]; 17683 E.$('content_' + this._actPT).show() 17684 }, 17685 _selectListVisible: function(a, b) { 17686 E.$(b[1] + "Selected" + b[2]).visible(!b[0]); 17687 E.$(b[1] + "Select" + b[2]).visible(b[0]) 17688 }, 17689 _initializeSuggest: function() {}, 17690 _onSelectedSuggest: function(name, zip, id) { 17691 with(this) { 17692 _finder.Zip = zip; 17693 _finder.Name = name; 17694 if (id > -1) _finderShowRect(id, 1); 17695 else _onGetSuggest() 17696 } 17697 }, 17698 _finderShowRect: function(id, x) { 17699 with(this._finder) { 17700 var d = c.getCoordinates(id), 17701 r = d.boundingRect, 17702 i; 17703 if (x) { 17704 objects[id].openPopup() 17705 } 17706 this._map.setBounds(new E.Bounds(r)); 17707 return d.middlePoint 17708 } 17709 }, 17710 _onShowPopup: function(a) { 17711 with(a.obj) if ((a.obj._search) && (_search.type == 1)) { 17712 with(this._finder) { 17713 for (var i = 1; i < items.length; i += 2) { 17714 items[i].visible((i - 1) / 2 == _search.id); 17715 items[i - 1].Class("find_result_item" + (((i - 1) / 2 == _search.id) ? "_selected" : '')) 17716 } 17717 var id = _search.id * 2, 17718 e, p = (e = items[id]).parent(), 17719 t = e.top() - p.sTop(); 17720 if (t < 0) p.sTop(p.sTop() + t); 17721 else if ((t += e.height() + items[id + 1].height()) > p.height()) p.sTop(p.sTop() + t - p.height()) 17722 } 17723 } 17724 }, 17725 _clickShowRect: function(id, x) { 17726 with(this._finder) { 17727 var d = geocodeInfo[id], 17728 r = d.boundingRect; 17729 objects[id].openPopup(); 17730 if (x == 2) this._map.setBounds(new E.Bounds(r)); 17731 else this._map.setCenterPos(new E.Bounds(r).getCenterLonLat()); 17732 return d.middlePoint 17733 } 17734 }, 17735 _addRoutePoint: function(id, type) { 17736 var a = (a = this._map._map._popup) ? a._close() : ''; 17737 this._router.c.addWaypoint(this._finder.c.getCoordinates(id).middlePoint, type) 17738 }, 17739 _finderClearObjects: function(a) { 17740 with(this._finder) layer.clearLayers(), objects = []; 17741 E.$('isr_fr').text('').height("") 17742 }, 17743 _onResponseFinder: function(response) { 17744 with(this) { 17745 var res = "", 17746 item, i = 0, 17747 ir, b, el = E.$(a), 17748 le; 17749 c._finder.layer.clearLayers(); 17750 c._finder.objects = []; 17751 c._finder.geocodeInfo = response.geocodeInfoArray; 17752 if (el != null) { 17753 if ((response.result == 0) || (response.result == 2)) { 17754 for (i = 0; i < response.geocodeInfoArray.length; i++) { 17755 with(response.geocodeInfoArray[i]) { 17756 ir = E.addI([city, zip, E.trim(street + ' ' + streetNumber), city != areaName0 ? areaName0 : '', city != areaName1 ? areaName1 : '', city != areaName0 ? areaName2 : '']); 17757 var ss = E.format("<div class='marker_img_mini_red' style='position:absolute;
17757left:5px;top:5px;'>{0}</div><div style='margin-left:15px'>{1}</div>", [String.fromCharCode(i + 65), ir.replace(/,/g, "<br>")]); 17758 c._finder.layer.addLayer(le = new E.Marker([middlePoint.Latitude, middlePoint.Longitude], { 17759 icon: new L.DivIcon({ 17760 html: String.fromCharCode(i + 65), 17761 iconSize: null, 17762 className: 'marker_img_red', 17763 iconAnchor: [12, 42] 17764 }), 17765 zIndex: response.geocodeInfoArray.length - i + 500 17766 }).bindPopup(ss)); 17767 c._finder.objects.push(le); 17768 le._search = { 17769 id: i, 17770 type: 1 17771 }; 17772 le._mainObj = le 17773 } 17774 res += E.format("<div class='find_result_item{3}' onclick='{2}({1},1)' ondblclick='{2}({1},2)'><table><tr><td><div class='marker_img_mini_red'>{4}</div></td><td>{0}</td></tr></table></div>", [ir, i, c._finder.key, i > 0 ? "" : '_selected', String.fromCharCode(i + 65)]) + E.format("{0}find_result_item_r' {8}><table><tr><td>{0}Add Flag0' {6}0)'>{1}{2}0)'>{3}{1}{0}Add Flag1' {6}1)'>{1}{2}1)'>{4}{1}{0}Add Flag2' {6}2)'>{1}{2}2)'>{5}</div></td></tr></table></div>", ["<div class='", "</div></td><td>", "<div class='Desc'{6}", E.lang('LI_from'), E.lang('LI_cross'), E.lang('LI_to'), "onclick='" + c._router.key + '({7},', i, i > 0 ? "style='display:none'" : '']) 17775 } 17776 } else if (response.result == 1) res += E.lang("TT_pagePanelNoSearchResult"); 17777 else if (response.result == 2) res += E.lang("pagePanelToManySearchResult"); 17778 el.height(i > 10 ? 180 : "").text(res); 17779 c._finder.items = el.childs() 17780 } 17781 c._onResponseRouter.call(this, response, 1) 17782 } 17783 }, 17784 _initRoute: function() { 17785 var a = ['dit', 'tit', 'tita', 'mit', 'ulit', 'rtm1t', 'rtm2t', 'ra1t', 'ra2t', 'ra3t', 'ra4t', 'car'], 17786 i, b; 17787 with(E.Tooltip) { 17788 makeTooltip("content_route_select_vehicle", "TT_CD", 0); 17789 makeTooltip("content_route_select_transport", "TT_PT", 0); 17790 makeTooltip("content_route_select_bicycle", "TT_B", 0); 17791 makeTooltip("content_route_select_walk", "TT_W", 0); 17792 for (i = 0; i < a.length; i++) { 17793 b = E.$(a[i]).clickP(this._groupClick, this); 17794 if (i < 5) makeTooltip(b, "TT_" + a[i], 0) 17795 } 17796 E.$('ra1t').clickP(a = function(a, b) { 17797 E.$(E.$(b).id() == 'ra1t' ? 'ra2t' : 'ra1t').checked(false).parent().replaceClass("on", "off") 17798 }); 17799 E.$('ra2t').clickP(a); 17800 for (i = 0, a = ['', 't']; i < a.length; i++) E.$('table_route_d' + a[i]).clickP(function(a, b) { 17801 displayCalendar(b, "yyyy-mm-dd", b) 17802 }).blur(closeCalendar) 17803 } 17804 b = E.bind(function() { 17805 this._doCalculateRoute(1) 17806 }, this), a = ['dt', 'tt', 'oi1', 'oi2', 'd', 't']; 17807 for (i = 0; i < a.length; i++) E.$('table_route_' + a[i]).change(b); 17808 with(this._router.c) { 17809 doCalculateRoute = E.bind(this._doCalculateRoute, this); 17810 with(this._router) { 17811 c._pReportHTML1 = _pReportHTML; 17812 E.$('bar_item_routeReport_div').click(function() { 17813 var router = this._router.c; 17814 with(router) if (_rri) _pReportHTML1(_rri[0], _rri[1], _rri[2]), _rri = null; 17815 this._activateRouteReport(router.wayPoints()._activeRoute) 17816 }, this); 17817 E.$('rr_ptn').click(function() { 17818 E.$('bar_item_routeReport_div').show().click() 17819 }) 17820 } 17821 _pReportHTML = function(a, b, c) { 17822 this._rri = [a, b, c] 17823 }; 17824 on("afterCalculateRoute", this._onRoute, this).on("removePoints", this._onClearRoute, this).on("beforeCalculateRoute", this._beforeCalc, this) 17825 } 17826 this._makeSelect('vit', E.langa("TT_vt")); 17827 this._makeSelect('rit', E.langa("TT_rt")); 17828 this._makeSelect('rtt', E.langa("TT_rtt")) 17829 }, 17830 _makeSelect: function(a, b, c) { 17831 return new E.MC.Select(a, b, c, this._validateSelect, this); 17832 var r = '', 17833 i; 17834 for (i = 0; i < b.length; i++) r += E.format("<option value={0}>{1}</option>", [i, b[i]]); 17835 return E.$(a).Class(d ? d : 'sel').text("<span>" + b[0] + "</span><select>" + r + (c ? c : '') + "</select").childs()[1].changeP(function(e, d) {
17836 this._validateSelect(a, E.$(d)) 17837 }, this) 17838 }, 17839 _validateSelect: function(a, b) { 17840 if (a == 'vit') { 17841 if (b.selected() == 0) this._truckOptions(false); 17842 else { 17843 if (!this._profile.isLogged()) { 17844 this._profile._setVehicle = true; 17845 this._profile.login(); 17846 this._validateSelect(a, b.select(0)) 17847 } else if (!this._profile.isService('viaToll')) { 17848 E.Overlay.showMessage("<div class='' style='width:300px;height:170px'>" + E.lang('PM_e_myto_info') + "</div>"); 17849 this._validateSelect('vit', b.select(0)) 17850 } else this._truckOptions(true) 17851 } 17852 } 17853 this._doCalculateRoute() 17854 }, 17855 _onRoute: function(a) { 17856 E.$('bar_item_routeReport_div').show(); 17857 E.$('bar_item_route_div').click(); 17858 E.$('content_ist_rr').show(); 17859 this._routeReports.length = 0; 17860 with(this._router.c) { 17861 if (a.elem != 'etr') { 17862 var e = E.$('rr_ss').text(""), 17863 k; 17864 for (var i = 0; i < _routeRep.count(); i++) { 17865 with(_routeRep.item(i)) { 17866 var str = E.format("<div class='rr_pt'></div><table class='{0}' border='0'><tr><td><div class='Dist Img'></div></td><td><div class='Dv val'>{1}</div></td><td><div class='Cost Img'></div></td><td><div class='Cv val'>{2}</div></td><td><div class='Time Img'></div></td><td><div class='Tv val'>{3}</div></td></tr></table>", ["RR_TE", totalRouteLength + " km", totalRouteCost + " zÅ", totalRouteTime]); 17867 e.append(k = E.newElem$('div', 'RouteReport' + (i == 0 ? " active" : "")).text(str)); 17868 this._routeReports.push(k.click(function(a, b) { 17869 this.activateRoute(b || 0) 17870 }, this._router.c.wayPoints(), i)) 17871 } 17872 } 17873 } else with(_etr.reports[0].data.Route) E.$('rr_ss').text(E.format("{4}'rr_te'>{5}{4}'im time3'>{1}{0}_dime3'>{2}{1}{1}{5}{4}'im time4'>{1}{0}_time4'>{3}{1}{1}{1}", ["<span class='rr_item", "</span>", parseInt(TotalRideTime) + ' min', parseInt(TotalWalkTime) + ' min', '<span class=', '<span class="rr_ss2">'])) 17874 } 17875 E.$("clearRoute").show() 17876 }, 17877 _beforeCalc: function() { 17878 E.$('bar_item_routeReport_div').hide(); 17879 E.$("clearRoute").hide(); 17880 E.$('content_ist_rr').hide() 17881 }, 17882 _onClearRoute: function() { 17883 this._beforeCalc() 17884 }, 17885 _doCalculateRoute: function(force) { 17886 function ch(a, b) { 17887 return (E.$(a).Class() == 'chk_on') && (b) 17888 } 17889 17890 function pt() { 17891 var a = parseDateTime(E.$('table_route_d'), E.$('table_route_t')).split(" "), 17892 b = a[0].split("-"), 17893 a = a[1].split(":"), 17894 ONE_DAY = 1000 * 60 * 60 * 24, 17895 date1_ms = new Date(1899, 12, 30).getTime(), 17896 date2_ms = new Date(b[0], b[1], b[2], a[0], a[1]); 17897 return Math.abs(date1_ms - date2_ms) / ONE_DAY 17898 } 17899 with(this._router) { 17900 clearTimeout(time); 17901 if ((c._wayPoints.isPointSet(0) > -1) && (c._wayPoints.isPointSet(2) > -1)) { 17902 if (activeRP == 'transport') { 17903 if (force == 1) time = setTimeout(doCalc, 2000); 17904 else { 17905 if (lastVehicle != 't') c.refreshFullTrace(), c._wayPoints.processTrace(); 17906 lastVehicle = 't'; 17907 c._rri = null; 17908 var d = function(a) { 17909 return E.$(a).checked() 17910 }, 17911 a = parseDateTime(E.$('table_route_dt'), E.$('table_route_tt')), 17912 b = ch('rtm1t', 1) ? 0 : 1; 17913 c.calculateETRRoute({ 17914 DateTimeStart: b == 0 ? a : '', 17915 DateTimeFinish: b == 1 ? a : '', 17916 routesPriority: ['default', 'comfortable', 'fast', 'direct'][E.$('rtt').att('val')], 17917 minMoveTime: isNaN(a = E.$('table_route_oi1').value()) || ((a = parseInt(a)) > 60) || (a < 0) ? 60 : a, 17918 maxWalkDistance: isNaN(a = E.$('table_route_oi2').value()) || ((a = parseInt(a)) > 1000) || (a < 0) ? 1000 : a, 17919 avoidBuses: ch('ra1t', 1), 17920 avoidTrams: ch('ra2t', 1), 17921 avoidSubway: ch('ra3t', 1), 17922 avoidRail: ch('ra4t', 1) 17923 }) 17924 } 17925 } else { 17926 var v = (activeRP == 'bicycle') ? 6 : ((activeRP == 'walk') ? 7 : (2 * E.$('vit').att('val'))), 17927 r = v == 7 || v == 6 ? 0 : [1, 0, 2][E.$('rit').att('val')]; 17928 if ((lastVehicle != v) || (r != lastRouteType) || force || (v == 2 && (lastVehicleType != parseInt(E.$('select_truckVehicle').selected()) + 1 || lastEuroType != E.$('select_EuroEmission').selected()))) c.refreshFullTrace(); 17929 lastVehicle = v; 17930 lastRouteType = r; 17931 c.calculateRoute(v == 7 || v == 6 ? c._vehicles.item(v) : this._myto.getRoadsParam(lastVehicleType = (v == 2 ? parseInt(E.$('select_truckVehicle').selected()) + 1 : 0), lastEuroType = E.$('select_EuroEmission').selected()), c._drivers.item(1), r, { 17932 useGroundRoad: true, 17933 useFerry: true, 17934 viaToll: v == 2, 17935 avoidToll: ch('mit', 1), 17936 avoidViaToll: ch('mit', v == 2), 17937 useLogistic: ch('ulit', v == 2), 17938 useDifficulties: ch('dit', v != 7 && v != 6), 17939 useTrafficTI: ch('tit', v == 0), 17940 useArchivalTraffic: ch('tita', v == 0), 17941 alternativeRoutes: ch('car', v == 0 || v == 2), 17942 journeyStartTime: pt() 17943 }, null, true) 17944 } 17945 } 17946 } 17947 }, 17948 _onActivateRoute: function(a) { 17949 a = a.routeIndex; 17950 if (this._routeReports.length > a) { 17951 for (var i = 0; i < this._routeReports.length; i++) this._routeReports[i].removeClass('active'); 17952 this._routeReports[a].addClass('active'); 17953 this._activateRouteReport(a) 17954 } 17955 }, 17956 _activateRouteReport: function(b) { 17957 var a = E.$$('.RouteReportItems'); 17958 if (a) { 17959 a = a.childs(); 17960 for (var i = 0; i < a.length; i++) a[i].hide(); 17961 a[b].show() 17962 } 17963 }, 17964 _groupClick: function(a, b) { 17965 b = (a = E.$(b)).att("act"); 17966 if (b) E.$(b).Class('chk_off'); 17967 if (a.Class() == 'chk_off') a.Class('chk_on'), this._doCalculateRoute(1); 17968 else a.hasClass('chk_off', 'chk_on'), this._doCalculateRoute(1); 17969 if (b = a.att("ac2")) E.$(b).visible(a.Class() == 'chk_on'); 17970 if (b = a.att("ac3")) E.$(b).visible(0) 17971 }, 17972 _truckOptions: function(v) { 17973 for (var i = 0, a = ['ulit']; i < a.length; i++) E.$(a[i]).visible(v); 17974 E.$('content_ith_tt_id').visible(v) 17975 }, 17976 _onLogin: function(a) { 17977 with(this._profile) { 17978 E.$('emapi_login_id').text(E.lang('TT_lo')); 17979 (a = E.$('emapi_login_id_user')).text(loginUser()).parent("td").show().width(a.width() + 18); 17980 if (hasPaidServices()) { 17981 E.$('tit').hide(); 17982 E.$('tita').hide(); 17983 if (isService('viaToll') && (_setVehicle)) { 17984 _setVehicle = false;
17985 this._validateSelect('vit', E.$('vit').obj("obj").select(1)) 17986 } 17987 this._poi.hideCategory(201); 17988 this._poi.hideCategory(202); 17989 with(this._router) { 17990 c.mtp = c._maxTracePoints; 17991 c._maxTracePoints = 15 17992 } 17993 } 17994 } 17995 }, 17996 _layerVisibleChange: function(a) {}, 17997 _onLogout: function(a) { 17998 E.$('tit').show(); 17999 E.$('tita').show(); 18000 with(this._router) c.maxTracePoints = c.mtp; 18001 E.$('emapi_login_id').text(E.lang('TT_li')); 18002 E.$('emapi_login_id_user').parent("td").hide(); 18003 this._validateSelect('vit', E.$('vit').childs()[1].select(0)) 18004 } 18005}); 18006 18007function initMap(div, token, options) { 18008 new E.MC(div, token, options) 18009} 18010E.DivIcon = L.DivIcon; 18011E.MC.include({ 18012 _vp: { 18013 id: 0, 18014 aKey: '', 18015 items: {}, 18016 idItems: [], 18017 count: 2, 18018 addPoint: 0 18019 }, 18020 _action: function(a, b, c) { 18021 this['_a' + a](this._vp.items[b], c) 18022 }, 18023 _aa: function(a, b) { 18024 a.showAlert(b == "mouseover") 18025 }, 18026 _ax: function(a, b) { 18027 a.actionX() 18028 }, 18029 _app: function() { 18030 return this._initElem('cross', 'viaP', 'c' + this._vp.id++).showAction('a', 0) 18031 }, 18032 _asearch: function(a, b) {}, 18033 _adel: function(a, b) { 18034 with(this._router.c) if (a.id > -1) removeWaypoint(_pId(a.id)); 18035 else this._delElem(a) 18036 }, 18037 _ainput: function(a, b) { 18038 if (b == 0 && !a.fClick) { 18039 a.fClick = a._input.replaceClass(' i_i', ' i_a'); 18040 a._input.value("") 18041 } 18042 with(this._router.c) if (a.id > -1) { 18043 a = _wayPoints._item(_pId(a.id)); 18044 if (b == 0) { 18045 this._map.setCenterPos(a.point.lonLat) 18046 } else this._map.setCenterPos(a.point.lonLat, 15) 18047 } 18048 }, 18049 _aup: function(a, b) { 18050 b = E.$('viaP'); 18051 with(a._div) this._swapPoints(a, a._type == 'e' ? (b.childCount() > 0 ? b.lastChild().obj('ct') : this._vp.items['b']) : (index() == 0 ? this._vp.items['b'] : prevSibling().obj('ct'))) 18052 }, 18053 _adown: function(a, b) { 18054 b = E.$('viaP'); 18055 with(a._div) this._swapPoints(a._type == 'b' ? (b.childCount() > 0 ? b.firstChild().obj('ct') : this._vp.items['e']) : (index() == b.childCount() - 1 ? this._vp.items['e'] : nextSibling().obj('ct')), a) 18056 }, 18057 _swapPoints: function(a, b) { 18058 var c, d, e; 18059 with(this._router.c) { 18060 if (a.id == -1 || b.id == -1) { 18061 if (a.id == -1) c = b, b = a, a = c; 18062 if (a.id != -1) { 18063 if (a._type[0] != b._type[0]) _wayPoints.setPointType(_pId(a.id), this._rt(b._type)); 18064 b.id = a.id; 18065 a.id = -1; 18066 a.setCountry('')._input.replaceClass(' i_a', ' i_i'); 18067 delete a.fClick; 18068 this._vp.idItems[b.id] = b 18069 } 18070 e = (c = b._input).value(); 18071 c.value((d = a._input).value()); 18072 d.value(e); 18073 this._pointsChange(b, 1, _wp(_pId(b.id)).lonLat); 18074 this._pointsChange(a, 0, 0, 1) 18075 } else swapWaypoint(_pId(a.id), _pId(b.id)) 18076 } 18077 }, 18078 _rp: function(a) { 18079 return (a[0] == 'c') 18080 }, 18081 _rt: function(a) { 18082 return { 18083 'b': 0, 18084 'e': 2, 18085 'c': 1, 18086 'f': -1 18087 } [a[0]] 18088 }, 18089 _initEM: function() { 18090 with(this._vp) { 18091 aKey = this._map._map.regAction(this._action, this); 18092 this._w = E.$('RR_WP').text(E.format("{0}'beginP'></div>{0}'viaP'></div><div class='AVP' onclick=\"{2}('pp');\">{1}</div>{0}'endP'></div>", ["<div id=", E.lang('LI_AWP'), aKey])); 18093 addPoint = E.$(".AVP") 18094 } 18095 with(this._router.c) { 18096 on('removePoints', this._clearAllPoints, this); 18097 addHook('PointsChange', E.bind(this._pChange, this)); 18098 _wayPoints.setPointType = function(index, type) { 18099 if (this._inRange(index)) with(this._item(index)) { 18100 pointType = type; 18101 point.pointType = type; 18102 icon.setIcon(this._icons[type]) 18103 } 18104 } 18105 } 18106 this._initElem('from', 'beginP', 'b').showAction(['a', 'up'], 0).setDescription(1); 18107 this._initElem('to', 'endP', 'e').showAction(['a', 'down'], 0).setDescription(2); 18108 with(this._router.c) { 18109 addWaypoint = E.bind(this._addWaypoint, this); 18110 setWaypoint = E.bind(this._setWaypoint, this); 18111 _wayPoints.setDescription1 = _wayPoints.setDescription; 18112 _wayPoints.setDescription = E.bind(function(a, b, c) { 18113 this._router.c._wayPoints.setDescription1(a, b, this._countries[c]) 18114 }, this) 18115 } 18116 this._initSearch('f ') 18117 }, 18118 _updateMiddlePoints: function() { 18119 with(this._vp) addPoint.visible(count < this._router.c._maxTracePoints); 18120 this._updateIndexPoint() 18121 }, 18122 _updateIndexPoint: function() { 18123 with(this._vp) { 18124 items['b'].setDescription(1); 18125 items['e'].setDescription(count); 18126 var a = E.$('viaP').childs(), 18127 i; 18128 for (var i = 0; i < a.length; i++) a[i].obj('ct').setDescription(i + 2) 18129 } 18130 }, 18131 _clearAllPoints: function() { 18132 with(this._vp) { 18133 count = 2; 18134 E.$('viaP').clear(); 18135 this._updateIndexPoint(); 18136 idItems = []; 18137 var a = items['b'], 18138 b = items['e'], 18139 f = items['f']; 18140 a.clear(), a.id = -1, b.id = -1, b.clear(); 18141 items = { 18142 b: a, 18143 e: b, 18144 f: f 18145 } 18146 } 18147 }, 18148 _initElem: function(desc, b, id) { 18149 if (id[0] == 'c') { 18150 if (!this._checkAdd(1)) return false; 18151 this._vp.count++ 18152 } 18153 var e = this._vp.items[id] = new E.ListInput(b, this._vp.aKey, { 18154 actions: [{ 18155 name: 'a', 18156 ac: ['m', 'c'] 18157 }, { 18158 name: 'x', 18159 ac: ['c'] 18160 }], 18161 id: id, 18162 desc: desc, 18163 alert: 'LI_A', 18164 as: 1, 18165 iclass: "i_i" 18166 });
18167 e._input.value(E.lang("LI_eg")); 18168 new EMAPI.MC.SuggestList(e._input, 'csec_r', '', { 18169 onSelectElem: E.bind(this._onSelectedSuggest, this), 18170 onGetSuggest: E.bind(this._onGetSuggest, this), 18171 onSearchClick: E.bind(this._onSearchClick, this) 18172 }, e._as['search'], e); 18173 if (id[0] == 'c') this._updateMiddlePoints(); 18174 return e 18175 }, 18176 _initSearch: function(a) { 18177 var e = this._vp.items[a] = new E.ListInput('isr_f', this._vp.aKey, { 18178 actions: [{ 18179 name: 'a', 18180 ac: ['m', 'c'] 18181 }, { 18182 name: 'x', 18183 ac: ['c'] 18184 }], 18185 id: a, 18186 alert: 'LI_A', 18187 iclass: "i_i" 18188 }).showAction('a', 0); 18189 e._input.value(E.lang("LI_eg")).parent().width(200); 18190 e.actionX = E.extFun(e.actionX, E.bind(this._finderClearObjects, this)); 18191 new EMAPI.MC.SuggestList(e._input, 'csec', 'isr_fr', { 18192 onSelectElem: E.bind(this._onSelectedSuggestFinder, this), 18193 onGetSuggest: E.bind(this._onGetSuggest, this), 18194 onSearchClick: E.bind(this._onSearchClickFinder, this) 18195 }, e._as['search'], e) 18196 }, 18197 _delElem: function(a) { 18198 with(this) if (this._rp(a._type)) a._div.remove(), _vp.count--; 18199 this._updateMiddlePoints() 18200 }, 18201 _onSelectedSuggest: function(name, zip, id, e, c) { 18202 with(this) { 18203 e.Zip = zip; 18204 e.Name = name; 18205 e.setCountry(c); 18206 this._pointsChange(e, 1, _finderShowRect(id)) 18207 } 18208 }, 18209 _onSelectedSuggestFinder: function(name, zip, id, e, c) { 18210 with(this._finder.c) this._onResponseFinder.call({ 18211 c: this, 18212 e: e, 18213 a: 'isr_fr' 18214 }, { 18215 geocodeInfoArray: _items = [_items[id]], 18216 result: 0 18217 }) 18218 }, 18219 _onGetSuggest: function(v, fun, e) { 18220 var sval0 = v[0], 18221 lval1 = '', 18222 l; 18223 if ((e.Name) && (e.Name.length > 0) && (e.Zip.length > 0)) { 18224 if (((l = sval0.split(',')).length > 1) && (l[0] == e.Name)) lval1 = e.Zip 18225 } 18226 with(this._finder.c) { 18227 setCountry(v[1]); 18228 search((((sval0.length > 0) && (lval1.length > 0)) ? sval0 + ';' + lval1 : sval0) + this._searchAdditional, fun) 18229 } 18230 return false 18231 }, 18232 _onSearchClick: function(a, b, e) { 18233 this._onGetSuggest(a, E.bind(this._onResponseRouter, { 18234 c: this, 18235 a: b, 18236 e: e 18237 }), e) 18238 }, 18239 _onSearchClickFinder: function(a, b, e) { 18240 this._onGetSuggest(a, E.bind(this._onResponseFinder, { 18241 c: this, 18242 a: b, 18243 e: e 18244 }), e) 18245 }, 18246 _onResponseRouter: function(response, popup) { 18247 with(this) { 18248 var i, a = response.geocodeInfoArray; 18249 if (a.length > 0) { 18250 i = c._finderShowRect(0, popup); 18251 with(a[0]) { 18252 e._input.value(E.trim(E.addI(city, street + ' ' + streetNumber)) + (streetNumber ? '' : ' ')); 18253 e.setCountry(c._countries[areaName0]) 18254 } 18255 } 18256 c._pointsChange(e, a.length > 0, i) 18257 } 18258 }, 18259 _pointsChange: function(e, v, l, n) { 18260 var a = this._rt(e._type), 18261 b = !v && ((a != 1) || e._input.value().length > 0) && (!n); 18262 e.showAction('a', b).showAlert(b, 1).setLonLat((!b) && l, l); 18263 if (a == -1) {} else with(this._router.c) if (v) { 18264 if (l) with(l)(e.id != -1) ? setWaypoint(_pId(e.id), l, 0, e) : addWaypoint(l, a, 0, e); 18265 _wayPoints._item(_pId(e.id)).icon._popup.hideRouteFlag = 1; 18266 v = ['del']; 18267 if (a != 2) v.push('down'); 18268 if (a != 0) v.push('up'); 18269 e.showAction(v, 1) 18270 } else { 18271 if (e.id > -1) { 18272 v = e.id; 18273 e.id = -1; 18274 this._vp.idItems[v] = -1 18275 } 18276 } 18277 }, 18278 _pChange: function(action, first, second) { 18279 E.$('bar_item_route_div').click(); 18280 if (action != 'removePoints') with(this._vp) { 18281 var e = idItems[first.id], 18282 f = second ? idItems[second.id] : 0; 18283 if (action == 'removePoint') { 18284 if (!this._delElem(e)) { 18285 if (e.id != -1) e._input.value(''), e.setCountry(); 18286 this._pointsChange(e, 0) 18287 } 18288 } else { 18289 e._input.value(first.description); 18290 if (!e.fClick) e.fClick = e._input.replaceClass(' i_i', ' i_a'); 18291 e.setCountry(first.country); 18292 this._pointsChange(e, 1); 18293 if (f) f._input.value(second.description), f.setCountry(second.country), this._pointsChange(f, 1) 18294 } 18295 } 18296 }, 18297 _checkAdd: function() { 18298 with(this._router.c) with(this._vp) { 18299 if (count >= _maxTracePoints) { 18300 E.Overlay.showMessage(E.lang('RR_MXR') + _maxTracePoints); 18301 return 0 18302 } else if (this._router.activeRP == 'transport') { 18303 E.Overlay.showMessage(E.lang("LI_B")); 18304 return 0 18305 } 18306 } 18307 return 1 18308 }, 18309 _addWaypoint: function(lonLat, pointType, callback, d) { 18310 with(this._router.c) { 18311 var index, a = d; 18312 if ((pointType == 0) || (pointType == 2)) { 18313 index = _wayPoints.isPointSet(pointType); 18314 if (index > -1) { 18315 setWaypoint(index, lonLat, callback, d); 18316 return false 18317 } 18318 index = 0 18319 } 18320 if ((pointType == 1) && !d && !this._checkAdd()) return false; 18321 index = _wayPoints.getAddPointIndex(pointType); 18322 _wayPoints.addPoint(pointType, E.LLP(lonLat), a ? a._input.value() : '', a ? a.getCountry() : ''); 18323 d = !d ? (pointType == 1 ? this._app() : this._vp.items[{ 18324 0: 'b', 18325 2: 'e' 18326 } [pointType]]) : d; 18327 d.id = _wayPoints.item(index).id; 18328 this._vp.idItems[d.id] = d; 18329 if (!a) _getDesctiption(index, callback); 18330 _onPointsChange("addPoint", _wp(index)) 18331 } 18332 return true 18333 }, 18334 _setWaypoint: function(index, lonLat, callback, a) { 18335 with(this._router.c) { 18336 _wayPoints.setPoint(index, E.LLP(lonLat), a ? a._input.value() : '', a ? a.getCountry() : ''); 18337 if (!a) _getDesctiption(index, callback); 18338 _onPointsChange("setPoint", _wp(index)) 18339 } 18340 } 18341}); 18342E.MC.prototype.addHook('initialize', '_initEM'); 18343E.MC.MytoEuroDataConst = { 18344 vehicles: [] 18345};
18346(function init() { 18347 var vehicles = [ 18348 [ 18349 ['Passenger car', 0, false, 0, 0, 0, 0, 50, E.Router.Fuel.cost, 0.00694, 0, 0, 0, 0, 0, 0, 0, 0.02083, 0.003472], { 18350 use: 2047, 18351 speed: [115, 85, 70, 60, 45, 35, 10, 50, 45, 40, 30], 18352 combustion: [7.0, 7.0, 7.0, 7.0, 8.0, 8.0, 9.0, 8.0, 9.0, 10.0, 0.0] 18353 }, 18354 [ 18355 [0, 0, 0], 18356 [0, 0, 0], 18357 [0, 0, 0], 18358 [0, 0, 0], 18359 [0, 0, 0], 18360 [0, 0, 0] 18361 ] 18362 ], 18363 [ 18364 ['Pojazd (3,5t - 12t)', 1, false, 0, 0, 0, 0, 600, E.Router.Fuel.cost, 0.017361, 10.0, 0, 2.4, 2.4, 5, 0, 0, 0.02083, 0.02083], { 18365 use: 447, 18366 speed: [89, 85, 70, 60, 45, 35, 10, 40, 35, 30, 30], 18367 combustion: [20.0, 20.0, 22.0, 22.0, 25.0, 28.0, 30.0, 25.0, 25.0, 20.0, 0.0] 18368 }, 18369 [ 18370 [0.80, 0.80, 0.66], 18371 [0.80, 0.80, 0.66], 18372 [0.80, 0.80, 0.66], 18373 [0.70, 0.70, 0.58], 18374 [0.58, 0.58, 0.47], 18375 [0.41, 0.41, 0.34], 18376 [0.41, 0.41, 0.34] 18377 ] 18378 ], 18379 [ 18380 ['Pojazd (>12t)', 1, false, 0, 0, 0, 0, 600, E.Router.Fuel.cost, 0.017361, 20.0, 0, 3.4, 2.5, 10, 0, 0, 0.02083, 0.02083], { 18381 use: 447, 18382 speed: [89, 85, 70, 60, 45, 35, 10, 40, 35, 30, 30], 18383 combustion: [22.0, 22.0, 24.0, 24.0, 26.0, 28.0, 30.0, 26.0, 26.0, 28.0, 0.0] 18384 }, 18385 [ 18386 [1.07, 1.07, 0.83], 18387 [1.07, 1.07, 0.83], 18388 [1.07, 1.07, 0.83], 18389 [0.93, 0.93, 0.75], 18390 [0.75, 0.75, 0.60], 18391 [0.56, 0.56, 0.42], 18392 [0.56, 0.56, 0.42] 18393 ] 18394 ], 18395 [ 18396 ['Autobus', 8, false, 0, 0, 0, 0, 600, E.Router.Fuel.cost, 0.017361, 8, 0, 3.0, 2.5, 4, 0, 0, 0.02083, 0.02083], { 18397 use: 447, 18398 speed: [100, 85, 70, 60, 45, 35, 10, 40, 35, 30, 30], 18399 combustion: [22.0, 22.0, 24.0, 24.0, 25.0, 28.0, 30.0, 26.0, 26.0, 28.0, 0.0] 18400 }, 18401 [ 18402 [0.80, 0.80, 0.66], 18403 [0.80, 0.80, 0.66], 18404 [0.80, 0.80, 0.66], 18405 [0.70, 0.70, 0.58], 18406 [0.58, 0.58, 0.47], 18407 [0.41, 0.41, 0.34], 18408 [0.41, 0.41, 0.34] 18409 ] 18410 ], 18411 ], 18412 i, j, k, a = ['Highway', 'Speedway', 'NationalRoad', 'RegionalRoad', 'LocalRoad', 'OtherRoad', 'UnpavedRoad', 'VehicularStreet', 'MainStreet', 'OtherStreet', 'Ferry'], 18413 b, c, d = ["name", "vehicleType", "ignoreFuel", "fixedCost", "costPerKilometer", "costPerHour", "tollRoadPerKilometer", "tankCapacity", "fuelCost", "refuelTime", "vehicleWeight", "vehicleLength", "vehicleHeight", "vehicleWidth", "vehicleWeightPerAxle", "vehicleCapacity", "vehicleLoadCapacity", "shippingTime", "borderPassTime"], 18414 e = [ 18415 ['HighwayInBUA', 'Highway'], 18416 ['SpeedwayInBUA', 'Speedway'], 18417 ['NationalRoadInBUA', 'NationalRoad'], 18418 ['RegionalRoadInBUA', 'RegionalRoad'] 18419 ], 18420 f = ['Highway', 'Speedway', 'NationalRoad'], 18421 g, h; 18422 for (i = 0; i < vehicles.length; i++) { 18423 b = vehicles[i]; 18424 for (j = 0, c = { 18425 id: i, 18426 routeOptions: [], 18427 EuroToll: [] 18428 }; j < d.length; j++) c[d[j]] = b[0][j];
18429 for (j = 0; j < a.length; j++) c.routeOptions.push({ 18430 use: (b[1].use >> j) % 2 == 1, 18431 id: j, 18432 roadType: a[j], 18433 speed: b[1].speed[j], 18434 combustion: b[1].combustion[j] 18435 }); 18436 for (j = 0; j < b[2].length; j++) { 18437 c.EuroToll.push(g = { 18438 id: j, 18439 name: 'Euro ' + j, 18440 routeOptions: [] 18441 }); 18442 for (k = 0; k < f.length; k++) g.routeOptions.push({ 18443 roadType: f[k], 18444 toll: b[2][j][k] 18445 }) 18446 } 18447 for (j = 0; j < e.length; j++) b = c.routeOptions[a.indexOf(e[j][1])], c.routeOptions.push({ 18448 use: b.use, 18449 id: a.length + j, 18450 roadType: e[j][0], 18451 speed: b.speed, 18452 combustion: b.combustion, 18453 toll: b.toll 18454 }); 18455 E.MC.MytoEuroDataConst.vehicles.push(c) 18456 } 18457})(); 18458E.MC.MytoEuroController = L.Class.extend({ 18459 _vehicles: null, 18460 initialize: function() { 18461 this._vehicles = new E.ArrayObjects(E.Router.VehicleParams); 18462 this._vehicles.initializeItems(E.MC.MytoEuroDataConst.vehicles) 18463 }, 18464 getVehicles: function() { 18465 return this._vehicles.items 18466 }, 18467 getEuroEmissionOptions: function() { 18468 var result = [], 18469 euro, i; 18470 if (this._vehicles.items.length > 0) { 18471 euro = this._vehicles.items[0].EuroToll; 18472 for (i = 0; i < euro.length; i++) result.push({ 18473 'name': euro[i].name, 18474 'id': euro[i].id 18475 }) 18476 } 18477 return euro 18478 }, 18479 getRoadsParam: function(v, e) { 18480 var r = null, 18481 i, j, ro, v1 = {}; 18482 with(this) { 18483 if ((v = findData(v, e)) == null) return r; 18484 var r = v.v.routeOptions.toArray(); 18485 with(v.e) for (j = 0; j < r.length; j++) { 18486 r[j].toll = 0; 18487 for (i = 0; i < routeOptions.length; i++) 18488 if (r[j].roadType == routeOptions[i].roadType) { 18489 r[j].toll = routeOptions[i].toll; 18490 break 18491 } 18492 } 18493 } 18494 L.Util.extend(v1, v.v); 18495 v1.routeOptions.fromArray(r); 18496 delete v1['EuroToll']; 18497 return v1 18498 }, 18499 setRoadsParam: function(v, e, p) { 18500 var i, j, f, r = p.routeOptions.toArray(); 18501 v = this.findData(v, e); 18502 e = v.e; 18503 v = v.v; 18504 for (j = 0; j < r.length; j++) { 18505 f = 0; 18506 for (i = 0; i < e.routeOptions.length; i++) 18507 if (r[j].roadType == e.routeOptions[i].roadType) { 18508 e.routeOptions[i].toll = r[j].toll; 18509 f = 1; 18510 break 18511 } if (!f) e.routeOptions.push({ 18512 'roadType': r[j].roadType, 18513 'toll': r[j].toll 18514 }) 18515 } 18516 delete p['routeOptions']; 18517 L.Util.extend(v, p); 18518 v.routeOptions.fromArray(r) 18519 }, 18520 findData: function(v, e) { 18521 var i, j; 18522 with(this) for (i = 0; i < _vehicles.count(); i++) 18523 if (_vehicles.item(i).id == v) { 18524 with(v = _vehicles.item(i)) for (j = 0; j < EuroToll.length; j++) 18525 if (EuroToll[j].id == e) return { 18526 e: EuroToll[j], 18527 v: v 18528 }; 18529 if (e != null) break 18530 } 18531 return { 18532 v: v 18533 } 18534 } 18535}); 18536E.MC.ObjectsSearcher = L.Class.extend({ 18537 _gueryId: 0, 18538 initialize: function(input, select, div, map) { 18539 with(map._map) { 18540 this._key = regAction(this._action, this); 18541 this._map = map; 18542 var e = new E.ListInput("content_isfp", this._key, { 18543 actions: [{ 18544 name: 'a', 18545 ac: ['m', 'c'] 18546 }, { 18547 name: 'x', 18548 ac: ['c'] 18549 }], 18550 iclass: "countryAddresSet i_i", 18551 id: 0 18552 }).showAction('a', 0); 18553 this._input = E.$(e._input).value(E.lang("OS_eg")); 18554 this._input.parent().width(200); 18555 this._select = select; 18556 this._res = E.$(div); 18557 on('onCategoriesChange', this._categories, this); 18558 this._actKey = regAction(this._runAction, this); 18559 this._layer = new E.ClusterLayer("POI", {}); 18560 this._layer.addTo(map._map); 18561 this._player = _poi._layer; 18562 this._poi = _poi; 18563 this._iconPoint = { 18564 icon: L.icon({ 18565 className: 'ETR_IconStop', 18566 iconUrl: E.blank 18567 }) 18568 }; 18569 this._overlay = new E.Overlay.Form();
18570 this._input.key(function(a) { 18571 a = a || window.event; 18572 if (a.keyCode == 13) this.searchRequest() 18573 }, this); 18574 this._clear = E.$('inputImageSearchId_POI_c').click(this._clearItems, this); 18575 on('objPopup', this._onShowPopup, this) 18576 } 18577 }, 18578 _action: function(a, b, c) { 18579 if ((!this._fClick) && (a == "input") && (c == 0)) { 18580 this._fClick = 1; 18581 this._input.value("").replaceClass(' i_i', ' i_a') 18582 } else if (a == "search") { 18583 this.searchRequest() 18584 } else if (a == "x") { 18585 this._input.value('').focus(); 18586 this._clearItems() 18587 } 18588 }, 18589 _onShowPopup: function(a) { 18590 with(a.obj) if ((a.obj._search) && (_search.type == 0)) { 18591 for (var i = 0; i < this._items.length; i++) this._items[i].Class("find_result_item" + (i == _search.id ? "_selected" : '')); 18592 var id = _search.id, 18593 e, p = (e = this._items[id]).parent(), 18594 t = e.top() - p.sTop(); 18595 if (t < 0) p.sTop(p.sTop() + t); 18596 else if ((t += e.height()) > p.height()) p.sTop(p.sTop() + t - p.height()) 18597 } 18598 }, 18599 _categories: function() { 18600 with(this) { 18601 var i, res = [], 18602 o = [], 18603 e = _poi.getPOICategory().sort(function(a, b) { 18604 return (a.name == b.name) ? 0 : (a.name > b.name ? 1 : -1) 18605 }); 18606 for (i = 0; i < e.length; i++) o.push(E.$(document.createElement("option")).att('id', e[i].id).att('type', 'p').text(e[i].name).value(i)); 18607 _select.text('').append(o) 18608 } 18609 }, 18610 searchRequest: function() { 18611 with(this) { 18612 var dist = parseInt(_map.getCenterPos().getLatLng().distanceTo(_map.getBounds().getTopLeft().getLatLng())), 18613 e = _getCategoryName(); 18614 this._gueryId++; 18615 if (e.length > 0) { 18616 var filter = this.filterRequest(_input.value(), e.join(';')); 18617 with(_map.getCenterPos()) _map._map.searchPOI({ 18618 categoryNames: filter.cat, 18619 searchText: filter.value, 18620 lon: lon, 18621 lat: lat, 18622 objectCount: 20, 18623 queryRadius: dist, 18624 objectIDs: '' 18625 }, _onRequestPOI, this); 18626 this._overlay.showWindow(E.newElem$('div', 'WaiterContent')) 18627 } 18628 } 18629 }, 18630 _clearItems: function() { 18631 this._clear.hide(); 18632 this._layer.clearLayers(); 18633 this._res.text('') 18634 }, 18635 _onRequestPOI: function(data, obj) { 18636 this._overlay.hide(); 18637 this._objects = []; 18638 var i, j, ires = '', 18639 res = '', 18640 obj, item, a = ['category', 'name', 'city', 'street', 'zip'], 18641 hh, bound = new L.LatLngBounds(); 18642 this._layer.clearObjects(); 18643 this._objects = []; 18644 with(data) if (searchObjectArray.length > 0) { 18645 for (i = 0; i < searchObjectArray.length; i++) { 18646 for (j = 0, ires = ''; j < a.length; j++) ires = E.addI(ires, searchObjectArray[i][a[j]]); 18647 with(searchObjectArray[i]) { 18648 var cat = this._getSubCategoryById(subcategoryId); 18649 res += E.format("<div class='find_result_item' onclick=\"{0}('{1}',0);\" ondblclick=\"{0}('{1}',1);\"><table><tr><td><div class='marker_img_mini'>{3}</div></td><td>{2}</td></tr></table></div>", [this._actKey, i, ires, String.fromCharCode(i + 65)]); 18650 hh = E.format("<div class='marker_img_mini' style='position:absolute;left:5px;top:5px;'>{3}</div><div style='margin-left:15px'><img src='{0}' style='border:0'><b> {1}</b>{2}</div>", [cat.iconUrl, cat.name, this._player._getConfigAction("parseObjectInfo", cat.main_cat, [{ 18651 nameLabel: '' 18652 }, { 18653 searchObjectArray: [searchObjectArray[i]] 18654 }]), String.fromCharCode(i + 65)]); 18655 hh = new E.Marker([lat, lon], { 18656 icon: new L.DivIcon({ 18657 html: String.fromCharCode(i + 65), 18658 iconSize: null, 18659 className: 'marker_img', 18660 iconAnchor: [12, 42] 18661 }), 18662 zIndex: searchObjectArray.length - i + 300 18663 }).bindPopup(hh, { 18664 offset: [0, -30] 18665 }); 18666 hh._search = { 18667 id: i, 18668 type: 0 18669 }; 18670 hh._mainObj = hh; 18671 this._objects.push(hh); 18672 hh.setZIndexOffset(400 + searchObjectArray.length - i); 18673 bound.extend([lat, lon]) 18674 } 18675 } 18676 this._map.setBounds(bound); 18677 this._layer.addLayers(this._objects); 18678 this._clear.show() 18679 } else res = E.lang("OS_NR"); 18680 this._res.height(i > 10 ? 180 : "").text(res); 18681 this._items = this._res.childs() 18682 }, 18683 _runAction: function(a, b) { 18684 var c = this._objects[a];
18685 this._map.setView(c.getLatLng()); 18686 this._layer.zoomToShowLayer(c, function() { 18687 c.openPopup() 18688 }); 18689 if (b == 10) { 18690 if (this._objects[a].__parent) this._objects[a].__parent.spiderfy(); 18691 var c = this._objects[a]; 18692 setTimeout(function() { 18693 c.openPopup() 18694 }, 100) 18695 } 18696 }, 18697 _getSubCategoryById: function(id) { 18698 with(this) { 18699 var cat = _player.category(id), 18700 i; 18701 with(_player._layer(cat.main_cat)) return { 18702 id: cat.id, 18703 main_cat: cat.main_cat, 18704 zoomMin: minZoom, 18705 zoomMax: maxZoom, 18706 iconUrl: cat.iconUrl, 18707 name: cat.name 18708 }; 18709 return -1 18710 } 18711 }, 18712 _getCategoryName: function() { 18713 with(this) { 18714 var res = [], 18715 i, j, e = _poi.getPOICategory(), 18716 id; 18717 if (E.$('categorySelect').visible()) id = _select.selected('id'); 18718 for (j = 0; j < e.length; j++) 18719 if ((!id) || (e[j].id == id)) 18720 for (var k = 0; k < e[j].subCat.length; k++) res.push(e[j].subCat[k].id); 18721 return res 18722 } 18723 }, 18724 filterRequest: function(request, category) { 18725 var item = [ 18726 [ 18727 [320], "Szpital / Klinika;Szpital;Szpitale;Klinika;Kliniki" 18728 ], 18729 [ 18730 [332], "Apteka;Apteki" 18731 ], 18732 [ 18733 [401], "Bank;Banki" 18734 ], 18735 [ 18736 [402], "Bankomat;Bankomaty" 18737 ], 18738 [ 18739 [403], "Basen;Basen;Baseny" 18740 ], 18741 [ 18742 [308, 329], "Centrum handlowe;Galeria handlowa;Galerie handlowe" 18743 ], 18744 [ 18745 [339], "dentysta;denty\u015bci;stomatolog;stomatolodzy" 18746 ], 18747 [ 18748 [404, 405], "Hotel / Motel;Hotel;Hotele" 18749 ], 18750 [ 18751 [346], "Kantor;Kantory" 18752 ], 18753 [ 18754 [323], "Kino;Kina" 18755 ], 18756 [ 18757 [363], "lekarz;lekarze" 18758 ], 18759 [ 18760 [314], "Lotnisko;Lotniska" 18761 ], 18762 [ 18763 [307], "Muzeum;Muzea" 18764 ], 18765 [ 18766 [315], "Opera;Opery" 18767 ], 18768 [ 18769 [406], "Posterunek policji;Policja;Policje;Posterunek;Posterunki" 18770 ], 18771 [ 18772 [212], "Przystanek autobusowy;PKS" 18773 ], 18774 [ 18775 [335, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394], "Restauracja;Restauracje" 18776 ], 18777 [ 18778 [331, 426, 333], "Stacja;Stacje;Stacja benzynowa;Stacje benzynowe;stacja paliw;stacje paliw" 18779 ], 18780 [ 18781 [321], "Teatr;Teatry" 18782 ], 18783 [ 18784 [399], "Urz\u0105d pocztowy;Poczta" 18785 ] 18786 ], 18787 val = request.split(',', 1), 18788 i, j, e; 18789 if (val.length > 0) val = E.trim(val[0].toLowerCase()); 18790 for (i = 0; i < item.length; i++) { 18791 e = item[i][1].split(';'); 18792 for (j = 0; j < e.length; j++) 18793 if (val == e[j].toLowerCase()) { 18794 val = request.split(',', 1); 18795 request = request.substring(val[0].length); 18796 return { 18797 cat: item[i][0].join(';'), 18798 value: request 18799 } 18800 } 18801 } 18802 return { 18803 cat: category, 18804 value: request 18805 } 18806 } 18807}); 18808L.Popup.include({ 18809 _driveFunc: '', 18810 hideRouteFlag: false, 18811 _adjustPan: function() { 18812 if (!this.options.autoPan) { 18813 return 18814 } 18815 var map = this._map, 18816 containerHeight = this._container.offsetHeight, 18817 containerWidth = this._containerWidth, 18818 layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom); 18819 if (L.Browser.any3d) { 18820 layerPos._add(L.DomUtil.getPosition(this._container)) 18821 } 18822 var containerPos = map.layerPointToContainerPoint(layerPos), 18823 padding = this.options.autoPanPadding, 18824 size = map.getSize(), 18825 dx = 0, 18826 dy = 0, 18827 of = map.offsets; 18828 if (containerPos.x < of [0]) { 18829 dx = containerPos.x - padding.x - of [0] 18830 } 18831 if (containerPos.x + containerWidth > size.x) { 18832 dx = containerPos.x + containerWidth - size.x + padding.x 18833 } 18834 if (containerPos.y < of [1]) { 18835 dy = containerPos.y - padding.y - of [1] 18836 } 18837 if (containerPos.y + containerHeight > size.y) { 18838 dy = containerPos.y + containerHeight - size.y + padding.y 18839 } 18840 if (dx || dy) { 18841 map.panBy(new L.Point(dx, dy)) 18842 } 18843 }, 18844 _updateContent: function() { 18845 with(this) { 18846 if (!_content) { 18847 return 18848 } 18849 if (E.type(_content) === 's') E.$(_contentNode).text(_content + ((!hideRouteFlag) ? E.format(_driveFunc, [_latlng.lat, _latlng.lng]) : '')); 18850 else E.$(_contentNode).clear().append(this._content); 18851 this.fire('contentupdate'); 18852 this._map._activePopup = this 18853 } 18854 } 18855}); 18856E.MC.SuggestList = L.Class.extend({
18857 _input: 0, 18858 _inputCountry: 0, 18859 _div: 0, 18860 _content: 0, 18861 _selected: 0, 18862 _delayTime: 300, 18863 _delayTimer: 0, 18864 _block: 0, 18865 _lastSearch: 0, 18866 _inputResponse: '', 18867 onGetSuggest: function(val, fun) {}, 18868 onSelectElem: function(item, zip, index) {}, 18869 osSearchClikc: function() {}, 18870 _visible: 0, 18871 _id: 0, 18872 _onSuggestResponseBind: 0, 18873 _changed: 0, 18874 initialize: function(inputDivId, inputCountry, inputResponse, options, searchClick, id) { 18875 with(this) { 18876 _input = E.$(inputDivId); 18877 _id = id; 18878 _inputCountry = E.$(inputCountry); 18879 _lastSearch = []; 18880 L.Util.extend(this, options); 18881 _input.focusP(hideSuggestList, this).blurP(function() { 18882 E.timeout(500, hideSuggestList, this) 18883 }, this).keyDownP(_onKeyDown, this).key(_onKeyPress, this).blur(this._onBlur, this).parent().append(_div = E.newElem$('div', 'suggest_list').hide().text("<div class='suggest_list_top'></div><div id='suggest_list_content' class='suggest_list_content'></div><div class='suggest_list_bottom'></div>")); 18884 _content = _div.getElem('suggest_list_content'); 18885 _onSuggestResponseBind = E.bind(_onSuggestResponse, this); 18886 _inputResponse = inputResponse; 18887 E.$(searchClick).click(_searchClick, this) 18888 } 18889 }, 18890 addLastSearch: function(searchElem) { 18891 this._lastSearch.unshift(searchElem); 18892 if (this.l_astSearch.length > 5) this._lastSearch.pop() 18893 }, 18894 _onKeyPress: function(evt) { 18895 return true 18896 }, 18897 _getCountry: function() { 18898 with(this) return _inputCountry.parent('div').visible() ? _inputCountry.selected() : 'PL' 18899 }, 18900 _getValue: function() { 18901 with(this) return [_input.value(), _getCountry()] 18902 }, 18903 _searchClick: function() { 18904 with(this) { 18905 hideSuggestList(); 18906 var a = this._getValue(); 18907 if (a[0].length > 2) onSearchClick(a, _inputResponse, _id) 18908 } 18909 }, 18910 _onBlur: function() { 18911 var self = this; 18912 setTimeout(function() { 18913 with(self) if (_changed) { 18914 _changed = 0; 18915 _searchClick() 18916 } 18917 }, 200) 18918 }, 18919 _onChange: function() { 18920 with(this) if (!_selectedItem) _searchClick() 18921 }, 18922 _onKeyDown: function(evt) { 18923 with(this) { 18924 _changed = !evt.ctrlKey && !evt.metaKey && !evt.altKey && evt.which != 8 ? 1 : _changed; 18925 evt = evt || window.event; 18926 if (_delayTimer) clearTimeout(_delayTimer); 18927 if ((evt.keyCode == 27) || (evt.keyCode == 188)) { 18928 hideSuggestList(); 18929 _block = true 18930 } else if (evt.keyCode == 39) { 18931 var val = _selectedItem.att("action"); 18932 _input.value(val + (val.indexOf(',') == -1 ? ', ' : ' ')); 18933 _id.Zip = _selectedItem.att("zip"); 18934 _id.Name = _input.value(); 18935 hideSuggestList(); 18936 _changed = 1 18937 } else if ((evt.keyCode == 13)) { 18938 _block = true; 18939 if (_selectedItem) { 18940 var val = _selectedItem.att("action"); 18941 _input.value(val + (val.indexOf(',') == -1 ? ', ' : ' ')); 18942 var zip = _selectedItem.att("zip"); 18943 onSelectElem(_selectedItem.att("action"), E.type(zip) == 'u' ? '' : zip, _selectedItem.att('id'), _id, _getCountry()); 18944 _changed = 0; 18945 hideSuggestList(); 18946 return false 18947 } else _onBlur(); 18948 return false 18949 } else if (((evt.keyCode == 40) || (evt.keyCode == 38)) && (this._visible == true)) { 18950 if (evt.keyCode == 38) { 18951 if (!_selectedItem) _selectedItem = _content.lastChild(); 18952 else { 18953 _selectedItem.Class('result_item'); 18954 if (_selectedItem.prevSibling().elem()) { 18955 if (_selectedItem.prevSibling().att('actionType') == 3) _selectedItem = _selectedItem.prevSibling(); 18956 _selectedItem = _selectedItem.prevSibling() 18957 } else _selectedItem = _content.lastChild() 18958 } 18959 this._selectedItem.Class('result_item_selected') 18960 } else { 18961 if (!_selectedItem) _selectedItem = _content.firstChild(); 18962 else { 18963 _selectedItem.Class('result_item'); 18964 if (this._selectedItem.nextSibling().elem()) { 18965 if (_selectedItem.nextSibling().att('actionType') == 3) _selectedItem = _selectedItem.nextSibling(); 18966 _selectedItem = _selectedItem.nextSibling() 18967 } else _selectedItem = _content.firstChild() 18968 } 18969 _selectedItem.Class('result_item_selected') 18970 } 18971 return false 18972 } else if ((evt.charCode == 32) || (evt.keyCode >= 48) || (evt.keyCode == 40) || (evt.keyCode == 8)) { 18973 _delayTimer = E.timeout(_delayTime, _onDelayTime, this); 18974 _block = false 18975 } 18976 } 18977 return true 18978 }, 18979 showSuggestList: function(a) { 18980 with(this) { 18981 var p = E.pos(_input.elem(), 1); 18982 _div.pos(p.left, p.top + _input.height()).show(); 18983 _content.clear().append(a); 18984 _visible = true 18985 } 18986 }, 18987 hideSuggestList: function() { 18988 this._selectedItem = null; 18989 this._div.hide(); 18990 this._visible = false 18991 }, 18992 _onDelayTime: function() { 18993 var a = this._getValue(); 18994 if (a[0].length > 2) this.onGetSuggest(a, this._onSuggestResponseBind, this._id); 18995 else this.hideSuggestList() 18996 }, 18997 _onSuggestResponse: function(response) { 18998 if (this._block) return false; 18999 19000 function ai(res, val) { 19001 return res + (val && (val.length > 0) && (res.length > 0) ? ', ' : '') + val 19002 } 19003 var ir = "", 19004 res = [], 19005 item, ir_1 = "", 19006 div, h, i;
19007 if (response.result == 0) { 19008 if (response.geocodeInfoArray.length > 10) response.geocodeInfoArray = response.geocodeInfoArray.slice(0, 10); 19009 for (i = 0; i < response.geocodeInfoArray.length; i++) { 19010 item = response.geocodeInfoArray[i]; 19011 ir_1 = ai(ai('', item['city']), item['street']); 19012 ir = ai(ai(ai(ai(ai(ai("", item['city']), item['zip']), item['street'] + ((item['streetNumber'] != undefined && item['streetNumber'].length > 0) ? (' ' + item['streetNumber']) : '')), item.city != item.areaName0 ? item['areaName0'] : ''), item.city != item.areaName1 ? item['areaName1'] : ''), item.city != item.areaName2 ? item['areaName2'] : ''); 19013 res.push(E.newElem$('div', 'result_item').att('id', i).att('action', ir_1).att('actionType', 1).att('area', item['areaName0']).att('zip', item['zip']).text(ir).clickP(this._suggestitemClick, this)) 19014 } 19015 if (this._lastSearch.length > 0) { 19016 res.push(E.$('div', 'result_item').att('actionType', 3).text(E.lang('TLastSearch'))); 19017 for (var j = 0; j < this._lastSearch.length; j++) res.push(E.$('div', 'result_item').att('id', -1).att('action', ir = this._lastSearch[j]).att('actionType', 2).att('area', '').att('zip', "").text(ir).clickP(this._suggestitemClick, this)) 19018 } 19019 if (res.length > 0) this.showSuggestList(res) 19020 } else this.hideSuggestList() 19021 }, 19022 _suggestitemClick: function(e, a) { 19023 with(this) { 19024 _changed = 0; 19025 _input.value(e = ((e = (a = E.$(a)).att("action")) + (e.indexOf(',') == -1 ? ',' : ' '))); 19026 onSelectElem(e, E.type(a.att("zip")) == 'u' ? '' : a.att("zip"), a.att("id"), _id, _getCountry()); 19027 hideSuggestList() 19028 } 19029 } 19030}); 19031E.MC.SwitchLayer = L.Control.extend({ 19032 options: { 19033 position: 'topright' 19034 }, 19035 _layersIndex: {}, 19036 _layersId: {}, 19037 _action: '', 19038 _items: [], 19039 _id: 10, 19040 onAdd: function(map) { 19041 this._items = [{ 19042 id: 0, 19043 name: E.lang('LP_SLM'), 19044 ch: 'r', 19045 duc: 1, 19046 caption: 1, 19047 layers: [] 19048 }, { 19049 id: 1, 19050 name: E.lang('LP_SLL'), 19051 ch: 'r', 19052 layers: [{ 19053 id: 4, 19054 name: "Traffic", 19055 ch: 'c', 19056 visible: 0, 19057 layers: [] 19058 }, { 19059 id: 5, 19060 name: E.lang('LP_SLMT'), 19061 ch: 'c', 19062 visible: 0, 19063 layers: [] 19064 }] 19065 }, { 19066 id: 2, 19067 name: "POI", 19068 ch: 'c', 19069 layers: [] 19070 }, { 19071 id: 3, 19072 name: E.lang('LP_SLO'), 19073 ch: 'c', 19074 layers: [] 19075 }]; 19076 this._initIndex(this._items); 19077 this._map = map.on("onCategoriesChange", this._redrawItems, this); 19078 map.on("MapInitialized", this._initMap, this); 19079 this._className = 'emapi-control-switcher'; 19080 this._cont = E.newElem$('div', this._className).block(['mousedown']).click(E.block); 19081 return this._cont.elem() 19082 }, 19083 _initMap: function() { 19084 this._layer = this._map._poi._layer; 19085 this._layer.on('onVisibleChange', this._onVisibleChange, this); 19086 this._action = this._map.regAction(this._clickAction, this); 19087 this._redrawItems() 19088 }, 19089 _initIndex: function(a, p) { 19090 for (var i = 0, c; i < a.length; i++) { 19091 this._layersIndex[(c = a[i]).id] = c; 19092 c.p = p; 19093 if (c.layers) this._initIndex(c.layers, c) 19094 } 19095 }, 19096 _redrawItems: function() { 19097 this._cont.text(this.initItems()) 19098 }, 19099 initItems: function(a) { 19100 this.fillItems(); 19101 return E.format('<ul id="switchLayer2" class="nav">{0}</ul>', [this.initLayers(this._items)]) 19102 }, 19103 initLayers: function(a, main, type) { 19104 var b = '', 19105 i, c; 19106 for (i = 0; i < a.length; i++) 19107 if (!(c = a[i]).layers || (c = a[i]).layers.length > 0) b += E.format("<li class='{0}{6}' {7}><a id='sla_{5}' href='#' onclick='{4}({5})'>{1}{2}</a>{3}</li>", [c.layers ? 'dropdown' : '', c.name, main ? E.format("<span class='{0}_{1}' id='sl_{2}'></span>", [type == 'c' ? 'ch' : 'rd', c.visible ? "on" : "off", c.id]) : "", c.layers ? '<ul style="' + (c.off ? 'display:none' : '') + '">' + this.initLayers(c.layers, 1, c.ch) + '</ul>' : '', this._action, c.id, c.off ? "" : '', c.off ? 'style="display:none"' : '']); 19108 return b 19109 }, 19110 fillItems: function() { 19111 with(this._map._poi) var layers = getPOICategory().concat(getUserCategory(), getCustomCategory()), 19112 i, items = [], 19113 nid, index; 19114 for (i = 0; i < layers.length; i++) { 19115 with(this._layer) with(layers[i]) { 19116 if (!this._layersId[id]) { 19117 nid = this._id++; 19118 this._layersIndex[index = _getConfigAction("getCategoryPositionIndex", id, id, 3)].layers.push(this._layersIndex[nid] = this._layersId[id] = { 19119 name: name.replace("Traffic - ", ""), 19120 layerid: id, 19121 id: nid, 19122 priority: _getConfigAction("getPriorityValue", id, id, ""), 19123 visible: visible, 19124 p: this._layersIndex[index] 19125 }) 19126 } 19127 } 19128 } 19129 for (var i in this._layersIndex) 19130 if (this._layersIndex[i].layers) this._layersIndex[i].layers.sort(function(a, b) { 19131 if (b.priority == a.priority) return (a.name > b.name); 19132 else return b.priority - a.priority 19133 }) 19134 }, 19135 _setLayerVisible: function(a, visible) { 19136 var l = this._layersIndex[a], 19137 layers = l.layers ? l.layers : [l], 19138 b; 19139 if (l.ch !== 'r') { 19140 for (var i = 0; i < layers.length; i++) 19141 if (!layers[i].off) this._layer.setCetegoryVisible(layers[i].layerid, visible) 19142 } 19143 }, 19144 _clickAction: function(a) { 19145 var l = this._layersIndex[a]; 19146 if (l.layerid == 'H') { 19147 var bounds = this._map.getBounds(), 19148 b2 = L.latLngBounds([49, 14], [55, 24.5]); 19149 if (!(b2.intersects(bounds) || b2.contains(bounds) || bounds.contains(b2))) { 19150 E.Overlay.showMessage("Dla obecnego widoku nie ma dostÄpnych zdjÄÄ satelitarnych"); 19151 return false 19152 } 19153 } 19154 if (!(l.p && l.p.duc && l.visible)) this._setLayerVisible(l.id, !l.visible); 19155 E.block(a) 19156 }, 19157 _onVisibleChange: function(a) { 19158 var l = this._layersId[a.layer.id], 19159 b = E.$$("sl_" + l.id), 19160 layers = l.layers ? l.layers : [l], 19161 a; 19162 if (b) b.replaceClass(!(l.visible = a.layer.visible) ? 'on' : 'off', l.visible ? 'on' : 'off'); 19163 b = l; 19164 if (l.visible) 19165 while (b = (a = b).p) 19166 if (b.ch == 'r') { 19167 for (var i = 0; i < b.layers.length; i++) { 19168 if (b.layers[i].id != a.id) this._setLayerVisible(b.layers[i].id, false) 19169 } 19170 } if (l.p && l.p.caption && l.visible) { 19171 E.$$("sla_" + l.p.id).text(l.p.name = l.name) 19172 } 19173 if (l.layerid == 'H') { 19174 E.$$("sla_11").parent().visible(!l.visible); 19175 if (l.visible) { 19176 this._layer.setCetegoryVisible('P', false) 19177 } 19178 this._layersIndex[11].off = l.visible 19179 } 19180 if (l = l.p) { 19181 l.visible = false; 19182 for (var i = 0, a = l.layers, vis = false; i < a.length; i++) { 19183 l.visible |= a[i].visible 19184 } 19185 if (b = E.$$("sl_" + l.id)) b.replaceClass(!l.visible ? 'on' : 'off', l.visible ? 'on' : 'off') 19186 } 19187 } 19188}); 19189E.Map.addInitHook(function() { 19190 new E.MC.SwitchLayer().addTo(this) 19191}); 19192E.MC.TruckSettingsEditor = L.Class.extend({ 19193 __params: null, 19194 _items: [], 19195 _roadTypes: {}, 19196 _onDoneSave: null, 19197 initialize: function(onDoneSave) { 19198 this._onDoneSave = onDoneSave; 19199 this._items = [] 19200 }, 19201 showEditor: function(params) { 19202 this._params = params;
19203 this._overlay = new E.Overlay.Form(); 19204 this._overlay.showWindow(this.renderWindow()); 19205 E.$("tr_re_close_window").click(this.hide, this); 19206 E.$("te_buddon_ok").click(this._closeSave, this) 19207 }, 19208 hide: function() { 19209 this._overlay.hide() 19210 }, 19211 renderWindow: function(overlayForm) { 19212 var res, r1 = res = '', 19213 a, i, cn = 'TruckSettingsEditor', 19214 o, j, it; 19215 this._items.length = 0; 19216 var div = E.newElem$("div", cn); 19217 div.onClick = E.bind(this.onClose, this); 19218 a = ["vehicleWeight", "vehicleWeightPerAxle", "vehicleHeight", "vehicleWidth"]; 19219 for (i = 0; i < a.length; i++) { 19220 res += E.format('<tr><td>{0}</td><td><input value="{1}" id="te_{2}"></td></tr>', [E.lang("TE_T" + a[i]), this._params[a[i]], a[i]]); 19221 this._items.push({ 19222 name: a[i], 19223 value: 'te_' + a[i], 19224 type: 1 19225 }) 19226 } 19227 res = E.format("<div class='close_window' id='tr_re_close_window'></div><table class='Vehicle'>{1}</table>", [cn, res]); 19228 a = ["roadType", "use", "speed", "combustion", "toll"]; 19229 for (i = 0; i < a.length; i++) r1 += '<td>' + E.lang("TE_T" + a[i]) + '</td>'; 19230 res += '<table class="Roads"><tr>' + r1 + ''; 19231 for (i = 0; i < this._params.routeOptions.count(); i++) { 19232 it = this._params.routeOptions.item(i); 19233 this._roadTypes[it.roadType] = i; 19234 o = 'te_' + i + '_' + a[i] + '_'; 19235 this._items.push({ 19236 type: 2, 19237 id: i, 19238 e: o, 19239 inBUA: it.roadType.indexOf('InBUA') > -1 19240 }); 19241 if (it.roadType.indexOf('InBUA') > -1) continue; 19242 for (j = 0; j < a.length; j++) { 19243 if (j == 0) res += '</tr><tr><td>' + E.lang("RT_" + it[a[j]]) + '</td>'; 19244 else if (j == 1) res += E.format('<td><input {0} type="checkbox" id="{1}1"></td>', [it[a[j]] ? 'checked="checked"' : '', o]); 19245 else if ((j == 2) || (j == 3) || (j == 4)) res += E.format('<td><input value="{0}" id="{1}{2}"></td>', [it[a[j]], o, j]) 19246 } 19247 } 19248 return div.text(res + "</tr></table><div class='button_OK' id='te_buddon_ok'></div>") 19249 }, 19250 _closeSave: function() { 19251 var it = this._items, 19252 p = this._params, 19253 i, a; 19254 for (i = 0; i < it.length; i++) 19255 if (it[i].type == 1) p[it[i].name] = parseFloat(E.$(it[i].value).value()); 19256 else if (it[i].type == 2 && !it[i].inBUA) with(p.routeOptions.item(it[i].id)) { 19257 use = E.$(it[i].e + '1').checked(); 19258 speed = parseInt(E.$(it[i].e + '2').value()); 19259 combustion = parseFloat(E.$(it[i].e + '3').value()); 19260 toll = parseFloat(E.$(it[i].e + '4').value()) 19261 } 19262 if (this._onDoneSave) this._onDoneSave(p); 19263 this.hide() 19264 } 19265}); 19266E.Tooltip = { 19267 makeTooltip: function(div, text, type) { 19268 E.$('ttip').append((text = E.newElem$("div", "Tooltip").text(E.lang(text)).att("type", type).hide()).obj("toolTip", E.$(div).over(this.showTooltip, text).out(text.hide, text))) 19269 }, 19270 showTooltip: function(a) { 19271 var a = this.obj("toolTip"), 19272 pos = E.pos(a.elem()); 19273 if (this.att("type") == 0) this.left(pos.left).top(pos.top + pos.height).show(); 19274 else if (this.att("type") == 2) this.left(pos.left).top(pos.top - a.height() - 10).show(); 19275 else this.left((a = E.$('content_panel')).left() + a.width()).top(pos.top - 1).show() 19276 }, 19277 hideTooltip: function() { 19278 this.hide() 19279 } 19280}; 19281E.pos = (function() { 19282 function resolveObject(s) { 19283 if (document.getElementById && document.getElementById(s) != null) { 19284 return document.getElementById(s) 19285 } else if (document.all && document.all[s] != null) { 19286 return document.all[s] 19287 } else if (document.anchors && document.anchors.length && document.anchors.length > 0 && document.anchors[0].x) { 19288 for (var i = 0; i < document.anchors.length; i++) { 19289 if (document.anchors[i].name == s) { 19290 return document.anchors[i] 19291 } 19292 } 19293 } 19294 } 19295 return function(o, p) { 19296 var fixBrowserQuirks = true; 19297 if (typeof(o) == "string") { 19298 o = resolveObject(o) 19299 } 19300 if (o == null) { 19301 return null 19302 } 19303 var left = 0; 19304 var top = 0; 19305 var width = 0; 19306 var height = 0; 19307 var parentNode = null; 19308 var offsetParent = null; 19309 offsetParent = o.offsetParent; 19310 var originalObject = o; 19311 var el = o; 19312 while (el.parentNode != null) { 19313 el = el.parentNode; 19314 if (el.offsetParent == null) {} else { 19315 var considerScroll = true; 19316 if (fixBrowserQuirks && window.opera) { 19317 if (el == originalObject.parentNode || el.nodeName == "TR") { 19318 considerScroll = false 19319 } 19320 } 19321 if (considerScroll) { 19322 if (el.scrollTop && el.scrollTop > 0) { 19323 top -= el.scrollTop 19324 } 19325 if (el.scrollLeft && el.scrollLeft > 0) { 19326 left -= el.scrollLeft 19327 } 19328 } 19329 } 19330 if (el == offsetParent) { 19331 left += o.offsetLeft; 19332 if (el.clientLeft && el.nodeName != "TABLE") { 19333 left += el.clientLeft 19334 } 19335 top += o.offsetTop; 19336 if (el.clientTop && el.nodeName != "TABLE") { 19337 top += el.clientTop 19338 } 19339 o = el; 19340 if (o.offsetParent == null) { 19341 if (o.offsetLeft) { 19342 left += o.offsetLeft 19343 } 19344 if (o.offsetTop) { 19345 top += o.offsetTop 19346 } 19347 } 19348 offsetParent = o.offsetParent 19349 } 19350 if ((p) && (el.style.position == "absolute")) break 19351 } 19352 if (originalObject.offsetWidth) { 19353 width = originalObject.offsetWidth 19354 } 19355 if (originalObject.offsetHeight) { 19356 height = originalObject.offsetHeight 19357 } 19358 return { 19359 'left': left, 19360 'top': top, 19361 'width': width, 19362 'height': height 19363 } 19364 }; 19365 return pos 19366})(); 19367E.MC.Select = L.Class.extend({ 19368 _div: '', 19369 _name: '', 19370 _select: '', 19371 initialize: function(a, b, c, d, e) { 19372 with(this) { 19373 _div = E.$(a); 19374 var r = '', 19375 i; 19376 for (i = 0; i < b.length; i++) r += E.format("<option value={0}>{1}</option>", E.isA(b[i]) ? b[i] : [i, b[i]]); 19377 _div.Class('sel').text("<table><tr><td><div class='l'></td><td></div><div class='m'>" + (E.isA(b[0]) ? b[0][1] : b[0]) + "</div></td><td><div class='r'></div></td></tr></table><select>" + r + (c ? c : '') + "</select").obj("obj", this); 19378 _name = _div.getElem(".m"); 19379 _select = _div.childs()[1].change(function(e, f) { 19380 this.self.updateName(); 19381 d.call(this.owner, a, this.self) 19382 }, { 19383 self: this, 19384 owner: e 19385 }) 19386 } 19387 }, 19388 updateName: function() { 19389 with(this) { 19390 _name.text(_select.selected('innerHTML')); 19391 _div.att('val', _select.selected()) 19392 } 19393 }, 19394 id: function(a) { 19395 this._select.id(a); 19396 return this 19397 }, 19398 width: function(a) { 19399 this._name.width(a); 19400 this._div.width(a + 35); 19401 this._select.width(a + 35); 19402 return this 19403 }, 19404 selected: function(a) { 19405 return this._select.selected(a) 19406 }, 19407 select: function(a) { 19408 this._select.select(a); 19409 this.updateName(); 19410 return this 19411 }, 19412 text: function(a) { 19413 this._select.text(a); 19414 return this 19415 }, 19416 append: function(a) { 19417 this._select.append(a) 19418 } 19419}); 19420E.RouterArgParser = L.Class.extend({ 19421 _router: null, 19422 _useCookie: 1, 19423 initialize: function(router) { 19424 this._router = router; 19425 var me = this; 19426 router._map._map._argParser._getLinkParams = function() { 19427 return E.ArgParser.prototype._getLinkParams.call(this) + '&' + me._getLinkParams() 19428 }; 19429 this.readParams() 19430 }, 19431 readParams: function() { 19432 var args = E.Util.getParameters(), 19433 c, i, a; 19434 if (this._useCookie) { 19435 c = E.Cookie.getCookie('RV'); 19436 if ((E.type(c) == 's') && (c.length > 0)) { 19437 for (i = 0, a = ['points', 'params', 'routeType'], c = c.split('&'); i < a.length; i++) 19438 if (!args[a[i]]) args[a[i]] = c[i] 19439 } 19440 } 19441 if (args['params']) { 19442 var res = parseInt(args['params']); 19443 for (var i = 0, a = E.$('.content_ith_at').childs(); i < a.length; i++) { 19444 if ((res >> i) & 1 == 1) a[i].replaceClass("chk_off", "chk_on"); 19445 else a[i].replaceClass("chk_on", "chk_off") 19446 } 19447 } 19448 if (args['routeType']) { 19449 E.$("rit").obj("obj").select(args['routeType']) 19450 } 19451 if (args['points']) { 19452 var points = this._router._decode(args['points'], 5);
19453 for (var i = 0; i < points.length; i++) this._router.addWaypoint(points[i], i == 0 ? 0 : 1 + (i == points.length - 1)) 19454 } 19455 if (this._useCookie) { 19456 this._router.on('PointsChange', this._onChange, this).on('afterCalculateRoute', this._onChange, this) 19457 } 19458 }, 19459 _getRouteParams: function() { 19460 var res = 0; 19461 for (var i = 0, a = E.$('.content_ith_at').childs(); i < a.length; i++) { 19462 if (a[i].hasClass("chk_on")) res += 1 << i 19463 } 19464 return res 19465 }, 19466 _getPoints: function() { 19467 var points = [], 19468 wp = this._router.wayPoints(); 19469 for (var i = 0; i < wp.count(); i++) { 19470 points.push(wp.item(i).lonLat) 19471 } 19472 return this._router._encode(points, 5) 19473 }, 19474 _onChange: function() { 19475 points = this._getPoints(); 19476 var p = points + '&' + this._getRouteParams() + '&' + E.$("rit").obj("obj").selected(); 19477 E.Cookie.setCookie('RV', p) 19478 }, 19479 _getLinkParams: function() { 19480 return E.format('points={0}¶ms={1}&routeType={2}', [this._getPoints(), this._getRouteParams(), E.$("rit").obj("obj").selected()]) 19481 } 19482}); 19483E.ArgParser.extend({ 19484 _getLinkParams: function() { 19485 var link = E.ArgParser.prototype._getLinkParams(); 19486 return link 19487 } 19488}); 19489L.drawVersion = '0.2.0-dev'; 19490L.drawLocal = { 19491 draw: { 19492 toolbar: { 19493 title: 'Anuluj rysowanie', 19494 text: 'Anuluj', 19495 polyline: 'Rysuj polyline', 19496 polygon: 'Rysuj polygon', 19497 rectangle: 'Rysuj kwardrat', 19498 circle: 'Rysuj okrÄ g', 19499 marker: 'Rysuj punkt' 19500 }, 19501 circle: { 19502 tooltip: { 19503 start: 'Kliknij na mapie by rospozcÄ Ä rysowanie.' 19504 } 19505 }, 19506 marker: { 19507 tooltip: { 19508 start: 'Kliknij na mapie by umieÅciÄ punkt' 19509 } 19510 }, 19511 polygon: { 19512 tooltip: { 19513 start: 'Kliknij aby rospozcÄ Ä rysowanie', 19514 cont: 'Kliknij aby kontynuowaÄ rysowanie', 19515 end: 'Kliknij dwukrotnie by zakoÅczyÄ rysowanie' 19516 } 19517 }, 19518 polyline: { 19519 error: '<strong>BÅÄ d:</strong> krawÄdzie nie mogÄ siÄ przecinaÄ!', 19520 tooltip: { 19521 start: 'Kliknij aby rospozcÄ Ä rysowanie', 19522 cont: 'Kliknij aby kontynuowaÄ rysowanie', 19523 end: 'Kliknij dwukrotnie by zakoÅczyÄ rysowanie' 19524 } 19525 }, 19526 rectangle: { 19527 tooltip: { 19528 start: 'Kliknij na mapie by rospozcÄ Ä rysowanie' 19529 } 19530 }, 19531 simpleshape: { 19532 tooltip: { 19533 end: 'Zwolnij pszycisk by zakoÅczyÄ rysowanie' 19534 } 19535 } 19536 }, 19537 edit: { 19538 toolbar: { 19539 edit: { 19540 title: 'Edytowanie obiektów', 19541 save: { 19542 title: 'Zapisz zmiany', 19543 text: 'Zapisz' 19544 }, 19545 cancel: { 19546 title: 'Anuluj edytowanie, wycofuje zmiany.', 19547 text: 'Anuluj' 19548 } 19549 }, 19550 remove: { 19551 title: 'UsuÅ obiekty', 19552 tooltip: 'Kliknij na obiekt by go usunÄ Ä' 19553 }, 19554 degeocode: { 19555 title: 'Degeokodowanie obieku', 19556 tooltip: 'NaciÅnij na obiekty by degeokodowaÄ' 19557 } 19558 } 19559 } 19560}; 19561L.Control.Draw = L.Control.extend({ 19562 options: { 19563 position: 'topleft', 19564 draw: {}, 19565 edit: false 19566 }, 19567 initialize: function(options) { 19568 if (L.version <= "0.5.1") { 19569 throw new Error('Leaflet.draw 0.2.0+ requires Leaflet 0.6.0+. Download latest from https://github.com/Leaflet/Leaflet/') 19570 } 19571 L.Control.prototype.initialize.call(this, options); 19572 var id, toolbar; 19573 this._toolbars = {}; 19574 if (L.DrawToolbar && this.options.draw) { 19575 toolbar = new L.DrawToolbar(this.options.draw); 19576 id = L.stamp(toolbar); 19577 this._toolbars[id] = toolbar; 19578 this._toolbars[id].on('enable', this._toolbarEnabled, this) 19579 } 19580 if (L.EditToolbar && this.options.edit) { 19581 toolbar = new L.EditToolbar(this.options.edit); 19582 id = L.stamp(toolbar); 19583 this._toolbars[id] = toolbar; 19584 this._toolbars[id].on('enable', this._toolbarEnabled, this) 19585 } 19586 }, 19587 onAdd: function(map) { 19588 var container = L.DomUtil.create('div', 'leaflet-draw'), 19589 addedTopClass = false, 19590 topClassName = 'leaflet-draw-toolbar-top', 19591 toolbarContainer; 19592 for (var toolbarId in this._toolbars) { 19593 if (this._toolbars.hasOwnProperty(toolbarId)) { 19594 toolbarContainer = this._toolbars[toolbarId].addToolbar(map); 19595 if (!addedTopClass) { 19596 if (!L.DomUtil.hasClass(toolbarContainer, topClassName)) { 19597 L.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName) 19598 } 19599 addedTopClass = true 19600 } 19601 container.appendChild(toolbarContainer) 19602 } 19603 } 19604 L.DomUtil.setPosition(container, new L.Point(53, 272)); 19605 return container 19606 }, 19607 onRemove: function() { 19608 for (var toolbarId in this._toolbars) { 19609 if (this._toolbars.hasOwnProperty(toolbarId)) { 19610 this._toolbars[toolbarId].removeToolbar() 19611 } 19612 } 19613 }, 19614 setDrawingOptions: function(options) { 19615 for (var toolbarId in this._toolbars) { 19616 if (this._toolbars[toolbarId] instanceof L.DrawToolbar) { 19617 this._toolbars[toolbarId].setOptions(options) 19618 } 19619 } 19620 }, 19621 _toolbarEnabled: function(e) { 19622 var id = '' + L.stamp(e.target); 19623 for (var toolbarId in this._toolbars) { 19624 if (this._toolbars.hasOwnProperty(toolbarId) && toolbarId !== id) { 19625 this._toolbars[toolbarId].disable() 19626 } 19627 } 19628 } 19629}); 19630L.Map.mergeOptions({ 19631 drawControl: false 19632}); 19633E.Map.addInitHook(function() { 19634 if (this.options.drawControl) { 19635 this.drawControl = new L.Control.Draw(); 19636 this.addControl(this.drawControl) 19637 } 19638}); 19639L.Toolbar = L.Class.extend({ 19640 includes: [L.Mixin.Events], 19641 initialize: function(options) { 19642 L.setOptions(this, options); 19643 this._modes = {}; 19644 this._actionButtons = []; 19645 this._activeMode = null 19646 }, 19647 enabled: function() { 19648 return this._activeMode !== null 19649 }, 19650 disable: function() { 19651 if (!this.enabled()) { 19652 return 19653 } 19654 this._activeMode.handler.disable() 19655 }, 19656 removeToolbar: function() { 19657 for (var handlerId in this._modes) { 19658 if (this._modes.hasOwnProperty(handlerId)) { 19659 this._disposeButton(this._modes[handlerId].button, this._modes[handlerId].handler.enable); 19660 this._modes[handlerId].handler.disable(); 19661 this._modes[handlerId].handler.off('enabled', this._handlerActivated, this).off('disabled', this._handlerDeactivated, this) 19662 } 19663 } 19664 this._modes = {}; 19665 for (var i = 0, l = this._actionButtons.length; i < l; i++) { 19666 this._disposeButton(this._actionButtons[i].button, this._actionButtons[i].callback) 19667 } 19668 this._actionButtons = []; 19669 this._actionsContainer = null 19670 }, 19671 _initModeHandler: function(handler, container, buttonIndex, classNamePredix) { 19672 var type = handler.type; 19673 this._modes[type] = {}; 19674 this._modes[type].handler = handler; 19675 this._modes[type].button = this._createButton({ 19676 title: this.options[type].title, 19677 className: classNamePredix + '-' + type, 19678 container: container, 19679 callback: this._modes[type].handler.enable, 19680 context: this._modes[type].handler 19681 });
19682 this._modes[type].buttonIndex = buttonIndex; 19683 this._modes[type].handler.on('enabled', this._handlerActivated, this).on('disabled', this._handlerDeactivated, this) 19684 }, 19685 _createButton: function(options) { 19686 var link = L.DomUtil.create('a', options.className || '', options.container); 19687 link.href = '#'; 19688 if (options.text) { 19689 link.innerHTML = options.text 19690 } 19691 if (options.title) { 19692 link.title = options.title 19693 } 19694 L.DomEvent.on(link, 'click', L.DomEvent.stopPropagation).on(link, 'mousedown', L.DomEvent.stopPropagation).on(link, 'dblclick', L.DomEvent.stopPropagation).on(link, 'click', L.DomEvent.preventDefault).on(link, 'click', options.callback, options.context); 19695 return link 19696 }, 19697 _disposeButton: function(button, callback) { 19698 L.DomEvent.off(button, 'click', L.DomEvent.stopPropagation).off(button, 'mousedown', L.DomEvent.stopPropagation).off(button, 'dblclick', L.DomEvent.stopPropagation).off(button, 'click', L.DomEvent.preventDefault).off(button, 'click', callback) 19699 }, 19700 _handlerActivated: function(e) { 19701 if (this._activeMode && this._activeMode.handler.enabled()) { 19702 this._activeMode.handler.disable() 19703 } 19704 this._activeMode = this._modes[e.handler]; 19705 L.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled'); 19706 this._showActionsToolbar(); 19707 this.fire('enable') 19708 }, 19709 _handlerDeactivated: function() { 19710 this._hideActionsToolbar(); 19711 L.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled'); 19712 this._activeMode = null; 19713 this.fire('disable') 19714 }, 19715 _createActions: function(buttons) { 19716 var container = L.DomUtil.create('ul', 'leaflet-draw-actions'), 19717 buttonWidth = 50, 19718 l = buttons.length, 19719 containerWidth = (l * buttonWidth) + (l - 1), 19720 li, button; 19721 for (var i = 0; i < l; i++) { 19722 li = L.DomUtil.create('li', '', container); 19723 button = this._createButton({ 19724 title: buttons[i].title, 19725 text: buttons[i].text, 19726 container: li, 19727 callback: buttons[i].callback, 19728 context: buttons[i].context 19729 }); 19730 this._actionButtons.push({ 19731 button: button, 19732 callback: buttons[i].callback 19733 }) 19734 } 19735 container.style.width = containerWidth + 'px'; 19736 return container 19737 }, 19738 _showActionsToolbar: function() { 19739 var buttonIndex = this._activeMode.buttonIndex, 19740 lastButtonIndex = this._lastButtonIndex, 19741 buttonHeight = 26, 19742 borderHeight = 1, 19743 toolbarPosition = (buttonIndex * buttonHeight) + (buttonIndex * borderHeight) - 1; 19744 this._actionsContainer.style.top = toolbarPosition + 'px'; 19745 if (buttonIndex === 0) { 19746 L.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop'); 19747 L.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top') 19748 } 19749 if (buttonIndex === lastButtonIndex) { 19750 L.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom'); 19751 L.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom') 19752 } 19753 this._actionsContainer.style.display = 'block' 19754 }, 19755 _hideActionsToolbar: function() { 19756 this._actionsContainer.style.display = 'none'; 19757 L.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop'); 19758 L.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom'); 19759 L.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top'); 19760 L.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom') 19761 } 19762}); 19763L.Tooltip = L.Class.extend({ 19764 initialize: function(map) { 19765 this._map = map; 19766 this._popupPane = map._panes.popupPane; 19767 this._container = L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane); 19768 this._singleLineLabel = false 19769 }, 19770 dispose: function() { 19771 this._popupPane.removeChild(this._container); 19772 this._container = null 19773 }, 19774 updateContent: function(labelText) { 19775 labelText.subtext = labelText.subtext || ''; 19776 if (labelText.subtext.length === 0 && !this._singleLineLabel) { 19777 L.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single'); 19778 this._singleLineLabel = true 19779 } else if (labelText.subtext.length > 0 && this._singleLineLabel) { 19780 L.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single'); 19781 this._singleLineLabel = false 19782 } 19783 this._container.innerHTML = (labelText.subtext.length > 0 ? '<span class="leaflet-draw-tooltip-subtext">' + labelText.subtext + '</span>' + '<br />' : '') + '<span>' + labelText.text + '</span>'; 19784 return this 19785 }, 19786 updatePosition: function(latlng) { 19787 var pos = this._map.latLngToLayerPoint(latlng); 19788 L.DomUtil.setPosition(this._container, pos); 19789 return this 19790 }, 19791 showAsError: function() { 19792 L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip'); 19793 return this 19794 }, 19795 removeError: function() { 19796 L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip'); 19797 return this 19798 } 19799}); 19800L.DrawToolbar = L.Toolbar.extend({ 19801 options: { 19802 polyline: { 19803 title: L.drawLocal.draw.toolbar.polyline 19804 }, 19805 polygon: { 19806 title: L.drawLocal.draw.toolbar.polygon 19807 }, 19808 rectangle: { 19809 title: L.drawLocal.draw.toolbar.rectangle 19810 }, 19811 circle: { 19812 title: L.drawLocal.draw.toolbar.circle 19813 }, 19814 marker: { 19815 title: L.drawLocal.draw.toolbar.marker 19816 } 19817 }, 19818 initialize: function(options) { 19819 for (var type in this.options) { 19820 if (this.options.hasOwnProperty(type)) { 19821 if (options[type]) { 19822 options[type] = L.extend({}, this.options[type], options[type]) 19823 } 19824 } 19825 } 19826 L.Toolbar.prototype.initialize.call(this, options) 19827 }, 19828 addToolbar: function(map) { 19829 var container = L.DomUtil.create('div', 'leaflet-draw-section'), 19830 buttonIndex = 0, 19831 buttonClassPrefix = 'leaflet-draw-draw'; 19832 this._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar'); 19833 if (this.options.polyline) { 19834 this._initModeHandler(new L.Draw.Polyline(map, this.options.polyline), this._toolbarContainer, buttonIndex++, buttonClassPrefix) 19835 } 19836 if (this.options.polygon) { 19837 this._initModeHandler(new L.Draw.Polygon(map, this.options.polygon), this._toolbarContainer, buttonIndex++, buttonClassPrefix) 19838 } 19839 if (this.options.rectangle) { 19840 this._initModeHandler(new L.Draw.Rectangle(map, this.options.rectangle), this._toolbarContainer, buttonIndex++, buttonClassPrefix) 19841 } 19842 if (this.options.circle) { 19843 this._initModeHandler(new L.Draw.Circle(map, this.options.circle), this._toolbarContainer, buttonIndex++, buttonClassPrefix) 19844 } 19845 if (this.options.marker) { 19846 this._initModeHandler(new L.Draw.Marker(map, this.options.marker), this._toolbarContainer, buttonIndex++, buttonClassPrefix) 19847 } 19848 this._lastButtonIndex = --buttonIndex; 19849 this._actionsContainer = this._createActions([{ 19850 title: L.drawLocal.draw.toolbar.title, 19851 text: L.drawLocal.draw.toolbar.text, 19852 callback: this.disable, 19853 context: this 19854 }]); 19855 container.appendChild(this._toolbarContainer); 19856 container.appendChild(this._actionsContainer); 19857 return container 19858 }, 19859 setOptions: function(options) { 19860 L.setOptions(this, options); 19861 for (var type in this._modes) { 19862 if (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) { 19863 this._modes[type].handler.setOptions(options[type]) 19864 } 19865 } 19866 } 19867}); 19868L.Draw = {}; 19869L.Draw.Feature = L.Handler.extend({ 19870 includes: L.Mixin.Events, 19871 initialize: function(map, options) { 19872 this._map = map; 19873 this._container = map._container; 19874 this._overlayPane = map._panes.overlayPane; 19875 this._popupPane = map._panes.popupPane; 19876 if (options && options.shapeOptions) { 19877 options.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions) 19878 } 19879 L.Util.extend(this.options, options) 19880 }, 19881 enable: function() { 19882 if (this._enabled) { 19883 return 19884 } 19885 L.Handler.prototype.enable.call(this); 19886 this.fire('enabled', { 19887 handler: this.type 19888 });
19889 this._map.fire('draw:drawstart', { 19890 layerType: this.type 19891 }) 19892 }, 19893 disable: function() { 19894 if (!this._enabled) { 19895 return 19896 } 19897 L.Handler.prototype.disable.call(this); 19898 this.fire('disabled', { 19899 handler: this.type 19900 }); 19901 this._map.fire('draw:drawstop', { 19902 layerType: this.type 19903 }) 19904 }, 19905 addHooks: function() { 19906 if (this._map) { 19907 L.DomUtil.disableTextSelection(); 19908 this._tooltip = new L.Tooltip(this._map); 19909 L.DomEvent.addListener(this._container, 'keyup', this._cancelDrawing, this) 19910 } 19911 }, 19912 removeHooks: function() { 19913 if (this._map) { 19914 L.DomUtil.enableTextSelection(); 19915 this._tooltip.dispose(); 19916 this._tooltip = null; 19917 L.DomEvent.removeListener(this._container, 'keyup', this._cancelDrawing) 19918 } 19919 }, 19920 setOptions: function(options) { 19921 L.setOptions(this, options) 19922 }, 19923 _fireCreatedEvent: function(layer) { 19924 this._map.fire('draw:created', { 19925 layer: layer, 19926 layerType: this.type 19927 }) 19928 }, 19929 _cancelDrawing: function(e) { 19930 if (e.keyCode === 27) { 19931 this.disable() 19932 } 19933 } 19934}); 19935L.SimpleShape = {}; 19936L.Draw.SimpleShape = L.Draw.Feature.extend({ 19937 addHooks: function() { 19938 L.Draw.Feature.prototype.addHooks.call(this); 19939 if (this._map) { 19940 this._map.dragging.disable(); 19941 this._container.style.cursor = 'crosshair'; 19942 this._tooltip.updateContent({ 19943 text: this._initialLabelText 19944 }); 19945 this._map.on('mousedown', this._onMouseDown, this).on('mousemove', this._onMouseMove, this) 19946 } 19947 }, 19948 removeHooks: function() { 19949 L.Draw.Feature.prototype.removeHooks.call(this); 19950 if (this._map) { 19951 this._map.dragging.enable(); 19952 this._container.style.cursor = ''; 19953 this._map.off('mousedown', this._onMouseDown, this).off('mousemove', this._onMouseMove, this); 19954 L.DomEvent.off(document, 'mouseup', this._onMouseUp); 19955 if (this._shape) { 19956 this._map.removeLayer(this._shape); 19957 delete this._shape 19958 } 19959 } 19960 this._isDrawing = false 19961 }, 19962 _onMouseDown: function(e) { 19963 this._isDrawing = true; 19964 this._startLatLng = e.latlng; 19965 L.DomEvent.on(document, 'mouseup', this._onMouseUp, this).preventDefault(e.originalEvent) 19966 }, 19967 _onMouseMove: function(e) { 19968 var latlng = e.latlng; 19969 this._tooltip.updatePosition(latlng); 19970 if (this._isDrawing) { 19971 this._tooltip.updateContent({ 19972 text: L.drawLocal.draw.simpleshape.tooltip.end 19973 }); 19974 this._drawShape(latlng) 19975 } 19976 }, 19977 _onMouseUp: function() { 19978 if (this._shape) { 19979 this._fireCreatedEvent() 19980 } 19981 this.disable() 19982 } 19983}); 19984L.Draw.Circle = L.Draw.SimpleShape.extend({ 19985 statics: { 19986 TYPE: 'circle' 19987 }, 19988 options: { 19989 shapeOptions: { 19990 stroke: true, 19991 color: '#f06eaa', 19992 weight: 4, 19993 opacity: 0.5, 19994 fill: true, 19995 fillColor: null, 19996 fillOpacity: 0.2, 19997 clickable: true 19998 } 19999 }, 20000 initialize: function(map, options) { 20001 this.type = L.Draw.Circle.TYPE; 20002 L.Draw.SimpleShape.prototype.initialize.call(this, map, options) 20003 }, 20004 _initialLabelText: L.drawLocal.draw.circle.tooltip.start, 20005 _drawShape: function(latlng) { 20006 if (!this._shape) { 20007 this._shape = new L.Circle(this._startLatLng, this._startLatLng.distanceTo(latlng), this.options.shapeOptions); 20008 this._map.addLayer(this._shape) 20009 } else { 20010 this._shape.setRadius(this._startLatLng.distanceTo(latlng)) 20011 } 20012 }, 20013 _fireCreatedEvent: function() { 20014 var circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions); 20015 L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle) 20016 }, 20017 _onMouseMove: function(e) { 20018 var latlng = e.latlng, 20019 radius; 20020 this._tooltip.updatePosition(latlng); 20021 if (this._isDrawing) { 20022 this._drawShape(latlng); 20023 radius = this._shape.getRadius().toFixed(1); 20024 this._tooltip.updateContent({ 20025 text: 'Release mouse to finish drawing.', 20026 subtext: 'Radius: ' + radius + ' m' 20027 }) 20028 } 20029 } 20030}); 20031L.Draw.Marker = L.Draw.Feature.extend({ 20032 statics: { 20033 TYPE: 'marker' 20034 }, 20035 options: { 20036 icon: new L.Icon.Default(), 20037 zIndexOffset: 2000 20038 }, 20039 initialize: function(map, options) { 20040 this.type = L.Draw.Marker.TYPE; 20041 L.Draw.Feature.prototype.initialize.call(this, map, options) 20042 }, 20043 addHooks: function() { 20044 L.Draw.Feature.prototype.addHooks.call(this); 20045 if (this._map) { 20046 this._tooltip.updateContent({ 20047 text: L.drawLocal.draw.marker.tooltip.start 20048 }); 20049 if (!this._mouseMarker) { 20050 this._mouseMarker = L.marker(this._map.getCenter(), { 20051 icon: L.divIcon({ 20052 className: 'leaflet-mouse-marker', 20053 iconAnchor: [20, 20], 20054 iconSize: [40, 40] 20055 }), 20056 opacity: 0, 20057 zIndexOffset: this.options.zIndexOffset 20058 }) 20059 } 20060 this._mouseMarker.on('click', this._onClick, this).addTo(this._map); 20061 this._map.on('mousemove', this._onMouseMove, this) 20062 } 20063 }, 20064 removeHooks: function() { 20065 L.Draw.Feature.prototype.removeHooks.call(this); 20066 if (this._map) { 20067 if (this._marker) { 20068 this._marker.off('click', this._onClick, this); 20069 this._map.off('click', this._onClick, this).removeLayer(this._marker); 20070 delete this._marker 20071 } 20072 this._mouseMarker.off('click', this._onClick, this); 20073 this._map.removeLayer(this._mouseMarker); 20074 delete this._mouseMarker; 20075 this._map.off('mousemove', this._onMouseMove, this) 20076 } 20077 }, 20078 _onMouseMove: function(e) { 20079 var latlng = e.latlng; 20080 this._tooltip.updatePosition(latlng); 20081 this._mouseMarker.setLatLng(latlng); 20082 if (!this._marker) { 20083 this._marker = new L.Marker(latlng, { 20084 icon: this.options.icon, 20085 zIndexOffset: this.options.zIndexOffset 20086 }); 20087 this._marker.on('click', this._onClick, this); 20088 this._map.on('click', this._onClick, this).addLayer(this._marker) 20089 } else { 20090 this._marker.setLatLng(latlng) 20091 } 20092 }, 20093 _onClick: function() { 20094 this._fireCreatedEvent(); 20095 this.disable() 20096 }, 20097 _fireCreatedEvent: function() { 20098 var marker = new L.Marker(this._marker.getLatLng(), { 20099 icon: this.options.icon 20100 });
20101 L.Draw.Feature.prototype._fireCreatedEvent.call(this, marker) 20102 } 20103}); 20104L.Draw.Polyline = L.Draw.Feature.extend({ 20105 statics: { 20106 TYPE: 'polyline' 20107 }, 20108 Poly: L.Polyline, 20109 options: { 20110 allowIntersection: true, 20111 drawError: { 20112 color: '#b00b00', 20113 message: L.drawLocal.draw.polyline.error, 20114 timeout: 2500 20115 }, 20116 icon: new L.DivIcon({ 20117 iconSize: new L.Point(8, 8), 20118 className: 'leaflet-div-icon leaflet-editing-icon' 20119 }), 20120 guidelineDistance: 20, 20121 shapeOptions: { 20122 stroke: true, 20123 color: '#f06eaa', 20124 weight: 4, 20125 opacity: 0.5, 20126 fill: false, 20127 clickable: true 20128 }, 20129 zIndexOffset: 2000 20130 }, 20131 initialize: function(map, options) { 20132 if (options && options.drawError) { 20133 options.drawError = L.Util.extend({}, this.options.drawError, options.drawError) 20134 } 20135 this.type = L.Draw.Polyline.TYPE; 20136 L.Draw.Feature.prototype.initialize.call(this, map, options) 20137 }, 20138 addHooks: function() { 20139 L.Draw.Feature.prototype.addHooks.call(this); 20140 if (this._map) { 20141 this._markers = []; 20142 this._markerGroup = new L.LayerGroup(); 20143 this._map.addLayer(this._markerGroup); 20144 this._poly = new L.Polyline([], this.options.shapeOptions); 20145 this._tooltip.updateContent(this._getTooltipText()); 20146 if (!this._mouseMarker) { 20147 this._mouseMarker = L.marker(this._map.getCenter(), { 20148 icon: L.divIcon({ 20149 className: 'leaflet-mouse-marker', 20150 iconAnchor: [20, 20], 20151 iconSize: [40, 40] 20152 }), 20153 opacity: 0, 20154 zIndexOffset: this.options.zIndexOffset 20155 }) 20156 } 20157 this._mouseMarker.on('click', this._onClick, this).addTo(this._map); 20158 this._map.on('mousemove', this._onMouseMove, this).on('zoomend', this._onZoomEnd, this) 20159 } 20160 }, 20161 removeHooks: function() { 20162 L.Draw.Feature.prototype.removeHooks.call(this); 20163 this._clearHideErrorTimeout(); 20164 this._cleanUpShape(); 20165 this._map.removeLayer(this._markerGroup); 20166 delete this._markerGroup; 20167 delete this._markers; 20168 this._map.removeLayer(this._poly); 20169 delete this._poly; 20170 this._mouseMarker.off('click', this._onClick, this); 20171 this._map.removeLayer(this._mouseMarker); 20172 delete this._mouseMarker; 20173 this._clearGuides(); 20174 this._map.off('mousemove', this._onMouseMove, this).off('zoomend', this._onZoomEnd, this) 20175 }, 20176 _finishShape: function() { 20177 var intersects = this._poly.newLatLngIntersects(this._poly.getLatLngs()[0], true); 20178 if ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) { 20179 this._showErrorTooltip(); 20180 return 20181 } 20182 this._fireCreatedEvent(); 20183 this.disable() 20184 }, 20185 _shapeIsValid: function() { 20186 return true 20187 }, 20188 _onZoomEnd: function() { 20189 this._updateGuide() 20190 }, 20191 _onMouseMove: function(e) { 20192 var newPos = e.layerPoint, 20193 latlng = e.latlng; 20194 this._currentLatLng = latlng; 20195 this._tooltip.updatePosition(latlng); 20196 this._updateGuide(newPos); 20197 this._mouseMarker.setLatLng(latlng); 20198 L.DomEvent.preventDefault(e.originalEvent) 20199 }, 20200 _onClick: function(e) { 20201 var latlng = e.target.getLatLng(), 20202 markerCount = this._markers.length; 20203 if (markerCount > 0 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) { 20204 this._showErrorTooltip(); 20205 return 20206 } else if (this._errorShown) { 20207 this._hideErrorTooltip() 20208 } 20209 this._markers.push(this._createMarker(latlng)); 20210 this._poly.addLatLng(latlng); 20211 if (this._poly.getLatLngs().length === 2) { 20212 this._map.addLayer(this._poly) 20213 } 20214 this._updateFinishHandler(); 20215 this._vertexAdded(latlng); 20216 this._clearGuides() 20217 }, 20218 _updateFinishHandler: function() { 20219 var markerCount = this._markers.length; 20220 if (markerCount > 1) { 20221 this._markers[markerCount - 1].on('click', this._finishShape, this) 20222 } 20223 if (markerCount > 2) { 20224 this._markers[markerCount - 2].off('click', this._finishShape, this) 20225 } 20226 }, 20227 _createMarker: function(latlng) { 20228 var marker = new L.Marker(latlng, { 20229 icon: this.options.icon, 20230 zIndexOffset: this.options.zIndexOffset * 2 20231 });
20232 this._markerGroup.addLayer(marker); 20233 return marker 20234 }, 20235 _updateGuide: function(newPos) { 20236 newPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng); 20237 var markerCount = this._markers.length; 20238 if (markerCount > 0) { 20239 if (!this._errorShown) { 20240 this._tooltip.updateContent(this._getTooltipText()) 20241 } 20242 this._clearGuides(); 20243 this._drawGuide(this._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()), newPos) 20244 } 20245 }, 20246 _drawGuide: function(pointA, pointB) { 20247 var length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))), 20248 i, fraction, dashPoint, dash; 20249 if (!this._guidesContainer) { 20250 this._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane) 20251 } 20252 for (i = this.options.guidelineDistance; i < length; i += this.options.guidelineDistance) { 20253 fraction = i / length; 20254 dashPoint = { 20255 x: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)), 20256 y: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y)) 20257 }; 20258 dash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer); 20259 dash.style.backgroundColor = !this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color; 20260 L.DomUtil.setPosition(dash, dashPoint) 20261 } 20262 }, 20263 _updateGuideColor: function(color) { 20264 if (this._guidesContainer) { 20265 for (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) { 20266 this._guidesContainer.childNodes[i].style.backgroundColor = color 20267 } 20268 } 20269 }, 20270 _clearGuides: function() { 20271 if (this._guidesContainer) { 20272 while (this._guidesContainer.firstChild) { 20273 this._guidesContainer.removeChild(this._guidesContainer.firstChild) 20274 } 20275 } 20276 }, 20277 _getTooltipText: function() { 20278 var labelText, distance, distanceStr; 20279 if (this._markers.length === 0) { 20280 labelText = { 20281 text: L.drawLocal.draw.polyline.tooltip.start 20282 } 20283 } else { 20284 distance = this._measurementRunningTotal + this._currentLatLng.distanceTo(this._markers[this._markers.length - 1].getLatLng()); 20285 distanceStr = distance > 1000 ? (distance / 1000).toFixed(2) + ' km' : Math.ceil(distance) + ' m'; 20286 if (this._markers.length === 1) { 20287 labelText = { 20288 text: L.drawLocal.draw.polyline.tooltip.cont, 20289 subtext: distanceStr 20290 } 20291 } else { 20292 labelText = { 20293 text: L.drawLocal.draw.polyline.tooltip.end, 20294 subtext: distanceStr 20295 } 20296 } 20297 } 20298 return labelText 20299 }, 20300 _showErrorTooltip: function() { 20301 this._errorShown = true; 20302 this._tooltip.showAsError().updateContent({ 20303 text: this.options.drawError.message 20304 }); 20305 this._updateGuideColor(this.options.drawError.color); 20306 this._poly.setStyle({ 20307 color: this.options.drawError.color 20308 }); 20309 this._clearHideErrorTimeout(); 20310 this._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout) 20311 }, 20312 _hideErrorTooltip: function() { 20313 this._errorShown = false; 20314 this._clearHideErrorTimeout(); 20315 this._tooltip.removeError().updateContent(this._getTooltipText()); 20316 this._updateGuideColor(this.options.shapeOptions.color); 20317 this._poly.setStyle({ 20318 color: this.options.shapeOptions.color 20319 }) 20320 }, 20321 _clearHideErrorTimeout: function() { 20322 if (this._hideErrorTimeout) { 20323 clearTimeout(this._hideErrorTimeout); 20324 this._hideErrorTimeout = null 20325 } 20326 }, 20327 _vertexAdded: function(latlng) { 20328 if (this._markers.length === 1) { 20329 this._measurementRunningTotal = 0 20330 } else { 20331 this._measurementRunningTotal += latlng.distanceTo(this._markers[this._markers.length - 2].getLatLng()) 20332 } 20333 }, 20334 _cleanUpShape: function() { 20335 if (this._markers.length > 0) { 20336 this._markers[this._markers.length - 1].off('click', this._finishShape, this) 20337 } 20338 }, 20339 _fireCreatedEvent: function() { 20340 var poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions); 20341 L.Draw.Feature.prototype._fireCreatedEvent.call(this, poly) 20342 } 20343}); 20344L.Draw.Polygon = L.Draw.Polyline.extend({ 20345 statics: { 20346 TYPE: 'polygon' 20347 }, 20348 Poly: L.Polygon, 20349 options: { 20350 showArea: false, 20351 shapeOptions: { 20352 stroke: true, 20353 color: '#f06eaa', 20354 weight: 4, 20355 opacity: 0.5, 20356 fill: true, 20357 fillColor: null, 20358 fillOpacity: 0.2, 20359 clickable: true 20360 } 20361 }, 20362 initialize: function(map, options) { 20363 L.Draw.Polyline.prototype.initialize.call(this, map, options); 20364 this.type = L.Draw.Polygon.TYPE 20365 }, 20366 _updateFinishHandler: function() { 20367 var markerCount = this._markers.length; 20368 if (markerCount === 1) { 20369 this._markers[0].on('click', this._finishShape, this) 20370 } 20371 if (markerCount > 2) { 20372 this._markers[markerCount - 1].on('dblclick', this._finishShape, this); 20373 if (markerCount > 3) { 20374 this._markers[markerCount - 2].off('dblclick', this._finishShape, this) 20375 } 20376 } 20377 }, 20378 _getTooltipText: function() { 20379 var text, subtext; 20380 if (this._markers.length === 0) { 20381 text = L.drawLocal.draw.polygon.tooltip.start 20382 } else if (this._markers.length < 3) { 20383 text = L.drawLocal.draw.polygon.tooltip.cont 20384 } else { 20385 text = L.drawLocal.draw.polygon.tooltip.end; 20386 subtext = this._area 20387 } 20388 return { 20389 text: text, 20390 subtext: subtext 20391 } 20392 }, 20393 _shapeIsValid: function() { 20394 return this._markers.length >= 3 20395 }, 20396 _vertexAdded: function() { 20397 if (this.options.allowIntersection || !this.options.showArea) { 20398 return 20399 } 20400 var latLngs = this._poly.getLatLngs(), 20401 area = L.PolygonUtil.geodesicArea(latLngs); 20402 if (area > 1000000) { 20403 area = (area * 0.000001).toFixed(2) + ' km²' 20404 } else if (area > 10000) { 20405 area = (area * 0.0001).toFixed(2) + ' ha' 20406 } else { 20407 area = area.toFixed(2) + ' m²' 20408 } 20409 this._area = area 20410 }, 20411 _cleanUpShape: function() { 20412 var markerCount = this._markers.length; 20413 if (markerCount > 0) { 20414 this._markers[0].off('click', this._finishShape, this); 20415 if (markerCount > 2) { 20416 this._markers[markerCount - 1].off('dblclick', this._finishShape, this) 20417 } 20418 } 20419 } 20420}); 20421L.Draw.Rectangle = L.Draw.SimpleShape.extend({ 20422 statics: { 20423 TYPE: 'rectangle' 20424 }, 20425 options: { 20426 shapeOptions: { 20427 stroke: true, 20428 color: '#f06eaa', 20429 weight: 4, 20430 opacity: 0.5, 20431 fill: true, 20432 fillColor: null, 20433 fillOpacity: 0.2, 20434 clickable: true 20435 } 20436 }, 20437 initialize: function(map, options) { 20438 this.type = L.Draw.Rectangle.TYPE; 20439 L.Draw.SimpleShape.prototype.initialize.call(this, map, options) 20440 }, 20441 _initialLabelText: L.drawLocal.draw.rectangle.tooltip.start, 20442 _drawShape: function(latlng) { 20443 if (!this._shape) { 20444 this._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions); 20445 this._map.addLayer(this._shape) 20446 } else { 20447 this._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng)) 20448 } 20449 }, 20450 _fireCreatedEvent: function() { 20451 var rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions); 20452 L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle) 20453 } 20454}); 20455L.EditToolbar = L.Toolbar.extend({ 20456 options: { 20457 edit: { 20458 title: L.drawLocal.edit.toolbar.edit.title, 20459 selectedPathOptions: { 20460 color: '#fe57a1', 20461 opacity: 0.6, 20462 dashArray: '10, 10', 20463 fill: true, 20464 fillColor: '#fe57a1', 20465 fillOpacity: 0.1 20466 } 20467 }, 20468 remove: { 20469 title: L.drawLocal.edit.toolbar.remove.title 20470 }, 20471 featureGroup: null 20472 }, 20473 initialize: function(options) { 20474 if (options.edit && typeof options.edit.selectedPathOptions === 'undefined') { 20475 options.edit.selectedPathOptions = this.options.edit.selectedPathOptions 20476 } 20477 options.edit = L.extend({}, this.options.edit, options.edit); 20478 options.remove = L.extend({}, this.options.remove, options.remove); 20479 L.Toolbar.prototype.initialize.call(this, options); 20480 this._selectedFeatureCount = 0 20481 }, 20482 addToolbar: function(map) { 20483 var container = L.DomUtil.create('div', 'leaflet-draw-section'), 20484 buttonIndex = 0, 20485 buttonClassPrefix = 'leaflet-draw-edit'; 20486 this._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar'); 20487 this._map = map; 20488 if (this.options.edit) { 20489 this._initModeHandler(new L.EditToolbar.Edit(map, { 20490 featureGroup: this.options.featureGroup, 20491 selectedPathOptions: this.options.edit.selectedPathOptions 20492 }), this._toolbarContainer, buttonIndex++, buttonClassPrefix) 20493 } 20494 if (this.options.remove) { 20495 this._initModeHandler(new L.EditToolbar.Delete(map, { 20496 featureGroup: this.options.featureGroup 20497 }), this._toolbarContainer, buttonIndex++, buttonClassPrefix) 20498 } 20499 if (this.options.degeocode) { 20500 this._initModeHandler(new L.EditToolbar.Degeocode(map, { 20501 featureGroup: this.options.featureGroup 20502 }), this._toolbarContainer, buttonIndex++, buttonClassPrefix) 20503 } 20504 this._lastButtonIndex = --buttonIndex; 20505 this._actionsContainer = this._createActions([{ 20506 title: L.drawLocal.edit.toolbar.edit.save.title, 20507 text: L.drawLocal.edit.toolbar.edit.save.text, 20508 callback: this._save, 20509 context: this 20510 }, { 20511 title: L.drawLocal.edit.toolbar.edit.cancel.title, 20512 text: L.drawLocal.edit.toolbar.edit.cancel.text, 20513 callback: this.disable, 20514 context: this 20515 }]); 20516 container.appendChild(this._toolbarContainer); 20517 container.appendChild(this._actionsContainer); 20518 return container 20519 }, 20520 disable: function() { 20521 if (!this.enabled()) { 20522 return 20523 } 20524 this._activeMode.handler.revertLayers(); 20525 L.Toolbar.prototype.disable.call(this) 20526 }, 20527 _save: function() { 20528 this._activeMode.handler.save(); 20529 this._activeMode.handler.disable() 20530 } 20531}); 20532L.Edit = L.Edit || {}; 20533L.Edit.SimpleShape = L.Handler.extend({ 20534 options: { 20535 moveIcon: new L.DivIcon({ 20536 iconSize: new L.Point(8, 8), 20537 className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move' 20538 }), 20539 resizeIcon: new L.DivIcon({ 20540 iconSize: new L.Point(8, 8), 20541 className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize' 20542 }) 20543 }, 20544 initialize: function(shape, options) { 20545 this._shape = shape; 20546 L.Util.setOptions(this, options) 20547 }, 20548 addHooks: function() { 20549 if (this._shape._map) { 20550 this._map = this._shape._map; 20551 if (!this._markerGroup) { 20552 this._initMarkers() 20553 } 20554 this._map.addLayer(this._markerGroup) 20555 } 20556 }, 20557 removeHooks: function() { 20558 if (this._shape._map) { 20559 this._unbindMarker(this._moveMarker); 20560 for (var i = 0, l = this._resizeMarkers.length; i < l; i++) { 20561 this._unbindMarker(this._resizeMarkers[i]) 20562 } 20563 this._resizeMarkers = null; 20564 this._map.removeLayer(this._markerGroup); 20565 delete this._markerGroup 20566 } 20567 this._map = null 20568 }, 20569 updateMarkers: function() { 20570 this._markerGroup.clearLayers(); 20571 this._initMarkers() 20572 }, 20573 _initMarkers: function() { 20574 if (!this._markerGroup) { 20575 this._markerGroup = new L.LayerGroup() 20576 } 20577 this._createMoveMarker(); 20578 this._createResizeMarker() 20579 }, 20580 _createMoveMarker: function() {}, 20581 _createResizeMarker: function() {}, 20582 _createMarker: function(latlng, icon) { 20583 var marker = new L.Marker(latlng, { 20584 draggable: true, 20585 icon: icon, 20586 zIndexOffset: 10 20587 });
20588 this._bindMarker(marker); 20589 this._markerGroup.addLayer(marker); 20590 return marker 20591 }, 20592 _bindMarker: function(marker) { 20593 marker.on('dragstart', this._onMarkerDragStart, this).on('drag', this._onMarkerDrag, this).on('dragend', this._onMarkerDragEnd, this) 20594 }, 20595 _unbindMarker: function(marker) { 20596 marker.off('dragstart', this._onMarkerDragStart, this).off('drag', this._onMarkerDrag, this).off('dragend', this._onMarkerDragEnd, this) 20597 }, 20598 _onMarkerDragStart: function(e) { 20599 var marker = e.target; 20600 marker.setOpacity(0) 20601 }, 20602 _fireEdit: function() { 20603 this._shape.edited = true; 20604 this._shape.fire('edit') 20605 }, 20606 _onMarkerDrag: function(e) { 20607 var marker = e.target, 20608 latlng = marker.getLatLng(); 20609 if (marker === this._moveMarker) { 20610 this._move(latlng) 20611 } else { 20612 this._resize(latlng) 20613 } 20614 this._shape.redraw() 20615 }, 20616 _onMarkerDragEnd: function(e) { 20617 var marker = e.target; 20618 marker.setOpacity(1); 20619 this._shape.fire('edit'); 20620 this._fireEdit() 20621 }, 20622 _move: function() {}, 20623 _resize: function() {} 20624}); 20625L.Edit = L.Edit || {}; 20626L.Edit.Circle = L.Edit.SimpleShape.extend({ 20627 _createMoveMarker: function() { 20628 var center = this._shape.getLatLng(); 20629 this._moveMarker = this._createMarker(center, this.options.moveIcon) 20630 }, 20631 _createResizeMarker: function() { 20632 var center = this._shape.getLatLng(), 20633 resizemarkerPoint = this._getResizeMarkerPoint(center); 20634 this._resizeMarkers = []; 20635 this._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon)) 20636 }, 20637 _getResizeMarkerPoint: function(latlng) { 20638 var delta = this._shape._radius * Math.cos(Math.PI / 4), 20639 point = this._map.project(latlng); 20640 return this._map.unproject([point.x + delta, point.y - delta]) 20641 }, 20642 _move: function(latlng) { 20643 var resizemarkerPoint = this._getResizeMarkerPoint(latlng); 20644 this._resizeMarkers[0].setLatLng(resizemarkerPoint); 20645 this._shape.setLatLng(latlng) 20646 }, 20647 _resize: function(latlng) { 20648 var moveLatLng = this._moveMarker.getLatLng(), 20649 radius = moveLatLng.distanceTo(latlng); 20650 this._shape.setRadius(radius) 20651 } 20652}); 20653L.Circle.addInitHook(function() { 20654 if (L.Edit.Circle) { 20655 this.editing = new L.Edit.Circle(this); 20656 if (this.options.editable) { 20657 this.editing.enable() 20658 } 20659 } 20660 this.on('add', function() { 20661 if (this.editing && this.editing.enabled()) { 20662 this.editing.addHooks() 20663 } 20664 }); 20665 this.on('remove', function() { 20666 if (this.editing && this.editing.enabled()) { 20667 this.editing.removeHooks() 20668 } 20669 }) 20670}); 20671L.Edit = L.Edit || {}; 20672L.Edit.Poly = L.Handler.extend({ 20673 options: { 20674 icon: new L.DivIcon({ 20675 iconSize: new L.Point(8, 8), 20676 className: 'leaflet-div-icon leaflet-editing-icon' 20677 }) 20678 }, 20679 initialize: function(poly, options) { 20680 this._poly = poly; 20681 L.setOptions(this, options) 20682 }, 20683 addHooks: function() { 20684 if (this._poly._map) { 20685 if (!this._markerGroup) { 20686 this._initMarkers() 20687 } 20688 this._poly._map.addLayer(this._markerGroup) 20689 } 20690 }, 20691 removeHooks: function() { 20692 if (this._poly._map) { 20693 this._poly._map.removeLayer(this._markerGroup); 20694 delete this._markerGroup; 20695 delete this._markers 20696 } 20697 }, 20698 updateMarkers: function() { 20699 this._markerGroup.clearLayers(); 20700 this._initMarkers() 20701 }, 20702 _initMarkers: function() { 20703 if (!this._markerGroup) { 20704 this._markerGroup = new L.LayerGroup() 20705 } 20706 this._markers = []; 20707 var latlngs = this._poly._latlngs, 20708 i, j, len, marker; 20709 for (i = 0, len = latlngs.length; i < len; i++) { 20710 marker = this._createMarker(latlngs[i], i); 20711 marker.on('click', this._onMarkerClick, this); 20712 this._markers.push(marker) 20713 } 20714 var markerLeft, markerRight; 20715 for (i = 0, j = len - 1; i < len; j = i++) { 20716 if (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) { 20717 continue 20718 } 20719 markerLeft = this._markers[j]; 20720 markerRight = this._markers[i]; 20721 this._createMiddleMarker(markerLeft, markerRight); 20722 this._updatePrevNext(markerLeft, markerRight) 20723 } 20724 }, 20725 _createMarker: function(latlng, index) { 20726 var marker = new L.Marker(latlng, { 20727 draggable: true, 20728 icon: this.options.icon 20729 });
20730 marker._origLatLng = latlng; 20731 marker._index = index; 20732 marker.on('drag', this._onMarkerDrag, this); 20733 marker.on('dragend', this._fireEdit, this); 20734 this._markerGroup.addLayer(marker); 20735 return marker 20736 }, 20737 _removeMarker: function(marker) { 20738 var i = marker._index; 20739 this._markerGroup.removeLayer(marker); 20740 this._markers.splice(i, 1); 20741 this._poly.spliceLatLngs(i, 1); 20742 this._updateIndexes(i, -1); 20743 marker.off('drag', this._onMarkerDrag, this).off('dragend', this._fireEdit, this).off('click', this._onMarkerClick, this) 20744 }, 20745 _fireEdit: function() { 20746 this._poly.edited = true; 20747 this._poly.fire('edit') 20748 }, 20749 _onMarkerDrag: function(e) { 20750 var marker = e.target; 20751 L.extend(marker._origLatLng, marker._latlng); 20752 if (marker._middleLeft) { 20753 marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker)) 20754 } 20755 if (marker._middleRight) { 20756 marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next)) 20757 } 20758 this._poly.redraw() 20759 }, 20760 _onMarkerClick: function(e) { 20761 if (this._poly._latlngs.length < 3) { 20762 return 20763 } 20764 var marker = e.target; 20765 this._removeMarker(marker); 20766 this._updatePrevNext(marker._prev, marker._next); 20767 if (marker._middleLeft) { 20768 this._markerGroup.removeLayer(marker._middleLeft) 20769 } 20770 if (marker._middleRight) { 20771 this._markerGroup.removeLayer(marker._middleRight) 20772 } 20773 if (marker._prev && marker._next) { 20774 this._createMiddleMarker(marker._prev, marker._next) 20775 } else if (!marker._prev) { 20776 marker._next._middleLeft = null 20777 } else if (!marker._next) { 20778 marker._prev._middleRight = null 20779 } 20780 this._fireEdit() 20781 }, 20782 _updateIndexes: function(index, delta) { 20783 this._markerGroup.eachLayer(function(marker) { 20784 if (marker._index > index) { 20785 marker._index += delta 20786 } 20787 }) 20788 }, 20789 _createMiddleMarker: function(marker1, marker2) { 20790 var latlng = this._getMiddleLatLng(marker1, marker2), 20791 marker = this._createMarker(latlng), 20792 onClick, onDragStart, onDragEnd; 20793 marker.setOpacity(0.6); 20794 marker1._middleRight = marker2._middleLeft = marker; 20795 onDragStart = function() { 20796 var i = marker2._index; 20797 marker._index = i; 20798 marker.off('click', onClick, this).on('click', this._onMarkerClick, this); 20799 latlng.lat = marker.getLatLng().lat; 20800 latlng.lng = marker.getLatLng().lng; 20801 this._poly.spliceLatLngs(i, 0, latlng); 20802 this._markers.splice(i, 0, marker); 20803 marker.setOpacity(1); 20804 this._updateIndexes(i, 1); 20805 marker2._index++; 20806 this._updatePrevNext(marker1, marker); 20807 this._updatePrevNext(marker, marker2) 20808 }; 20809 onDragEnd = function() { 20810 marker.off('dragstart', onDragStart, this); 20811 marker.off('dragend', onDragEnd, this); 20812 this._createMiddleMarker(marker1, marker); 20813 this._createMiddleMarker(marker, marker2) 20814 }; 20815 onClick = function() { 20816 onDragStart.call(this); 20817 onDragEnd.call(this); 20818 this._fireEdit() 20819 }; 20820 marker.on('click', onClick, this).on('dragstart', onDragStart, this).on('dragend', onDragEnd, this); 20821 this._markerGroup.addLayer(marker) 20822 }, 20823 _updatePrevNext: function(marker1, marker2) { 20824 if (marker1) { 20825 marker1._next = marker2 20826 } 20827 if (marker2) { 20828 marker2._prev = marker1 20829 } 20830 }, 20831 _getMiddleLatLng: function(marker1, marker2) { 20832 var map = this._poly._map, 20833 p1 = map.latLngToLayerPoint(marker1.getLatLng()), 20834 p2 = map.latLngToLayerPoint(marker2.getLatLng()); 20835 return map.layerPointToLatLng(p1._add(p2)._divideBy(2)) 20836 } 20837}); 20838L.Polyline.addInitHook(function() { 20839 if (this.editing) { 20840 return 20841 } 20842 if (L.Edit.Poly) { 20843 this.editing = new L.Edit.Poly(this); 20844 if (this.options.editable) { 20845 this.editing.enable() 20846 } 20847 } 20848 this.on('add', function() { 20849 if (this.editing && this.editing.enabled()) { 20850 this.editing.addHooks() 20851 } 20852 }); 20853 this.on('remove', function() { 20854 if (this.editing && this.editing.enabled()) { 20855 this.editing.removeHooks() 20856 } 20857 }) 20858}); 20859L.Edit = L.Edit || {}; 20860L.Edit.Rectangle = L.Edit.SimpleShape.extend({ 20861 _createMoveMarker: function() { 20862 var bounds = this._shape.getBounds(), 20863 center = bounds.getCenter(); 20864 this._moveMarker = this._createMarker(center, this.options.moveIcon) 20865 }, 20866 _createResizeMarker: function() { 20867 var corners = this._getCorners(); 20868 this._resizeMarkers = []; 20869 for (var i = 0, l = corners.length; i < l; i++) { 20870 this._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon)); 20871 this._resizeMarkers[i]._cornerIndex = i 20872 } 20873 }, 20874 _onMarkerDragStart: function(e) { 20875 L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e); 20876 var corners = this._getCorners(), 20877 marker = e.target, 20878 currentCornerIndex = marker._cornerIndex; 20879 this._oppositeCorner = corners[(currentCornerIndex + 2) % 4]; 20880 this._toggleCornerMarkers(0, currentCornerIndex) 20881 }, 20882 _onMarkerDragEnd: function(e) { 20883 var marker = e.target, 20884 bounds, center; 20885 if (marker === this._moveMarker) { 20886 bounds = this._shape.getBounds(); 20887 center = bounds.getCenter(); 20888 marker.setLatLng(center) 20889 } 20890 this._toggleCornerMarkers(1); 20891 this._repositionCornerMarkers(); 20892 L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e) 20893 }, 20894 _move: function(newCenter) { 20895 var latlngs = this._shape.getLatLngs(), 20896 bounds = this._shape.getBounds(), 20897 center = bounds.getCenter(), 20898 offset, newLatLngs = []; 20899 for (var i = 0, l = latlngs.length; i < l; i++) { 20900 offset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng]; 20901 newLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]) 20902 } 20903 this._shape.setLatLngs(newLatLngs); 20904 this._repositionCornerMarkers() 20905 }, 20906 _resize: function(latlng) { 20907 var bounds; 20908 this._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner)); 20909 bounds = this._shape.getBounds(); 20910 this._moveMarker.setLatLng(bounds.getCenter()) 20911 }, 20912 _getCorners: function() { 20913 var bounds = this._shape.getBounds(), 20914 nw = bounds.getNorthWest(), 20915 ne = bounds.getNorthEast(), 20916 se = bounds.getSouthEast(),
20917 sw = bounds.getSouthWest(); 20918 return [nw, ne, se, sw] 20919 }, 20920 _toggleCornerMarkers: function(opacity) { 20921 for (var i = 0, l = this._resizeMarkers.length; i < l; i++) { 20922 this._resizeMarkers[i].setOpacity(opacity) 20923 } 20924 }, 20925 _repositionCornerMarkers: function() { 20926 var corners = this._getCorners(); 20927 for (var i = 0, l = this._resizeMarkers.length; i < l; i++) { 20928 this._resizeMarkers[i].setLatLng(corners[i]) 20929 } 20930 } 20931}); 20932L.Rectangle.addInitHook(function() { 20933 if (L.Edit.Rectangle) { 20934 this.editing = new L.Edit.Rectangle(this); 20935 if (this.options.editable) { 20936 this.editing.enable() 20937 } 20938 } 20939}); 20940L.EditToolbar.Delete = L.Handler.extend({ 20941 statics: { 20942 TYPE: 'remove' 20943 }, 20944 includes: L.Mixin.Events, 20945 initialize: function(map, options) { 20946 L.Handler.prototype.initialize.call(this, map); 20947 L.Util.setOptions(this, options); 20948 this._deletableLayers = this.options.featureGroup; 20949 if (!(this._deletableLayers instanceof L.FeatureGroup)) { 20950 throw new Error('options.featureGroup must be a L.FeatureGroup') 20951 } 20952 this.type = L.EditToolbar.Delete.TYPE 20953 }, 20954 enable: function() { 20955 if (this._enabled) { 20956 return 20957 } 20958 L.Handler.prototype.enable.call(this); 20959 this._deletableLayers.on('layeradd', this._enableLayerDelete, this).on('layerremove', this._disableLayerDelete, this); 20960 this.fire('enabled', { 20961 handler: this.type 20962 }) 20963 }, 20964 disable: function() { 20965 if (!this._enabled) { 20966 return 20967 } 20968 L.Handler.prototype.disable.call(this); 20969 this._deletableLayers.off('layeradd', this._enableLayerDelete, this).off('layerremove', this._disableLayerDelete, this); 20970 this.fire('disabled', { 20971 handler: this.type 20972 }) 20973 }, 20974 addHooks: function() { 20975 if (this._map) { 20976 this._deletableLayers.eachLayer(this._enableLayerDelete, this); 20977 this._deletedLayers = new L.layerGroup(); 20978 this._tooltip = new L.Tooltip(this._map); 20979 this._tooltip.updateContent({ 20980 text: L.drawLocal.edit.toolbar.remove.tooltip 20981 }); 20982 this._map.on('mousemove', this._onMouseMove, this) 20983 } 20984 }, 20985 removeHooks: function() { 20986 if (this._map) { 20987 this._deletableLayers.eachLayer(this._disableLayerDelete, this); 20988 this._deletedLayers = null; 20989 this._tooltip.dispose(); 20990 this._tooltip = null; 20991 this._map.off('mousemove', this._onMouseMove, this) 20992 } 20993 }, 20994 revertLayers: function() { 20995 this._deletedLayers.eachLayer(function(layer) { 20996 this._deletableLayers.addLayer(layer) 20997 }, this) 20998 }, 20999 save: function() { 21000 this._map.fire('draw:deleted', { 21001 layers: this._deletedLayers 21002 }) 21003 }, 21004 _enableLayerDelete: function(e) { 21005 var layer = e.layer || e.target || e; 21006 layer.on('click', this._removeLayer, this) 21007 }, 21008 _disableLayerDelete: function(e) { 21009 var layer = e.layer || e.target || e; 21010 layer.off('click', this._removeLayer, this); 21011 this._deletedLayers.removeLayer(layer) 21012 }, 21013 _removeLayer: function(e) { 21014 var layer = e.layer || e.target || e; 21015 this._deletableLayers.removeLayer(layer); 21016 this._deletedLayers.addLayer(layer) 21017 }, 21018 _onMouseMove: function(e) { 21019 this._tooltip.updatePosition(e.latlng) 21020 } 21021}); 21022L.EditToolbar.Edit = L.Handler.extend({ 21023 statics: { 21024 TYPE: 'edit' 21025 }, 21026 includes: L.Mixin.Events, 21027 initialize: function(map, options) { 21028 L.Handler.prototype.initialize.call(this, map); 21029 this._selectedPathOptions = options.selectedPathOptions; 21030 this._featureGroup = options.featureGroup; 21031 if (!(this._featureGroup instanceof L.FeatureGroup)) { 21032 throw new Error('options.featureGroup must be a L.FeatureGroup') 21033 } 21034 this._uneditedLayerProps = {}; 21035 this.type = L.EditToolbar.Edit.TYPE 21036 }, 21037 enable: function() { 21038 if (this._enabled) { 21039 return 21040 } 21041 L.Handler.prototype.enable.call(this); 21042 this._featureGroup.on('layeradd', this._enableLayerEdit, this).on('layerremove', this._disableLayerEdit, this); 21043 this.fire('enabled', { 21044 handler: this.type 21045 }) 21046 }, 21047 disable: function() { 21048 if (!this._enabled) { 21049 return 21050 } 21051 this.fire('disabled', { 21052 handler: this.type 21053 });
21054 this._featureGroup.off('layeradd', this._enableLayerEdit, this).off('layerremove', this._disableLayerEdit, this); 21055 L.Handler.prototype.disable.call(this) 21056 }, 21057 addHooks: function() { 21058 if (this._map) { 21059 this._featureGroup.eachLayer(this._enableLayerEdit, this); 21060 if (this._tooltip) { 21061 this._tooltip = new L.Tooltip(this._map); 21062 this._tooltip.updateContent({ 21063 text: L.drawLocal.edit.tooltip.text, 21064 subtext: L.drawLocal.edit.tooltip.subtext 21065 }); 21066 this._map.on('mousemove', this._onMouseMove, this) 21067 } 21068 } 21069 }, 21070 removeHooks: function() { 21071 if (this._map) { 21072 this._featureGroup.eachLayer(this._disableLayerEdit, this); 21073 this._uneditedLayerProps = {}; 21074 if (this._tooltip) { 21075 this._tooltip.dispose(); 21076 this._tooltip = null; 21077 this._map.off('mousemove', this._onMouseMove, this) 21078 } 21079 } 21080 }, 21081 revertLayers: function() { 21082 this._featureGroup.eachLayer(function(layer) { 21083 this._revertLayer(layer) 21084 }, this) 21085 }, 21086 save: function() { 21087 var editedLayers = new L.LayerGroup(); 21088 this._featureGroup.eachLayer(function(layer) { 21089 if (layer.edited) { 21090 editedLayers.addLayer(layer); 21091 layer.edited = false 21092 } 21093 }); 21094 this._map.fire('draw:edited', { 21095 layers: editedLayers 21096 }) 21097 }, 21098 _backupLayer: function(layer) { 21099 var id = L.Util.stamp(layer); 21100 if (!this._uneditedLayerProps[id]) { 21101 if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) { 21102 this._uneditedLayerProps[id] = { 21103 latlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs()) 21104 } 21105 } else if (layer instanceof L.Circle) { 21106 this._uneditedLayerProps[id] = { 21107 latlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()), 21108 radius: layer.getRadius() 21109 } 21110 } else { 21111 this._uneditedLayerProps[id] = { 21112 latlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()) 21113 } 21114 } 21115 } 21116 }, 21117 _revertLayer: function(layer) { 21118 var id = L.Util.stamp(layer); 21119 layer.edited = false; 21120 if (this._uneditedLayerProps.hasOwnProperty(id)) { 21121 if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) { 21122 layer.setLatLngs(this._uneditedLayerProps[id].latlngs) 21123 } else if (layer instanceof L.Circle) { 21124 layer.setLatLng(this._uneditedLayerProps[id].latlng); 21125 layer.setRadius(this._uneditedLayerProps[id].radius) 21126 } else { 21127 layer.setLatLng(this._uneditedLayerProps[id].latlng) 21128 } 21129 } 21130 }, 21131 _toggleMarkerHighlight: function(marker) { 21132 var icon = marker._icon; 21133 icon.style.display = 'none'; 21134 if (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) { 21135 L.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected'); 21136 this._offsetMarker(icon, -4) 21137 } else { 21138 L.DomUtil.addClass(icon, 'leaflet-edit-marker-selected'); 21139 this._offsetMarker(icon, 4) 21140 } 21141 icon.style.display = '' 21142 }, 21143 _offsetMarker: function(icon, offset) { 21144 var iconMarginTop = parseInt(icon.style.marginTop, 10) - offset, 21145 iconMarginLeft = parseInt(icon.style.marginLeft, 10) - offset; 21146 icon.style.marginTop = iconMarginTop + 'px'; 21147 icon.style.marginLeft = iconMarginLeft + 'px' 21148 }, 21149 _enableLayerEdit: function(e) { 21150 var layer = e.layer || e.target || e, 21151 pathOptions; 21152 this._backupLayer(layer); 21153 if (this._selectedPathOptions) { 21154 pathOptions = L.Util.extend({}, this._selectedPathOptions); 21155 if (layer instanceof L.Marker) { 21156 this._toggleMarkerHighlight(layer) 21157 } else { 21158 layer.options.previousOptions = layer.options; 21159 if (!(layer instanceof L.Circle) && !(layer instanceof L.Polygon) && !(layer instanceof L.Rectangle)) { 21160 pathOptions.fill = false 21161 } 21162 layer.setStyle(pathOptions) 21163 } 21164 } 21165 if (layer instanceof L.Marker) { 21166 layer.dragging.enable(); 21167 layer.on('dragend', this._onMarkerDragEnd) 21168 } else { 21169 layer.editing.enable() 21170 } 21171 }, 21172 _disableLayerEdit: function(e) { 21173 var layer = e.layer || e.target || e; 21174 layer.edited = false; 21175 if (this._selectedPathOptions) { 21176 if (layer instanceof L.Marker) { 21177 this._toggleMarkerHighlight(layer) 21178 } else { 21179 layer.setStyle(layer.options.previousOptions); 21180 delete layer.options.previousOptions 21181 } 21182 } 21183 if (layer instanceof L.Marker) { 21184 layer.dragging.disable(); 21185 layer.off('dragend', this._onMarkerDragEnd, this) 21186 } else { 21187 layer.editing.disable() 21188 } 21189 }, 21190 _onMarkerDragEnd: function(e) { 21191 var layer = e.target; 21192 layer.edited = true 21193 }, 21194 _onMouseMove: function(e) { 21195 this._tooltip.updatePosition(e.latlng) 21196 } 21197}); 21198L.EditToolbar.Degeocode = L.Handler.extend({ 21199 statics: { 21200 TYPE: 'degeocode' 21201 }, 21202 _encode: E.Util.encodeRepresentation, 21203 includes: L.Mixin.Events, 21204 initialize: function(map, options) { 21205 L.Handler.prototype.initialize.call(this, map); 21206 L.Util.setOptions(this, options);
21207 this._degeocodeLayers = this.options.featureGroup; 21208 if (!(this._degeocodeLayers instanceof L.FeatureGroup)) { 21209 throw new Error('options.featureGroup must be a L.FeatureGroup') 21210 } 21211 this.type = L.EditToolbar.Degeocode.TYPE 21212 }, 21213 enable: function() { 21214 if (this._enabled) { 21215 return 21216 } 21217 L.Handler.prototype.enable.call(this); 21218 this.fire('enabled', { 21219 handler: this.type 21220 }) 21221 }, 21222 disable: function() { 21223 if (!this._enabled) { 21224 return 21225 } 21226 L.Handler.prototype.disable.call(this); 21227 this.fire('disabled', { 21228 handler: this.type 21229 }) 21230 }, 21231 addHooks: function() { 21232 if (this._map) { 21233 this._degeocodeLayers.eachLayer(this._enableLayerDegeocode, this); 21234 this._tooltip = new L.Tooltip(this._map); 21235 this._tooltip.updateContent({ 21236 text: L.drawLocal.edit.toolbar.degeocode.tooltip 21237 }); 21238 this._map.on('mousemove', this._onMouseMove, this) 21239 } 21240 }, 21241 removeHooks: function() { 21242 if (this._map) { 21243 this._degeocodeLayers.eachLayer(this._disableLayerDegeocode, this); 21244 this._tooltip.dispose(); 21245 this._tooltip = null; 21246 this._map.off('mousemove', this._onMouseMove, this) 21247 } 21248 }, 21249 revertLayers: function() {}, 21250 _enableLayerDegeocode: function(e) { 21251 var layer = e.layer || e.target || e; 21252 layer.on('click', this._degeocodeLayer, this) 21253 }, 21254 _disableLayerDegeocode: function(e) { 21255 var layer = e.layer || e.target || e; 21256 layer.off('click', this._degeocodeLayer, this) 21257 }, 21258 _onMouseMove: function(e) { 21259 this._tooltip.updatePosition(e.latlng) 21260 }, 21261 _degeocodeLayer: function(e) { 21262 var layer = e.layer || e.target || e; 21263 this._map.shapeDegeocodeGeometry({
21264 zoom: this._map.getZoom(), 21265 geometry: [this._encode(layer.getLatLngs(), 5)] 21266 }, this._onDone, this); 21267 this._overlay = E.Overlay.showMessage("Wait for data") 21268 }, 21269 _onDone: function(a) { 21270 var c = '', 21271 b = a.items.split(','); 21272 for (a = 0; a < b.length; a++) { 21273 c += b[a] + "\n" 21274 } 21275 this._overlay.hide(); 21276 this._overlay = E.Overlay.showMessage("<textarea rows='24' cols='50'>" + c + "</textarea>") 21277 } 21278}); 21279L.LatLngUtil = { 21280 cloneLatLngs: function(latlngs) { 21281 var clone = []; 21282 for (var i = 0, l = latlngs.length; i < l; i++) { 21283 clone.push(this.cloneLatLng(latlngs[i])) 21284 } 21285 return clone 21286 }, 21287 cloneLatLng: function(latlng) { 21288 return L.latLng(latlng.lat, latlng.lng) 21289 } 21290}; 21291L.Util.extend(L.LineUtil, { 21292 segmentsIntersect: function(p, p1, p2, p3) { 21293 return this._checkCounterclockwise(p, p2, p3) !== this._checkCounterclockwise(p1, p2, p3) && this._checkCounterclockwise(p, p1, p2) !== this._checkCounterclockwise(p, p1, p3) 21294 }, 21295 _checkCounterclockwise: function(p, p1, p2) { 21296 return (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x) 21297 } 21298}); 21299L.Polygon.include({ 21300 intersects: function() { 21301 var polylineIntersects, points = this._originalPoints, 21302 len, firstPoint, lastPoint, maxIndex; 21303 if (this._tooFewPointsForIntersection()) { 21304 return false 21305 } 21306 polylineIntersects = L.Polyline.prototype.intersects.call(this); 21307 if (polylineIntersects) { 21308 return true 21309 } 21310 len = points.length; 21311 firstPoint = points[0]; 21312 lastPoint = points[len - 1]; 21313 maxIndex = len - 2; 21314 return this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1) 21315 } 21316}); 21317L.PolygonUtil = { 21318 geodesicArea: function(latLngs) { 21319 var pointsCount = latLngs.length, 21320 area = 0.0, 21321 d2r = L.LatLng.DEG_TO_RAD, 21322 p1, p2; 21323 if (pointsCount > 2) { 21324 for (var i = 0; i < pointsCount; i++) { 21325 p1 = latLngs[i]; 21326 p2 = latLngs[(i + 1) % pointsCount]; 21327 area += ((p2.lng - p1.lng) * d2r) * (2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r)) 21328 } 21329 area = area * 6378137.0 * 6378137.0 / 2.0 21330 } 21331 return Math.abs(area) 21332 } 21333}; 21334L.Polyline.include({ 21335 intersects: function() { 21336 var points = this._originalPoints, 21337 len = points ? points.length : 0, 21338 i, p, p1; 21339 if (this._tooFewPointsForIntersection()) { 21340 return false 21341 } 21342 for (i = len - 1; i >= 3; i--) { 21343 p = points[i - 1]; 21344 p1 = points[i]; 21345 if (this._lineSegmentsIntersectsRange(p, p1, i - 2)) { 21346 return true 21347 } 21348 } 21349 return false 21350 }, 21351 newLatLngIntersects: function(latlng, skipFirst) { 21352 if (!this._map) { 21353 return false 21354 } 21355 return this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst) 21356 }, 21357 newPointIntersects: function(newPoint, skipFirst) { 21358 var points = this._originalPoints, 21359 len = points ? points.length : 0, 21360 lastPoint = points ? points[len - 1] : null, 21361 maxIndex = len - 2; 21362 if (this._tooFewPointsForIntersection(1)) { 21363 return false 21364 } 21365 return this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0) 21366 }, 21367 _tooFewPointsForIntersection: function(extraPoints) { 21368 var points = this._originalPoints, 21369 len = points ? points.length : 0; 21370 len += extraPoints || 0; 21371 return !this._originalPoints || len <= 3 21372 }, 21373 _lineSegmentsIntersectsRange: function(p, p1, maxIndex, minIndex) { 21374 var points = this._originalPoints, 21375 p2, p3; 21376 minIndex = minIndex || 0; 21377 for (var j = maxIndex; j > minIndex; j--) { 21378 p2 = points[j - 1]; 21379 p3 = points[j]; 21380 if (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) { 21381 return true 21382 } 21383 } 21384 return false 21385 } 21386});
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.