gnu-social/plugins/Mapstraction/usermap-mxn-openlayers.min.js

1 line
34 KiB
JavaScript
Raw Normal View History

(function(){var h=null;var e="core";var b;var a=document.getElementsByTagName("script");for(var f=0;f<a.length;f++){var d=a[f].src.replace(/%20/g,"").match(/^(.*?)mxn\.js(\?\(\[?(.*?)\]?\))?$/);if(d!=null){b=d[1];if(d[3]){var g=d[3].split(",[");h=g[0].replace("]","");if(g[1]){e+=","+g[1]}}break}}if(h==null||h=="none"){return}h=h.replace(/ /g,"").split(",");e=e.replace(/ /g,"").split(",");for(f=0;f<e.length;f++){document.write("<script type='text/javascript' src='"+b+"mxn."+e[f]+".js'><\/script>");for(var c=0;c<h.length;c++){document.write("<script type='text/javascript' src='"+b+"mxn."+h[c]+"."+e[f]+".js'><\/script>")}}})();(function(){var c={};var b=function(i,h,g,e,f){if(!d(i,h,g)){throw"Method "+g+" of object "+h+" is not supported by API "+i+". Are you missing a script tag?"}return c[i][h][g].apply(e,f)};var d=function(g,f,e){if(typeof(c[g])=="undefined"){throw"API "+g+" not loaded. Are you missing a script tag?"}if(typeof(c[g][f])=="undefined"){throw"Object definition "+f+" in API "+g+" not loaded. Are you missing a script tag?"}return typeof(c[g][f][e])=="function"};var a=window.mxn={register:function(f,e){if(!c.hasOwnProperty(f)){c[f]={}}a.util.merge(c[f],e)},addProxyMethods:function(g,k,f){for(var e=0;e<k.length;e++){var h=k[e];if(f){g.prototype[h]=new Function("return this.invoker.go('"+h+"', arguments, { overrideApi: true } );")}else{g.prototype[h]=new Function("return this.invoker.go('"+h+"', arguments);")}}},addEvents:function(f,h){for(var e=0;e<h.length;e++){var g=h[e];if(g in f){throw"Event or method "+g+" already declared."}f[g]=new a.Event(g,f)}}};a.Event=function(g,f){var e=[];if(!g){throw"Event name must be provided"}this.addHandler=function(i,h){e.push({context:h,handler:i})};this.removeHandler=function(l,h){for(var k=0;k<e.length;k++){if(e[k].handler==l&&e[k].context==h){e.splice(k,1)}}};this.removeAllHandlers=function(){e=[]};this.fire=function(l){var h=[g,f,l];for(var k=0;k<e.length;k++){e[k].handler.apply(e[k].context,h)}}};a.Invoker=function(g,h,l){var k=g;var f=h;var e=l;var i={overrideApi:false,context:null,fallback:null};this.go=function(p,n,m){if(typeof(m)=="undefined"){m=i}var o=m.overrideApi?n[0]:e.apply(k);if(typeof(o)!="string"){throw"API ID not available."}if(typeof(m.context)!="undefined"&&m.context!==null){n=Array.prototype.slice.apply(n);n.push(m.context)}if(typeof(m.fallback)=="function"&&!d(o,f,p)){return m.fallback.apply(k,n)}else{return b(o,f,p,k,n)}}};a.util={merge:function(g,e){for(var f in e){if(e.hasOwnProperty(f)){if(!g.hasOwnProperty(f)){g[f]=e[f]}else{a.util.merge(g[f],e[f])}}}},$m:function(){var g=[];for(var f=0;f<arguments.length;f++){var e=arguments[f];if(typeof(e)=="string"){e=document.getElementById(e)}if(arguments.length==1){return e}g.push(e)}return g},loadScript:function(i,k){var f=document.createElement("script");f.type="text/javascript";f.src=i;if(k){if(f.addEventListener){f.addEventListener("load",k,true)}else{if(f.attachEvent){var e=false;f.attachEvent("onreadystatechange",function(){if(!e&&document.readyState==="complete"){e=true;k()}})}}}var g=document.getElementsByTagName("head")[0];g.appendChild(f);return},convertLatLonXY_Yahoo:function(e,m){var h=1<<(26-m);var k=h/360;var l=h/(2*Math.PI);var g=new YCoordPoint(h/2,h/2);var i=new YCoordPoint();i.x=Math.floor(g.x+e.lon*k);var f=Math.sin(e.lat*Math.PI/180);i.y=Math.floor(g.y+0.5*Math.log((1+f)/(1-f))*-l);return i},loadStyle:function(e){var f=document.createElement("link");f.type="text/css";f.rel="stylesheet";f.href=e;document.getElementsByTagName("head")[0].appendChild(f);return},getStyle:function(e,g){var f;if(e.currentStyle){f=e.currentStyle[g]}else{if(window.getComputedStyle){f=window.getComputedStyle(e,"").getPropertyValue(g)}}return f},lonToMetres:function(f,e){return f*(111200*Math.cos(e*(Math.PI/180)))},metresToLon:function(e,f){return e/(111200*Math.cos(f*(Math.PI/180)))},KMToMiles:function(e){return e/1.609344},milesToKM:function(e){return e*1.609344},getDegreesFromGoogleZoomLevel:function(f,e){return(360*f)/(Math.pow(2,e+8))},getGoogleZoomLevelFromDegrees:function(f,e){return a.util.logN((360*f)/e,2)-