Leaflet/dist/leaflet.js

6 lines
91 KiB
JavaScript
Raw Normal View History

2010-09-23 20:56:29 +08:00
/*
2012-02-13 22:25:57 +08:00
Copyright (c) 2010-2012, 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
*/
2012-06-18 17:10:20 +08:00
(function(){var a,b;typeof exports!="undefined"?a=exports:(a={},b=window.L,a.noConflict=function(){return window.L=b,a},window.L=a),a.version="0.4",a.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){var c=arguments.length>2?Array.prototype.slice.call(arguments,2):null;return function(){return a.apply(b,c||arguments)}},stamp:function(){var a=0,b="_leaflet_id";return function(c){return c[b]=c[b]||++a,c[b]}}(),requestAnimFrame:function(){function b(a){window.setTimeout(a,1e3/60)}var c=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||b;return function(d,e,f,g){d=e?a.Util.bind(d,e):d;if(!f||c!==b)return c.call(window,d,g);d()}}(),cancelAnimFrame:function(){var a=window.cancelAnimationFrame||window.webkitCancelRequestAnimationFrame||window.mozCancelRequestAnimationFrame||window.oCancelRequestAnimationFrame||window.msCancelRequestAnimationFrame||clearTimeout;return function(b){if(!b)return;return a.call(window,b)}}(),limitExecByInterval:function(a,b,c){var d,e;return function f(){var g=arguments;if(d){e=!0;return}d=!0,setTimeout(function(){d=!1,e&&(f.apply(c,g),e=!1)},b),a.apply(c,g)}},falseFn:function(){return!1},formatNum:function(a,b){var c=Math.pow(10,b||5);return Math.round(a*c)/c},setOptions:function(b,c){return b.options=a.Util.extend({},b.options,c),b.options},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})},emptyImageUrl:"data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs="},a.Class=function(){},a.Class.extend=function(b){var c=function(){this.initialize&&this.initialize.apply(this,arguments)},d=function(){};d.prototype=this.prototype;var e=new d;e.constructor=c,c.prototype=e;for(var f in this)this.hasOwnProperty(f)&&f!=="prototype"&&(c[f]=this[f]);return b.statics&&(a.Util.extend(c,b.statics),delete b.statics),b.includes&&(a.Util.extend.apply(null,[e].concat(b.includes)),delete b.includes),b.options&&e.options&&(b.options=a.Util.extend({},e.options,b.options)),a.Util.extend(e,b),c},a.Class.include=function(b){a.Util.extend(this.prototype,b)},a.Class.mergeOptions=function(b){a.Util.extend(this.prototype.options,b)},a.Mixin={},a.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(b,c){if(!this.hasEventListeners(b))return this;var d=a.Util.extend({type:b,target:this},c),e=this._leaflet_events[b].slice();for(var f=0,g=e.length;f<g;f++)e[f].action.call(e[f].context||this,d);return this}},a.Mixin.Events.on=a.Mixin.Events.addEventListener,a.Mixin.Events.off=a.Mixin.Events.removeEventListener,a.Mixin.Events.fire=a.Mixin.Events.fireEvent,function(){var b=navigator.userAgent.toLowerCase(),c=!!window.ActiveXObject,d=b.indexOf("webkit")!==-1,e=typeof orientation!="undefined"?!0:!1,f=b.indexOf("android")!==-1,g=window.opera;a.Browser={ie:c,ie6:c&&!window.XMLHttpRequest,webkit:d,webkit3d:d&&"WebKitCSSMatrix"in window&&"m11"in new window.WebKitCSSMatrix,gecko:b.indexOf("gecko")!==-1,opera:g,android:f,mobileWebkit:e&&d,mobileOpera:e&&g,mobile:e,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),