Skip to content
Browse files

Fix regression.

  • Loading branch information...
1 parent ec6559f commit 415662519b3b33a2d98b0a810af284fdbc320aaf @tmcw tmcw committed
Showing with 7 additions and 7 deletions.
  1. +1 −1 control/lib/gridutil.js
  2. +1 −1 dist/wax.g.js
  3. +1 −1 dist/wax.g.min.js
  4. +1 −1 dist/wax.mm.js
  5. +1 −1 dist/wax.mm.min.js
  6. +1 −1 dist/wax.ol.js
  7. +1 −1 dist/wax.ol.min.js
View
2 control/lib/gridutil.js
@@ -93,7 +93,7 @@ wax.GridInstance.prototype.getFeature = function(x, y, tile_element, options) {
// If this layers formatter hasn't been loaded yet,
// download and load it now.
if (this.grid_tile.keys[key] && this.grid_tile.data[this.grid_tile.keys[key]]) {
- return this.formatter.format(options, data_val);
+ return this.formatter.format(options, this.grid_tile.data[this.grid_tile.keys[key]]);
}
};
View
2 dist/wax.g.js
@@ -299,7 +299,7 @@ wax.GridInstance.prototype.getFeature = function(x, y, tile_element, options) {
// If this layers formatter hasn't been loaded yet,
// download and load it now.
if (this.grid_tile.keys[key] && this.grid_tile.data[this.grid_tile.keys[key]]) {
- return this.formatter.format(options, data_val);
+ return this.formatter.format(options, this.grid_tile.data[this.grid_tile.keys[key]]);
}
};
View
2 dist/wax.g.min.js
@@ -5,4 +5,4 @@
* copyright Dustin Diaz 2011
* https://github.com/ded/reqwest
* license MIT
- */!function(window){function readyState(a,b,c){return function(){a&&a.readyState==4&&(twoHundo.test(a.status)?b(a):c(a))}}function setHeaders(a,b){var c=b.headers||{};c.Accept="text/javascript, text/html, application/xml, text/xml, */*",c["X-Requested-With"]=c["X-Requested-With"]||"XMLHttpRequest";if(b.data){c["Content-type"]="application/x-www-form-urlencoded";for(var d in c)c.hasOwnProperty(d)&&a.setRequestHeader(d,c[d],!1)}}function getCallbackName(a){var b=a.jsonpCallback||"callback";if(a.url.slice(-(b.length+2))==b+"=?"){var c="reqwest_"+uniqid++;a.url=a.url.substr(0,a.url.length-1)+c;return c}var d=new RegExp(b+"=([\\w]+)");return a.url.match(d)[1]}function generalCallback(a){lastValue=a}function getRequest(a,b,c){if(a.type!="jsonp"){var d=xhr();d.open(a.method||"GET",typeof a=="string"?a:a.url,!0),setHeaders(d,a),d.onreadystatechange=readyState(d,b,c),a.before&&a.before(d),d.send(a.data||null);return d}var e=doc.createElement("script");window[getCallbackName(a)]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0;var f=function(){a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e)};e.onload=f,e.onreadystatechange=function(){e.readyState=="loaded"||e.readyState=="complete"&&f()},head.appendChild(e)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){if(/\.json$/.test(a))return"json";if(/\.jsonp$/.test(a))return"jsonp";if(/\.js$/.test(a))return"js";if(/\.html?$/.test(a))return"html";if(/\.xml$/.test(a))return"xml";return"js"}function init(o,fn){function complete(a){o.complete&&o.complete(a)}function success(resp){o.timeout&&clearTimeout(self.timeout)&&(self.timeout=null);var r=resp.responseText;switch(type){case"json":resp=eval("("+r+")");break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.success&&o.success(resp),complete(resp)}function error(a){o.error&&o.error(a),complete(a)}this.url=typeof o=="string"?o:o.url,this.timeout=null;var type=o.type||setType(this.url),self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort(),error()},o.timeout)),this.request=getRequest(o,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function enc(a){return encodeURIComponent(a)}function serial(a){var b=a.name;if(a.disabled||!b)return"";b=enc(b);switch(a.tagName.toLowerCase()){case"input":switch(a.type){case"reset":case"button":case"image":case"file":return"";case"checkbox":case"radio":return a.checked?b+"="+(a.value?enc(a.value):!0)+"&":"";default:return b+"="+(a.value?enc(a.value):!0)+"&"}break;case"textarea":return b+"="+enc(a.value)+"&";case"select":return b+"="+enc(a.options[a.selectedIndex].value)+"&"}return""}var twoHundo=/^20\d$/,doc=document,byTag="getElementsByTagName",head=doc[byTag]("head")[0],xhr="XMLHttpRequest"in window?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")},uniqid=0,lastValue;Reqwest.prototype={abort:function(){this.request.abort()},retry:function(){init.call(this,this.o,this.fn)}},reqwest.serialize=function(a){var b=a[byTag]("input"),c=a[byTag]("select"),d=a[byTag]("textarea");return(v(b).chain().toArray().map(serial).value().join("")+v(c).chain().toArray().map(serial).value().join("")+v(d).chain().toArray().map(serial).value().join("")).replace(/&$/,"")},reqwest.serializeArray=function(a){for(var b=this.serialize(a).split("&"),c=0,d=b.length,e=[],f;c<d;c++)b[c]&&(f=b[c].split("="))&&e.push({name:f[0],value:f[1]});return e};var old=window.reqwest;reqwest.noConflict=function(){window.reqwest=old;return this},window.reqwest=reqwest}(this);var wax=wax||{};Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(typeof a!="function")throw new TypeError;if(c==0&&arguments.length==1)throw new TypeError;var d=0,e;if(arguments.length>=2)e=arguments[1];else do{if(d in b){e=b[d++];break}if(++d>=c)throw new TypeError}while(!0);while(d<c)d in b&&(e=a.call(undefined,e,b[d],d,b)),d++;return e}),wax.Record=function(a,b){var c=function(a,b){var c=a.split(".").reduce(function(a,b){return[a[1]||a[0],a[1]?a[1][b]:a[0][b]]},[b||window,null]);if(c[0]&&c[1])return c;throw a+" not found."},d=function(a,b){var d=c(a),e;b=b.length?wax.Record(b):[];if(Object.create)e=Object.create(d[1].prototype),d[1].apply(e,b);else switch(b.length){case 0:e=new d[1];break;case 1:e=new d[1](b[0]);break;case 2:e=new d[1](b[0],b[1]);break;case 3:e=new d[1](b[0],b[1],b[2]);break;case 4:e=new d[1](b[0],b[1],b[2],b[3]);break;case 5:e=new d[1](b[0],b[1],b[2],b[3],b[4]);break;default:}return e},e=function(a,b,d){var e=c(a,d),f=b.length?wax.Record(b):[];return d&&a.indexOf(".")===-1?e[1].apply(d,f):e[1].apply(e[0],f)},f=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@literal","@chain","@inject","@group"],a.split(" ")[0])!==-1},g=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@chain"],a.split(" ")[0])!==-1},h=function(a){if(wax.util.isArray(a)&&a[0]&&f(a[0]))return{verb:a[0].split(" ")[0],subject:a[0].split(" ")[1],object:a.slice(1)};return!1},i,j=!1,k=null,l=null,m=h(a);if(!m){if(a!==null&&typeof a=="object"){var n=wax.util.keys(a);for(i=0;i<n.length;i++){var o=n[i];a[o]=wax.Record(a[o],b)}return a}return a}switch(m.verb){case"@group":for(i=0;i<m.object.length;i++)k=wax.Record(m.object[i],b),l=h(m.object[i]),l&&g(l.verb)&&(b=k);return b;case"@new":return d(m.subject,m.object);case"@literal":j=c(m.subject);return j?j[1]:null;case"@inject":return e(m.subject,m.object,b);case"@chain":return e(m.subject,m.object,b);case"@call":return e(m.subject,m.object,null)}};var wax=wax||{};wax.request={cache:{},locks:{},promises:{},get:function(a,b){if(this.cache[a])return b(this.cache[a][0],this.cache[a][1]);this.promises[a]=this.promises[a]||[],this.promises[a].push(b);if(!this.locks[a]){var c=this;this.locks[a]=!0,reqwest({url:a+"?callback=grid",type:"jsonp",jsonpCallback:"callback",success:function(b){c.locks[a]=!1,c.cache[a]=[null,b];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])},error:function(b){c.locks[a]=!1,c.cache[a]=[b,null];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])}})}}},wax.GridInstance=function(a,b){this.grid_tile=a,this.formatter=b,this.tileRes=4},wax.GridInstance.prototype.resolveCode=function(a){a>=93&&a--,a>=35&&a--,a-=32;return a},wax.GridInstance.prototype.getFeature=function(a,b,c,d){if(!!this.grid_tile&&!!this.grid_tile.grid){var e=wax.util.offset(c),f=e.left,g=e.top;if(b-g<0)return;if(a-f<0)return;if(Math.floor((b-g)/this.tileRes)>256)return;if(Math.floor((a-f)/this.tileRes)>256)return;var h=this.grid_tile.grid[Math.floor((b-g)/this.tileRes)].charCodeAt(Math.floor((a-f)/this.tileRes));h=this.resolveCode(h);if(this.grid_tile.keys[h]&&this.grid_tile.data[this.grid_tile.keys[h]])return this.formatter.format(d,data_val)}},wax.GridManager=function(){this.grid_tiles={},this.key_maps={},this.formatters={},this.locks={}},wax.GridManager.prototype.getGrid=function(a,b){var c=this;c.getFormatter(c.formatterUrl(a),function(d,e){if(d||!e)return b(d,null);wax.request.get(c.tileDataUrl(a),function(a,c){if(a)return b(a,null);b(null,new wax.GridInstance(c,e))})})},wax.GridManager.prototype.tileDataUrl=function(a){return a.replace(/(\.png|\.jpg|\.jpeg)(\d*)/,".grid.json")},wax.GridManager.prototype.formatterUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")},wax.GridManager.prototype.getFormatter=function(a,b){var c=this;typeof this.formatters[a]!="undefined"?b(null,this.formatters[a]):wax.request.get(a,function(d,e){e&&e.formatter?c.formatters[a]=new wax.Formatter(e):c.formatters[a]=!1,b(d,c.formatters[a])})},wax.Formatter=function(obj){if(obj.formatter&&typeof obj.formatter=="string")try{eval("this.f = "+obj.formatter)}catch(e){console&&console.log(e)}else this.f=function(){}},wax.Formatter.prototype.format=function(a,b){try{return this.f(a,b)}catch(c){console&&console.log(c)}};var wax=wax||{};wax.Legend=function(a,b){this.legends={},this.context=a,this.container=b,this.container||(this.container=document.createElement("div"),this.container.className="wax-legends"),this.context.appendChild(this.container)},wax.Legend.prototype.render=function(a){var b;for(b in this.legends)this.legends[b].style.display="none";var c=wax.util.bind(function(a,b){b?this.legends[a]?this.legends[a].style.display="block":(this.legends[a]=document.createElement("div"),this.legends[a].className="wax-legend",this.legends[a].innerHTML=b,this.container.appendChild(this.legends[a])):this.legends[a]=!1},this);for(var d=0;d<a.length;d++)b=this.legendUrl(a[d]),wax.request.get(b,function(a,d){d&&d.legend&&c(b,d.legend)})},wax.Legend.prototype.legendUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")};var w=function(a){a.melt=function(b,c){b.apply(c,[a,c]);return a};return a},wax=wax||{};wax.tooltip={},wax.tooltip=function(a){this._currentTooltip=undefined,a=a||{},a.animationOut&&(this.animationOut=a.animationOut),a.animationIn&&(this.animationIn=a.animationIn)},wax.tooltip.prototype.isPopup=function(a){return a&&a.className.indexOf("wax-popup")!==-1},wax.tooltip.prototype.getTooltip=function(a,b,c,d){tooltip=document.createElement("div"),tooltip.className="wax-tooltip wax-tooltip-"+c,tooltip.innerHTML=a,b.appendChild(tooltip);return tooltip},wax.tooltip.prototype.hideTooltip=function(a){if(!!a){var b,c=function(){this.parentNode.removeChild(this)};a.style["-webkit-transition"]!==undefined&&this.animationOut?b="webkitTransitionEnd":a.style.MozTransition!==undefined&&this.animationOut&&(b="transitionend"),b?(a.addEventListener(b,c,!1),a.addEventListener("transitionend",c,!1),a.className+=" "+this.animationOut):a.parentNode.removeChild(a)}},wax.tooltip.prototype.click=function(a,b,c){this.unselect(b);var d=this.getTooltip(a,b,c),e=document.createElement("a");e.href="#close",e.className="close",e.innerHTML="Close";var f=wax.util.bind(function(a){this.hideTooltip(d),this._currentTooltip=undefined,a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault();return!1},this);e.addEventListener?e.addEventListener("click",f,!1):e.attachEvent&&e.attachEvent("onclick",f),d.className+=" wax-popup",d.innerHTML=a,d.appendChild(e),this._currentTooltip=d},wax.tooltip.prototype.select=function(a,b,c,d){if(!!a){if(this.isPopup(this._currentTooltip))return;this._currentTooltip=this.getTooltip(a,b,c,d),b.style.cursor="pointer"}},wax.tooltip.prototype.unselect=function(a){this.isPopup(this._currentTooltip)||(a.style.cursor="default",this._currentTooltip&&(this.hideTooltip(this._currentTooltip),this._currentTooltip=undefined))},wax.tooltip.prototype.out=wax.tooltip.prototype.unselect,wax.tooltip.prototype.over=wax.tooltip.prototype.select,wax.tooltip.prototype.click=wax.tooltip.prototype.click,wax.util=wax.util||{},wax.util={offset:function(a){var b=a.offsetWidth,c=a.offsetHeight,d=a.offsetTop,e=a.offsetLeft;try{while(a=a.offsetParent){d+=a.offsetTop,e+=a.offsetLeft;var f=a.style.transform||a.style["-webkit-transform"]||a.style.MozTransform;if(f){var g=f.match(/translate\((.+)px, (.+)px\)/);g&&(d+=parseInt(g[2],10),e+=parseInt(g[1],10))}}}catch(h){}d+=document.body.offsetTop,e+=document.body.offsetLeft,d+=document.body.parentNode.offsetTop,e+=document.body.parentNode.offsetLeft;var i=document.defaultView?window.getComputedStyle(document.body.parentNode):document.body.parentNode.currentStyle;document.body.parentNode.offsetTop!==parseInt(i.marginTop,10)&&(d+=parseInt(i.marginTop,10),e+=parseInt(i.marginLeft,10));return{top:d,left:e,height:c,width:b}},bind:function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,c.concat(Array.prototype.slice.call(arguments)))}},isString:function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},indexOf:function(a,b){var c=Array.prototype.indexOf;if(a===null)return-1;var d,e;if(c&&a.indexOf===c)return a.indexOf(b);for(d=0,e=a.length;d<e;d++)if(a[d]===b)return d;return-1},isArray:Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},keys:Object.keys||function(a){var b=Object.prototype.hasOwnProperty;if(a!==Object(a))throw new TypeError("Invalid object");var c=[];for(var d in a)b.call(a,d)&&(c[c.length]=d);return c},eventoffset:function(a){var b=0,c=0;if(!a)var a=window.event;if(a.pageX||a.pageY)return{x:a.pageX,y:a.pageY};if(a.clientX||a.clientY){var d=document.documentElement,e=document.body,f=document.body.parentNode.currentStyle,g=parseInt(f.marginTop,10)||0,h=parseInt(f.marginLeft,10)||0;return{x:a.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0)+h,y:a.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)+g}}}},wax=wax||{},wax.g=wax.g||{},wax.g.interaction=function(a,b){b=b||{};var c={modifyingEvents:["dragstart","dragend","drag","zoom_changed","resize","center_changed","bounds_changed"],waxGM:new wax.GridManager,callbacks:b.callbacks||new wax.tooltip,clickAction:b.clickAction||"full",add:function(){for(var b=0;b<this.modifyingEvents.length;b++)google.maps.event.addListener(a,this.modifyingEvents[b],wax.util.bind(this.clearTileGrid,this));google.maps.event.addListener(a,"mousemove",this.onMove()),google.maps.event.addListener(a,"click",this.click());return this},getTileGrid:function(){if(!this._getTileGrid){this._getTileGrid=[];var b=a.getZoom(),c=wax.util.offset(a.getDiv());for(var d in a.mapTypes){if(!a.mapTypes[d].interactive)continue;var e=a.mapTypes[d];for(var f in e.cache){if(f.split("/")[0]!=b)continue;var g=wax.util.offset(e.cache[f]);this._getTileGrid.push([g.top-c.top,g.left-c.left,e.cache[f]])}}}return this._getTileGrid},clearTileGrid:function(a,b){this._getTileGrid=null},getTile:function(a){var b,c=this.getTileGrid();for(var d=0;d<c.length;d++)if(c[d][0]<a.pixel.y&&c[d][0]+256>a.pixel.y&&c[d][1]<a.pixel.x&&c[d][1]+256>a.pixel.x){b=c[d][2];break}return b||!1},onMove:function(b){this._onMove||(this._onMove=wax.util.bind(function(b){var c=this.getTile(b);c&&this.waxGM.getGrid(c.src,wax.util.bind(function(d,e){if(!d&&!!e){var f=e.getFeature(b.pixel.x+wax.util.offset(a.getDiv()).left,b.pixel.y+wax.util.offset(a.getDiv()).top,c,{format:"teaser"});f&&this.feature!==f?(this.feature=f,this.callbacks.out(a.getDiv()),this.callbacks.over(f,a.getDiv(),0,b)):f||(this.feature=null,this.callbacks.out(a.getDiv()))}},this))},this));return this._onMove},click:function(b){this._onClick||(this._onClick=wax.util.bind(function(b){var c=this.getTile(b);c&&this.waxGM.getGrid(c.src,wax.util.bind(function(d,e){if(!d&&!!e){var f=e.getFeature(b.pixel.x+wax.util.offset(a.getDiv()).left,b.pixel.y+wax.util.offset(a.getDiv()).top,c,{format:this.clickAction});if(f)switch(this.clickAction){case"full":this.callbacks.click(f,a.getDiv(),0,b);break;case"location":window.location=f}}},this))},this));return this._onClick}};return c.add(a)},wax=wax||{},wax.g=wax.g||{},wax.g.legend=function(a,b){b=b||{};var c={add:function(){var c;this.legend=new wax.Legend(a.getDiv(),b.container),google.maps.event.addListener(a,"idle",wax.util.bind(function(){if(!c){c=[];for(var b in a.mapTypes){if(!a.mapTypes[b].interactive)continue;var d=a.mapTypes[b];for(var e in d.cache){c.push(d.cache[e].src);break}}c.length&&this.legend.render(c)}},this));return this}};return c.add(a)};var wax=wax||{};wax.g=wax.g||{},wax.g.MapType=function(a){a=a||{},this.name=a.name||"",this.alt=a.alt||"",this.filetype=a.filetype||".png",this.layerName=a.layerName||"world-light",a.zoomRange?(this.minZoom=a.zoomRange[0],this.maxZoom=a.zoomRange[1]):(this.minZoom=0,this.maxZoom=18),this.baseUrl=a.baseUrl||"http://a.tile.mapbox.com/",this.blankImage=a.blankImage||"",this.interactive=!0,this.tileSize=new google.maps.Size(256,256),this.cache={}},wax.g.MapType.prototype.getTile=function(a,b,c){var d=b+"/"+a.x+"/"+a.y;if(!this.cache[d]){var e=this.cache[d]=new Image(256,256);this.cache[d].src=this.getTileUrl(a,b),this.cache[d].setAttribute("gTileKey",d),this.cache[d].onerror=function(){e.style.display="none"}}return this.cache[d]},wax.g.MapType.prototype.releaseTile=function(a){var b=a.getAttribute("gTileKey");this.cache[b]&&delete this.cache[b],a.parentNode&&a.parentNode.removeChild(a)},wax.g.MapType.prototype.getTileUrl=function(a,b){var c=Math.pow(2,b),d=c-1-a.y,e=a.x%c;e=e<0?a.x%c+c:e;return d>=0?this.baseUrl+"1.0.0/"+this.layerName+"/"+b+"/"+e+"/"+d+this.filetype:this.blankImage}
+ */!function(window){function readyState(a,b,c){return function(){a&&a.readyState==4&&(twoHundo.test(a.status)?b(a):c(a))}}function setHeaders(a,b){var c=b.headers||{};c.Accept="text/javascript, text/html, application/xml, text/xml, */*",c["X-Requested-With"]=c["X-Requested-With"]||"XMLHttpRequest";if(b.data){c["Content-type"]="application/x-www-form-urlencoded";for(var d in c)c.hasOwnProperty(d)&&a.setRequestHeader(d,c[d],!1)}}function getCallbackName(a){var b=a.jsonpCallback||"callback";if(a.url.slice(-(b.length+2))==b+"=?"){var c="reqwest_"+uniqid++;a.url=a.url.substr(0,a.url.length-1)+c;return c}var d=new RegExp(b+"=([\\w]+)");return a.url.match(d)[1]}function generalCallback(a){lastValue=a}function getRequest(a,b,c){if(a.type!="jsonp"){var d=xhr();d.open(a.method||"GET",typeof a=="string"?a:a.url,!0),setHeaders(d,a),d.onreadystatechange=readyState(d,b,c),a.before&&a.before(d),d.send(a.data||null);return d}var e=doc.createElement("script");window[getCallbackName(a)]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0;var f=function(){a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e)};e.onload=f,e.onreadystatechange=function(){e.readyState=="loaded"||e.readyState=="complete"&&f()},head.appendChild(e)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){if(/\.json$/.test(a))return"json";if(/\.jsonp$/.test(a))return"jsonp";if(/\.js$/.test(a))return"js";if(/\.html?$/.test(a))return"html";if(/\.xml$/.test(a))return"xml";return"js"}function init(o,fn){function complete(a){o.complete&&o.complete(a)}function success(resp){o.timeout&&clearTimeout(self.timeout)&&(self.timeout=null);var r=resp.responseText;switch(type){case"json":resp=eval("("+r+")");break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.success&&o.success(resp),complete(resp)}function error(a){o.error&&o.error(a),complete(a)}this.url=typeof o=="string"?o:o.url,this.timeout=null;var type=o.type||setType(this.url),self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort(),error()},o.timeout)),this.request=getRequest(o,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function enc(a){return encodeURIComponent(a)}function serial(a){var b=a.name;if(a.disabled||!b)return"";b=enc(b);switch(a.tagName.toLowerCase()){case"input":switch(a.type){case"reset":case"button":case"image":case"file":return"";case"checkbox":case"radio":return a.checked?b+"="+(a.value?enc(a.value):!0)+"&":"";default:return b+"="+(a.value?enc(a.value):!0)+"&"}break;case"textarea":return b+"="+enc(a.value)+"&";case"select":return b+"="+enc(a.options[a.selectedIndex].value)+"&"}return""}var twoHundo=/^20\d$/,doc=document,byTag="getElementsByTagName",head=doc[byTag]("head")[0],xhr="XMLHttpRequest"in window?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")},uniqid=0,lastValue;Reqwest.prototype={abort:function(){this.request.abort()},retry:function(){init.call(this,this.o,this.fn)}},reqwest.serialize=function(a){var b=a[byTag]("input"),c=a[byTag]("select"),d=a[byTag]("textarea");return(v(b).chain().toArray().map(serial).value().join("")+v(c).chain().toArray().map(serial).value().join("")+v(d).chain().toArray().map(serial).value().join("")).replace(/&$/,"")},reqwest.serializeArray=function(a){for(var b=this.serialize(a).split("&"),c=0,d=b.length,e=[],f;c<d;c++)b[c]&&(f=b[c].split("="))&&e.push({name:f[0],value:f[1]});return e};var old=window.reqwest;reqwest.noConflict=function(){window.reqwest=old;return this},window.reqwest=reqwest}(this);var wax=wax||{};Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(typeof a!="function")throw new TypeError;if(c==0&&arguments.length==1)throw new TypeError;var d=0,e;if(arguments.length>=2)e=arguments[1];else do{if(d in b){e=b[d++];break}if(++d>=c)throw new TypeError}while(!0);while(d<c)d in b&&(e=a.call(undefined,e,b[d],d,b)),d++;return e}),wax.Record=function(a,b){var c=function(a,b){var c=a.split(".").reduce(function(a,b){return[a[1]||a[0],a[1]?a[1][b]:a[0][b]]},[b||window,null]);if(c[0]&&c[1])return c;throw a+" not found."},d=function(a,b){var d=c(a),e;b=b.length?wax.Record(b):[];if(Object.create)e=Object.create(d[1].prototype),d[1].apply(e,b);else switch(b.length){case 0:e=new d[1];break;case 1:e=new d[1](b[0]);break;case 2:e=new d[1](b[0],b[1]);break;case 3:e=new d[1](b[0],b[1],b[2]);break;case 4:e=new d[1](b[0],b[1],b[2],b[3]);break;case 5:e=new d[1](b[0],b[1],b[2],b[3],b[4]);break;default:}return e},e=function(a,b,d){var e=c(a,d),f=b.length?wax.Record(b):[];return d&&a.indexOf(".")===-1?e[1].apply(d,f):e[1].apply(e[0],f)},f=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@literal","@chain","@inject","@group"],a.split(" ")[0])!==-1},g=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@chain"],a.split(" ")[0])!==-1},h=function(a){if(wax.util.isArray(a)&&a[0]&&f(a[0]))return{verb:a[0].split(" ")[0],subject:a[0].split(" ")[1],object:a.slice(1)};return!1},i,j=!1,k=null,l=null,m=h(a);if(!m){if(a!==null&&typeof a=="object"){var n=wax.util.keys(a);for(i=0;i<n.length;i++){var o=n[i];a[o]=wax.Record(a[o],b)}return a}return a}switch(m.verb){case"@group":for(i=0;i<m.object.length;i++)k=wax.Record(m.object[i],b),l=h(m.object[i]),l&&g(l.verb)&&(b=k);return b;case"@new":return d(m.subject,m.object);case"@literal":j=c(m.subject);return j?j[1]:null;case"@inject":return e(m.subject,m.object,b);case"@chain":return e(m.subject,m.object,b);case"@call":return e(m.subject,m.object,null)}};var wax=wax||{};wax.request={cache:{},locks:{},promises:{},get:function(a,b){if(this.cache[a])return b(this.cache[a][0],this.cache[a][1]);this.promises[a]=this.promises[a]||[],this.promises[a].push(b);if(!this.locks[a]){var c=this;this.locks[a]=!0,reqwest({url:a+"?callback=grid",type:"jsonp",jsonpCallback:"callback",success:function(b){c.locks[a]=!1,c.cache[a]=[null,b];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])},error:function(b){c.locks[a]=!1,c.cache[a]=[b,null];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])}})}}},wax.GridInstance=function(a,b){this.grid_tile=a,this.formatter=b,this.tileRes=4},wax.GridInstance.prototype.resolveCode=function(a){a>=93&&a--,a>=35&&a--,a-=32;return a},wax.GridInstance.prototype.getFeature=function(a,b,c,d){if(!!this.grid_tile&&!!this.grid_tile.grid){var e=wax.util.offset(c),f=e.left,g=e.top;if(b-g<0)return;if(a-f<0)return;if(Math.floor((b-g)/this.tileRes)>256)return;if(Math.floor((a-f)/this.tileRes)>256)return;var h=this.grid_tile.grid[Math.floor((b-g)/this.tileRes)].charCodeAt(Math.floor((a-f)/this.tileRes));h=this.resolveCode(h);if(this.grid_tile.keys[h]&&this.grid_tile.data[this.grid_tile.keys[h]])return this.formatter.format(d,this.grid_tile.data[this.grid_tile.keys[h]])}},wax.GridManager=function(){this.grid_tiles={},this.key_maps={},this.formatters={},this.locks={}},wax.GridManager.prototype.getGrid=function(a,b){var c=this;c.getFormatter(c.formatterUrl(a),function(d,e){if(d||!e)return b(d,null);wax.request.get(c.tileDataUrl(a),function(a,c){if(a)return b(a,null);b(null,new wax.GridInstance(c,e))})})},wax.GridManager.prototype.tileDataUrl=function(a){return a.replace(/(\.png|\.jpg|\.jpeg)(\d*)/,".grid.json")},wax.GridManager.prototype.formatterUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")},wax.GridManager.prototype.getFormatter=function(a,b){var c=this;typeof this.formatters[a]!="undefined"?b(null,this.formatters[a]):wax.request.get(a,function(d,e){e&&e.formatter?c.formatters[a]=new wax.Formatter(e):c.formatters[a]=!1,b(d,c.formatters[a])})},wax.Formatter=function(obj){if(obj.formatter&&typeof obj.formatter=="string")try{eval("this.f = "+obj.formatter)}catch(e){console&&console.log(e)}else this.f=function(){}},wax.Formatter.prototype.format=function(a,b){try{return this.f(a,b)}catch(c){console&&console.log(c)}};var wax=wax||{};wax.Legend=function(a,b){this.legends={},this.context=a,this.container=b,this.container||(this.container=document.createElement("div"),this.container.className="wax-legends"),this.context.appendChild(this.container)},wax.Legend.prototype.render=function(a){var b;for(b in this.legends)this.legends[b].style.display="none";var c=wax.util.bind(function(a,b){b?this.legends[a]?this.legends[a].style.display="block":(this.legends[a]=document.createElement("div"),this.legends[a].className="wax-legend",this.legends[a].innerHTML=b,this.container.appendChild(this.legends[a])):this.legends[a]=!1},this);for(var d=0;d<a.length;d++)b=this.legendUrl(a[d]),wax.request.get(b,function(a,d){d&&d.legend&&c(b,d.legend)})},wax.Legend.prototype.legendUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")};var w=function(a){a.melt=function(b,c){b.apply(c,[a,c]);return a};return a},wax=wax||{};wax.tooltip={},wax.tooltip=function(a){this._currentTooltip=undefined,a=a||{},a.animationOut&&(this.animationOut=a.animationOut),a.animationIn&&(this.animationIn=a.animationIn)},wax.tooltip.prototype.isPopup=function(a){return a&&a.className.indexOf("wax-popup")!==-1},wax.tooltip.prototype.getTooltip=function(a,b,c,d){tooltip=document.createElement("div"),tooltip.className="wax-tooltip wax-tooltip-"+c,tooltip.innerHTML=a,b.appendChild(tooltip);return tooltip},wax.tooltip.prototype.hideTooltip=function(a){if(!!a){var b,c=function(){this.parentNode.removeChild(this)};a.style["-webkit-transition"]!==undefined&&this.animationOut?b="webkitTransitionEnd":a.style.MozTransition!==undefined&&this.animationOut&&(b="transitionend"),b?(a.addEventListener(b,c,!1),a.addEventListener("transitionend",c,!1),a.className+=" "+this.animationOut):a.parentNode.removeChild(a)}},wax.tooltip.prototype.click=function(a,b,c){this.unselect(b);var d=this.getTooltip(a,b,c),e=document.createElement("a");e.href="#close",e.className="close",e.innerHTML="Close";var f=wax.util.bind(function(a){this.hideTooltip(d),this._currentTooltip=undefined,a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault();return!1},this);e.addEventListener?e.addEventListener("click",f,!1):e.attachEvent&&e.attachEvent("onclick",f),d.className+=" wax-popup",d.innerHTML=a,d.appendChild(e),this._currentTooltip=d},wax.tooltip.prototype.select=function(a,b,c,d){if(!!a){if(this.isPopup(this._currentTooltip))return;this._currentTooltip=this.getTooltip(a,b,c,d),b.style.cursor="pointer"}},wax.tooltip.prototype.unselect=function(a){this.isPopup(this._currentTooltip)||(a.style.cursor="default",this._currentTooltip&&(this.hideTooltip(this._currentTooltip),this._currentTooltip=undefined))},wax.tooltip.prototype.out=wax.tooltip.prototype.unselect,wax.tooltip.prototype.over=wax.tooltip.prototype.select,wax.tooltip.prototype.click=wax.tooltip.prototype.click,wax.util=wax.util||{},wax.util={offset:function(a){var b=a.offsetWidth,c=a.offsetHeight,d=a.offsetTop,e=a.offsetLeft;try{while(a=a.offsetParent){d+=a.offsetTop,e+=a.offsetLeft;var f=a.style.transform||a.style["-webkit-transform"]||a.style.MozTransform;if(f){var g=f.match(/translate\((.+)px, (.+)px\)/);g&&(d+=parseInt(g[2],10),e+=parseInt(g[1],10))}}}catch(h){}d+=document.body.offsetTop,e+=document.body.offsetLeft,d+=document.body.parentNode.offsetTop,e+=document.body.parentNode.offsetLeft;var i=document.defaultView?window.getComputedStyle(document.body.parentNode):document.body.parentNode.currentStyle;document.body.parentNode.offsetTop!==parseInt(i.marginTop,10)&&(d+=parseInt(i.marginTop,10),e+=parseInt(i.marginLeft,10));return{top:d,left:e,height:c,width:b}},bind:function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,c.concat(Array.prototype.slice.call(arguments)))}},isString:function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},indexOf:function(a,b){var c=Array.prototype.indexOf;if(a===null)return-1;var d,e;if(c&&a.indexOf===c)return a.indexOf(b);for(d=0,e=a.length;d<e;d++)if(a[d]===b)return d;return-1},isArray:Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},keys:Object.keys||function(a){var b=Object.prototype.hasOwnProperty;if(a!==Object(a))throw new TypeError("Invalid object");var c=[];for(var d in a)b.call(a,d)&&(c[c.length]=d);return c},eventoffset:function(a){var b=0,c=0;if(!a)var a=window.event;if(a.pageX||a.pageY)return{x:a.pageX,y:a.pageY};if(a.clientX||a.clientY){var d=document.documentElement,e=document.body,f=document.body.parentNode.currentStyle,g=parseInt(f.marginTop,10)||0,h=parseInt(f.marginLeft,10)||0;return{x:a.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0)+h,y:a.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)+g}}}},wax=wax||{},wax.g=wax.g||{},wax.g.interaction=function(a,b){b=b||{};var c={modifyingEvents:["dragstart","dragend","drag","zoom_changed","resize","center_changed","bounds_changed"],waxGM:new wax.GridManager,callbacks:b.callbacks||new wax.tooltip,clickAction:b.clickAction||"full",add:function(){for(var b=0;b<this.modifyingEvents.length;b++)google.maps.event.addListener(a,this.modifyingEvents[b],wax.util.bind(this.clearTileGrid,this));google.maps.event.addListener(a,"mousemove",this.onMove()),google.maps.event.addListener(a,"click",this.click());return this},getTileGrid:function(){if(!this._getTileGrid){this._getTileGrid=[];var b=a.getZoom(),c=wax.util.offset(a.getDiv());for(var d in a.mapTypes){if(!a.mapTypes[d].interactive)continue;var e=a.mapTypes[d];for(var f in e.cache){if(f.split("/")[0]!=b)continue;var g=wax.util.offset(e.cache[f]);this._getTileGrid.push([g.top-c.top,g.left-c.left,e.cache[f]])}}}return this._getTileGrid},clearTileGrid:function(a,b){this._getTileGrid=null},getTile:function(a){var b,c=this.getTileGrid();for(var d=0;d<c.length;d++)if(c[d][0]<a.pixel.y&&c[d][0]+256>a.pixel.y&&c[d][1]<a.pixel.x&&c[d][1]+256>a.pixel.x){b=c[d][2];break}return b||!1},onMove:function(b){this._onMove||(this._onMove=wax.util.bind(function(b){var c=this.getTile(b);c&&this.waxGM.getGrid(c.src,wax.util.bind(function(d,e){if(!d&&!!e){var f=e.getFeature(b.pixel.x+wax.util.offset(a.getDiv()).left,b.pixel.y+wax.util.offset(a.getDiv()).top,c,{format:"teaser"});f&&this.feature!==f?(this.feature=f,this.callbacks.out(a.getDiv()),this.callbacks.over(f,a.getDiv(),0,b)):f||(this.feature=null,this.callbacks.out(a.getDiv()))}},this))},this));return this._onMove},click:function(b){this._onClick||(this._onClick=wax.util.bind(function(b){var c=this.getTile(b);c&&this.waxGM.getGrid(c.src,wax.util.bind(function(d,e){if(!d&&!!e){var f=e.getFeature(b.pixel.x+wax.util.offset(a.getDiv()).left,b.pixel.y+wax.util.offset(a.getDiv()).top,c,{format:this.clickAction});if(f)switch(this.clickAction){case"full":this.callbacks.click(f,a.getDiv(),0,b);break;case"location":window.location=f}}},this))},this));return this._onClick}};return c.add(a)},wax=wax||{},wax.g=wax.g||{},wax.g.legend=function(a,b){b=b||{};var c={add:function(){var c;this.legend=new wax.Legend(a.getDiv(),b.container),google.maps.event.addListener(a,"idle",wax.util.bind(function(){if(!c){c=[];for(var b in a.mapTypes){if(!a.mapTypes[b].interactive)continue;var d=a.mapTypes[b];for(var e in d.cache){c.push(d.cache[e].src);break}}c.length&&this.legend.render(c)}},this));return this}};return c.add(a)};var wax=wax||{};wax.g=wax.g||{},wax.g.MapType=function(a){a=a||{},this.name=a.name||"",this.alt=a.alt||"",this.filetype=a.filetype||".png",this.layerName=a.layerName||"world-light",a.zoomRange?(this.minZoom=a.zoomRange[0],this.maxZoom=a.zoomRange[1]):(this.minZoom=0,this.maxZoom=18),this.baseUrl=a.baseUrl||"http://a.tile.mapbox.com/",this.blankImage=a.blankImage||"",this.interactive=!0,this.tileSize=new google.maps.Size(256,256),this.cache={}},wax.g.MapType.prototype.getTile=function(a,b,c){var d=b+"/"+a.x+"/"+a.y;if(!this.cache[d]){var e=this.cache[d]=new Image(256,256);this.cache[d].src=this.getTileUrl(a,b),this.cache[d].setAttribute("gTileKey",d),this.cache[d].onerror=function(){e.style.display="none"}}return this.cache[d]},wax.g.MapType.prototype.releaseTile=function(a){var b=a.getAttribute("gTileKey");this.cache[b]&&delete this.cache[b],a.parentNode&&a.parentNode.removeChild(a)},wax.g.MapType.prototype.getTileUrl=function(a,b){var c=Math.pow(2,b),d=c-1-a.y,e=a.x%c;e=e<0?a.x%c+c:e;return d>=0?this.baseUrl+"1.0.0/"+this.layerName+"/"+b+"/"+e+"/"+d+this.filetype:this.blankImage}
View
2 dist/wax.mm.js
@@ -299,7 +299,7 @@ wax.GridInstance.prototype.getFeature = function(x, y, tile_element, options) {
// If this layers formatter hasn't been loaded yet,
// download and load it now.
if (this.grid_tile.keys[key] && this.grid_tile.data[this.grid_tile.keys[key]]) {
- return this.formatter.format(options, data_val);
+ return this.formatter.format(options, this.grid_tile.data[this.grid_tile.keys[key]]);
}
};
View
2 dist/wax.mm.min.js
@@ -5,4 +5,4 @@
* copyright Dustin Diaz 2011
* https://github.com/ded/reqwest
* license MIT
- */!function(window){function readyState(a,b,c){return function(){a&&a.readyState==4&&(twoHundo.test(a.status)?b(a):c(a))}}function setHeaders(a,b){var c=b.headers||{};c.Accept="text/javascript, text/html, application/xml, text/xml, */*",c["X-Requested-With"]=c["X-Requested-With"]||"XMLHttpRequest";if(b.data){c["Content-type"]="application/x-www-form-urlencoded";for(var d in c)c.hasOwnProperty(d)&&a.setRequestHeader(d,c[d],!1)}}function getCallbackName(a){var b=a.jsonpCallback||"callback";if(a.url.slice(-(b.length+2))==b+"=?"){var c="reqwest_"+uniqid++;a.url=a.url.substr(0,a.url.length-1)+c;return c}var d=new RegExp(b+"=([\\w]+)");return a.url.match(d)[1]}function generalCallback(a){lastValue=a}function getRequest(a,b,c){if(a.type!="jsonp"){var d=xhr();d.open(a.method||"GET",typeof a=="string"?a:a.url,!0),setHeaders(d,a),d.onreadystatechange=readyState(d,b,c),a.before&&a.before(d),d.send(a.data||null);return d}var e=doc.createElement("script");window[getCallbackName(a)]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0;var f=function(){a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e)};e.onload=f,e.onreadystatechange=function(){e.readyState=="loaded"||e.readyState=="complete"&&f()},head.appendChild(e)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){if(/\.json$/.test(a))return"json";if(/\.jsonp$/.test(a))return"jsonp";if(/\.js$/.test(a))return"js";if(/\.html?$/.test(a))return"html";if(/\.xml$/.test(a))return"xml";return"js"}function init(o,fn){function complete(a){o.complete&&o.complete(a)}function success(resp){o.timeout&&clearTimeout(self.timeout)&&(self.timeout=null);var r=resp.responseText;switch(type){case"json":resp=eval("("+r+")");break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.success&&o.success(resp),complete(resp)}function error(a){o.error&&o.error(a),complete(a)}this.url=typeof o=="string"?o:o.url,this.timeout=null;var type=o.type||setType(this.url),self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort(),error()},o.timeout)),this.request=getRequest(o,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function enc(a){return encodeURIComponent(a)}function serial(a){var b=a.name;if(a.disabled||!b)return"";b=enc(b);switch(a.tagName.toLowerCase()){case"input":switch(a.type){case"reset":case"button":case"image":case"file":return"";case"checkbox":case"radio":return a.checked?b+"="+(a.value?enc(a.value):!0)+"&":"";default:return b+"="+(a.value?enc(a.value):!0)+"&"}break;case"textarea":return b+"="+enc(a.value)+"&";case"select":return b+"="+enc(a.options[a.selectedIndex].value)+"&"}return""}var twoHundo=/^20\d$/,doc=document,byTag="getElementsByTagName",head=doc[byTag]("head")[0],xhr="XMLHttpRequest"in window?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")},uniqid=0,lastValue;Reqwest.prototype={abort:function(){this.request.abort()},retry:function(){init.call(this,this.o,this.fn)}},reqwest.serialize=function(a){var b=a[byTag]("input"),c=a[byTag]("select"),d=a[byTag]("textarea");return(v(b).chain().toArray().map(serial).value().join("")+v(c).chain().toArray().map(serial).value().join("")+v(d).chain().toArray().map(serial).value().join("")).replace(/&$/,"")},reqwest.serializeArray=function(a){for(var b=this.serialize(a).split("&"),c=0,d=b.length,e=[],f;c<d;c++)b[c]&&(f=b[c].split("="))&&e.push({name:f[0],value:f[1]});return e};var old=window.reqwest;reqwest.noConflict=function(){window.reqwest=old;return this},window.reqwest=reqwest}(this);var wax=wax||{};Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(typeof a!="function")throw new TypeError;if(c==0&&arguments.length==1)throw new TypeError;var d=0,e;if(arguments.length>=2)e=arguments[1];else do{if(d in b){e=b[d++];break}if(++d>=c)throw new TypeError}while(!0);while(d<c)d in b&&(e=a.call(undefined,e,b[d],d,b)),d++;return e}),wax.Record=function(a,b){var c=function(a,b){var c=a.split(".").reduce(function(a,b){return[a[1]||a[0],a[1]?a[1][b]:a[0][b]]},[b||window,null]);if(c[0]&&c[1])return c;throw a+" not found."},d=function(a,b){var d=c(a),e;b=b.length?wax.Record(b):[];if(Object.create)e=Object.create(d[1].prototype),d[1].apply(e,b);else switch(b.length){case 0:e=new d[1];break;case 1:e=new d[1](b[0]);break;case 2:e=new d[1](b[0],b[1]);break;case 3:e=new d[1](b[0],b[1],b[2]);break;case 4:e=new d[1](b[0],b[1],b[2],b[3]);break;case 5:e=new d[1](b[0],b[1],b[2],b[3],b[4]);break;default:}return e},e=function(a,b,d){var e=c(a,d),f=b.length?wax.Record(b):[];return d&&a.indexOf(".")===-1?e[1].apply(d,f):e[1].apply(e[0],f)},f=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@literal","@chain","@inject","@group"],a.split(" ")[0])!==-1},g=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@chain"],a.split(" ")[0])!==-1},h=function(a){if(wax.util.isArray(a)&&a[0]&&f(a[0]))return{verb:a[0].split(" ")[0],subject:a[0].split(" ")[1],object:a.slice(1)};return!1},i,j=!1,k=null,l=null,m=h(a);if(!m){if(a!==null&&typeof a=="object"){var n=wax.util.keys(a);for(i=0;i<n.length;i++){var o=n[i];a[o]=wax.Record(a[o],b)}return a}return a}switch(m.verb){case"@group":for(i=0;i<m.object.length;i++)k=wax.Record(m.object[i],b),l=h(m.object[i]),l&&g(l.verb)&&(b=k);return b;case"@new":return d(m.subject,m.object);case"@literal":j=c(m.subject);return j?j[1]:null;case"@inject":return e(m.subject,m.object,b);case"@chain":return e(m.subject,m.object,b);case"@call":return e(m.subject,m.object,null)}};var wax=wax||{};wax.request={cache:{},locks:{},promises:{},get:function(a,b){if(this.cache[a])return b(this.cache[a][0],this.cache[a][1]);this.promises[a]=this.promises[a]||[],this.promises[a].push(b);if(!this.locks[a]){var c=this;this.locks[a]=!0,reqwest({url:a+"?callback=grid",type:"jsonp",jsonpCallback:"callback",success:function(b){c.locks[a]=!1,c.cache[a]=[null,b];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])},error:function(b){c.locks[a]=!1,c.cache[a]=[b,null];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])}})}}},wax.GridInstance=function(a,b){this.grid_tile=a,this.formatter=b,this.tileRes=4},wax.GridInstance.prototype.resolveCode=function(a){a>=93&&a--,a>=35&&a--,a-=32;return a},wax.GridInstance.prototype.getFeature=function(a,b,c,d){if(!!this.grid_tile&&!!this.grid_tile.grid){var e=wax.util.offset(c),f=e.left,g=e.top;if(b-g<0)return;if(a-f<0)return;if(Math.floor((b-g)/this.tileRes)>256)return;if(Math.floor((a-f)/this.tileRes)>256)return;var h=this.grid_tile.grid[Math.floor((b-g)/this.tileRes)].charCodeAt(Math.floor((a-f)/this.tileRes));h=this.resolveCode(h);if(this.grid_tile.keys[h]&&this.grid_tile.data[this.grid_tile.keys[h]])return this.formatter.format(d,data_val)}},wax.GridManager=function(){this.grid_tiles={},this.key_maps={},this.formatters={},this.locks={}},wax.GridManager.prototype.getGrid=function(a,b){var c=this;c.getFormatter(c.formatterUrl(a),function(d,e){if(d||!e)return b(d,null);wax.request.get(c.tileDataUrl(a),function(a,c){if(a)return b(a,null);b(null,new wax.GridInstance(c,e))})})},wax.GridManager.prototype.tileDataUrl=function(a){return a.replace(/(\.png|\.jpg|\.jpeg)(\d*)/,".grid.json")},wax.GridManager.prototype.formatterUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")},wax.GridManager.prototype.getFormatter=function(a,b){var c=this;typeof this.formatters[a]!="undefined"?b(null,this.formatters[a]):wax.request.get(a,function(d,e){e&&e.formatter?c.formatters[a]=new wax.Formatter(e):c.formatters[a]=!1,b(d,c.formatters[a])})},wax.Formatter=function(obj){if(obj.formatter&&typeof obj.formatter=="string")try{eval("this.f = "+obj.formatter)}catch(e){console&&console.log(e)}else this.f=function(){}},wax.Formatter.prototype.format=function(a,b){try{return this.f(a,b)}catch(c){console&&console.log(c)}};var wax=wax||{};wax.Legend=function(a,b){this.legends={},this.context=a,this.container=b,this.container||(this.container=document.createElement("div"),this.container.className="wax-legends"),this.context.appendChild(this.container)},wax.Legend.prototype.render=function(a){var b;for(b in this.legends)this.legends[b].style.display="none";var c=wax.util.bind(function(a,b){b?this.legends[a]?this.legends[a].style.display="block":(this.legends[a]=document.createElement("div"),this.legends[a].className="wax-legend",this.legends[a].innerHTML=b,this.container.appendChild(this.legends[a])):this.legends[a]=!1},this);for(var d=0;d<a.length;d++)b=this.legendUrl(a[d]),wax.request.get(b,function(a,d){d&&d.legend&&c(b,d.legend)})},wax.Legend.prototype.legendUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")};var w=function(a){a.melt=function(b,c){b.apply(c,[a,c]);return a};return a},wax=wax||{};wax.tooltip={},wax.tooltip=function(a){this._currentTooltip=undefined,a=a||{},a.animationOut&&(this.animationOut=a.animationOut),a.animationIn&&(this.animationIn=a.animationIn)},wax.tooltip.prototype.isPopup=function(a){return a&&a.className.indexOf("wax-popup")!==-1},wax.tooltip.prototype.getTooltip=function(a,b,c,d){tooltip=document.createElement("div"),tooltip.className="wax-tooltip wax-tooltip-"+c,tooltip.innerHTML=a,b.appendChild(tooltip);return tooltip},wax.tooltip.prototype.hideTooltip=function(a){if(!!a){var b,c=function(){this.parentNode.removeChild(this)};a.style["-webkit-transition"]!==undefined&&this.animationOut?b="webkitTransitionEnd":a.style.MozTransition!==undefined&&this.animationOut&&(b="transitionend"),b?(a.addEventListener(b,c,!1),a.addEventListener("transitionend",c,!1),a.className+=" "+this.animationOut):a.parentNode.removeChild(a)}},wax.tooltip.prototype.click=function(a,b,c){this.unselect(b);var d=this.getTooltip(a,b,c),e=document.createElement("a");e.href="#close",e.className="close",e.innerHTML="Close";var f=wax.util.bind(function(a){this.hideTooltip(d),this._currentTooltip=undefined,a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault();return!1},this);e.addEventListener?e.addEventListener("click",f,!1):e.attachEvent&&e.attachEvent("onclick",f),d.className+=" wax-popup",d.innerHTML=a,d.appendChild(e),this._currentTooltip=d},wax.tooltip.prototype.select=function(a,b,c,d){if(!!a){if(this.isPopup(this._currentTooltip))return;this._currentTooltip=this.getTooltip(a,b,c,d),b.style.cursor="pointer"}},wax.tooltip.prototype.unselect=function(a){this.isPopup(this._currentTooltip)||(a.style.cursor="default",this._currentTooltip&&(this.hideTooltip(this._currentTooltip),this._currentTooltip=undefined))},wax.tooltip.prototype.out=wax.tooltip.prototype.unselect,wax.tooltip.prototype.over=wax.tooltip.prototype.select,wax.tooltip.prototype.click=wax.tooltip.prototype.click,wax.util=wax.util||{},wax.util={offset:function(a){var b=a.offsetWidth,c=a.offsetHeight,d=a.offsetTop,e=a.offsetLeft;try{while(a=a.offsetParent){d+=a.offsetTop,e+=a.offsetLeft;var f=a.style.transform||a.style["-webkit-transform"]||a.style.MozTransform;if(f){var g=f.match(/translate\((.+)px, (.+)px\)/);g&&(d+=parseInt(g[2],10),e+=parseInt(g[1],10))}}}catch(h){}d+=document.body.offsetTop,e+=document.body.offsetLeft,d+=document.body.parentNode.offsetTop,e+=document.body.parentNode.offsetLeft;var i=document.defaultView?window.getComputedStyle(document.body.parentNode):document.body.parentNode.currentStyle;document.body.parentNode.offsetTop!==parseInt(i.marginTop,10)&&(d+=parseInt(i.marginTop,10),e+=parseInt(i.marginLeft,10));return{top:d,left:e,height:c,width:b}},bind:function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,c.concat(Array.prototype.slice.call(arguments)))}},isString:function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},indexOf:function(a,b){var c=Array.prototype.indexOf;if(a===null)return-1;var d,e;if(c&&a.indexOf===c)return a.indexOf(b);for(d=0,e=a.length;d<e;d++)if(a[d]===b)return d;return-1},isArray:Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},keys:Object.keys||function(a){var b=Object.prototype.hasOwnProperty;if(a!==Object(a))throw new TypeError("Invalid object");var c=[];for(var d in a)b.call(a,d)&&(c[c.length]=d);return c},eventoffset:function(a){var b=0,c=0;if(!a)var a=window.event;if(a.pageX||a.pageY)return{x:a.pageX,y:a.pageY};if(a.clientX||a.clientY){var d=document.documentElement,e=document.body,f=document.body.parentNode.currentStyle,g=parseInt(f.marginTop,10)||0,h=parseInt(f.marginLeft,10)||0;return{x:a.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0)+h,y:a.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)+g}}}},wax=wax||{},wax.mm=wax.mm||{},wax.mm.boxselector=function(a,b){var c=null,d=typeof b=="function"?b:b.callback,e={add:function(a){this.boxDiv=document.createElement("div"),this.boxDiv.id=a.parent.id+"-boxselector-box",this.boxDiv.className="boxselector-box",a.parent.appendChild(this.boxDiv),com.modestmaps.addEvent(a.parent,"mousedown",this.mouseDown()),a.addCallback("drawn",this.drawbox())},remove:function(){a.parent.removeChild(this.boxDiv),a.removeCallback("mousedown",this.drawbox())},getMousePoint:function(b){var c=new com.modestmaps.Point(b.clientX,b.clientY);c.x+=document.body.scrollLeft+document.documentElement.scrollLeft,c.y+=document.body.scrollTop+document.documentElement.scrollTop;for(var d=a.parent;d;d=d.offsetParent)c.x-=d.offsetLeft,c.y-=d.offsetTop;return c},mouseDown:function(){this._mouseDown||(this._mouseDown=wax.util.bind(function(b){if(b.shiftKey){c=this.getMousePoint(b),this.boxDiv.style.left=c.x+"px",this.boxDiv.style.top=c.y+"px",com.modestmaps.addEvent(a.parent,"mousemove",this.mouseMove()),com.modestmaps.addEvent(a.parent,"mouseup",this.mouseUp()),a.parent.style.cursor="crosshair";return com.modestmaps.cancelEvent(b)}},this));return this._mouseDown},mouseMove:function(a){this._mouseMove||(this._mouseMove=wax.util.bind(function(a){var b=this.getMousePoint(a);this.boxDiv.style.display="block",b.x<c.x?this.boxDiv.style.left=b.x+"px":this.boxDiv.style.left=c.x+"px",this.boxDiv.style.width=Math.abs(b.x-c.x)+"px",b.y<c.y?this.boxDiv.style.top=b.y+"px":this.boxDiv.style.top=c.y+"px",this.boxDiv.style.height=Math.abs(b.y-c.y)+"px";return com.modestmaps.cancelEvent(a)},this));return this._mouseMove},mouseUp:function(){this._mouseUp||(this._mouseUp=wax.util.bind(function(b){var f=e.getMousePoint(b),g=a.pointLocation(f),h=a.pointLocation(c),i=[new com.modestmaps.Location(Math.max(g.lat,h.lat),Math.min(g.lon,h.lon)),new com.modestmaps.Location(Math.min(g.lat,h.lat),Math.max(g.lon,h.lon))];this.box=[g,h],d(i),com.modestmaps.removeEvent(a.parent,"mousemove",this.mouseMove()),com.modestmaps.removeEvent(a.parent,"mouseup",this.mouseUp()),a.parent.style.cursor="auto"},this));return this._mouseUp},drawbox:function(){this._drawbox||(this._drawbox=wax.util.bind(function(a,b){if(this.boxDiv){this.boxDiv.style.display="block",this.boxDiv.style.height="auto",this.boxDiv.style.width="auto";var c=a.locationPoint(this.box[0]),d=a.locationPoint(this.box[1]);this.boxDiv.style.left=Math.max(0,d.x)+"px",this.boxDiv.style.top=Math.max(0,d.y)+"px",this.boxDiv.style.right=Math.max(0,a.dimensions.x-c.x)+"px",this.boxDiv.style.bottom=Math.max(0,a.dimensions.y-c.y)+"px"}},this));return this._drawbox}};return e.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.fullscreen=function(a,b){var c={state:1,add:function(a){this.a=document.createElement("a"),this.a.className="wax-fullscreen",this.a.href="#fullscreen",this.a.innerHTML="fullscreen",a.parent.appendChild(this.a),com.modestmaps.addEvent(this.a,"click",this.click(a));return this},click:function(a){if(this._click)return this._click;this._click=wax.util.bind(function(b){b&&com.modestmaps.cancelEvent(b),this.state?(this.smallSize=[a.parent.offsetWidth,a.parent.offsetHeight],a.parent.className+=" wax-fullscreen-map",a.setSize(a.parent.offsetWidth,a.parent.offsetHeight)):(a.parent.className=a.parent.className.replace("wax-fullscreen-map",""),a.setSize(this.smallSize[0],this.smallSize[1])),this.state=!this.state},this);return this._click}};return c.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.locationHash={stateChange:function(a){com.modestmaps.addEvent(window,"hashchange",function(){a(location.hash)},!1)},getState:function(){return location.hash},pushState:function(a){location.hash=a}},wax.mm.hash=function(a,b){var c,d=90-1e-8,e=function(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,a.apply(e,f)};c&&clearTimeout(d);if(c||!d)d=setTimeout(g,b)}},f=function(a,b){return e(a,b,!1)},g={map:this,parser:function(b){var c=b.split("/");for(var d=0;d<c.length;d++){if(isNaN(c[d]))return!0;c[d]=Number(c)}if(c.length<3)return!0;c.length==3&&a.setCenterZoom(new com.modestmaps.Location(c[1],c[2]),c[0])},add:function(a){b.manager.getState()?g.stateChange(b.manager.getState()):(g.initialize(),g.move()),a.addCallback("drawn",f(g.move,500)),b.manager.stateChange(g.stateChange)},formatter:function(){var b=a.getCenter(),c=a.getZoom(),d=Math.max(0,Math.ceil(Math.log(c)/Math.LN2));return"#"+[c.toFixed(2),b.lat.toFixed(d),b.lon.toFixed(d)].join("/")},move:function(){var a=g.formatter();c!==a&&(c=a,b.manager.pushState(c))},stateChange:function(a){a!==c&&g.parser((c=a).substring(1))&&g.move()},initialize:function(){b.defaultCenter&&a.setCenter(b.defaultCenter),b.defaultZoom&&a.setZoom(b.defaultZoom)}};return g.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.interaction=function(a,b){var c=com.modestmaps;b=b||{};var d={modifyingEvents:["zoomed","panned","centered","extentset","resized","drawn"],waxGM:new wax.GridManager,callbacks:b.callbacks||new wax.tooltip,clickAction:b.clickAction||"full",clickHandler:b.clickHandler||function(a){window.location=a},add:function(){for(var b=0;b<this.modifyingEvents.length;b++)a.addCallback(this.modifyingEvents[b],wax.util.bind(this.clearTileGrid,this));c.addEvent(a.parent,"mousemove",this.onMove()),c.addEvent(a.parent,"mousedown",this.onDown()),c.addEvent(a.parent,"touchstart",this.onDown());return this},getTileGrid:function(){var b=a.getZoom();return this._getTileGrid||(this._getTileGrid=function(a){var c=[];for(var d in a)if(d.split(",")[0]==b){var e=wax.util.offset(a[d]);c.push([e.top,e.left,a[d]])}return c}(a.tiles))},clearTileGrid:function(a,b){this._getTileGrid=null},getTile:function(a){var b,c=this.getTileGrid();for(var d=0;d<c.length;d++)if(c[d][0]<a.y&&c[d][0]+256>a.y&&c[d][1]<a.x&&c[d][1]+256>a.x){b=c[d][2];break}return b||!1},clearTimeout:function(){if(this.clickTimeout){window.clearTimeout(this.clickTimeout),this.clickTimeout=null;return!0}return!1},onMove:function(b){this._onMove||(this._onMove=wax.util.bind(function(b){var c=wax.util.eventoffset(b),d=this.getTile(c);d&&this.waxGM.getGrid(d.src,wax.util.bind(function(e,f){if(!e&&f){var g=f.getFeature(c.x,c.y,d,{format:"teaser"});g?g&&this.feature!==g?(this.feature=g,this.callbacks.out(a.parent),this.callbacks.over(g,a.parent,0,b)):g||(this.feature=null,this.callbacks.out(a.parent)):(this.feature=null,this.callbacks.out(a.parent))}},this))},this));return this._onMove},onDown:function(b){this._onDown||(this._onDown=wax.util.bind(function(b){this.clearTimeout()||(b.type==="mousedown"?(this.downEvent=wax.util.eventoffset(b),c.addEvent(a.parent,"mouseup",this.onUp())):b.type==="touchstart"&&b.touches.length===1&&(console.log("good touch"),c.addEvent(a.parent,"touchend",this.onUp())))},this));return this._onDown},onUp:function(){this._onUp||(this._onUp=wax.util.bind(function(b){c.removeEvent(a.parent,"mouseup",this.onUp());var d=4,e=wax.util.eventoffset(b);Math.round(e.y/d)===Math.round(this.downEvent.y/d)&&Math.round(e.x/d)===Math.round(this.downEvent.x/d)&&(this.clickTimeout=window.setTimeout(wax.util.bind(function(){this.click()(e)},this),300))},this));return this._onUp},click:function(b){this._onClick||(this._onClick=wax.util.bind(function(c){var d=this.getTile(c);d&&this.waxGM.getGrid(d.src,wax.util.bind(function(e,f){if(f){var g=f.getFeature(c.x,c.y,d,{format:this.clickAction});if(g)switch(this.clickAction){case"full":this.callbacks.click(g,a.parent,0,b);break;case"location":this.clickHandler(g)}}},this))},this));return this._onClick}};return d.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.legend=function(a,b){b=b||{};var c={add:function(){this.legend=new wax.Legend(a.parent,b.container),this.legend.render([a.provider.getTileUrl({zoom:0,column:0,row:0})])}};return c.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.mobile=function(a,b){b=b||{};var c=com.modestmaps,d=navigator.userAgent.toLowerCase(),e=d.indexOf("webkit")!=-1,f=d.indexOf("mobile")!=-1,g=f&&e,h=function(a){var b=document.createElement("canvas"),c=parseInt(a.style.width,10),d=parseInt(a.style.height,10),e=c/2,f=d/2,g=Math.min(c,d)/4,h=b.getContext("2d");b.setAttribute("width",c),b.setAttribute("height",d),h.globalAlpha=.5;var i=h.createLinearGradient(0,0,300,225);i.addColorStop(0,"black"),i.addColorStop(1,"rgb(200, 200, 200)"),h.fillStyle=i,h.fillRect(0,0,c,d),h.fillStyle="rgb(255, 255, 255)",h.beginPath(),h.moveTo(e-g*.6,f-g),h.lineTo(e-g*.6,f+g),h.lineTo(e+g*.6,f),h.fill(),a.appendChild(b)},i=function(a){a.style.position="absolute",a.style.height="50px",a.style.left=a.style.right="0";var b=document.createElement("canvas");b.setAttribute("width",a.offsetWidth),b.setAttribute("height",a.offsetHeight);var c=b.getContext("2d");c.globalAlpha=1,c.fillStyle="rgba(255, 255, 255, 0.5)",c.fillRect(0,0,a.offsetWidth,a.offsetHeight),c.fillStyle="rgb(0, 0, 0)",c.font="bold 20px sans-serif",c.fillText("back",20,30),a.appendChild(b)},j=function(a){a.style.position="absolute",a.style.width=a.style.height="auto",a.style.top=window.pageYOffset+"px",a.style.left=a.style.right="0px"},k=function(a){a.style.position="relative",a.style.width=a.style.height=a.style.top=a.style.left=a.style.right="auto"},l,m,n,o,p=b.overlayDraw||h,q=b.backDraw||i;bodyDraw=b.bodyDraw||function(){};var r={add:function(a){g&&(o=document.createElement("meta"),o.id="wax-touch",o.setAttribute("name","viewport"),l=document.createElement("div"),l.id=a.parent.id+"-mobileoverlay",l.className="wax-mobileoverlay",l.style.position="absolute",l.style.width=a.dimensions.x+"px",l.style.height=a.dimensions.y+"px",a.parent.appendChild(l),p(l),n=document.createElement("div"),backDiv=document.createElement("div"),m=document.body,newBody=document.createElement("body"),newBody.appendChild(backDiv),c.addEvent(l,"touchstart",this.toTouch),c.addEvent(backDiv,"touchstart",this.toPage));return this},toTouch:function(){a.parent.parentNode.replaceChild(n,a.parent),newBody.insertBefore(a.parent,backDiv),document.body=newBody,bodyDraw(newBody),q(backDiv),o.setAttribute("content","initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"),document.head.appendChild(o),a._smallSize=[a.parent.clientWidth,a.parent.clientHeight],j(a.parent),a.setSize(a.parent.offsetWidth,window.innerHeight),backDiv.style.display="block",l.style.display="none"},toPage:function(){document.body=m,n.parentNode.replaceChild(a.parent,n),k(a.parent),a.setSize(a._smallSize[0],a._smallSize[1]),backDiv.style.display="none",l.style.display="block"}};return r.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.pointselector=function(a,b){function k(a){var b=[];for(var c=0;c<a.length;c++)b.push(new g.Location(a[c].lat,a[c].lon));return b}var c=null,d=null,e=5,f,g=com.modestmaps,h=[],i=typeof b=="function"?b:b.callback,j=function(b){var c=wax.util.eventoffset(b),d=new g.Point(c.x,c.y),e={x:parseFloat(g.getStyle(document.documentElement,"margin-left")),y:parseFloat(g.getStyle(document.documentElement,"margin-top"))};isNaN(e.x)||(d.x-=e.x),isNaN(e.y)||(d.y-=e.y);for(var f=a.parent;f;f=f.offsetParent)d.x-=f.offsetLeft,d.y-=f.offsetTop;return d},l={add:function(a){g.addEvent(a.parent,"mousedown",this.mouseDown()),a.addCallback("drawn",l.drawPoints());return this},deletePoint:function(a,b){confirm("Delete this point?")&&(a.pointDiv.parentNode.removeChild(a.pointDiv),h.splice(wax.util.indexOf(h,a),1),i(k(h)))},drawPoints:function(){this._drawPoints||(this._drawPoints=wax.util.bind(function(){var b=new g.Point(0,0);for(var c=0;c<h.length;c++){var d=a.locationPoint(h[c]);h[c].pointDiv||(h[c].pointDiv=document.createElement("div"),h[c].pointDiv.className="wax-point-div",h[c].pointDiv.style.position="absolute",h[c].pointDiv.style.display="block",h[c].pointDiv.location=h[c],g.addEvent(h[c].pointDiv,"mouseup",function(d){var e=h[c];return function(b){g.removeEvent(a.parent,"mouseup",l.mouseUp()),l.deletePoint(e,b)}}()),a.parent.appendChild(h[c].pointDiv)),h[c].pointDiv.style.left=d.x+"px",h[c].pointDiv.style.top=d.y+"px"}},this));return this._drawPoints},mouseDown:function(){this._mouseDown||(this._mouseDown=wax.util.bind(function(b){c=j(b),g.addEvent(a.parent,"mouseup",this.mouseUp())},this));return this._mouseDown},addLocation:function(a){h.push(a),l.drawPoints()(),i(k(h))},mouseUp:function(){this._mouseUp||(this._mouseUp=wax.util.bind(function(b){!c||(d=j(b),g.Point.distance(c,d)<e&&(this.addLocation(a.pointLocation(c)),i(k(h))),c=null)},this));return this._mouseUp}};return l.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.zoombox=function(a,b){var c=null,d={add:function(a){this.box=document.createElement("div"),this.box.id=a.parent.id+"-zoombox-box",this.box.className="zoombox-box",a.parent.appendChild(this.box),com.modestmaps.addEvent(a.parent,"mousedown",this.mouseDown())},remove:function(){a.parent.removeChild(this.box),a.removeCallback("mousedown",this.mouseDown)},getMousePoint:function(b){var c=new com.modestmaps.Point(b.clientX,b.clientY);c.x+=document.body.scrollLeft+document.documentElement.scrollLeft,c.y+=document.body.scrollTop+document.documentElement.scrollTop;for(var d=a.parent;d;d=d.offsetParent)c.x-=d.offsetLeft,c.y-=d.offsetTop;return c},mouseDown:function(){this._mouseDown||(this._mouseDown=wax.util.bind(function(b){if(b.shiftKey){c=this.getMousePoint(b),this.box.style.left=c.x+"px",this.box.style.top=c.y+"px",com.modestmaps.addEvent(a.parent,"mousemove",this.mouseMove()),com.modestmaps.addEvent(a.parent,"mouseup",this.mouseUp()),a.parent.style.cursor="crosshair";return com.modestmaps.cancelEvent(b)}},this));return this._mouseDown},mouseMove:function(a){this._mouseMove||(this._mouseMove=wax.util.bind(function(a){var b=this.getMousePoint(a);this.box.style.display="block",b.x<c.x?this.box.style.left=b.x+"px":this.box.style.left=c.x+"px",this.box.style.width=Math.abs(b.x-c.x)+"px",b.y<c.y?this.box.style.top=b.y+"px":this.box.style.top=c.y+"px",this.box.style.height=Math.abs(b.y-c.y)+"px";return com.modestmaps.cancelEvent(a)},this));return this._mouseMove},mouseUp:function(b){this._mouseUp||(this._mouseUp=wax.util.bind(function(b){var d=this.getMousePoint(b),e=a.pointLocation(d),f=a.pointLocation(c);a.setExtent([e,f]),this.box.style.display="none",com.modestmaps.removeEvent(a.parent,"mousemove",this.mouseMove()),com.modestmaps.removeEvent(a.parent,"mouseup",this.mouseUp()),a.parent.style.cursor="auto"},this));return this._mouseUp}};return d.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.zoomer=function(a){var b=document.createElement("a");b.innerHTML="+",b.href="#",b.className="zoomer zoomin",com.modestmaps.addEvent(b,"mousedown",function(a){com.modestmaps.cancelEvent(a)}),com.modestmaps.addEvent(b,"click",function(b){com.modestmaps.cancelEvent(b),a.zoomIn()},!1),a.parent.appendChild(b);var c=document.createElement("a");c.innerHTML="-",c.href="#",c.className="zoomer zoomout",com.modestmaps.addEvent(c,"mousedown",function(a){com.modestmaps.cancelEvent(a)}),com.modestmaps.addEvent(c,"click",function(b){com.modestmaps.cancelEvent(b),a.zoomOut()},!1),a.parent.appendChild(c);var d={add:function(a){a.addCallback("drawn",function(a,d){a.coordinate.zoom===a.provider.outerLimits()[0].zoom?c.className="zoomer zoomout zoomdisabled":a.coordinate.zoom===a.provider.outerLimits()[1].zoom?b.className="zoomer zoomin zoomdisabled":(b.className="zoomer zoomin",c.className="zoomer zoomout")});return this}};return d.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.provider=function(a){this.layerName=a.layerName,this.baseUrls=typeof a.baseUrl=="string"?[a.baseUrl]:a.baseUrl,this.n_urls=this.baseUrls.length,this.filetype=a.filetype||".png",this.zoomRange=a.zoomRange||[0,18]},wax.mm.provider.prototype={outerLimits:function(){return[(new com.modestmaps.Coordinate(0,0,0)).zoomTo(this.zoomRange[0]),(new com.modestmaps.Coordinate(1,1,0)).zoomTo(this.zoomRange[1])]},getTileUrl:function(a){var b;a=this.sourceCoordinate(a);if(!a)return null;var c=Math.pow(2,a.zoom);a.row=Math.pow(2,a.zoom)-a.row-1,this.n_urls===1?b=this.baseUrls[0]:b=this.baseUrls[parseInt(c*a.row+a.column,10)%this.n_urls];var d=["1.0.0",this.layerName,a.zoom,a.column,a.row].join("/");return b+d+this.filetype}},com.modestmaps.extend(wax.mm.provider,com.modestmaps.MapProvider)
+ */!function(window){function readyState(a,b,c){return function(){a&&a.readyState==4&&(twoHundo.test(a.status)?b(a):c(a))}}function setHeaders(a,b){var c=b.headers||{};c.Accept="text/javascript, text/html, application/xml, text/xml, */*",c["X-Requested-With"]=c["X-Requested-With"]||"XMLHttpRequest";if(b.data){c["Content-type"]="application/x-www-form-urlencoded";for(var d in c)c.hasOwnProperty(d)&&a.setRequestHeader(d,c[d],!1)}}function getCallbackName(a){var b=a.jsonpCallback||"callback";if(a.url.slice(-(b.length+2))==b+"=?"){var c="reqwest_"+uniqid++;a.url=a.url.substr(0,a.url.length-1)+c;return c}var d=new RegExp(b+"=([\\w]+)");return a.url.match(d)[1]}function generalCallback(a){lastValue=a}function getRequest(a,b,c){if(a.type!="jsonp"){var d=xhr();d.open(a.method||"GET",typeof a=="string"?a:a.url,!0),setHeaders(d,a),d.onreadystatechange=readyState(d,b,c),a.before&&a.before(d),d.send(a.data||null);return d}var e=doc.createElement("script");window[getCallbackName(a)]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0;var f=function(){a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e)};e.onload=f,e.onreadystatechange=function(){e.readyState=="loaded"||e.readyState=="complete"&&f()},head.appendChild(e)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){if(/\.json$/.test(a))return"json";if(/\.jsonp$/.test(a))return"jsonp";if(/\.js$/.test(a))return"js";if(/\.html?$/.test(a))return"html";if(/\.xml$/.test(a))return"xml";return"js"}function init(o,fn){function complete(a){o.complete&&o.complete(a)}function success(resp){o.timeout&&clearTimeout(self.timeout)&&(self.timeout=null);var r=resp.responseText;switch(type){case"json":resp=eval("("+r+")");break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.success&&o.success(resp),complete(resp)}function error(a){o.error&&o.error(a),complete(a)}this.url=typeof o=="string"?o:o.url,this.timeout=null;var type=o.type||setType(this.url),self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort(),error()},o.timeout)),this.request=getRequest(o,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function enc(a){return encodeURIComponent(a)}function serial(a){var b=a.name;if(a.disabled||!b)return"";b=enc(b);switch(a.tagName.toLowerCase()){case"input":switch(a.type){case"reset":case"button":case"image":case"file":return"";case"checkbox":case"radio":return a.checked?b+"="+(a.value?enc(a.value):!0)+"&":"";default:return b+"="+(a.value?enc(a.value):!0)+"&"}break;case"textarea":return b+"="+enc(a.value)+"&";case"select":return b+"="+enc(a.options[a.selectedIndex].value)+"&"}return""}var twoHundo=/^20\d$/,doc=document,byTag="getElementsByTagName",head=doc[byTag]("head")[0],xhr="XMLHttpRequest"in window?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")},uniqid=0,lastValue;Reqwest.prototype={abort:function(){this.request.abort()},retry:function(){init.call(this,this.o,this.fn)}},reqwest.serialize=function(a){var b=a[byTag]("input"),c=a[byTag]("select"),d=a[byTag]("textarea");return(v(b).chain().toArray().map(serial).value().join("")+v(c).chain().toArray().map(serial).value().join("")+v(d).chain().toArray().map(serial).value().join("")).replace(/&$/,"")},reqwest.serializeArray=function(a){for(var b=this.serialize(a).split("&"),c=0,d=b.length,e=[],f;c<d;c++)b[c]&&(f=b[c].split("="))&&e.push({name:f[0],value:f[1]});return e};var old=window.reqwest;reqwest.noConflict=function(){window.reqwest=old;return this},window.reqwest=reqwest}(this);var wax=wax||{};Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(typeof a!="function")throw new TypeError;if(c==0&&arguments.length==1)throw new TypeError;var d=0,e;if(arguments.length>=2)e=arguments[1];else do{if(d in b){e=b[d++];break}if(++d>=c)throw new TypeError}while(!0);while(d<c)d in b&&(e=a.call(undefined,e,b[d],d,b)),d++;return e}),wax.Record=function(a,b){var c=function(a,b){var c=a.split(".").reduce(function(a,b){return[a[1]||a[0],a[1]?a[1][b]:a[0][b]]},[b||window,null]);if(c[0]&&c[1])return c;throw a+" not found."},d=function(a,b){var d=c(a),e;b=b.length?wax.Record(b):[];if(Object.create)e=Object.create(d[1].prototype),d[1].apply(e,b);else switch(b.length){case 0:e=new d[1];break;case 1:e=new d[1](b[0]);break;case 2:e=new d[1](b[0],b[1]);break;case 3:e=new d[1](b[0],b[1],b[2]);break;case 4:e=new d[1](b[0],b[1],b[2],b[3]);break;case 5:e=new d[1](b[0],b[1],b[2],b[3],b[4]);break;default:}return e},e=function(a,b,d){var e=c(a,d),f=b.length?wax.Record(b):[];return d&&a.indexOf(".")===-1?e[1].apply(d,f):e[1].apply(e[0],f)},f=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@literal","@chain","@inject","@group"],a.split(" ")[0])!==-1},g=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@chain"],a.split(" ")[0])!==-1},h=function(a){if(wax.util.isArray(a)&&a[0]&&f(a[0]))return{verb:a[0].split(" ")[0],subject:a[0].split(" ")[1],object:a.slice(1)};return!1},i,j=!1,k=null,l=null,m=h(a);if(!m){if(a!==null&&typeof a=="object"){var n=wax.util.keys(a);for(i=0;i<n.length;i++){var o=n[i];a[o]=wax.Record(a[o],b)}return a}return a}switch(m.verb){case"@group":for(i=0;i<m.object.length;i++)k=wax.Record(m.object[i],b),l=h(m.object[i]),l&&g(l.verb)&&(b=k);return b;case"@new":return d(m.subject,m.object);case"@literal":j=c(m.subject);return j?j[1]:null;case"@inject":return e(m.subject,m.object,b);case"@chain":return e(m.subject,m.object,b);case"@call":return e(m.subject,m.object,null)}};var wax=wax||{};wax.request={cache:{},locks:{},promises:{},get:function(a,b){if(this.cache[a])return b(this.cache[a][0],this.cache[a][1]);this.promises[a]=this.promises[a]||[],this.promises[a].push(b);if(!this.locks[a]){var c=this;this.locks[a]=!0,reqwest({url:a+"?callback=grid",type:"jsonp",jsonpCallback:"callback",success:function(b){c.locks[a]=!1,c.cache[a]=[null,b];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])},error:function(b){c.locks[a]=!1,c.cache[a]=[b,null];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])}})}}},wax.GridInstance=function(a,b){this.grid_tile=a,this.formatter=b,this.tileRes=4},wax.GridInstance.prototype.resolveCode=function(a){a>=93&&a--,a>=35&&a--,a-=32;return a},wax.GridInstance.prototype.getFeature=function(a,b,c,d){if(!!this.grid_tile&&!!this.grid_tile.grid){var e=wax.util.offset(c),f=e.left,g=e.top;if(b-g<0)return;if(a-f<0)return;if(Math.floor((b-g)/this.tileRes)>256)return;if(Math.floor((a-f)/this.tileRes)>256)return;var h=this.grid_tile.grid[Math.floor((b-g)/this.tileRes)].charCodeAt(Math.floor((a-f)/this.tileRes));h=this.resolveCode(h);if(this.grid_tile.keys[h]&&this.grid_tile.data[this.grid_tile.keys[h]])return this.formatter.format(d,this.grid_tile.data[this.grid_tile.keys[h]])}},wax.GridManager=function(){this.grid_tiles={},this.key_maps={},this.formatters={},this.locks={}},wax.GridManager.prototype.getGrid=function(a,b){var c=this;c.getFormatter(c.formatterUrl(a),function(d,e){if(d||!e)return b(d,null);wax.request.get(c.tileDataUrl(a),function(a,c){if(a)return b(a,null);b(null,new wax.GridInstance(c,e))})})},wax.GridManager.prototype.tileDataUrl=function(a){return a.replace(/(\.png|\.jpg|\.jpeg)(\d*)/,".grid.json")},wax.GridManager.prototype.formatterUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")},wax.GridManager.prototype.getFormatter=function(a,b){var c=this;typeof this.formatters[a]!="undefined"?b(null,this.formatters[a]):wax.request.get(a,function(d,e){e&&e.formatter?c.formatters[a]=new wax.Formatter(e):c.formatters[a]=!1,b(d,c.formatters[a])})},wax.Formatter=function(obj){if(obj.formatter&&typeof obj.formatter=="string")try{eval("this.f = "+obj.formatter)}catch(e){console&&console.log(e)}else this.f=function(){}},wax.Formatter.prototype.format=function(a,b){try{return this.f(a,b)}catch(c){console&&console.log(c)}};var wax=wax||{};wax.Legend=function(a,b){this.legends={},this.context=a,this.container=b,this.container||(this.container=document.createElement("div"),this.container.className="wax-legends"),this.context.appendChild(this.container)},wax.Legend.prototype.render=function(a){var b;for(b in this.legends)this.legends[b].style.display="none";var c=wax.util.bind(function(a,b){b?this.legends[a]?this.legends[a].style.display="block":(this.legends[a]=document.createElement("div"),this.legends[a].className="wax-legend",this.legends[a].innerHTML=b,this.container.appendChild(this.legends[a])):this.legends[a]=!1},this);for(var d=0;d<a.length;d++)b=this.legendUrl(a[d]),wax.request.get(b,function(a,d){d&&d.legend&&c(b,d.legend)})},wax.Legend.prototype.legendUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")};var w=function(a){a.melt=function(b,c){b.apply(c,[a,c]);return a};return a},wax=wax||{};wax.tooltip={},wax.tooltip=function(a){this._currentTooltip=undefined,a=a||{},a.animationOut&&(this.animationOut=a.animationOut),a.animationIn&&(this.animationIn=a.animationIn)},wax.tooltip.prototype.isPopup=function(a){return a&&a.className.indexOf("wax-popup")!==-1},wax.tooltip.prototype.getTooltip=function(a,b,c,d){tooltip=document.createElement("div"),tooltip.className="wax-tooltip wax-tooltip-"+c,tooltip.innerHTML=a,b.appendChild(tooltip);return tooltip},wax.tooltip.prototype.hideTooltip=function(a){if(!!a){var b,c=function(){this.parentNode.removeChild(this)};a.style["-webkit-transition"]!==undefined&&this.animationOut?b="webkitTransitionEnd":a.style.MozTransition!==undefined&&this.animationOut&&(b="transitionend"),b?(a.addEventListener(b,c,!1),a.addEventListener("transitionend",c,!1),a.className+=" "+this.animationOut):a.parentNode.removeChild(a)}},wax.tooltip.prototype.click=function(a,b,c){this.unselect(b);var d=this.getTooltip(a,b,c),e=document.createElement("a");e.href="#close",e.className="close",e.innerHTML="Close";var f=wax.util.bind(function(a){this.hideTooltip(d),this._currentTooltip=undefined,a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault();return!1},this);e.addEventListener?e.addEventListener("click",f,!1):e.attachEvent&&e.attachEvent("onclick",f),d.className+=" wax-popup",d.innerHTML=a,d.appendChild(e),this._currentTooltip=d},wax.tooltip.prototype.select=function(a,b,c,d){if(!!a){if(this.isPopup(this._currentTooltip))return;this._currentTooltip=this.getTooltip(a,b,c,d),b.style.cursor="pointer"}},wax.tooltip.prototype.unselect=function(a){this.isPopup(this._currentTooltip)||(a.style.cursor="default",this._currentTooltip&&(this.hideTooltip(this._currentTooltip),this._currentTooltip=undefined))},wax.tooltip.prototype.out=wax.tooltip.prototype.unselect,wax.tooltip.prototype.over=wax.tooltip.prototype.select,wax.tooltip.prototype.click=wax.tooltip.prototype.click,wax.util=wax.util||{},wax.util={offset:function(a){var b=a.offsetWidth,c=a.offsetHeight,d=a.offsetTop,e=a.offsetLeft;try{while(a=a.offsetParent){d+=a.offsetTop,e+=a.offsetLeft;var f=a.style.transform||a.style["-webkit-transform"]||a.style.MozTransform;if(f){var g=f.match(/translate\((.+)px, (.+)px\)/);g&&(d+=parseInt(g[2],10),e+=parseInt(g[1],10))}}}catch(h){}d+=document.body.offsetTop,e+=document.body.offsetLeft,d+=document.body.parentNode.offsetTop,e+=document.body.parentNode.offsetLeft;var i=document.defaultView?window.getComputedStyle(document.body.parentNode):document.body.parentNode.currentStyle;document.body.parentNode.offsetTop!==parseInt(i.marginTop,10)&&(d+=parseInt(i.marginTop,10),e+=parseInt(i.marginLeft,10));return{top:d,left:e,height:c,width:b}},bind:function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,c.concat(Array.prototype.slice.call(arguments)))}},isString:function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},indexOf:function(a,b){var c=Array.prototype.indexOf;if(a===null)return-1;var d,e;if(c&&a.indexOf===c)return a.indexOf(b);for(d=0,e=a.length;d<e;d++)if(a[d]===b)return d;return-1},isArray:Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},keys:Object.keys||function(a){var b=Object.prototype.hasOwnProperty;if(a!==Object(a))throw new TypeError("Invalid object");var c=[];for(var d in a)b.call(a,d)&&(c[c.length]=d);return c},eventoffset:function(a){var b=0,c=0;if(!a)var a=window.event;if(a.pageX||a.pageY)return{x:a.pageX,y:a.pageY};if(a.clientX||a.clientY){var d=document.documentElement,e=document.body,f=document.body.parentNode.currentStyle,g=parseInt(f.marginTop,10)||0,h=parseInt(f.marginLeft,10)||0;return{x:a.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0)+h,y:a.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)+g}}}},wax=wax||{},wax.mm=wax.mm||{},wax.mm.boxselector=function(a,b){var c=null,d=typeof b=="function"?b:b.callback,e={add:function(a){this.boxDiv=document.createElement("div"),this.boxDiv.id=a.parent.id+"-boxselector-box",this.boxDiv.className="boxselector-box",a.parent.appendChild(this.boxDiv),com.modestmaps.addEvent(a.parent,"mousedown",this.mouseDown()),a.addCallback("drawn",this.drawbox())},remove:function(){a.parent.removeChild(this.boxDiv),a.removeCallback("mousedown",this.drawbox())},getMousePoint:function(b){var c=new com.modestmaps.Point(b.clientX,b.clientY);c.x+=document.body.scrollLeft+document.documentElement.scrollLeft,c.y+=document.body.scrollTop+document.documentElement.scrollTop;for(var d=a.parent;d;d=d.offsetParent)c.x-=d.offsetLeft,c.y-=d.offsetTop;return c},mouseDown:function(){this._mouseDown||(this._mouseDown=wax.util.bind(function(b){if(b.shiftKey){c=this.getMousePoint(b),this.boxDiv.style.left=c.x+"px",this.boxDiv.style.top=c.y+"px",com.modestmaps.addEvent(a.parent,"mousemove",this.mouseMove()),com.modestmaps.addEvent(a.parent,"mouseup",this.mouseUp()),a.parent.style.cursor="crosshair";return com.modestmaps.cancelEvent(b)}},this));return this._mouseDown},mouseMove:function(a){this._mouseMove||(this._mouseMove=wax.util.bind(function(a){var b=this.getMousePoint(a);this.boxDiv.style.display="block",b.x<c.x?this.boxDiv.style.left=b.x+"px":this.boxDiv.style.left=c.x+"px",this.boxDiv.style.width=Math.abs(b.x-c.x)+"px",b.y<c.y?this.boxDiv.style.top=b.y+"px":this.boxDiv.style.top=c.y+"px",this.boxDiv.style.height=Math.abs(b.y-c.y)+"px";return com.modestmaps.cancelEvent(a)},this));return this._mouseMove},mouseUp:function(){this._mouseUp||(this._mouseUp=wax.util.bind(function(b){var f=e.getMousePoint(b),g=a.pointLocation(f),h=a.pointLocation(c),i=[new com.modestmaps.Location(Math.max(g.lat,h.lat),Math.min(g.lon,h.lon)),new com.modestmaps.Location(Math.min(g.lat,h.lat),Math.max(g.lon,h.lon))];this.box=[g,h],d(i),com.modestmaps.removeEvent(a.parent,"mousemove",this.mouseMove()),com.modestmaps.removeEvent(a.parent,"mouseup",this.mouseUp()),a.parent.style.cursor="auto"},this));return this._mouseUp},drawbox:function(){this._drawbox||(this._drawbox=wax.util.bind(function(a,b){if(this.boxDiv){this.boxDiv.style.display="block",this.boxDiv.style.height="auto",this.boxDiv.style.width="auto";var c=a.locationPoint(this.box[0]),d=a.locationPoint(this.box[1]);this.boxDiv.style.left=Math.max(0,d.x)+"px",this.boxDiv.style.top=Math.max(0,d.y)+"px",this.boxDiv.style.right=Math.max(0,a.dimensions.x-c.x)+"px",this.boxDiv.style.bottom=Math.max(0,a.dimensions.y-c.y)+"px"}},this));return this._drawbox}};return e.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.fullscreen=function(a,b){var c={state:1,add:function(a){this.a=document.createElement("a"),this.a.className="wax-fullscreen",this.a.href="#fullscreen",this.a.innerHTML="fullscreen",a.parent.appendChild(this.a),com.modestmaps.addEvent(this.a,"click",this.click(a));return this},click:function(a){if(this._click)return this._click;this._click=wax.util.bind(function(b){b&&com.modestmaps.cancelEvent(b),this.state?(this.smallSize=[a.parent.offsetWidth,a.parent.offsetHeight],a.parent.className+=" wax-fullscreen-map",a.setSize(a.parent.offsetWidth,a.parent.offsetHeight)):(a.parent.className=a.parent.className.replace("wax-fullscreen-map",""),a.setSize(this.smallSize[0],this.smallSize[1])),this.state=!this.state},this);return this._click}};return c.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.locationHash={stateChange:function(a){com.modestmaps.addEvent(window,"hashchange",function(){a(location.hash)},!1)},getState:function(){return location.hash},pushState:function(a){location.hash=a}},wax.mm.hash=function(a,b){var c,d=90-1e-8,e=function(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,a.apply(e,f)};c&&clearTimeout(d);if(c||!d)d=setTimeout(g,b)}},f=function(a,b){return e(a,b,!1)},g={map:this,parser:function(b){var c=b.split("/");for(var d=0;d<c.length;d++){if(isNaN(c[d]))return!0;c[d]=Number(c)}if(c.length<3)return!0;c.length==3&&a.setCenterZoom(new com.modestmaps.Location(c[1],c[2]),c[0])},add:function(a){b.manager.getState()?g.stateChange(b.manager.getState()):(g.initialize(),g.move()),a.addCallback("drawn",f(g.move,500)),b.manager.stateChange(g.stateChange)},formatter:function(){var b=a.getCenter(),c=a.getZoom(),d=Math.max(0,Math.ceil(Math.log(c)/Math.LN2));return"#"+[c.toFixed(2),b.lat.toFixed(d),b.lon.toFixed(d)].join("/")},move:function(){var a=g.formatter();c!==a&&(c=a,b.manager.pushState(c))},stateChange:function(a){a!==c&&g.parser((c=a).substring(1))&&g.move()},initialize:function(){b.defaultCenter&&a.setCenter(b.defaultCenter),b.defaultZoom&&a.setZoom(b.defaultZoom)}};return g.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.interaction=function(a,b){var c=com.modestmaps;b=b||{};var d={modifyingEvents:["zoomed","panned","centered","extentset","resized","drawn"],waxGM:new wax.GridManager,callbacks:b.callbacks||new wax.tooltip,clickAction:b.clickAction||"full",clickHandler:b.clickHandler||function(a){window.location=a},add:function(){for(var b=0;b<this.modifyingEvents.length;b++)a.addCallback(this.modifyingEvents[b],wax.util.bind(this.clearTileGrid,this));c.addEvent(a.parent,"mousemove",this.onMove()),c.addEvent(a.parent,"mousedown",this.onDown()),c.addEvent(a.parent,"touchstart",this.onDown());return this},getTileGrid:function(){var b=a.getZoom();return this._getTileGrid||(this._getTileGrid=function(a){var c=[];for(var d in a)if(d.split(",")[0]==b){var e=wax.util.offset(a[d]);c.push([e.top,e.left,a[d]])}return c}(a.tiles))},clearTileGrid:function(a,b){this._getTileGrid=null},getTile:function(a){var b,c=this.getTileGrid();for(var d=0;d<c.length;d++)if(c[d][0]<a.y&&c[d][0]+256>a.y&&c[d][1]<a.x&&c[d][1]+256>a.x){b=c[d][2];break}return b||!1},clearTimeout:function(){if(this.clickTimeout){window.clearTimeout(this.clickTimeout),this.clickTimeout=null;return!0}return!1},onMove:function(b){this._onMove||(this._onMove=wax.util.bind(function(b){var c=wax.util.eventoffset(b),d=this.getTile(c);d&&this.waxGM.getGrid(d.src,wax.util.bind(function(e,f){if(!e&&f){var g=f.getFeature(c.x,c.y,d,{format:"teaser"});g?g&&this.feature!==g?(this.feature=g,this.callbacks.out(a.parent),this.callbacks.over(g,a.parent,0,b)):g||(this.feature=null,this.callbacks.out(a.parent)):(this.feature=null,this.callbacks.out(a.parent))}},this))},this));return this._onMove},onDown:function(b){this._onDown||(this._onDown=wax.util.bind(function(b){this.clearTimeout()||(b.type==="mousedown"?(this.downEvent=wax.util.eventoffset(b),c.addEvent(a.parent,"mouseup",this.onUp())):b.type==="touchstart"&&b.touches.length===1&&(console.log("good touch"),c.addEvent(a.parent,"touchend",this.onUp())))},this));return this._onDown},onUp:function(){this._onUp||(this._onUp=wax.util.bind(function(b){c.removeEvent(a.parent,"mouseup",this.onUp());var d=4,e=wax.util.eventoffset(b);Math.round(e.y/d)===Math.round(this.downEvent.y/d)&&Math.round(e.x/d)===Math.round(this.downEvent.x/d)&&(this.clickTimeout=window.setTimeout(wax.util.bind(function(){this.click()(e)},this),300))},this));return this._onUp},click:function(b){this._onClick||(this._onClick=wax.util.bind(function(c){var d=this.getTile(c);d&&this.waxGM.getGrid(d.src,wax.util.bind(function(e,f){if(f){var g=f.getFeature(c.x,c.y,d,{format:this.clickAction});if(g)switch(this.clickAction){case"full":this.callbacks.click(g,a.parent,0,b);break;case"location":this.clickHandler(g)}}},this))},this));return this._onClick}};return d.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.legend=function(a,b){b=b||{};var c={add:function(){this.legend=new wax.Legend(a.parent,b.container),this.legend.render([a.provider.getTileUrl({zoom:0,column:0,row:0})])}};return c.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.mobile=function(a,b){b=b||{};var c=com.modestmaps,d=navigator.userAgent.toLowerCase(),e=d.indexOf("webkit")!=-1,f=d.indexOf("mobile")!=-1,g=f&&e,h=function(a){var b=document.createElement("canvas"),c=parseInt(a.style.width,10),d=parseInt(a.style.height,10),e=c/2,f=d/2,g=Math.min(c,d)/4,h=b.getContext("2d");b.setAttribute("width",c),b.setAttribute("height",d),h.globalAlpha=.5;var i=h.createLinearGradient(0,0,300,225);i.addColorStop(0,"black"),i.addColorStop(1,"rgb(200, 200, 200)"),h.fillStyle=i,h.fillRect(0,0,c,d),h.fillStyle="rgb(255, 255, 255)",h.beginPath(),h.moveTo(e-g*.6,f-g),h.lineTo(e-g*.6,f+g),h.lineTo(e+g*.6,f),h.fill(),a.appendChild(b)},i=function(a){a.style.position="absolute",a.style.height="50px",a.style.left=a.style.right="0";var b=document.createElement("canvas");b.setAttribute("width",a.offsetWidth),b.setAttribute("height",a.offsetHeight);var c=b.getContext("2d");c.globalAlpha=1,c.fillStyle="rgba(255, 255, 255, 0.5)",c.fillRect(0,0,a.offsetWidth,a.offsetHeight),c.fillStyle="rgb(0, 0, 0)",c.font="bold 20px sans-serif",c.fillText("back",20,30),a.appendChild(b)},j=function(a){a.style.position="absolute",a.style.width=a.style.height="auto",a.style.top=window.pageYOffset+"px",a.style.left=a.style.right="0px"},k=function(a){a.style.position="relative",a.style.width=a.style.height=a.style.top=a.style.left=a.style.right="auto"},l,m,n,o,p=b.overlayDraw||h,q=b.backDraw||i;bodyDraw=b.bodyDraw||function(){};var r={add:function(a){g&&(o=document.createElement("meta"),o.id="wax-touch",o.setAttribute("name","viewport"),l=document.createElement("div"),l.id=a.parent.id+"-mobileoverlay",l.className="wax-mobileoverlay",l.style.position="absolute",l.style.width=a.dimensions.x+"px",l.style.height=a.dimensions.y+"px",a.parent.appendChild(l),p(l),n=document.createElement("div"),backDiv=document.createElement("div"),m=document.body,newBody=document.createElement("body"),newBody.appendChild(backDiv),c.addEvent(l,"touchstart",this.toTouch),c.addEvent(backDiv,"touchstart",this.toPage));return this},toTouch:function(){a.parent.parentNode.replaceChild(n,a.parent),newBody.insertBefore(a.parent,backDiv),document.body=newBody,bodyDraw(newBody),q(backDiv),o.setAttribute("content","initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0"),document.head.appendChild(o),a._smallSize=[a.parent.clientWidth,a.parent.clientHeight],j(a.parent),a.setSize(a.parent.offsetWidth,window.innerHeight),backDiv.style.display="block",l.style.display="none"},toPage:function(){document.body=m,n.parentNode.replaceChild(a.parent,n),k(a.parent),a.setSize(a._smallSize[0],a._smallSize[1]),backDiv.style.display="none",l.style.display="block"}};return r.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.pointselector=function(a,b){function k(a){var b=[];for(var c=0;c<a.length;c++)b.push(new g.Location(a[c].lat,a[c].lon));return b}var c=null,d=null,e=5,f,g=com.modestmaps,h=[],i=typeof b=="function"?b:b.callback,j=function(b){var c=wax.util.eventoffset(b),d=new g.Point(c.x,c.y),e={x:parseFloat(g.getStyle(document.documentElement,"margin-left")),y:parseFloat(g.getStyle(document.documentElement,"margin-top"))};isNaN(e.x)||(d.x-=e.x),isNaN(e.y)||(d.y-=e.y);for(var f=a.parent;f;f=f.offsetParent)d.x-=f.offsetLeft,d.y-=f.offsetTop;return d},l={add:function(a){g.addEvent(a.parent,"mousedown",this.mouseDown()),a.addCallback("drawn",l.drawPoints());return this},deletePoint:function(a,b){confirm("Delete this point?")&&(a.pointDiv.parentNode.removeChild(a.pointDiv),h.splice(wax.util.indexOf(h,a),1),i(k(h)))},drawPoints:function(){this._drawPoints||(this._drawPoints=wax.util.bind(function(){var b=new g.Point(0,0);for(var c=0;c<h.length;c++){var d=a.locationPoint(h[c]);h[c].pointDiv||(h[c].pointDiv=document.createElement("div"),h[c].pointDiv.className="wax-point-div",h[c].pointDiv.style.position="absolute",h[c].pointDiv.style.display="block",h[c].pointDiv.location=h[c],g.addEvent(h[c].pointDiv,"mouseup",function(d){var e=h[c];return function(b){g.removeEvent(a.parent,"mouseup",l.mouseUp()),l.deletePoint(e,b)}}()),a.parent.appendChild(h[c].pointDiv)),h[c].pointDiv.style.left=d.x+"px",h[c].pointDiv.style.top=d.y+"px"}},this));return this._drawPoints},mouseDown:function(){this._mouseDown||(this._mouseDown=wax.util.bind(function(b){c=j(b),g.addEvent(a.parent,"mouseup",this.mouseUp())},this));return this._mouseDown},addLocation:function(a){h.push(a),l.drawPoints()(),i(k(h))},mouseUp:function(){this._mouseUp||(this._mouseUp=wax.util.bind(function(b){!c||(d=j(b),g.Point.distance(c,d)<e&&(this.addLocation(a.pointLocation(c)),i(k(h))),c=null)},this));return this._mouseUp}};return l.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.zoombox=function(a,b){var c=null,d={add:function(a){this.box=document.createElement("div"),this.box.id=a.parent.id+"-zoombox-box",this.box.className="zoombox-box",a.parent.appendChild(this.box),com.modestmaps.addEvent(a.parent,"mousedown",this.mouseDown())},remove:function(){a.parent.removeChild(this.box),a.removeCallback("mousedown",this.mouseDown)},getMousePoint:function(b){var c=new com.modestmaps.Point(b.clientX,b.clientY);c.x+=document.body.scrollLeft+document.documentElement.scrollLeft,c.y+=document.body.scrollTop+document.documentElement.scrollTop;for(var d=a.parent;d;d=d.offsetParent)c.x-=d.offsetLeft,c.y-=d.offsetTop;return c},mouseDown:function(){this._mouseDown||(this._mouseDown=wax.util.bind(function(b){if(b.shiftKey){c=this.getMousePoint(b),this.box.style.left=c.x+"px",this.box.style.top=c.y+"px",com.modestmaps.addEvent(a.parent,"mousemove",this.mouseMove()),com.modestmaps.addEvent(a.parent,"mouseup",this.mouseUp()),a.parent.style.cursor="crosshair";return com.modestmaps.cancelEvent(b)}},this));return this._mouseDown},mouseMove:function(a){this._mouseMove||(this._mouseMove=wax.util.bind(function(a){var b=this.getMousePoint(a);this.box.style.display="block",b.x<c.x?this.box.style.left=b.x+"px":this.box.style.left=c.x+"px",this.box.style.width=Math.abs(b.x-c.x)+"px",b.y<c.y?this.box.style.top=b.y+"px":this.box.style.top=c.y+"px",this.box.style.height=Math.abs(b.y-c.y)+"px";return com.modestmaps.cancelEvent(a)},this));return this._mouseMove},mouseUp:function(b){this._mouseUp||(this._mouseUp=wax.util.bind(function(b){var d=this.getMousePoint(b),e=a.pointLocation(d),f=a.pointLocation(c);a.setExtent([e,f]),this.box.style.display="none",com.modestmaps.removeEvent(a.parent,"mousemove",this.mouseMove()),com.modestmaps.removeEvent(a.parent,"mouseup",this.mouseUp()),a.parent.style.cursor="auto"},this));return this._mouseUp}};return d.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.zoomer=function(a){var b=document.createElement("a");b.innerHTML="+",b.href="#",b.className="zoomer zoomin",com.modestmaps.addEvent(b,"mousedown",function(a){com.modestmaps.cancelEvent(a)}),com.modestmaps.addEvent(b,"click",function(b){com.modestmaps.cancelEvent(b),a.zoomIn()},!1),a.parent.appendChild(b);var c=document.createElement("a");c.innerHTML="-",c.href="#",c.className="zoomer zoomout",com.modestmaps.addEvent(c,"mousedown",function(a){com.modestmaps.cancelEvent(a)}),com.modestmaps.addEvent(c,"click",function(b){com.modestmaps.cancelEvent(b),a.zoomOut()},!1),a.parent.appendChild(c);var d={add:function(a){a.addCallback("drawn",function(a,d){a.coordinate.zoom===a.provider.outerLimits()[0].zoom?c.className="zoomer zoomout zoomdisabled":a.coordinate.zoom===a.provider.outerLimits()[1].zoom?b.className="zoomer zoomin zoomdisabled":(b.className="zoomer zoomin",c.className="zoomer zoomout")});return this}};return d.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.provider=function(a){this.layerName=a.layerName,this.baseUrls=typeof a.baseUrl=="string"?[a.baseUrl]:a.baseUrl,this.n_urls=this.baseUrls.length,this.filetype=a.filetype||".png",this.zoomRange=a.zoomRange||[0,18]},wax.mm.provider.prototype={outerLimits:function(){return[(new com.modestmaps.Coordinate(0,0,0)).zoomTo(this.zoomRange[0]),(new com.modestmaps.Coordinate(1,1,0)).zoomTo(this.zoomRange[1])]},getTileUrl:function(a){var b;a=this.sourceCoordinate(a);if(!a)return null;var c=Math.pow(2,a.zoom);a.row=Math.pow(2,a.zoom)-a.row-1,this.n_urls===1?b=this.baseUrls[0]:b=this.baseUrls[parseInt(c*a.row+a.column,10)%this.n_urls];var d=["1.0.0",this.layerName,a.zoom,a.column,a.row].join("/");return b+d+this.filetype}},com.modestmaps.extend(wax.mm.provider,com.modestmaps.MapProvider)
View
2 dist/wax.ol.js
@@ -299,7 +299,7 @@ wax.GridInstance.prototype.getFeature = function(x, y, tile_element, options) {
// If this layers formatter hasn't been loaded yet,
// download and load it now.
if (this.grid_tile.keys[key] && this.grid_tile.data[this.grid_tile.keys[key]]) {
- return this.formatter.format(options, data_val);
+ return this.formatter.format(options, this.grid_tile.data[this.grid_tile.keys[key]]);
}
};
View
2 dist/wax.ol.min.js
@@ -5,4 +5,4 @@
* copyright Dustin Diaz 2011
* https://github.com/ded/reqwest
* license MIT
- */!function(window){function readyState(a,b,c){return function(){a&&a.readyState==4&&(twoHundo.test(a.status)?b(a):c(a))}}function setHeaders(a,b){var c=b.headers||{};c.Accept="text/javascript, text/html, application/xml, text/xml, */*",c["X-Requested-With"]=c["X-Requested-With"]||"XMLHttpRequest";if(b.data){c["Content-type"]="application/x-www-form-urlencoded";for(var d in c)c.hasOwnProperty(d)&&a.setRequestHeader(d,c[d],!1)}}function getCallbackName(a){var b=a.jsonpCallback||"callback";if(a.url.slice(-(b.length+2))==b+"=?"){var c="reqwest_"+uniqid++;a.url=a.url.substr(0,a.url.length-1)+c;return c}var d=new RegExp(b+"=([\\w]+)");return a.url.match(d)[1]}function generalCallback(a){lastValue=a}function getRequest(a,b,c){if(a.type!="jsonp"){var d=xhr();d.open(a.method||"GET",typeof a=="string"?a:a.url,!0),setHeaders(d,a),d.onreadystatechange=readyState(d,b,c),a.before&&a.before(d),d.send(a.data||null);return d}var e=doc.createElement("script");window[getCallbackName(a)]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0;var f=function(){a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e)};e.onload=f,e.onreadystatechange=function(){e.readyState=="loaded"||e.readyState=="complete"&&f()},head.appendChild(e)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){if(/\.json$/.test(a))return"json";if(/\.jsonp$/.test(a))return"jsonp";if(/\.js$/.test(a))return"js";if(/\.html?$/.test(a))return"html";if(/\.xml$/.test(a))return"xml";return"js"}function init(o,fn){function complete(a){o.complete&&o.complete(a)}function success(resp){o.timeout&&clearTimeout(self.timeout)&&(self.timeout=null);var r=resp.responseText;switch(type){case"json":resp=eval("("+r+")");break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.success&&o.success(resp),complete(resp)}function error(a){o.error&&o.error(a),complete(a)}this.url=typeof o=="string"?o:o.url,this.timeout=null;var type=o.type||setType(this.url),self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort(),error()},o.timeout)),this.request=getRequest(o,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function enc(a){return encodeURIComponent(a)}function serial(a){var b=a.name;if(a.disabled||!b)return"";b=enc(b);switch(a.tagName.toLowerCase()){case"input":switch(a.type){case"reset":case"button":case"image":case"file":return"";case"checkbox":case"radio":return a.checked?b+"="+(a.value?enc(a.value):!0)+"&":"";default:return b+"="+(a.value?enc(a.value):!0)+"&"}break;case"textarea":return b+"="+enc(a.value)+"&";case"select":return b+"="+enc(a.options[a.selectedIndex].value)+"&"}return""}var twoHundo=/^20\d$/,doc=document,byTag="getElementsByTagName",head=doc[byTag]("head")[0],xhr="XMLHttpRequest"in window?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")},uniqid=0,lastValue;Reqwest.prototype={abort:function(){this.request.abort()},retry:function(){init.call(this,this.o,this.fn)}},reqwest.serialize=function(a){var b=a[byTag]("input"),c=a[byTag]("select"),d=a[byTag]("textarea");return(v(b).chain().toArray().map(serial).value().join("")+v(c).chain().toArray().map(serial).value().join("")+v(d).chain().toArray().map(serial).value().join("")).replace(/&$/,"")},reqwest.serializeArray=function(a){for(var b=this.serialize(a).split("&"),c=0,d=b.length,e=[],f;c<d;c++)b[c]&&(f=b[c].split("="))&&e.push({name:f[0],value:f[1]});return e};var old=window.reqwest;reqwest.noConflict=function(){window.reqwest=old;return this},window.reqwest=reqwest}(this);var wax=wax||{};Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(typeof a!="function")throw new TypeError;if(c==0&&arguments.length==1)throw new TypeError;var d=0,e;if(arguments.length>=2)e=arguments[1];else do{if(d in b){e=b[d++];break}if(++d>=c)throw new TypeError}while(!0);while(d<c)d in b&&(e=a.call(undefined,e,b[d],d,b)),d++;return e}),wax.Record=function(a,b){var c=function(a,b){var c=a.split(".").reduce(function(a,b){return[a[1]||a[0],a[1]?a[1][b]:a[0][b]]},[b||window,null]);if(c[0]&&c[1])return c;throw a+" not found."},d=function(a,b){var d=c(a),e;b=b.length?wax.Record(b):[];if(Object.create)e=Object.create(d[1].prototype),d[1].apply(e,b);else switch(b.length){case 0:e=new d[1];break;case 1:e=new d[1](b[0]);break;case 2:e=new d[1](b[0],b[1]);break;case 3:e=new d[1](b[0],b[1],b[2]);break;case 4:e=new d[1](b[0],b[1],b[2],b[3]);break;case 5:e=new d[1](b[0],b[1],b[2],b[3],b[4]);break;default:}return e},e=function(a,b,d){var e=c(a,d),f=b.length?wax.Record(b):[];return d&&a.indexOf(".")===-1?e[1].apply(d,f):e[1].apply(e[0],f)},f=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@literal","@chain","@inject","@group"],a.split(" ")[0])!==-1},g=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@chain"],a.split(" ")[0])!==-1},h=function(a){if(wax.util.isArray(a)&&a[0]&&f(a[0]))return{verb:a[0].split(" ")[0],subject:a[0].split(" ")[1],object:a.slice(1)};return!1},i,j=!1,k=null,l=null,m=h(a);if(!m){if(a!==null&&typeof a=="object"){var n=wax.util.keys(a);for(i=0;i<n.length;i++){var o=n[i];a[o]=wax.Record(a[o],b)}return a}return a}switch(m.verb){case"@group":for(i=0;i<m.object.length;i++)k=wax.Record(m.object[i],b),l=h(m.object[i]),l&&g(l.verb)&&(b=k);return b;case"@new":return d(m.subject,m.object);case"@literal":j=c(m.subject);return j?j[1]:null;case"@inject":return e(m.subject,m.object,b);case"@chain":return e(m.subject,m.object,b);case"@call":return e(m.subject,m.object,null)}};var wax=wax||{};wax.request={cache:{},locks:{},promises:{},get:function(a,b){if(this.cache[a])return b(this.cache[a][0],this.cache[a][1]);this.promises[a]=this.promises[a]||[],this.promises[a].push(b);if(!this.locks[a]){var c=this;this.locks[a]=!0,reqwest({url:a+"?callback=grid",type:"jsonp",jsonpCallback:"callback",success:function(b){c.locks[a]=!1,c.cache[a]=[null,b];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])},error:function(b){c.locks[a]=!1,c.cache[a]=[b,null];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])}})}}},wax.GridInstance=function(a,b){this.grid_tile=a,this.formatter=b,this.tileRes=4},wax.GridInstance.prototype.resolveCode=function(a){a>=93&&a--,a>=35&&a--,a-=32;return a},wax.GridInstance.prototype.getFeature=function(a,b,c,d){if(!!this.grid_tile&&!!this.grid_tile.grid){var e=wax.util.offset(c),f=e.left,g=e.top;if(b-g<0)return;if(a-f<0)return;if(Math.floor((b-g)/this.tileRes)>256)return;if(Math.floor((a-f)/this.tileRes)>256)return;var h=this.grid_tile.grid[Math.floor((b-g)/this.tileRes)].charCodeAt(Math.floor((a-f)/this.tileRes));h=this.resolveCode(h);if(this.grid_tile.keys[h]&&this.grid_tile.data[this.grid_tile.keys[h]])return this.formatter.format(d,data_val)}},wax.GridManager=function(){this.grid_tiles={},this.key_maps={},this.formatters={},this.locks={}},wax.GridManager.prototype.getGrid=function(a,b){var c=this;c.getFormatter(c.formatterUrl(a),function(d,e){if(d||!e)return b(d,null);wax.request.get(c.tileDataUrl(a),function(a,c){if(a)return b(a,null);b(null,new wax.GridInstance(c,e))})})},wax.GridManager.prototype.tileDataUrl=function(a){return a.replace(/(\.png|\.jpg|\.jpeg)(\d*)/,".grid.json")},wax.GridManager.prototype.formatterUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")},wax.GridManager.prototype.getFormatter=function(a,b){var c=this;typeof this.formatters[a]!="undefined"?b(null,this.formatters[a]):wax.request.get(a,function(d,e){e&&e.formatter?c.formatters[a]=new wax.Formatter(e):c.formatters[a]=!1,b(d,c.formatters[a])})},wax.Formatter=function(obj){if(obj.formatter&&typeof obj.formatter=="string")try{eval("this.f = "+obj.formatter)}catch(e){console&&console.log(e)}else this.f=function(){}},wax.Formatter.prototype.format=function(a,b){try{return this.f(a,b)}catch(c){console&&console.log(c)}};var wax=wax||{};wax.Legend=function(a,b){this.legends={},this.context=a,this.container=b,this.container||(this.container=document.createElement("div"),this.container.className="wax-legends"),this.context.appendChild(this.container)},wax.Legend.prototype.render=function(a){var b;for(b in this.legends)this.legends[b].style.display="none";var c=wax.util.bind(function(a,b){b?this.legends[a]?this.legends[a].style.display="block":(this.legends[a]=document.createElement("div"),this.legends[a].className="wax-legend",this.legends[a].innerHTML=b,this.container.appendChild(this.legends[a])):this.legends[a]=!1},this);for(var d=0;d<a.length;d++)b=this.legendUrl(a[d]),wax.request.get(b,function(a,d){d&&d.legend&&c(b,d.legend)})},wax.Legend.prototype.legendUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")};var w=function(a){a.melt=function(b,c){b.apply(c,[a,c]);return a};return a},wax=wax||{};wax.tooltip={},wax.tooltip=function(a){this._currentTooltip=undefined,a=a||{},a.animationOut&&(this.animationOut=a.animationOut),a.animationIn&&(this.animationIn=a.animationIn)},wax.tooltip.prototype.isPopup=function(a){return a&&a.className.indexOf("wax-popup")!==-1},wax.tooltip.prototype.getTooltip=function(a,b,c,d){tooltip=document.createElement("div"),tooltip.className="wax-tooltip wax-tooltip-"+c,tooltip.innerHTML=a,b.appendChild(tooltip);return tooltip},wax.tooltip.prototype.hideTooltip=function(a){if(!!a){var b,c=function(){this.parentNode.removeChild(this)};a.style["-webkit-transition"]!==undefined&&this.animationOut?b="webkitTransitionEnd":a.style.MozTransition!==undefined&&this.animationOut&&(b="transitionend"),b?(a.addEventListener(b,c,!1),a.addEventListener("transitionend",c,!1),a.className+=" "+this.animationOut):a.parentNode.removeChild(a)}},wax.tooltip.prototype.click=function(a,b,c){this.unselect(b);var d=this.getTooltip(a,b,c),e=document.createElement("a");e.href="#close",e.className="close",e.innerHTML="Close";var f=wax.util.bind(function(a){this.hideTooltip(d),this._currentTooltip=undefined,a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault();return!1},this);e.addEventListener?e.addEventListener("click",f,!1):e.attachEvent&&e.attachEvent("onclick",f),d.className+=" wax-popup",d.innerHTML=a,d.appendChild(e),this._currentTooltip=d},wax.tooltip.prototype.select=function(a,b,c,d){if(!!a){if(this.isPopup(this._currentTooltip))return;this._currentTooltip=this.getTooltip(a,b,c,d),b.style.cursor="pointer"}},wax.tooltip.prototype.unselect=function(a){this.isPopup(this._currentTooltip)||(a.style.cursor="default",this._currentTooltip&&(this.hideTooltip(this._currentTooltip),this._currentTooltip=undefined))},wax.tooltip.prototype.out=wax.tooltip.prototype.unselect,wax.tooltip.prototype.over=wax.tooltip.prototype.select,wax.tooltip.prototype.click=wax.tooltip.prototype.click,wax.util=wax.util||{},wax.util={offset:function(a){var b=a.offsetWidth,c=a.offsetHeight,d=a.offsetTop,e=a.offsetLeft;try{while(a=a.offsetParent){d+=a.offsetTop,e+=a.offsetLeft;var f=a.style.transform||a.style["-webkit-transform"]||a.style.MozTransform;if(f){var g=f.match(/translate\((.+)px, (.+)px\)/);g&&(d+=parseInt(g[2],10),e+=parseInt(g[1],10))}}}catch(h){}d+=document.body.offsetTop,e+=document.body.offsetLeft,d+=document.body.parentNode.offsetTop,e+=document.body.parentNode.offsetLeft;var i=document.defaultView?window.getComputedStyle(document.body.parentNode):document.body.parentNode.currentStyle;document.body.parentNode.offsetTop!==parseInt(i.marginTop,10)&&(d+=parseInt(i.marginTop,10),e+=parseInt(i.marginLeft,10));return{top:d,left:e,height:c,width:b}},bind:function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,c.concat(Array.prototype.slice.call(arguments)))}},isString:function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},indexOf:function(a,b){var c=Array.prototype.indexOf;if(a===null)return-1;var d,e;if(c&&a.indexOf===c)return a.indexOf(b);for(d=0,e=a.length;d<e;d++)if(a[d]===b)return d;return-1},isArray:Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},keys:Object.keys||function(a){var b=Object.prototype.hasOwnProperty;if(a!==Object(a))throw new TypeError("Invalid object");var c=[];for(var d in a)b.call(a,d)&&(c[c.length]=d);return c},eventoffset:function(a){var b=0,c=0;if(!a)var a=window.event;if(a.pageX||a.pageY)return{x:a.pageX,y:a.pageY};if(a.clientX||a.clientY){var d=document.documentElement,e=document.body,f=document.body.parentNode.currentStyle,g=parseInt(f.marginTop,10)||0,h=parseInt(f.marginLeft,10)||0;return{x:a.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0)+h,y:a.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)+g}}}};var wax=wax||{};wax.ol=wax.ol||{},wax.ol.Embedder=OpenLayers.Class(OpenLayers.Control,{initialize:function(a){a=a||{},OpenLayers.Control.prototype.initialize.apply(this,[a||{}])},setMap:function(a){$("#"+this.el+"-script").length&&(OpenLayers.Control.prototype.setMap.apply(this,arguments),$(a.div).prepend($('<input type="text" class="embed-src" />').css({"z-index":"9999999999",position:"relative"}).val("<div id='"+this.el+"-script'>"+$("#"+this.el+"-script").html()+"</div>"))),this.activate()},CLASS_NAME:"wax.ol.Embedder"});var wax=wax||{};wax.ol=wax.ol||{};var addEv=function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)};wax.ol.Interaction=OpenLayers.Class(OpenLayers.Control,{feature:{},handlerOptions:null,handlers:null,gm:new wax.GridManager,initialize:function(a){this.options=a||{},this.clickAction=this.options.clickAction||"full",OpenLayers.Control.prototype.initialize.apply(this,[this.options||{}]),this.callbacks=this.options.callbacks||new wax.tooltip},setMap:function(a){addEv(a.viewPortDiv,"mousemove",wax.util.bind(this.getInfoForHover,this)),addEv(a.viewPortDiv,"mouseout",wax.util.bind(this.resetLayers,this)),this.clickHandler=new OpenLayers.Handler.Click(this,{click:this.getInfoForClick}),this.clickHandler.setMap(a),this.clickHandler.activate(),a.events.on({addlayer:this.resetLayers,changelayer:this.resetLayers,removelayer:this.resetLayers,changebaselayer:this.resetLayers,scope:this}),OpenLayers.Control.prototype.setMap.apply(this,arguments)},getTileStack:function(a,b){var c=[];layerfound:for(var d=0;d<a.length;d++)for(var e=0;e<a[d].grid.length;e++)for(var f=0;f<a[d].grid[e].length;f++){a[d].grid[e][f].imgDiv&&a[d].grid[e][f].frame==a[d].grid[e][f].imgDiv;var g=wax.util.offset(a[d].grid[e][f].frame);if(g&&g.top<b.pageY&&g.top+256>b.pageY&&g.left<b.pageX&&g.left+256>b.pageX){c.push(a[d].grid[e][f]);continue layerfound}}return c},viableLayers:function(){if(this._viableLayers)return this._viableLayers;this._viableLayers=[];for(var a in this.map.layers)this.map.layers[a].visibility===!0&&this.map.layers[a].CLASS_NAME==="OpenLayers.Layer.TMS"&&this._viableLayers.push(this.map.layers[a]);return this._viableLayers},resetLayers:function(){this._viableLayers=null,this.callbacks.out(this.map.viewPortDiv)},getInfoForClick:function(a){var b=this.viableLayers(),c=this.getTileStack(this.viableLayers(),a),d=null,e=null,f=this;for(var g=0;g<c.length;g++)this.gm.getGrid(c[g].url,function(b,d){if(!!d){var e=d.getFeature(a.pageX,a.pageY,c[g].frame,{format:f.clickAction});if(e)switch(f.clickAction){case"full":f.callbacks.click(e,c[g].layer.map.viewPortDiv,g);break;case"location":window.location=e}}})},getInfoForHover:function(a){var b={format:"teaser"},c=this.viableLayers(),d=this.getTileStack(this.viableLayers(),a),e=null,f=null,g=this;for(var h=0;h<d.length;h++)this.gm.getGrid(d[h].url,function(c,e){if(e&&d[h]){var f=e.getFeature(a.pageX,a.pageY,d[h].frame,b);if(f){if(!d[h])return;f&&g.feature[h]!==f?(g.feature[h]=f,g.callbacks.out(d[h].layer.map.div),g.callbacks.over(f,d[h].layer.map.div,h,a)):f||(g.feature[h]=null,g.callbacks.out(d[h].layer.map.div))}else g.feature[h]=null,g.callbacks.out(d[h].layer.map.div)}})},CLASS_NAME:"wax.ol.Interaction"});var wax=wax||{};wax.ol=wax.ol||{},wax.ol.Legend=OpenLayers.Class(OpenLayers.Control,{CLASS_NAME:"wax.ol.Legend",legend:null,options:null,initialize:function(a){this.options=a||{},OpenLayers.Control.prototype.initialize.apply(this,[a||{}])},activate:function(){this.legend=new wax.Legend(this.map.viewPortDiv,this.options.container);return OpenLayers.Control.prototype.activate.apply(this,arguments)},setMap:function(a){OpenLayers.Control.prototype.setMap.apply(this,arguments),this.activate(),this.map.events.on({addlayer:this.setLegend,changelayer:this.setLegend,removelayer:this.setLegend,changebaselayer:this.setLegend,scope:this})},setLegend:function(){var a=[];for(var b=0;b<this.map.layers.length;b++){var c=this.map.layers[b];c&&c.getURL&&c.visibility&&a.push(c.getURL(new OpenLayers.Bounds))}this.legend.render(a)}});var wax=wax||{};wax.ol=wax.ol||{},wax.ol.Switcher=OpenLayers.Class(OpenLayers.Control,{CLASS_NAME:"wax.ol.Switcher",initialize:function(a){this.$element=$(a.e),this.options=a||{},OpenLayers.Control.prototype.initialize.apply(this,[a||{}])},setMap:function(a){OpenLayers.Control.prototype.setMap.apply(this,arguments),this.map.events.on({addlayer:this.redraw,changelayer:this.redraw,removelayer:this.redraw,changebaselayer:this.redraw,scope:this}),this.redraw()},layerClick:function(a){var b=a.currentTarget,c=$(b).data("layer");$("a.active",this.$element).removeClass("active"),$.each(this.map.getLayersBy("isBaseLayer",!1),function(){this.CLASS_NAME!=="OpenLayers.Layer.Vector.RootContainer"&&this.displayInLayerSwitcher&&this.setVisibility(!1)}),c.setVisibility(!0),$(b).addClass("active")},needsRedraw:function(){if(!this.layerStates||this.layerStates.length||this.map.layers.length!=this.layerStates.length)return!0;for(var a=0,b=this.layerStates.length;a<b;a++){var c=this.layerStates[a],d=this.map.layers[a];if(c.name!=d.name||c.inRange!=d.inRange||c.id!=d.id||c.visibility!=d.visibility)return!0}return!1},redraw:function(){if(this.needsRedraw()){this.$element.html("");var a=this.map.layers.length;this.layerStates=[];for(var b=0;b<a;b++){var c=this.map.layers[b];this.layerStates[b]={name:c.name,visibility:c.visibility,inRange:c.inRange,id:c.id}}var d=this.map.layers.slice();for(b=0,a=d.length;b<a;b++){var e=d[b];if(e.displayInLayerSwitcher){var f=e.isBaseLayer?e===this.map.baseLayer:e.getVisibility(),g=$.proxy(function(a){this.layerClick(a);return!1},this),h=$("<a></a>");h.click(g).attr("href","#").text(e.name).addClass("layer-toggle").data("layer",e).attr("disabled",!e.inRange),f&&h.addClass("active")}this.$element.append(h),this.$element.trigger("layeradded",h)}}}})
+ */!function(window){function readyState(a,b,c){return function(){a&&a.readyState==4&&(twoHundo.test(a.status)?b(a):c(a))}}function setHeaders(a,b){var c=b.headers||{};c.Accept="text/javascript, text/html, application/xml, text/xml, */*",c["X-Requested-With"]=c["X-Requested-With"]||"XMLHttpRequest";if(b.data){c["Content-type"]="application/x-www-form-urlencoded";for(var d in c)c.hasOwnProperty(d)&&a.setRequestHeader(d,c[d],!1)}}function getCallbackName(a){var b=a.jsonpCallback||"callback";if(a.url.slice(-(b.length+2))==b+"=?"){var c="reqwest_"+uniqid++;a.url=a.url.substr(0,a.url.length-1)+c;return c}var d=new RegExp(b+"=([\\w]+)");return a.url.match(d)[1]}function generalCallback(a){lastValue=a}function getRequest(a,b,c){if(a.type!="jsonp"){var d=xhr();d.open(a.method||"GET",typeof a=="string"?a:a.url,!0),setHeaders(d,a),d.onreadystatechange=readyState(d,b,c),a.before&&a.before(d),d.send(a.data||null);return d}var e=doc.createElement("script");window[getCallbackName(a)]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0;var f=function(){a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e)};e.onload=f,e.onreadystatechange=function(){e.readyState=="loaded"||e.readyState=="complete"&&f()},head.appendChild(e)}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function setType(a){if(/\.json$/.test(a))return"json";if(/\.jsonp$/.test(a))return"jsonp";if(/\.js$/.test(a))return"js";if(/\.html?$/.test(a))return"html";if(/\.xml$/.test(a))return"xml";return"js"}function init(o,fn){function complete(a){o.complete&&o.complete(a)}function success(resp){o.timeout&&clearTimeout(self.timeout)&&(self.timeout=null);var r=resp.responseText;switch(type){case"json":resp=eval("("+r+")");break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.success&&o.success(resp),complete(resp)}function error(a){o.error&&o.error(a),complete(a)}this.url=typeof o=="string"?o:o.url,this.timeout=null;var type=o.type||setType(this.url),self=this;fn=fn||function(){},o.timeout&&(this.timeout=setTimeout(function(){self.abort(),error()},o.timeout)),this.request=getRequest(o,success,error)}function reqwest(a,b){return new Reqwest(a,b)}function enc(a){return encodeURIComponent(a)}function serial(a){var b=a.name;if(a.disabled||!b)return"";b=enc(b);switch(a.tagName.toLowerCase()){case"input":switch(a.type){case"reset":case"button":case"image":case"file":return"";case"checkbox":case"radio":return a.checked?b+"="+(a.value?enc(a.value):!0)+"&":"";default:return b+"="+(a.value?enc(a.value):!0)+"&"}break;case"textarea":return b+"="+enc(a.value)+"&";case"select":return b+"="+enc(a.options[a.selectedIndex].value)+"&"}return""}var twoHundo=/^20\d$/,doc=document,byTag="getElementsByTagName",head=doc[byTag]("head")[0],xhr="XMLHttpRequest"in window?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")},uniqid=0,lastValue;Reqwest.prototype={abort:function(){this.request.abort()},retry:function(){init.call(this,this.o,this.fn)}},reqwest.serialize=function(a){var b=a[byTag]("input"),c=a[byTag]("select"),d=a[byTag]("textarea");return(v(b).chain().toArray().map(serial).value().join("")+v(c).chain().toArray().map(serial).value().join("")+v(d).chain().toArray().map(serial).value().join("")).replace(/&$/,"")},reqwest.serializeArray=function(a){for(var b=this.serialize(a).split("&"),c=0,d=b.length,e=[],f;c<d;c++)b[c]&&(f=b[c].split("="))&&e.push({name:f[0],value:f[1]});return e};var old=window.reqwest;reqwest.noConflict=function(){window.reqwest=old;return this},window.reqwest=reqwest}(this);var wax=wax||{};Array.prototype.reduce||(Array.prototype.reduce=function(a){"use strict";if(this===void 0||this===null)throw new TypeError;var b=Object(this),c=b.length>>>0;if(typeof a!="function")throw new TypeError;if(c==0&&arguments.length==1)throw new TypeError;var d=0,e;if(arguments.length>=2)e=arguments[1];else do{if(d in b){e=b[d++];break}if(++d>=c)throw new TypeError}while(!0);while(d<c)d in b&&(e=a.call(undefined,e,b[d],d,b)),d++;return e}),wax.Record=function(a,b){var c=function(a,b){var c=a.split(".").reduce(function(a,b){return[a[1]||a[0],a[1]?a[1][b]:a[0][b]]},[b||window,null]);if(c[0]&&c[1])return c;throw a+" not found."},d=function(a,b){var d=c(a),e;b=b.length?wax.Record(b):[];if(Object.create)e=Object.create(d[1].prototype),d[1].apply(e,b);else switch(b.length){case 0:e=new d[1];break;case 1:e=new d[1](b[0]);break;case 2:e=new d[1](b[0],b[1]);break;case 3:e=new d[1](b[0],b[1],b[2]);break;case 4:e=new d[1](b[0],b[1],b[2],b[3]);break;case 5:e=new d[1](b[0],b[1],b[2],b[3],b[4]);break;default:}return e},e=function(a,b,d){var e=c(a,d),f=b.length?wax.Record(b):[];return d&&a.indexOf(".")===-1?e[1].apply(d,f):e[1].apply(e[0],f)},f=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@literal","@chain","@inject","@group"],a.split(" ")[0])!==-1},g=function(a){return wax.util.isString(a)&&wax.util.indexOf(["@new","@call","@chain"],a.split(" ")[0])!==-1},h=function(a){if(wax.util.isArray(a)&&a[0]&&f(a[0]))return{verb:a[0].split(" ")[0],subject:a[0].split(" ")[1],object:a.slice(1)};return!1},i,j=!1,k=null,l=null,m=h(a);if(!m){if(a!==null&&typeof a=="object"){var n=wax.util.keys(a);for(i=0;i<n.length;i++){var o=n[i];a[o]=wax.Record(a[o],b)}return a}return a}switch(m.verb){case"@group":for(i=0;i<m.object.length;i++)k=wax.Record(m.object[i],b),l=h(m.object[i]),l&&g(l.verb)&&(b=k);return b;case"@new":return d(m.subject,m.object);case"@literal":j=c(m.subject);return j?j[1]:null;case"@inject":return e(m.subject,m.object,b);case"@chain":return e(m.subject,m.object,b);case"@call":return e(m.subject,m.object,null)}};var wax=wax||{};wax.request={cache:{},locks:{},promises:{},get:function(a,b){if(this.cache[a])return b(this.cache[a][0],this.cache[a][1]);this.promises[a]=this.promises[a]||[],this.promises[a].push(b);if(!this.locks[a]){var c=this;this.locks[a]=!0,reqwest({url:a+"?callback=grid",type:"jsonp",jsonpCallback:"callback",success:function(b){c.locks[a]=!1,c.cache[a]=[null,b];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])},error:function(b){c.locks[a]=!1,c.cache[a]=[b,null];for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a][0],c.cache[a][1])}})}}},wax.GridInstance=function(a,b){this.grid_tile=a,this.formatter=b,this.tileRes=4},wax.GridInstance.prototype.resolveCode=function(a){a>=93&&a--,a>=35&&a--,a-=32;return a},wax.GridInstance.prototype.getFeature=function(a,b,c,d){if(!!this.grid_tile&&!!this.grid_tile.grid){var e=wax.util.offset(c),f=e.left,g=e.top;if(b-g<0)return;if(a-f<0)return;if(Math.floor((b-g)/this.tileRes)>256)return;if(Math.floor((a-f)/this.tileRes)>256)return;var h=this.grid_tile.grid[Math.floor((b-g)/this.tileRes)].charCodeAt(Math.floor((a-f)/this.tileRes));h=this.resolveCode(h);if(this.grid_tile.keys[h]&&this.grid_tile.data[this.grid_tile.keys[h]])return this.formatter.format(d,this.grid_tile.data[this.grid_tile.keys[h]])}},wax.GridManager=function(){this.grid_tiles={},this.key_maps={},this.formatters={},this.locks={}},wax.GridManager.prototype.getGrid=function(a,b){var c=this;c.getFormatter(c.formatterUrl(a),function(d,e){if(d||!e)return b(d,null);wax.request.get(c.tileDataUrl(a),function(a,c){if(a)return b(a,null);b(null,new wax.GridInstance(c,e))})})},wax.GridManager.prototype.tileDataUrl=function(a){return a.replace(/(\.png|\.jpg|\.jpeg)(\d*)/,".grid.json")},wax.GridManager.prototype.formatterUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")},wax.GridManager.prototype.getFormatter=function(a,b){var c=this;typeof this.formatters[a]!="undefined"?b(null,this.formatters[a]):wax.request.get(a,function(d,e){e&&e.formatter?c.formatters[a]=new wax.Formatter(e):c.formatters[a]=!1,b(d,c.formatters[a])})},wax.Formatter=function(obj){if(obj.formatter&&typeof obj.formatter=="string")try{eval("this.f = "+obj.formatter)}catch(e){console&&console.log(e)}else this.f=function(){}},wax.Formatter.prototype.format=function(a,b){try{return this.f(a,b)}catch(c){console&&console.log(c)}};var wax=wax||{};wax.Legend=function(a,b){this.legends={},this.context=a,this.container=b,this.container||(this.container=document.createElement("div"),this.container.className="wax-legends"),this.context.appendChild(this.container)},wax.Legend.prototype.render=function(a){var b;for(b in this.legends)this.legends[b].style.display="none";var c=wax.util.bind(function(a,b){b?this.legends[a]?this.legends[a].style.display="block":(this.legends[a]=document.createElement("div"),this.legends[a].className="wax-legend",this.legends[a].innerHTML=b,this.container.appendChild(this.legends[a])):this.legends[a]=!1},this);for(var d=0;d<a.length;d++)b=this.legendUrl(a[d]),wax.request.get(b,function(a,d){d&&d.legend&&c(b,d.legend)})},wax.Legend.prototype.legendUrl=function(a){return a.replace(/\d+\/\d+\/\d+\.\w+/,"layer.json")};var w=function(a){a.melt=function(b,c){b.apply(c,[a,c]);return a};return a},wax=wax||{};wax.tooltip={},wax.tooltip=function(a){this._currentTooltip=undefined,a=a||{},a.animationOut&&(this.animationOut=a.animationOut),a.animationIn&&(this.animationIn=a.animationIn)},wax.tooltip.prototype.isPopup=function(a){return a&&a.className.indexOf("wax-popup")!==-1},wax.tooltip.prototype.getTooltip=function(a,b,c,d){tooltip=document.createElement("div"),tooltip.className="wax-tooltip wax-tooltip-"+c,tooltip.innerHTML=a,b.appendChild(tooltip);return tooltip},wax.tooltip.prototype.hideTooltip=function(a){if(!!a){var b,c=function(){this.parentNode.removeChild(this)};a.style["-webkit-transition"]!==undefined&&this.animationOut?b="webkitTransitionEnd":a.style.MozTransition!==undefined&&this.animationOut&&(b="transitionend"),b?(a.addEventListener(b,c,!1),a.addEventListener("transitionend",c,!1),a.className+=" "+this.animationOut):a.parentNode.removeChild(a)}},wax.tooltip.prototype.click=function(a,b,c){this.unselect(b);var d=this.getTooltip(a,b,c),e=document.createElement("a");e.href="#close",e.className="close",e.innerHTML="Close";var f=wax.util.bind(function(a){this.hideTooltip(d),this._currentTooltip=undefined,a.returnValue=!1,a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault();return!1},this);e.addEventListener?e.addEventListener("click",f,!1):e.attachEvent&&e.attachEvent("onclick",f),d.className+=" wax-popup",d.innerHTML=a,d.appendChild(e),this._currentTooltip=d},wax.tooltip.prototype.select=function(a,b,c,d){if(!!a){if(this.isPopup(this._currentTooltip))return;this._currentTooltip=this.getTooltip(a,b,c,d),b.style.cursor="pointer"}},wax.tooltip.prototype.unselect=function(a){this.isPopup(this._currentTooltip)||(a.style.cursor="default",this._currentTooltip&&(this.hideTooltip(this._currentTooltip),this._currentTooltip=undefined))},wax.tooltip.prototype.out=wax.tooltip.prototype.unselect,wax.tooltip.prototype.over=wax.tooltip.prototype.select,wax.tooltip.prototype.click=wax.tooltip.prototype.click,wax.util=wax.util||{},wax.util={offset:function(a){var b=a.offsetWidth,c=a.offsetHeight,d=a.offsetTop,e=a.offsetLeft;try{while(a=a.offsetParent){d+=a.offsetTop,e+=a.offsetLeft;var f=a.style.transform||a.style["-webkit-transform"]||a.style.MozTransform;if(f){var g=f.match(/translate\((.+)px, (.+)px\)/);g&&(d+=parseInt(g[2],10),e+=parseInt(g[1],10))}}}catch(h){}d+=document.body.offsetTop,e+=document.body.offsetLeft,d+=document.body.parentNode.offsetTop,e+=document.body.parentNode.offsetLeft;var i=document.defaultView?window.getComputedStyle(document.body.parentNode):document.body.parentNode.currentStyle;document.body.parentNode.offsetTop!==parseInt(i.marginTop,10)&&(d+=parseInt(i.marginTop,10),e+=parseInt(i.marginLeft,10));return{top:d,left:e,height:c,width:b}},bind:function(a,b){var c=Array.prototype.slice.call(arguments,2);return function(){return a.apply(b,c.concat(Array.prototype.slice.call(arguments)))}},isString:function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},indexOf:function(a,b){var c=Array.prototype.indexOf;if(a===null)return-1;var d,e;if(c&&a.indexOf===c)return a.indexOf(b);for(d=0,e=a.length;d<e;d++)if(a[d]===b)return d;return-1},isArray:Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},keys:Object.keys||function(a){var b=Object.prototype.hasOwnProperty;if(a!==Object(a))throw new TypeError("Invalid object");var c=[];for(var d in a)b.call(a,d)&&(c[c.length]=d);return c},eventoffset:function(a){var b=0,c=0;if(!a)var a=window.event;if(a.pageX||a.pageY)return{x:a.pageX,y:a.pageY};if(a.clientX||a.clientY){var d=document.documentElement,e=document.body,f=document.body.parentNode.currentStyle,g=parseInt(f.marginTop,10)||0,h=parseInt(f.marginLeft,10)||0;return{x:a.clientX+(d&&d.scrollLeft||e&&e.scrollLeft||0)-(d&&d.clientLeft||e&&e.clientLeft||0)+h,y:a.clientY+(d&&d.scrollTop||e&&e.scrollTop||0)-(d&&d.clientTop||e&&e.clientTop||0)+g}}}};var wax=wax||{};wax.ol=wax.ol||{},wax.ol.Embedder=OpenLayers.Class(OpenLayers.Control,{initialize:function(a){a=a||{},OpenLayers.Control.prototype.initialize.apply(this,[a||{}])},setMap:function(a){$("#"+this.el+"-script").length&&(OpenLayers.Control.prototype.setMap.apply(this,arguments),$(a.div).prepend($('<input type="text" class="embed-src" />').css({"z-index":"9999999999",position:"relative"}).val("<div id='"+this.el+"-script'>"+$("#"+this.el+"-script").html()+"</div>"))),this.activate()},CLASS_NAME:"wax.ol.Embedder"});var wax=wax||{};wax.ol=wax.ol||{};var addEv=function(a,b,c){a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c)};wax.ol.Interaction=OpenLayers.Class(OpenLayers.Control,{feature:{},handlerOptions:null,handlers:null,gm:new wax.GridManager,initialize:function(a){this.options=a||{},this.clickAction=this.options.clickAction||"full",OpenLayers.Control.prototype.initialize.apply(this,[this.options||{}]),this.callbacks=this.options.callbacks||new wax.tooltip},setMap:function(a){addEv(a.viewPortDiv,"mousemove",wax.util.bind(this.getInfoForHover,this)),addEv(a.viewPortDiv,"mouseout",wax.util.bind(this.resetLayers,this)),this.clickHandler=new OpenLayers.Handler.Click(this,{click:this.getInfoForClick}),this.clickHandler.setMap(a),this.clickHandler.activate(),a.events.on({addlayer:this.resetLayers,changelayer:this.resetLayers,removelayer:this.resetLayers,changebaselayer:this.resetLayers,scope:this}),OpenLayers.Control.prototype.setMap.apply(this,arguments)},getTileStack:function(a,b){var c=[];layerfound:for(var d=0;d<a.length;d++)for(var e=0;e<a[d].grid.length;e++)for(var f=0;f<a[d].grid[e].length;f++){a[d].grid[e][f].imgDiv&&a[d].grid[e][f].frame==a[d].grid[e][f].imgDiv;var g=wax.util.offset(a[d].grid[e][f].frame);if(g&&g.top<b.pageY&&g.top+256>b.pageY&&g.left<b.pageX&&g.left+256>b.pageX){c.push(a[d].grid[e][f]);continue layerfound}}return c},viableLayers:function(){if(this._viableLayers)return this._viableLayers;this._viableLayers=[];for(var a in this.map.layers)this.map.layers[a].visibility===!0&&this.map.layers[a].CLASS_NAME==="OpenLayers.Layer.TMS"&&this._viableLayers.push(this.map.layers[a]);return this._viableLayers},resetLayers:function(){this._viableLayers=null,this.callbacks.out(this.map.viewPortDiv)},getInfoForClick:function(a){var b=this.viableLayers(),c=this.getTileStack(this.viableLayers(),a),d=null,e=null,f=this;for(var g=0;g<c.length;g++)this.gm.getGrid(c[g].url,function(b,d){if(!!d){var e=d.getFeature(a.pageX,a.pageY,c[g].frame,{format:f.clickAction});if(e)switch(f.clickAction){case"full":f.callbacks.click(e,c[g].layer.map.viewPortDiv,g);break;case"location":window.location=e}}})},getInfoForHover:function(a){var b={format:"teaser"},c=this.viableLayers(),d=this.getTileStack(this.viableLayers(),a),e=null,f=null,g=this;for(var h=0;h<d.length;h++)this.gm.getGrid(d[h].url,function(c,e){if(e&&d[h]){var f=e.getFeature(a.pageX,a.pageY,d[h].frame,b);if(f){if(!d[h])return;f&&g.feature[h]!==f?(g.feature[h]=f,g.callbacks.out(d[h].layer.map.div),g.callbacks.over(f,d[h].layer.map.div,h,a)):f||(g.feature[h]=null,g.callbacks.out(d[h].layer.map.div))}else g.feature[h]=null,g.callbacks.out(d[h].layer.map.div)}})},CLASS_NAME:"wax.ol.Interaction"});var wax=wax||{};wax.ol=wax.ol||{},wax.ol.Legend=OpenLayers.Class(OpenLayers.Control,{CLASS_NAME:"wax.ol.Legend",legend:null,options:null,initialize:function(a){this.options=a||{},OpenLayers.Control.prototype.initialize.apply(this,[a||{}])},activate:function(){this.legend=new wax.Legend(this.map.viewPortDiv,this.options.container);return OpenLayers.Control.prototype.activate.apply(this,arguments)},setMap:function(a){OpenLayers.Control.prototype.setMap.apply(this,arguments),this.activate(),this.map.events.on({addlayer:this.setLegend,changelayer:this.setLegend,removelayer:this.setLegend,changebaselayer:this.setLegend,scope:this})},setLegend:function(){var a=[];for(var b=0;b<this.map.layers.length;b++){var c=this.map.layers[b];c&&c.getURL&&c.visibility&&a.push(c.getURL(new OpenLayers.Bounds))}this.legend.render(a)}});var wax=wax||{};wax.ol=wax.ol||{},wax.ol.Switcher=OpenLayers.Class(OpenLayers.Control,{CLASS_NAME:"wax.ol.Switcher",initialize:function(a){this.$element=$(a.e),this.options=a||{},OpenLayers.Control.prototype.initialize.apply(this,[a||{}])},setMap:function(a){OpenLayers.Control.prototype.setMap.apply(this,arguments),this.map.events.on({addlayer:this.redraw,changelayer:this.redraw,removelayer:this.redraw,changebaselayer:this.redraw,scope:this}),this.redraw()},layerClick:function(a){var b=a.currentTarget,c=$(b).data("layer");$("a.active",this.$element).removeClass("active"),$.each(this.map.getLayersBy("isBaseLayer",!1),function(){this.CLASS_NAME!=="OpenLayers.Layer.Vector.RootContainer"&&this.displayInLayerSwitcher&&this.setVisibility(!1)}),c.setVisibility(!0),$(b).addClass("active")},needsRedraw:function(){if(!this.layerStates||this.layerStates.length||this.map.layers.length!=this.layerStates.length)return!0;for(var a=0,b=this.layerStates.length;a<b;a++){var c=this.layerStates[a],d=this.map.layers[a];if(c.name!=d.name||c.inRange!=d.inRange||c.id!=d.id||c.visibility!=d.visibility)return!0}return!1},redraw:function(){if(this.needsRedraw()){this.$element.html("");var a=this.map.layers.length;this.layerStates=[];for(var b=0;b<a;b++){var c=this.map.layers[b];this.layerStates[b]={name:c.name,visibility:c.visibility,inRange:c.inRange,id:c.id}}var d=this.map.layers.slice();for(b=0,a=d.length;b<a;b++){var e=d[b];if(e.displayInLayerSwitcher){var f=e.isBaseLayer?e===this.map.baseLayer:e.getVisibility(),g=$.proxy(function(a){this.layerClick(a);return!1},this),h=$("<a></a>");h.click(g).attr("href","#").text(e.name).addClass("layer-toggle").data("layer",e).attr("disabled",!e.inRange),f&&h.addClass("active")}this.$element.append(h),this.$element.trigger("layeradded",h)}}}})

0 comments on commit 4156625

Please sign in to comment.
Something went wrong with that request. Please try again.