Leaflet/dist/leaflet.js

6 lines
81 KiB
JavaScript
Raw Normal View History

2010-09-23 20:56:29 +08:00
/*
2011-03-31 17:05:35 +08:00
Copyright (c) 2010-2011, CloudMade, Vladimir Agafonkin
2011-12-13 04:10:29 +08:00
Leaflet is a modern open-source JavaScript library for interactive maps.
http://leaflet.cloudmade.com
2010-09-23 20:56:29 +08:00
*/
(function(a){a.L={VERSION:"0.3",ROOT_URL:a.L_ROOT_URL||function(){var a=document.getElementsByTagName("script"),b=/\/?leaflet[\-\._]?([\w\-\._]*)\.js\??/,c,d,e,f;for(c=0,d=a.length;c<d;c++){e=a[c].src,f=e.match(b);if(f)return f[1]==="include"?"../../dist/":e.replace(b,"")+"/"}return""}(),noConflict:function(){return a.L=this._originalL,this},_originalL:a.L}})(this),L.Util={extend:function(a){var b=Array.prototype.slice.call(arguments,1);for(var c=0,d=b.length,e;c<d;c++){e=b[c]||{};for(var f in e)e.hasOwnProperty(f)&&(a[f]=e[f])}return a},bind:function(a,b){return function(){return a.apply(b,arguments)}},stamp:function(){var a=0,b="_leaflet_id";return function(c){return c[b]=c[b]||++a,c[b]}}(),requestAnimFrame:function(){function a(a){window.setTimeout(a,1e3/60)}var b=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||a;return function(c,d,e,f){c=d?L.Util.bind(c,d):c,e&&b===a?c():b(c,f)}}(),limitExecByInterval:function(a,b,c){function g(){d=!1,e&&(f.callee.apply(c,f),e=!1)}var d,e,f;return function(){f=arguments,d?e=!0:(d=!0,setTimeout(g,b),a.apply(c,f))}},falseFn:function(){return!1},formatNum:function(a,b){var c=Math.pow(10,b||5);return Math.round(a*c)/c},setOptions:function(a,b){a.options=L.Util.extend({},a.options,b)},getParamString:function(a){var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c+"="+a[c]);return"?"+b.join("&")},template:function(a,b){return a.replace(/\{ *([\w_]+) *\}/g,function(a,c){var d=b[c];if(!b.hasOwnProperty(c))throw Error("No value provided for variable "+a);return d})}},L.Class=function(){},L.Class.extend=function(a){var b=function(){this.initialize&&this.initialize.apply(this,arguments)},c=function(){};c.prototype=this.prototype;var d=new c;d.constructor=b,b.prototype=d,b.superclass=this.prototype;for(var e in this)this.hasOwnProperty(e)&&e!=="prototype"&&e!=="superclass"&&(b[e]=this[e]);return a.statics&&(L.Util.extend(b,a.statics),delete a.statics),a.includes&&(L.Util.extend.apply(null,[d].concat(a.includes)),delete a.includes),a.options&&d.options&&(a.options=L.Util.extend({},d.options,a.options)),L.Util.extend(d,a),b.extend=L.Class.extend,b.include=function(a){L.Util.extend(this.prototype,a)},b},L.Mixin={},L.Mixin.Events={addEventListener:function(a,b,c){var d=this._leaflet_events=this._leaflet_events||{};return d[a]=d[a]||[],d[a].push({action:b,context:c||this}),this},hasEventListeners:function(a){var b="_leaflet_events";return b in this&&a in this[b]&&this[b][a].length>0},removeEventListener:function(a,b,c){if(!this.hasEventListeners(a))return this;for(var d=0,e=this._leaflet_events,f=e[a].length;d<f;d++)if(e[a][d].action===b&&(!c||e[a][d].context===c))return e[a].splice(d,1),this;return this},fireEvent:function(a,b){if(!this.hasEventListeners(a))return this;var c=L.Util.extend({type:a,target:this},b),d=this._leaflet_events[a].slice();for(var e=0,f=d.length;e<f;e++)d[e].action.call(d[e].context||this,c);return this}},L.Mixin.Events.on=L.Mixin.Events.addEventListener,L.Mixin.Events.off=L.Mixin.Events.removeEventListener,L.Mixin.Events.fire=L.Mixin.Events.fireEvent,function(){var a=navigator.userAgent.toLowerCase(),b=!!window.ActiveXObject,c=a.indexOf("webkit")!==-1,d=typeof orientation!="undefined"?!0:!1,e=a.indexOf("android")!==-1,f=window.opera;L.Browser={ie:b,ie6:b&&!window.XMLHttpRequest,webkit:c,webkit3d:c&&"WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix,gecko:a.indexOf("gecko")!==-1,opera:f,android:e,mobileWebkit:d&&c,mobileOpera:d&&f,mobile:d,touch:function(){var a=!1,b="ontouchstart";if(b in document.documentElement)return!0;var c=document.createElement("div");return!c.setAttribute||!c.removeAttribute?!1:(c.setAttribute(b,"return;"),typeof c[b]=="function"&&(a=!0),c.removeAttribute(b),c=null,a)}()}}(),L.Point=function(a,b,c){this.x=c?Math.round(a):a,this.y=c?Math.round(b):b},L.Point.prototype={add:function(a){return this.clone()._add(a)},_add:function(a){return this.x+=a.x,this.y+=a.y,this},subtract:function(a){return this.clone()._subtract(a)},_subtra