Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Of course you don't, IE

  • Loading branch information...
commit da137c6f1d3f48c9a43324e0a193f4fb3162761f 1 parent d4afea0
authored May 23, 2011
3  build/wax.mm.js
@@ -827,7 +827,8 @@ wax.hash = function(map, options) {
827 827
     var hash = {
828 828
         map: this,
829 829
         parser: function(s) {
830  
-            var args = s.split('/').map(Number);
  830
+            var args = s.split('/');
  831
+            for (var i = 0; i < args.length; i++) args[i] = Number(args);
831 832
             if (args.length < 3 || args.some(isNaN)) {
832 833
                 return true; // replace bogus hash
833 834
             } else if (args.length == 3) {
2  build/wax.mm.min.js
@@ -3,4 +3,4 @@
3 3
   * copyright Dustin Diaz 2011
4 4
   * https://github.com/ded/reqwest
5 5
   * license MIT
6  
-  */!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.substr(-(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"),f=getCallbackName(a);window[f]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0,e.onload=function(){a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e)},head.insertBefore(e,topScript)}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",topScript=doc[byTag]("script")[0],head=topScript.parentNode,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||{};wax.util=wax.util||{},wax.util.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},wax.util.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},wax.util.isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},wax.util.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},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 for(;;){if(d in b){e=b[d++];break}if(++d>=c)throw new TypeError}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&&wax.util.indexOf(".",a)===-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.util={offset:function(a){var b=a.offsetWidth,c=a.offsetHeight,d=a.offsetTop,e=a.offsetLeft;while(a=a.offsetParent)d+=a.offsetTop,e+=a.offsetLeft;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)))}}},wax.request={cache:{},locks:{},promises:{},get:function(a,b){if(this.cache[a])return b(this.cache[a]);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]=b;for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a])},error:function(){c.locks[a]=!1,c.cache[a]=null;for(var b=0;b<c.promises[a].length;b++)c.promises[a][b](c.cache[a])}})}}},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(Math.floor((b-g)/this.tileRes)>256||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])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){if(!d)return b(!1);wax.request.get(c.tileDataUrl(a),function(a){b(new wax.GridInstance(a,d))})})},wax.GridManager.prototype.makeEvent=function(a){return{target:a.target||a.srcElement,pX:a.pageX||a.clientX,pY:a.pageY||a.clientY,evt:a}},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(this.formatters[a]):wax.request.get(a,function(d){d&&d.formatter?c.formatters[a]=new wax.Formatter(d):c.formatters[a]=!1,b(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.context=a,this.container=b||$('<div class="wax-legends"></div>')[0],this.legends={},$(this.context).append(this.container)},wax.Legend.prototype.render=function(a){$(".wax-legend",this.container).hide();var b=wax.util.bind(function(a,b){b?this.legends[a]?this.legends[a].show():(this.legends[a]=$("<div class='wax-legend'></div>").append(b),this.container.append(this.legends[a])):this.legends[a]=!1},this),c=function(a){a&&a.legend&&b(e,a.legend)};for(var d=0;d<a.length;d++){var e=this.legendUrl(a[d]);wax.request.get(e,c)}},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.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.click=function(a,b,c){var d=wax.tooltip.getToolTip(a,b,c),e=document.createElement("a");e.href="#close",e.className="close",e.innerHTML="Close",e.addListener("click",function(){d.parentNode.removeChild(d);return!1}),d.className+=" wax-popup",d.innerHTML=a,d.appendChild(e)},wax.tooltip.select=function(a,b,c,d){!a||(wax.tooltip.getToolTip(a,b,c,d),b.style.cursor="pointer")},wax.tooltip.unselect=function(a,b,c,d){b.style.cursor="default"},wax=wax||{},wax.boxselector=function(a,b){var c=null,d=typeof b=="function"?b:b.callback,e={add:function(a){this.containerDiv=document.createElement("div"),this.containerDiv.id=a.parent.id+"-zoombox",this.containerDiv.className="boxselector-box-container",this.containerDiv.style.width=a.dimensions.x+"px",this.containerDiv.style.height=a.dimensions.y+"px",this.boxDiv=document.createElement("div"),this.boxDiv.id=a.parent.id+"-boxselector-box",this.boxDiv.className="boxselector-box",this.containerDiv.appendChild(this.boxDiv),a.parent.appendChild(this.containerDiv),com.modestmaps.addEvent(this.containerDiv,"mousedown",this.mouseDown()),a.addCallback("drawn",this.drawbox())},remove:function(){this.containerDiv.parentNode.removeChild(this.containerDiv),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(){return 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)},mouseMove:function(a){return 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)},mouseUp:function(){return 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";return com.modestmaps.cancelEvent(b)},this)},drawbox:function(){return 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 e.add(a)};if(!com){var com={};com.modestmaps||(com.modestmaps={})}com.modestmaps.Map.prototype.embedder=function(a){a=a||{},$("#"+this.el+"-script").length&&$(this.parent).prepend($('<input type="text" class="embed-src" />').css({"z-index":"9999999999",position:"relative"}).val("<div id='"+this.el+"-script'>"+$("#"+this.el+"-script").html()+"</div>"));return this},wax=wax||{},wax.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){return this._click=this._click||wax.util.bind(function(b){b&&b.preventDefault(),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 c.add(a)},wax=wax||{};var limit=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)}},throttle=function(a,b){return limit(a,b,!1)},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.hash=function(a,b){var c,d=90-1e-8,a,e={map:this,parser:function(b){var c=b.split("/").map(Number);if(c.length<3||c.some(isNaN))return!0;c.length==3&&a.setCenterZoom(new com.modestmaps.Location(c[1],c[2]),c[0])},add:function(a){b.manager.getState()?e.stateChange(b.manager.getState()):e.initialize()&&e.move(),a.addCallback("drawn",throttle(e.move,500)),b.manager.stateChange(e.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=e.formatter();c!==a&&(c=a,b.manager.pushState(c))},stateChange:function(a){a!==c&&e.parser((c=a).substring(1))&&e.move()},initialize:function(){b.defaultCenter&&a.setCenter(b.defaultCenter),b.defaultZoom&&a.setZoom(b.defaultZoom)}};return e.add(a)},wax=wax||{},wax.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||{out:wax.tooltip.unselect,over:wax.tooltip.select,click:wax.tooltip.click},clickAction:b.clickAction||"full",add:function(){for(var b=0;b<this.modifyingEvents.length;b++)a.addCallback(this.modifyingEvents[b],this.clearMap);c.addEvent(a.parent,"mousemove",this.onMove()),c.addEvent(a.parent,"mousedown",this.mouseDown());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._waxGetTileGrid=null},getTile:function(a){var b,c=this.getTileGrid();for(var d=0;d<c.length;d++)if(c[d][0]<a.pageY&&c[d][0]+256>a.pageY&&c[d][1]<a.pageX&&c[d][1]+256>a.pageX){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){return 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){if(d){var e=d.getFeature(b.pageX,b.pageY,c,{format:"teaser"});e?e&&this.feature!==e?(this.feature=e,this.callbacks.out(e,a.parent,0,b),this.callbacks.over(e,a.parent,0,b)):e||(this.feature=null,this.callbacks.out(e,a.parent,0,b)):(this.feature=null,this.callbacks.out({},a.parent,0,b))}},this))},this)},mouseDown:function(b){return this._mouseDown=this._mouseDown||wax.util.bind(function(b){this.clearTimeout()||(this.downEvent=b,c.addEvent(a.parent,"mouseup",this.mouseUp()))},this)},mouseUp:function(){return this._mouseUp=this._mouseUp||wax.util.bind(function(b){c.removeEvent(a.parent,"mouseup",this.mouseUp());var d=4;Math.round(b.pageY/d)===Math.round(this.downEvent.pageY/d)&&Math.round(b.pageX/d)===Math.round(this.downEvent.pageX/d)&&(this.clickTimeout=window.setTimeout(wax.util.bind(function(){this.click()(b)},this),300))},this)},click:function(a){return this._onClick=this._onClick||wax.util.bind(function(a){var b=this.getTile(a);b&&this.waxGM.getGrid(b.src,wax.util.bind(function(c){if(c){var d=c.getFeature(a.pageX,a.pageY,b,{format:this.clickAction});if(d)switch(this.clickAction){case"full":this.callbacks.click(d,this.parent,0,a);break;case"location":window.location=d}}},this))},this)}};return d.add(a)},wax=wax||{},wax.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.mobile={},wax=wax||{},wax.pointselector=function(a,b){var c=null,d=null,e=5,f=com.modestmaps,g=[],h=typeof b=="function"?b:b.callback,i=function(b){var c=new f.Point(b.clientX,b.clientY);c.x+=document.body.scrollLeft+document.documentElement.scrollLeft,c.y+=document.body.scrollTop+document.documentElement.scrollTop,c.x-=parseFloat(f.getStyle(document.documentElement,"margin-left")),c.y-=parseFloat(f.getStyle(document.documentElement,"margin-top"));for(var d=a.parent;d;d=d.offsetParent)c.x-=d.offsetLeft,c.y-=d.offsetTop;return c},j={add:function(a){this.overlayDiv=document.createElement("div"),this.overlayDiv.id=a.parent.id+"-boxselector",this.overlayDiv.className="pointselector-box-container",this.overlayDiv.style.width=a.dimensions.x+"px",this.overlayDiv.style.height=a.dimensions.y+"px",a.parent.appendChild(this.overlayDiv),f.addEvent(this.overlayDiv,"mousedown",j.mouseDown),a.addCallback("drawn",j.drawPoints);return this},deletePoint:function(a,b){confirm("Delete this point?")&&(a.pointDiv.parentNode.removeChild(a.pointDiv),g.splice(g.indexOf(a),1),h(j.cleanLocations(g)))},drawPoints:function(){var b=new f.Point(0,0);for(var c=0;c<g.length;c++){var d=a.locationPoint(g[c]);g[c].pointDiv||(g[c].pointDiv=document.createElement("div"),g[c].pointDiv.className="wax-point-div",g[c].pointDiv.style.position="absolute",g[c].pointDiv.style.display="block",g[c].pointDiv.location=g[c],f.addEvent(g[c].pointDiv,"mouseup",function(b){var d=g[c];return function(b){f.removeEvent(a.parent,"mouseup",j.mouseUp),j.deletePoint(d,b)}}()),this.overlayDiv.appendChild(g[c].pointDiv)),g[c].pointDiv.style.left=d.x+"px",g[c].pointDiv.style.top=d.y+"px"}},mouseDown:function(b){c=i(b),f.addEvent(a.parent,"mouseup",j.mouseUp)},addLocation:function(a){g.push(a),j.drawPoints()},cleanLocations:function(a){var b=[];for(var c=0;c<a.length;c++)b.push(new f.Location(a[c].lat,a[c].lon));return b},mouseUp:function(b){!c||(d=i(b),f.Point.distance(c,d)<e&&(j.addLocation(a.pointLocation(c)),h(j.cleanLocations(g))),c=null,f.removeEvent(a.parent,"mouseup",j.mouseUp))}};return j.add(a)},wax=wax||{},wax.zoombox=function(a,b){var c=null,d={add:function(a){this.boxDiv=document.createElement("div"),this.boxDiv.id=a.parent.id+"-zoombox",this.boxDiv.className="zoombox-box-container",this.boxDiv.style.width=a.dimensions.x+"px",this.boxDiv.style.height=a.dimensions.y+"px",this.box=document.createElement("div"),this.box.id=a.parent.id+"-zoombox-box",this.box.className="zoombox-box",this.boxDiv.appendChild(this.box),com.modestmaps.addEvent(this.boxDiv,"mousedown",this.mouseDown()),a.parent.appendChild(this.boxDiv)},remove:function(){this.boxDiv.parentNode.removeChild(this.boxDiv),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(){return 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)},mouseMove:function(a){return 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)},mouseUp:function(b){return 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";return com.modestmaps.cancelEvent(b)},this)}};return d.add(a)},wax=wax||{},wax.zoomer=function(a){var b=document.createElement("a");b.innerHTML="+",b.href="#",b.className="zoomer zoomin",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,"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.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.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.provider,com.modestmaps.MapProvider)
  6
+  */!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.substr(-(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"),f=getCallbackName(a);window[f]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0,e.onload=function(){a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e)},head.insertBefore(e,topScript)}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",topScript=doc[byTag]("script")[0],head=topScript.parentNode,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||{};wax.util=wax.util||{},wax.util.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)},wax.util.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},wax.util.isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},wax.util.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},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 for(;;){if(d in b){e=b[d++];break}if(++d>=c)throw new TypeError}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&&wax.util.indexOf(".",a)===-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.util={offset:function(a){var b=a.offsetWidth,c=a.offsetHeight,d=a.offsetTop,e=a.offsetLeft;while(a=a.offsetParent)d+=a.offsetTop,e+=a.offsetLeft;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)))}}},wax.request={cache:{},locks:{},promises:{},get:function(a,b){if(this.cache[a])return b(this.cache[a]);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]=b;for(var d=0;d<c.promises[a].length;d++)c.promises[a][d](c.cache[a])},error:function(){c.locks[a]=!1,c.cache[a]=null;for(var b=0;b<c.promises[a].length;b++)c.promises[a][b](c.cache[a])}})}}},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(Math.floor((b-g)/this.tileRes)>256||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])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){if(!d)return b(!1);wax.request.get(c.tileDataUrl(a),function(a){b(new wax.GridInstance(a,d))})})},wax.GridManager.prototype.makeEvent=function(a){return{target:a.target||a.srcElement,pX:a.pageX||a.clientX,pY:a.pageY||a.clientY,evt:a}},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(this.formatters[a]):wax.request.get(a,function(d){d&&d.formatter?c.formatters[a]=new wax.Formatter(d):c.formatters[a]=!1,b(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.context=a,this.container=b||$('<div class="wax-legends"></div>')[0],this.legends={},$(this.context).append(this.container)},wax.Legend.prototype.render=function(a){$(".wax-legend",this.container).hide();var b=wax.util.bind(function(a,b){b?this.legends[a]?this.legends[a].show():(this.legends[a]=$("<div class='wax-legend'></div>").append(b),this.container.append(this.legends[a])):this.legends[a]=!1},this),c=function(a){a&&a.legend&&b(e,a.legend)};for(var d=0;d<a.length;d++){var e=this.legendUrl(a[d]);wax.request.get(e,c)}},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.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.click=function(a,b,c){var d=wax.tooltip.getToolTip(a,b,c),e=document.createElement("a");e.href="#close",e.className="close",e.innerHTML="Close",e.addListener("click",function(){d.parentNode.removeChild(d);return!1}),d.className+=" wax-popup",d.innerHTML=a,d.appendChild(e)},wax.tooltip.select=function(a,b,c,d){!a||(wax.tooltip.getToolTip(a,b,c,d),b.style.cursor="pointer")},wax.tooltip.unselect=function(a,b,c,d){b.style.cursor="default"},wax=wax||{},wax.boxselector=function(a,b){var c=null,d=typeof b=="function"?b:b.callback,e={add:function(a){this.containerDiv=document.createElement("div"),this.containerDiv.id=a.parent.id+"-zoombox",this.containerDiv.className="boxselector-box-container",this.containerDiv.style.width=a.dimensions.x+"px",this.containerDiv.style.height=a.dimensions.y+"px",this.boxDiv=document.createElement("div"),this.boxDiv.id=a.parent.id+"-boxselector-box",this.boxDiv.className="boxselector-box",this.containerDiv.appendChild(this.boxDiv),a.parent.appendChild(this.containerDiv),com.modestmaps.addEvent(this.containerDiv,"mousedown",this.mouseDown()),a.addCallback("drawn",this.drawbox())},remove:function(){this.containerDiv.parentNode.removeChild(this.containerDiv),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(){return 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)},mouseMove:function(a){return 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)},mouseUp:function(){return 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";return com.modestmaps.cancelEvent(b)},this)},drawbox:function(){return 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 e.add(a)};if(!com){var com={};com.modestmaps||(com.modestmaps={})}com.modestmaps.Map.prototype.embedder=function(a){a=a||{},$("#"+this.el+"-script").length&&$(this.parent).prepend($('<input type="text" class="embed-src" />').css({"z-index":"9999999999",position:"relative"}).val("<div id='"+this.el+"-script'>"+$("#"+this.el+"-script").html()+"</div>"));return this},wax=wax||{},wax.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){return this._click=this._click||wax.util.bind(function(b){b&&b.preventDefault(),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 c.add(a)},wax=wax||{};var limit=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)}},throttle=function(a,b){return limit(a,b,!1)},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.hash=function(a,b){var c,d=90-1e-8,a,e={map:this,parser:function(b){var c=b.split("/");for(var d=0;d<c.length;d++)c[d]=Number(c);if(c.length<3||c.some(isNaN))return!0;c.length==3&&a.setCenterZoom(new com.modestmaps.Location(c[1],c[2]),c[0])},add:function(a){b.manager.getState()?e.stateChange(b.manager.getState()):e.initialize()&&e.move(),a.addCallback("drawn",throttle(e.move,500)),b.manager.stateChange(e.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=e.formatter();c!==a&&(c=a,b.manager.pushState(c))},stateChange:function(a){a!==c&&e.parser((c=a).substring(1))&&e.move()},initialize:function(){b.defaultCenter&&a.setCenter(b.defaultCenter),b.defaultZoom&&a.setZoom(b.defaultZoom)}};return e.add(a)},wax=wax||{},wax.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||{out:wax.tooltip.unselect,over:wax.tooltip.select,click:wax.tooltip.click},clickAction:b.clickAction||"full",add:function(){for(var b=0;b<this.modifyingEvents.length;b++)a.addCallback(this.modifyingEvents[b],this.clearMap);c.addEvent(a.parent,"mousemove",this.onMove()),c.addEvent(a.parent,"mousedown",this.mouseDown());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._waxGetTileGrid=null},getTile:function(a){var b,c=this.getTileGrid();for(var d=0;d<c.length;d++)if(c[d][0]<a.pageY&&c[d][0]+256>a.pageY&&c[d][1]<a.pageX&&c[d][1]+256>a.pageX){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){return 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){if(d){var e=d.getFeature(b.pageX,b.pageY,c,{format:"teaser"});e?e&&this.feature!==e?(this.feature=e,this.callbacks.out(e,a.parent,0,b),this.callbacks.over(e,a.parent,0,b)):e||(this.feature=null,this.callbacks.out(e,a.parent,0,b)):(this.feature=null,this.callbacks.out({},a.parent,0,b))}},this))},this)},mouseDown:function(b){return this._mouseDown=this._mouseDown||wax.util.bind(function(b){this.clearTimeout()||(this.downEvent=b,c.addEvent(a.parent,"mouseup",this.mouseUp()))},this)},mouseUp:function(){return this._mouseUp=this._mouseUp||wax.util.bind(function(b){c.removeEvent(a.parent,"mouseup",this.mouseUp());var d=4;Math.round(b.pageY/d)===Math.round(this.downEvent.pageY/d)&&Math.round(b.pageX/d)===Math.round(this.downEvent.pageX/d)&&(this.clickTimeout=window.setTimeout(wax.util.bind(function(){this.click()(b)},this),300))},this)},click:function(a){return this._onClick=this._onClick||wax.util.bind(function(a){var b=this.getTile(a);b&&this.waxGM.getGrid(b.src,wax.util.bind(function(c){if(c){var d=c.getFeature(a.pageX,a.pageY,b,{format:this.clickAction});if(d)switch(this.clickAction){case"full":this.callbacks.click(d,this.parent,0,a);break;case"location":window.location=d}}},this))},this)}};return d.add(a)},wax=wax||{},wax.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.mobile={},wax=wax||{},wax.pointselector=function(a,b){var c=null,d=null,e=5,f=com.modestmaps,g=[],h=typeof b=="function"?b:b.callback,i=function(b){var c=new f.Point(b.clientX,b.clientY);c.x+=document.body.scrollLeft+document.documentElement.scrollLeft,c.y+=document.body.scrollTop+document.documentElement.scrollTop,c.x-=parseFloat(f.getStyle(document.documentElement,"margin-left")),c.y-=parseFloat(f.getStyle(document.documentElement,"margin-top"));for(var d=a.parent;d;d=d.offsetParent)c.x-=d.offsetLeft,c.y-=d.offsetTop;return c},j={add:function(a){this.overlayDiv=document.createElement("div"),this.overlayDiv.id=a.parent.id+"-boxselector",this.overlayDiv.className="pointselector-box-container",this.overlayDiv.style.width=a.dimensions.x+"px",this.overlayDiv.style.height=a.dimensions.y+"px",a.parent.appendChild(this.overlayDiv),f.addEvent(this.overlayDiv,"mousedown",j.mouseDown),a.addCallback("drawn",j.drawPoints);return this},deletePoint:function(a,b){confirm("Delete this point?")&&(a.pointDiv.parentNode.removeChild(a.pointDiv),g.splice(g.indexOf(a),1),h(j.cleanLocations(g)))},drawPoints:function(){var b=new f.Point(0,0);for(var c=0;c<g.length;c++){var d=a.locationPoint(g[c]);g[c].pointDiv||(g[c].pointDiv=document.createElement("div"),g[c].pointDiv.className="wax-point-div",g[c].pointDiv.style.position="absolute",g[c].pointDiv.style.display="block",g[c].pointDiv.location=g[c],f.addEvent(g[c].pointDiv,"mouseup",function(b){var d=g[c];return function(b){f.removeEvent(a.parent,"mouseup",j.mouseUp),j.deletePoint(d,b)}}()),this.overlayDiv.appendChild(g[c].pointDiv)),g[c].pointDiv.style.left=d.x+"px",g[c].pointDiv.style.top=d.y+"px"}},mouseDown:function(b){c=i(b),f.addEvent(a.parent,"mouseup",j.mouseUp)},addLocation:function(a){g.push(a),j.drawPoints()},cleanLocations:function(a){var b=[];for(var c=0;c<a.length;c++)b.push(new f.Location(a[c].lat,a[c].lon));return b},mouseUp:function(b){!c||(d=i(b),f.Point.distance(c,d)<e&&(j.addLocation(a.pointLocation(c)),h(j.cleanLocations(g))),c=null,f.removeEvent(a.parent,"mouseup",j.mouseUp))}};return j.add(a)},wax=wax||{},wax.zoombox=function(a,b){var c=null,d={add:function(a){this.boxDiv=document.createElement("div"),this.boxDiv.id=a.parent.id+"-zoombox",this.boxDiv.className="zoombox-box-container",this.boxDiv.style.width=a.dimensions.x+"px",this.boxDiv.style.height=a.dimensions.y+"px",this.box=document.createElement("div"),this.box.id=a.parent.id+"-zoombox-box",this.box.className="zoombox-box",this.boxDiv.appendChild(this.box),com.modestmaps.addEvent(this.boxDiv,"mousedown",this.mouseDown()),a.parent.appendChild(this.boxDiv)},remove:function(){this.boxDiv.parentNode.removeChild(this.boxDiv),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(){return 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)},mouseMove:function(a){return 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)},mouseUp:function(b){return 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";return com.modestmaps.cancelEvent(b)},this)}};return d.add(a)},wax=wax||{},wax.zoomer=function(a){var b=document.createElement("a");b.innerHTML="+",b.href="#",b.className="zoomer zoomin",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,"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.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.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.provider,com.modestmaps.MapProvider)
3  control/mm/hash.js
@@ -47,7 +47,8 @@ wax.hash = function(map, options) {
47 47
     var hash = {
48 48
         map: this,
49 49
         parser: function(s) {
50  
-            var args = s.split('/').map(Number);
  50
+            var args = s.split('/');
  51
+            for (var i = 0; i < args.length; i++) args[i] = Number(args);
51 52
             if (args.length < 3 || args.some(isNaN)) {
52 53
                 return true; // replace bogus hash
53 54
             } else if (args.length == 3) {

0 notes on commit da137c6

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