Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add modestmaps/mmg demo

  • Loading branch information...
commit 7dc7df55e29fb59ecdb3af021b06b6109cd4c425 1 parent 18cb37f
Ansis Brammanis ansis authored
48 mapbox-streets-mm/index.html
... ... @@ -0,0 +1,48 @@
  1 +<html>
  2 + <head>
  3 + <title>Museums in Washington, DC</title>
  4 +
  5 + <link rel="stylesheet" href="mmg.css"/>
  6 +
  7 + <script src="modestmaps.min.js"></script>
  8 + <script src="wax.mm.min.js"></script>
  9 + <script src="mmg.js"></script>
  10 + <script src="mmg_interaction.js"> </script>
  11 + <script src="simplestyle_factory.js"> </script>
  12 + </head>
  13 + <body>
  14 + <div id="mapbox" style="width: 800px; height: 400px"></div>
  15 + <script type="text/javascript">
  16 +
  17 + // Define the map to use from MapBox
  18 + // This is the TileJSON endpoint copied from the embed button on your map
  19 + // In this example we are using MapBox streets
  20 + // http://api.tiles.mapbox.com/v3/mapbox.mapbox-streets.jsonp
  21 + var url = 'mapbox.mapbox-streets-dc.jsonp';
  22 +
  23 + // Get metadata about the map from MapBox
  24 + wax.tilejson(url, function(tilejson) {
  25 +
  26 + // Make a new ModestMaps map in your container div
  27 + var map = new MM.Map('mapbox', new wax.mm.connector(tilejson));
  28 +
  29 + // Center the map using tilejson metadata
  30 + map.setCenterZoom(new MM.Location(
  31 + tilejson.center[1], // latitude
  32 + tilejson.center[0]), // longitude
  33 + tilejson.center[2]); // zoom level
  34 +
  35 +
  36 + // Define a GeoJSON data layer
  37 + var markerLayer = mmg().factory(simplestyle_factory)
  38 + // URL of our GeoJSON
  39 + .url('museums.geojson', function(f, l) {
  40 + mmg_interaction(l);
  41 + });
  42 +
  43 + // Add the marker layer to the map
  44 + map.addLayer(markerLayer);
  45 + });
  46 + </script>
  47 + </body>
  48 +</html>
1  mapbox-streets-mm/mapbox.mapbox-streets-dc.jsonp
... ... @@ -0,0 +1 @@
  1 +grid({"attribution":"<a href='http://mapbox.com/about/maps' target='_blank'>Terms & Feedback</a>","bounds":[-180,-85,180,85],"center":[-77.035,38.9,15],"id":"mapbox.mapbox-streets","maxzoom":17,"minzoom":0,"name":"MapBox Streets","scheme":"xyz","tilejson":"2.0.0","tiles":["http://a.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png","http://b.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png","http://c.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png","http://d.tiles.mapbox.com/v3/mapbox.mapbox-streets/{z}/{x}/{y}.png"],"webpage":"http://tiles.mapbox.com/mapbox/map/mapbox-streets"});
42 mapbox-streets-mm/mmg.css
... ... @@ -0,0 +1,42 @@
  1 +.wax-movetip {
  2 + z-index:999999;
  3 + position:absolute;
  4 + }
  5 +
  6 +.wax-intip {
  7 + position:relative;
  8 + left:-50%;
  9 + max-width:400px;
  10 + -webkit-user-select:auto;
  11 + background:#fff;
  12 + color:#000;
  13 + padding:20px;
  14 + border-radius:5px;
  15 + box-shadow:2px 2px 5px -2px #ccc;
  16 + border:2px solid #ccc;
  17 + }
  18 +
  19 +.wax-intip:after,
  20 +.wax-intip:before {
  21 + top:100%;
  22 + border:solid transparent;
  23 + content:" ";
  24 + height:0;
  25 + width:0;
  26 + position:absolute;
  27 + pointer-events:none;
  28 + }
  29 +
  30 +.wax-intip:after {
  31 + border-top-color:#fff;
  32 + border-width:15px;
  33 + left:50%;
  34 + margin-left:-15px;
  35 + }
  36 +
  37 +.wax-intip:before {
  38 + border-top-color:#ccc;
  39 + border-width:18px;
  40 + left:50%;
  41 + margin-left:-18px;
  42 + }
187 mapbox-streets-mm/mmg.js
... ... @@ -0,0 +1,187 @@
  1 +function mmg() {
  2 +
  3 + [].indexOf||(Array.prototype.indexOf=function(a,b,c){for(c=this.length,b=(c+~~b)%c;b<c&&(!(b in this)||this[b]!==a);b++);return b^c?b:-1;});
  4 +
  5 + var m = {},
  6 + // external list of geojson features
  7 + features = [],
  8 + // internal list of markers
  9 + markers = [],
  10 + // the absolute position of the parent element
  11 + position = null,
  12 + // a factory function for creating DOM elements out of
  13 + // GeoJSON objects
  14 + factory = null,
  15 + // a sorter function for sorting GeoJSON objects
  16 + // in the DOM
  17 + sorter = null,
  18 + // a list of urls from which features can be loaded.
  19 + // these can be templated with {z}, {x}, and {y}
  20 + urls,
  21 + // map bounds
  22 + left = null,
  23 + right = null;
  24 +
  25 + // reposition a single marker element
  26 + function reposition(marker) {
  27 + // remember the tile coordinate so we don't have to reproject every time
  28 + if (!marker.coord) marker.coord = m.map.locationCoordinate(marker.location);
  29 + var pos = m.map.coordinatePoint(marker.coord);
  30 + var pos_loc;
  31 +
  32 + // If this point has wound around the world, adjust its position
  33 + // to the new, onscreen location
  34 + if (pos.x < 0) {
  35 + pos_loc = new MM.Location(marker.location.lat, marker.location.lon);
  36 + pos_loc.lon += Math.ceil((left.lon - marker.location.lon) / 360) * 360;
  37 + pos = m.map.locationPoint(pos_loc);
  38 + marker.coord = m.map.locationCoordinate(pos_loc);
  39 + } else if (pos.x > m.map.dimensions.x) {
  40 + pos_loc = new MM.Location(marker.location.lat, marker.location.lon);
  41 + pos_loc.lon -= Math.ceil((marker.location.lon - right.lon) / 360) * 360;
  42 + pos = m.map.locationPoint(pos_loc);
  43 + marker.coord = m.map.locationCoordinate(pos_loc);
  44 + }
  45 +
  46 + pos.scale = 1;
  47 + pos.width = pos.height = 0;
  48 + MM.moveElement(marker.element, pos);
  49 + }
  50 +
  51 + m.draw = function() {
  52 + if (!m.map) return;
  53 + left = m.map.pointLocation(new MM.Point(0, 0));
  54 + right = m.map.pointLocation(new MM.Point(m.map.dimensions.x, 0));
  55 + for (var i = 0; i < markers.length; i++) {
  56 + reposition(markers[i]);
  57 + }
  58 + };
  59 +
  60 + m.add = function(marker) {
  61 + if (!marker || !marker.element) return null;
  62 + parent.appendChild(marker.element);
  63 + markers.push(marker);
  64 + return marker;
  65 + };
  66 +
  67 + m.remove = function(marker) {
  68 + if (!marker) return null;
  69 + parent.removeChild(marker.element);
  70 + markers.splice(markers.indexOf(marker), 1);
  71 + return marker;
  72 + };
  73 +
  74 + m.markers = function(x) {
  75 + if (!arguments.length) return markers;
  76 + };
  77 +
  78 + // Public data interface
  79 + m.features = function(x) {
  80 + // Return features
  81 + if (!arguments.length) return features;
  82 +
  83 + // Clear features
  84 + while (parent.hasChildNodes()) {
  85 + // removing lastChild iteratively is faster than
  86 + // innerHTML = ''
  87 + // http://jsperf.com/innerhtml-vs-removechild-yo/2
  88 + parent.removeChild(parent.lastChild);
  89 + }
  90 +
  91 + // clear markers representation
  92 + markers = [];
  93 + // Set features
  94 + if (!x) x = [];
  95 + features = x.slice();
  96 +
  97 + features.sort(sorter);
  98 +
  99 + for (var i = 0; i < features.length; i++) {
  100 + m.add({
  101 + element: factory(features[i]),
  102 + location: new MM.Location(features[i].geometry.coordinates[1], features[i].geometry.coordinates[0]),
  103 + data: features[i]
  104 + });
  105 + }
  106 +
  107 + if (m.map && m.map.coordinate) m.map.draw();
  108 +
  109 + return m;
  110 + };
  111 +
  112 + m.url = function(x, callback) {
  113 + if (!arguments.length) return urls;
  114 + if (typeof reqwest === 'undefined') throw 'reqwest is required for url loading';
  115 + if (typeof x === 'string') x = [x];
  116 +
  117 + urls = x;
  118 + function add_features(x) {
  119 + if (x && x.features) m.features(x.features);
  120 + if (callback) callback(x.features, m);
  121 + }
  122 +
  123 + reqwest((urls[0].match(/geojsonp$/)) ? {
  124 + url: urls[0] + (~urls[0].indexOf('?') ? '&' : '?') + 'callback=grid',
  125 + type: 'jsonp',
  126 + jsonpCallback: 'callback',
  127 + success: add_features,
  128 + error: add_features
  129 + } : {
  130 + url: urls[0],
  131 + type: 'json',
  132 + success: add_features,
  133 + error: add_features
  134 + });
  135 + return m;
  136 + };
  137 +
  138 + m.extent = function() {
  139 + var ext = [{ lat: Infinity, lon: Infinity}, { lat: -Infinity, lon: -Infinity }];
  140 + var ft = m.features();
  141 + for (var i = 0; i < ft.length; i++) {
  142 + var coords = ft[i].geometry.coordinates;
  143 + if (coords[0] < ext[0].lon) ext[0].lon = coords[0];
  144 + if (coords[1] < ext[0].lat) ext[0].lat = coords[1];
  145 + if (coords[0] > ext[1].lon) ext[1].lon = coords[0];
  146 + if (coords[1] > ext[1].lat) ext[1].lat = coords[1];
  147 + }
  148 + return ext;
  149 + };
  150 +
  151 + // Factory interface
  152 + m.factory = function(x) {
  153 + if (!arguments.length) return factory;
  154 + factory = x;
  155 + return m;
  156 + };
  157 + m.factory(function defaultFactory(feature) {
  158 + var d = document.createElement('div');
  159 + d.className = 'mmg-default';
  160 + d.style.position = 'absolute';
  161 + return d;
  162 + });
  163 +
  164 + m.sort = function(x) {
  165 + if (!arguments.length) return sorter;
  166 + sorter = x;
  167 + return m;
  168 + };
  169 + m.sort(function(a, b) {
  170 + return b.geometry.coordinates[1] -
  171 + a.geometry.coordinates[1];
  172 + });
  173 +
  174 + m.destroy = function() {
  175 + if (this.parent.parentNode) {
  176 + this.parent.parentNode.removeChild(this.parent);
  177 + }
  178 + };
  179 +
  180 + // The parent DOM element
  181 + var parent = document.createElement('div');
  182 + parent.style.cssText = 'position: absolute; top: 0px;' +
  183 + 'left: 0px; width: 100%; height: 100%; margin: 0; padding: 0; z-index: 0';
  184 + m.parent = parent;
  185 +
  186 + return m;
  187 +}
145 mapbox-streets-mm/mmg_interaction.js
... ... @@ -0,0 +1,145 @@
  1 +function mmg_interaction(mmg) {
  2 +
  3 + var mi = {},
  4 + tooltips = [],
  5 + exclusive = true,
  6 + hide_on_move = true,
  7 + show_on_hover = true,
  8 + close_timer = null,
  9 + formatter;
  10 +
  11 + mi.formatter = function(x) {
  12 + if (!arguments.length) return formatter;
  13 + formatter = x;
  14 + return mi;
  15 + };
  16 + mi.formatter(function(feature) {
  17 + var o = '',
  18 + props = feature.properties;
  19 +
  20 + if (props.title) {
  21 + o += '<strong>' + props.title + '</strong><br />';
  22 + }
  23 + if (props.description) {
  24 + o += props.description;
  25 + }
  26 +
  27 + if (typeof html_sanitize !== undefined) {
  28 + o = html_sanitize(o,
  29 + function(url) {
  30 + if (/^(https?:\/\/|data:image)/.test(url)) return url;
  31 + },
  32 + function(x) { return x; });
  33 + }
  34 +
  35 + return o;
  36 + });
  37 +
  38 + mi.hide_on_move = function(x) {
  39 + if (!arguments.length) return hide_on_move;
  40 + hide_on_move = x;
  41 + return mi;
  42 + };
  43 +
  44 + mi.exclusive = function(x) {
  45 + if (!arguments.length) return exclusive;
  46 + exclusive = x;
  47 + return mi;
  48 + };
  49 +
  50 + mi.show_on_hover = function(x) {
  51 + if (!arguments.length) return show_on_hover;
  52 + show_on_hover = x;
  53 + return mi;
  54 + };
  55 +
  56 + mi.hide_tooltips = function() {
  57 + while (tooltips.length) mmg.remove(tooltips.pop());
  58 + for (var i = 0; i < markers.length; i++) {
  59 + delete markers[i].clicked;
  60 + }
  61 + };
  62 +
  63 + mi.bind_marker = function(marker) {
  64 + var delayed_close = function() {
  65 + if (!marker.clicked) close_timer = window.setTimeout(function() {
  66 + mi.hide_tooltips();
  67 + }, 200);
  68 + };
  69 +
  70 + var show = function(e) {
  71 + var content = formatter(marker.data);
  72 + // Don't show a popup if the formatter returns an
  73 + // empty string. This does not do any magic around DOM elements.
  74 + if (!content) return;
  75 +
  76 + if (exclusive && tooltips.length > 0) {
  77 + mi.hide_tooltips();
  78 + }
  79 +
  80 + var tooltip = document.createElement('div');
  81 + tooltip.className = 'wax-movetip';
  82 +
  83 + var intip = tooltip.appendChild(document.createElement('div'));
  84 + intip.className = 'wax-intip';
  85 +
  86 + if (typeof content == 'string') {
  87 + intip.innerHTML = content;
  88 + } else {
  89 + intip.appendChild(content);
  90 + }
  91 +
  92 + // Here we're adding the tooltip to the dom briefly
  93 + // to gauge its size. There should be a better way to do this.
  94 + document.body.appendChild(tooltip);
  95 + intip.style.marginTop = -(
  96 + (marker.element.offsetHeight * 0.5) +
  97 + tooltip.offsetHeight + 20) + 'px';
  98 + document.body.removeChild(tooltip);
  99 +
  100 + if (show_on_hover) {
  101 + tooltip.onmouseover = function() {
  102 + if (close_timer) window.clearTimeout(close_timer);
  103 + };
  104 + tooltip.onmouseout = delayed_close;
  105 + }
  106 +
  107 + var t = {
  108 + element: tooltip,
  109 + data: {},
  110 + location: marker.location.copy()
  111 + };
  112 + tooltips.push(t);
  113 + mmg.add(t);
  114 + mmg.draw();
  115 + };
  116 +
  117 + marker.element.onclick = function() {
  118 + show();
  119 + marker.clicked = true;
  120 + };
  121 +
  122 + if (show_on_hover) {
  123 + marker.element.onmouseover = show;
  124 + marker.element.onmouseout = delayed_close;
  125 + }
  126 + };
  127 +
  128 + if (mmg && mmg.map) {
  129 + mmg.map.addCallback('panned', function() {
  130 + if (hide_on_move) {
  131 + while (tooltips.length) {
  132 + mmg.remove(tooltips.pop());
  133 + }
  134 + }
  135 + });
  136 + var markers = mmg.markers();
  137 + for (var i = 0; i < markers.length; i++) {
  138 + mi.bind_marker(markers[i]);
  139 + }
  140 + } else {
  141 + if (console) console.log('mmg must be added to a map before interaction is assigned');
  142 + }
  143 +
  144 + return mi;
  145 +}
14 mapbox-streets-mm/modestmaps.min.js
... ... @@ -0,0 +1,14 @@
  1 +/*
  2 + * Modest Maps JS v1.0.0-beta1
  3 + * http://modestmaps.com/
  4 + *
  5 + * Copyright (c) 2011 Stamen Design, All Rights Reserved.
  6 + *
  7 + * Open source under the BSD License.
  8 + * http://creativecommons.org/licenses/BSD/
  9 + *
  10 + * Versioned using Semantic Versioning (v.major.minor.patch)
  11 + * See CHANGELOG and http://semver.org/ for more details.
  12 + *
  13 + */
  14 +var previousMM=MM;if(!com){var com={};if(!com.modestmaps){com.modestmaps={}}}var MM=com.modestmaps={noConflict:function(){MM=previousMM;return this}};(function(b){b.extend=function(e,c){for(var d in c.prototype){if(typeof e.prototype[d]=="undefined"){e.prototype[d]=c.prototype[d]}}return e};b.getFrame=function(){return function(c){(window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(d){window.setTimeout(function(){d(+new Date())},10)})(c)}}();b.transformProperty=(function(e){if(!this.document){return}var d=document.documentElement.style;for(var c=0;c<e.length;c++){if(e[c] in d){return e[c]}}return false})(["transformProperty","WebkitTransform","OTransform","MozTransform","msTransform"]);b.matrixString=function(c){if(c.scale*c.width%1){c.scale+=(1-c.scale*c.width%1)/c.width}var d=c.scale||1;if(b._browser.webkit3d){return"scale3d("+d+","+d+", 1) translate3d("+c.x.toFixed(0)+"px,"+c.y.toFixed(0)+"px, 0px)"}else{return"scale("+d+","+d+") translate("+c.x.toFixed(6)+"px,"+c.y.toFixed(6)+"px)"}};b._browser=(function(c){return{webkit:("WebKitCSSMatrix" in c),webkit3d:("WebKitCSSMatrix" in c)&&("m11" in new WebKitCSSMatrix())}})(this);b.moveElement=function(e,c){if(b.transformProperty){if(!c.scale){c.scale=1}if(!c.width){c.width=0}if(!c.height){c.height=0}var d=b.matrixString(c);if(e[b.transformProperty]!==d){e.style[b.transformProperty]=e[b.transformProperty]=d}}else{e.style.left=c.x+"px";e.style.top=c.y+"px";if(c.width&&c.height&&c.scale){e.style.width=Math.ceil(c.width*c.scale)+"px";e.style.height=Math.ceil(c.height*c.scale)+"px"}}};b.cancelEvent=function(c){c.cancelBubble=true;c.cancel=true;c.returnValue=false;if(c.stopPropagation){c.stopPropagation()}if(c.preventDefault){c.preventDefault()}return false};b.bind=function(e,f){var g=Array.prototype.slice;var d=Function.prototype.bind;if(e.bind===d&&d){return d.apply(e,g.call(arguments,1))}var c=g.call(arguments,2);return function(){return e.apply(f,c.concat(g.call(arguments)))}};b.coerceLayer=function(c){if(typeof c=="string"){return new b.Layer(new b.TemplatedMapProvider(c))}else{if("draw" in c&&typeof c.draw=="function"){return c}else{return new b.Layer(c)}}};b.addEvent=function(e,d,c){if(e.addEventListener){e.addEventListener(d,c,false);if(d=="mousewheel"){e.addEventListener("DOMMouseScroll",c,false)}}else{if(e.attachEvent){e["e"+d+c]=c;e[d+c]=function(){e["e"+d+c](window.event)};e.attachEvent("on"+d,e[d+c])}}};b.removeEvent=function(e,d,c){if(e.removeEventListener){e.removeEventListener(d,c,false);if(d=="mousewheel"){e.removeEventListener("DOMMouseScroll",c,false)}}else{if(e.detachEvent){e.detachEvent("on"+d,e[d+c]);e[d+c]=null}}};b.getStyle=function(d,c){if(d.currentStyle){return d.currentStyle[c]}else{if(window.getComputedStyle){return document.defaultView.getComputedStyle(d,null).getPropertyValue(c)}}};b.Point=function(c,d){this.x=parseFloat(c);this.y=parseFloat(d)};b.Point.prototype={x:0,y:0,toString:function(){return"("+this.x.toFixed(3)+", "+this.y.toFixed(3)+")"},copy:function(){return new b.Point(this.x,this.y)}};b.Point.distance=function(d,c){return Math.sqrt(Math.pow(c.x-d.x,2)+Math.pow(c.y-d.y,2))};b.Point.interpolate=function(e,d,c){return new b.Point(e.x+(d.x-e.x)*c,e.y+(d.y-e.y)*c)};b.Coordinate=function(e,c,d){this.row=e;this.column=c;this.zoom=d};b.Coordinate.prototype={row:0,column:0,zoom:0,toString:function(){return"("+this.row.toFixed(3)+", "+this.column.toFixed(3)+" @"+this.zoom.toFixed(3)+")"},toKey:function(){return this.zoom+","+this.row+","+this.column},copy:function(){return new b.Coordinate(this.row,this.column,this.zoom)},container:function(){return new b.Coordinate(Math.floor(this.row),Math.floor(this.column),Math.floor(this.zoom))},zoomTo:function(c){var d=Math.pow(2,c-this.zoom);return new b.Coordinate(this.row*d,this.column*d,c)},zoomBy:function(d){var c=Math.pow(2,d);return new b.Coordinate(this.row*c,this.column*c,this.zoom+d)},up:function(c){if(c===undefined){c=1}return new b.Coordinate(this.row-c,this.column,this.zoom)},right:function(c){if(c===undefined){c=1}return new b.Coordinate(this.row,this.column+c,this.zoom)},down:function(c){if(c===undefined){c=1}return new b.Coordinate(this.row+c,this.column,this.zoom)},left:function(c){if(c===undefined){c=1}return new b.Coordinate(this.row,this.column-c,this.zoom)}};b.Location=function(c,d){this.lat=parseFloat(c);this.lon=parseFloat(d)};b.Location.prototype={lat:0,lon:0,toString:function(){return"("+this.lat.toFixed(3)+", "+this.lon.toFixed(3)+")"},copy:function(){return new b.Location(this.lat,this.lon)}};b.Location.distance=function(j,i,f){if(!f){f=6378000}var p=Math.PI/180,h=j.lat*p,o=j.lon*p,g=i.lat*p,n=i.lon*p,m=Math.cos(h)*Math.cos(o)*Math.cos(g)*Math.cos(n),l=Math.cos(h)*Math.sin(o)*Math.cos(g)*Math.sin(n),k=Math.sin(h)*Math.sin(g);return Math.acos(m+l+k)*f};b.Location.interpolate=function(j,h,n){if(j.lat===h.lat&&j.lon===h.lon){return new b.Location(j.lat,j.lon)}var t=Math.PI/180,l=j.lat*t,o=j.lon*t,k=h.lat*t,m=h.lon*t;var p=2*Math.asin(Math.sqrt(Math.pow(Math.sin((l-k)/2),2)+Math.cos(l)*Math.cos(k)*Math.pow(Math.sin((o-m)/2),2)));var g=Math.sin((1-n)*p)/Math.sin(p);var c=Math.sin(n*p)/Math.sin(p);var s=g*Math.cos(l)*Math.cos(o)+c*Math.cos(k)*Math.cos(m);var r=g*Math.cos(l)*Math.sin(o)+c*Math.cos(k)*Math.sin(m);var q=g*Math.sin(l)+c*Math.sin(k);var e=Math.atan2(q,Math.sqrt(Math.pow(s,2)+Math.pow(r,2)));var i=Math.atan2(r,s);return new b.Location(e/t,i/t)};b.Location.bearing=function(e,d){var c=Math.atan2(Math.sin(lon1-lon2)*Math.cos(lat2),Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon1-lon2))/-(Math.PI/180);return(c<0)?c+360:c};b.Extent=function(h,d,g,f){if(h instanceof b.Location&&d instanceof b.Location){var e=h,c=d;h=e.lat;d=e.lon;g=c.lat;f=c.lon}if(isNaN(g)){g=h}if(isNaN(f)){f=d}this.north=Math.max(h,g);this.south=Math.min(h,g);this.east=Math.max(f,d);this.west=Math.min(f,d)};b.Extent.prototype={north:0,south:0,east:0,west:0,copy:function(){return new b.Extent(this.north,this.west,this.south,this.east)},toString:function(c){if(isNaN(c)){c=3}return[this.north.toFixed(c),this.west.toFixed(c),this.south.toFixed(c),this.east.toFixed(c)].join(", ")},northWest:function(){return new b.Location(this.north,this.west)},southEast:function(){return new b.Location(this.south,this.east)},northEast:function(){return new b.Location(this.north,this.east)},southWest:function(){return new b.Location(this.south,this.west)},center:function(){return new b.Location(this.south+(this.north-this.south)/2,this.east+(this.west-this.east)/2)},encloseLocation:function(c){if(c.lat>this.north){this.north=c.lat}if(c.lat<this.south){this.south=c.lat}if(c.lon>this.east){this.east=c.lon}if(c.lon<this.west){this.west=c.lon}},encloseLocations:function(d){var c=d.length;for(var e=0;e<c;e++){this.encloseLocation(d[e])}},setFromLocations:function(d){var c=d.length,f=d[0];this.north=this.south=f.lat;this.east=this.west=f.lon;for(var e=1;e<c;e++){this.encloseLocation(d[e])}},encloseExtent:function(c){if(c.north>this.north){this.north=c.north}if(c.south<this.south){this.south=c.south}if(c.east>this.east){this.east=c.east}if(c.west<this.west){this.west=c.west}},containsLocation:function(c){return c.lat>=this.south&&c.lat<=this.north&&c.lon>=this.west&&c.lon<=this.east},toArray:function(){return[this.northWest(),this.southEast()]}};b.Extent.fromString=function(d){var c=d.split(/\s*,\s*/);if(c.length!=4){throw"Invalid extent string (expecting 4 comma-separated numbers)"}return new b.Extent(parseFloat(c[0]),parseFloat(c[1]),parseFloat(c[2]),parseFloat(c[3]))};b.Extent.fromArray=function(c){var d=new b.Extent();d.setFromLocations(c);return d};b.Transformation=function(e,g,c,d,f,h){this.ax=e;this.bx=g;this.cx=c;this.ay=d;this.by=f;this.cy=h};b.Transformation.prototype={ax:0,bx:0,cx:0,ay:0,by:0,cy:0,transform:function(c){return new b.Point(this.ax*c.x+this.bx*c.y+this.cx,this.ay*c.x+this.by*c.y+this.cy)},untransform:function(c){return new b.Point((c.x*this.by-c.y*this.bx-this.cx*this.by+this.cy*this.bx)/(this.ax*this.by-this.ay*this.bx),(c.x*this.ay-c.y*this.ax-this.cx*this.ay+this.cy*this.ax)/(this.bx*this.ay-this.by*this.ax))}};b.deriveTransformation=function(m,l,g,f,c,p,i,h,e,d,o,n){var k=b.linearSolution(m,l,g,c,p,i,e,d,o);var j=b.linearSolution(m,l,f,c,p,h,e,d,n);return new b.Transformation(k[0],k[1],k[2],j[0],j[1],j[2])};b.linearSolution=function(f,o,i,e,n,h,d,m,g){f=parseFloat(f);o=parseFloat(o);i=parseFloat(i);e=parseFloat(e);n=parseFloat(n);h=parseFloat(h);d=parseFloat(d);m=parseFloat(m);g=parseFloat(g);var l=(((h-g)*(o-n))-((i-h)*(n-m)))/(((e-d)*(o-n))-((f-e)*(n-m)));var k=(((h-g)*(f-e))-((i-h)*(e-d)))/(((n-m)*(f-e))-((o-n)*(e-d)));var j=i-(f*l)-(o*k);return[l,k,j]};b.Projection=function(d,c){if(!c){c=new b.Transformation(1,0,0,0,1,0)}this.zoom=d;this.transformation=c};b.Projection.prototype={zoom:0,transformation:null,rawProject:function(c){throw"Abstract method not implemented by subclass."},rawUnproject:function(c){throw"Abstract method not implemented by subclass."},project:function(c){c=this.rawProject(c);if(this.transformation){c=this.transformation.transform(c)}return c},unproject:function(c){if(this.transformation){c=this.transformation.untransform(c)}c=this.rawUnproject(c);return c},locationCoordinate:function(d){var c=new b.Point(Math.PI*d.lon/180,Math.PI*d.lat/180);c=this.project(c);return new b.Coordinate(c.y,c.x,this.zoom)},coordinateLocation:function(d){d=d.zoomTo(this.zoom);var c=new b.Point(d.column,d.row);c=this.unproject(c);return new b.Location(180*c.y/Math.PI,180*c.x/Math.PI)}};b.LinearProjection=function(d,c){b.Projection.call(this,d,c)};b.LinearProjection.prototype={rawProject:function(c){return new b.Point(c.x,c.y)},rawUnproject:function(c){return new b.Point(c.x,c.y)}};b.extend(b.LinearProjection,b.Projection);b.MercatorProjection=function(d,c){b.Projection.call(this,d,c)};b.MercatorProjection.prototype={rawProject:function(c){return new b.Point(c.x,Math.log(Math.tan(0.25*Math.PI+0.5*c.y)))},rawUnproject:function(c){return new b.Point(c.x,2*Math.atan(Math.pow(Math.E,c.y))-0.5*Math.PI)}};b.extend(b.MercatorProjection,b.Projection);b.MapProvider=function(c){if(c){this.getTile=c}};b.MapProvider.prototype={tileLimits:[new b.Coordinate(0,0,0),new b.Coordinate(1,1,0).zoomTo(18)],getTileUrl:function(c){throw"Abstract method not implemented by subclass."},getTile:function(c){throw"Abstract method not implemented by subclass."},releaseTile:function(c){},setZoomRange:function(d,c){this.tileLimits[0]=this.tileLimits[0].zoomTo(d);this.tileLimits[1]=this.tileLimits[1].zoomTo(c)},sourceCoordinate:function(g){var d=this.tileLimits[0].zoomTo(g.zoom),e=this.tileLimits[1].zoomTo(g.zoom),c=Math.pow(2,g.zoom),f;if(g.column<0){f=(g.column+c)%c}else{f=g.column%c}if(g.row<d.row||g.row>=e.row){return null}else{if(f<d.column||f>=e.column){return null}else{return new b.Coordinate(g.row,f,g.zoom)}}}};b.TemplatedMapProvider=function(e,c){var f=e.match(/{(Q|quadkey)}/);if(f){e=e.replace("{subdomains}","{S}").replace("{zoom}","{Z}").replace("{quadkey}","{Q}")}var d=(c&&c.length&&e.indexOf("{S}")>=0);var g=function(k){var j=this.sourceCoordinate(k);if(!j){return null}var i=e;if(d){var h=parseInt(j.zoom+j.row+j.column,10)%c.length;i=i.replace("{S}",c[h])}if(f){return i.replace("{Z}",j.zoom.toFixed(0)).replace("{Q}",this.quadKey(j.row,j.column,j.zoom))}else{return i.replace("{Z}",j.zoom.toFixed(0)).replace("{X}",j.column.toFixed(0)).replace("{Y}",j.row.toFixed(0))}};b.MapProvider.call(this,g)};b.TemplatedMapProvider.prototype={quadKey:function(g,e,f){var d="";for(var c=1;c<=f;c++){d+=(((g>>f-c)&1)<<1)|((e>>f-c)&1)}return d||"0"},getTile:function(c){return this.getTileUrl(c)}};b.extend(b.TemplatedMapProvider,b.MapProvider);b.TemplatedLayer=function(d,c){return new b.Layer(new b.TemplatedMapProvider(d,c))};b.getMousePoint=function(g,f){var c=new b.Point(g.clientX,g.clientY);c.x+=document.body.scrollLeft+document.documentElement.scrollLeft;c.y+=document.body.scrollTop+document.documentElement.scrollTop;for(var d=f.parent;d;d=d.offsetParent){c.x-=d.offsetLeft;c.y-=d.offsetTop}return c};b.MouseWheelHandler=function(d,c){if(d){this.init(d,c)}else{if(arguments.length>1){this.precise=c?true:false}}};b.MouseWheelHandler.prototype={precise:false,init:function(d){this.map=d;this._mouseWheel=b.bind(this.mouseWheel,this);this._zoomDiv=document.body.appendChild(document.createElement("div"));this._zoomDiv.style.cssText="visibility:hidden;top:0;height:0;width:0;overflow-y:scroll";var c=this._zoomDiv.appendChild(document.createElement("div"));c.style.height="2000px";b.addEvent(d.parent,"mousewheel",this._mouseWheel)},remove:function(){b.removeEvent(this.map.parent,"mousewheel",this._mouseWheel);this._zoomDiv.parentNode.removeChild(this._zoomDiv)},mouseWheel:function(g){var h=0;this.prevTime=this.prevTime||new Date().getTime();try{this._zoomDiv.scrollTop=1000;this._zoomDiv.dispatchEvent(g);h=1000-this._zoomDiv.scrollTop}catch(d){h=g.wheelDelta||(-g.detail*5)}var f=new Date().getTime()-this.prevTime;if(Math.abs(h)>0&&(f>200)&&!this.precise){var c=b.getMousePoint(g,this.map);this.map.zoomByAbout(h>0?1:-1,c);this.prevTime=new Date().getTime()}else{if(this.precise){var c=b.getMousePoint(g,this.map);this.map.zoomByAbout(h*0.001,c)}}return b.cancelEvent(g)}};b.DoubleClickHandler=function(c){if(c!==undefined){this.init(c)}};b.DoubleClickHandler.prototype={init:function(c){this.map=c;this._doubleClick=b.bind(this.doubleClick,this);b.addEvent(c.parent,"dblclick",this._doubleClick)},remove:function(){b.removeEvent(this.map.parent,"dblclick",this._doubleClick)},doubleClick:function(d){var c=b.getMousePoint(d,this.map);this.map.zoomByAbout(d.shiftKey?-1:1,c);return b.cancelEvent(d)}};b.DragHandler=function(c){if(c!==undefined){this.init(c)}};b.DragHandler.prototype={init:function(c){this.map=c;this._mouseDown=b.bind(this.mouseDown,this);b.addEvent(c.parent,"mousedown",this._mouseDown)},remove:function(){b.removeEvent(this.map.parent,"mousedown",this._mouseDown)},mouseDown:function(c){b.addEvent(document,"mouseup",this._mouseUp=b.bind(this.mouseUp,this));b.addEvent(document,"mousemove",this._mouseMove=b.bind(this.mouseMove,this));this.prevMouse=new b.Point(c.clientX,c.clientY);this.map.parent.style.cursor="move";return b.cancelEvent(c)},mouseMove:function(c){if(this.prevMouse){this.map.panBy(c.clientX-this.prevMouse.x,c.clientY-this.prevMouse.y);this.prevMouse.x=c.clientX;this.prevMouse.y=c.clientY;this.prevMouse.t=+new Date()}return b.cancelEvent(c)},mouseUp:function(c){b.removeEvent(document,"mouseup",this._mouseUp);b.removeEvent(document,"mousemove",this._mouseMove);this.prevMouse=null;this.map.parent.style.cursor="";return b.cancelEvent(c)}};b.MouseHandler=function(c){if(c!==undefined){this.init(c)}};b.MouseHandler.prototype={init:function(c){this.map=c;this.handlers=[new b.DragHandler(c),new b.DoubleClickHandler(c),new b.MouseWheelHandler(c)]},remove:function(){for(var c=0;c<this.handlers.length;c++){this.handlers[c].remove()}}};var a=(function(){var c=window.documentMode;return("onhashchange" in window)&&(c===undefined||c>7)})();b.Hash=function(c){this.onMapMove=b.bind(this.onMapMove,this);this.onHashChange=b.bind(this.onHashChange,this);if(c){this.init(c)}};b.Hash.prototype={map:null,lastHash:null,parseHash:function(f){var c=f.split("/");if(c.length==3){var d=parseInt(c[0],10),e=parseFloat(c[1]),g=parseFloat(c[2]);if(isNaN(d)||isNaN(e)||isNaN(g)){return false}else{return{center:new b.Location(e,g),zoom:d}}}else{return false}},formatHash:function(f){var c=f.getCenter(),e=f.getZoom(),d=Math.max(0,Math.ceil(Math.log(e)/Math.LN2));return"#"+[e,c.lat.toFixed(d),c.lon.toFixed(d)].join("/")},init:function(c){this.map=c;this.map.addCallback("drawn",this.onMapMove);this.lastHash=null;this.onHashChange();if(!this.isListening){this.startListening()}},remove:function(){this.map=null;if(this.isListening){this.stopListening()}},onMapMove:function(d){if(this.movingMap||this.map.zoom===0){return false}var c=this.formatHash(d);if(this.lastHash!=c){location.replace(c);this.lastHash=c}},movingMap:false,update:function(){var e=location.hash;if(e===this.lastHash){return}var d=e.substr(1),c=this.parseHash(d);if(c){this.movingMap=true;this.map.setCenterZoom(c.center,c.zoom);this.movingMap=false}else{this.onMapMove(this.map)}},changeDefer:100,changeTimeout:null,onHashChange:function(){if(!this.changeTimeout){var c=this;this.changeTimeout=setTimeout(function(){c.update();c.changeTimeout=null},this.changeDefer)}},isListening:false,hashChangeInterval:null,startListening:function(){if(a){window.addEventListener("hashchange",this.onHashChange,false)}else{clearInterval(this.hashChangeInterval);this.hashChangeInterval=setInterval(this.onHashChange,50)}this.isListening=true},stopListening:function(){if(a){window.removeEventListener("hashchange",this.onHashChange)}else{clearInterval(this.hashChangeInterval)}this.isListening=false}};b.TouchHandler=function(d,c){if(d){this.init(d,c)}};b.TouchHandler.prototype={maxTapTime:250,maxTapDistance:30,maxDoubleTapDelay:350,locations:{},taps:[],wasPinching:false,lastPinchCenter:null,init:function(d,c){this.map=d;c=c||{};if(!this.isTouchable()){return false}this._touchStartMachine=b.bind(this.touchStartMachine,this);this._touchMoveMachine=b.bind(this.touchMoveMachine,this);this._touchEndMachine=b.bind(this.touchEndMachine,this);b.addEvent(d.parent,"touchstart",this._touchStartMachine);b.addEvent(d.parent,"touchmove",this._touchMoveMachine);b.addEvent(d.parent,"touchend",this._touchEndMachine);this.options={};this.options.snapToZoom=c.snapToZoom||true},isTouchable:function(){var c=document.createElement("div");c.setAttribute("ongesturestart","return;");return(typeof c.ongesturestart==="function")},remove:function(){if(!this.isTouchable()){return false}b.removeEvent(this.map.parent,"touchstart",this._touchStartMachine);b.removeEvent(this.map.parent,"touchmove",this._touchMoveMachine);b.removeEvent(this.map.parent,"touchend",this._touchEndMachine)},updateTouches:function(g){for(var f=0;f<g.touches.length;f+=1){var d=g.touches[f];if(d.identifier in this.locations){var c=this.locations[d.identifier];c.x=d.screenX;c.y=d.screenY;c.scale=g.scale}else{this.locations[d.identifier]={scale:g.scale,startPos:{x:d.screenX,y:d.screenY},x:d.screenX,y:d.screenY,time:new Date().getTime()}}}},sameTouch:function(c,d){return(c&&c.touch)&&(d.identifier==c.touch.identifier)},touchStartMachine:function(c){this.updateTouches(c);return b.cancelEvent(c)},touchMoveMachine:function(c){switch(c.touches.length){case 1:this.onPanning(c.touches[0]);break;case 2:this.onPinching(c);break}this.updateTouches(c);return b.cancelEvent(c)},touchEndMachine:function(m){var d=new Date().getTime();if(m.touches.length===0&&this.wasPinching){this.onPinched(this.lastPinchCenter)}for(var k=0;k<m.changedTouches.length;k+=1){var p=m.changedTouches[k],l=this.locations[p.identifier];if(!l||l.wasPinch){continue}var o={x:p.screenX,y:p.screenY},g=d-l.time,f=b.Point.distance(o,l.startPos);if(f>this.maxTapDistance){}else{if(g>this.maxTapTime){o.end=d;o.duration=g;this.onHold(o)}else{o.time=d;this.onTap(o)}}}var n={};for(var h=0;h<m.touches.length;h++){n[m.touches[h].identifier]=true}for(var c in this.locations){if(!(c in n)){delete n[c]}}return b.cancelEvent(m)},onHold:function(c){},onTap:function(c){if(this.taps.length&&(c.time-this.taps[0].time)<this.maxDoubleTapDelay){this.onDoubleTap(c);this.taps=[];return}this.taps=[c]},onDoubleTap:function(d){var f=this.map.getZoom(),g=Math.round(f)+1,c=g-f;var e=new b.Point(d.x,d.y);this.map.zoomByAbout(c,e)},onPanning:function(e){var d={x:e.screenX,y:e.screenY},c=this.locations[e.identifier];this.map.panBy(d.x-c.x,d.y-c.y)},onPinching:function(j){var i=j.touches[0],h=j.touches[1],l=new b.Point(i.screenX,i.screenY),k=new b.Point(h.screenX,h.screenY),f=this.locations[i.identifier],d=this.locations[h.identifier];f.wasPinch=true;d.wasPinch=true;var c=b.Point.interpolate(l,k,0.5);this.map.zoomByAbout(Math.log(j.scale)/Math.LN2-Math.log(f.scale)/Math.LN2,c);var g=b.Point.interpolate(f,d,0.5);this.map.panBy(c.x-g.x,c.y-g.y);this.wasPinching=true;this.lastPinchCenter=c},onPinched:function(c){if(this.options.snapToZoom){var d=this.map.getZoom(),e=Math.round(d);this.map.zoomByAbout(e-d,c)}this.wasPinching=false}};b.CallbackManager=function(c,e){this.owner=c;this.callbacks={};for(var d=0;d<e.length;d++){this.callbacks[e[d]]=[]}};b.CallbackManager.prototype={owner:null,callbacks:null,addCallback:function(c,d){if(typeof(d)=="function"&&this.callbacks[c]){this.callbacks[c].push(d)}},removeCallback:function(f,g){if(typeof(g)=="function"&&this.callbacks[f]){var d=this.callbacks[f],c=d.length;for(var e=0;e<c;e++){if(d[e]===g){d.splice(e,1);break}}}},dispatchCallback:function(f,d){if(this.callbacks[f]){for(var c=0;c<this.callbacks[f].length;c+=1){try{this.callbacks[f][c](this.owner,d)}catch(g){}}}}};b.RequestManager=function(){this.loadingBay=document.createDocumentFragment();this.requestsById={};this.openRequestCount=0;this.maxOpenRequests=4;this.requestQueue=[];this.callbackManager=new b.CallbackManager(this,["requestcomplete","requesterror"])};b.RequestManager.prototype={loadingBay:null,requestsById:null,requestQueue:null,openRequestCount:null,maxOpenRequests:null,callbackManager:null,addCallback:function(c,d){this.callbackManager.addCallback(c,d)},removeCallback:function(c,d){this.callbackManager.removeCallback(c,d)},dispatchCallback:function(d,c){this.callbackManager.dispatchCallback(d,c)},clear:function(){this.clearExcept({})},clearRequest:function(e){if(e in this.requestsById){delete this.requestsById[e]}for(var c=0;c<this.requestQueue.length;c++){var d=this.requestQueue[c];if(d&&d.id==e){this.requestQueue[c]=null}}},clearExcept:function(g){for(var f=0;f<this.requestQueue.length;f++){var h=this.requestQueue[f];if(h&&!(h.id in g)){this.requestQueue[f]=null}}var c=this.loadingBay.childNodes;for(var e=c.length-1;e>=0;e--){var d=c[e];if(!(d.id in g)){this.loadingBay.removeChild(d);this.openRequestCount--;d.src=d.coord=d.onload=d.onerror=null}}for(var l in this.requestsById){if(!(l in g)){if(this.requestsById.hasOwnProperty(l)){var k=this.requestsById[l];delete this.requestsById[l];if(k!==null){k=k.id=k.coord=k.url=null}}}}},hasRequest:function(c){return(c in this.requestsById)},requestTile:function(f,e,c){if(!(f in this.requestsById)){var d={id:f,coord:e.copy(),url:c};this.requestsById[f]=d;if(c){this.requestQueue.push(d)}}},getProcessQueue:function(){if(!this._processQueue){var c=this;this._processQueue=function(){c.processQueue()}}return this._processQueue},processQueue:function(e){if(e&&this.requestQueue.length>8){this.requestQueue.sort(e)}while(this.openRequestCount<this.maxOpenRequests&&this.requestQueue.length>0){var d=this.requestQueue.pop();if(d){this.openRequestCount++;var c=document.createElement("img");c.id=d.id;c.style.position="absolute";c.coord=d.coord;this.loadingBay.appendChild(c);c.onload=c.onerror=this.getLoadComplete();c.src=d.url;d=d.id=d.coord=d.url=null}}},_loadComplete:null,getLoadComplete:function(){if(!this._loadComplete){var c=this;this._loadComplete=function(f){f=f||window.event;var d=f.srcElement||f.target;d.onload=d.onerror=null;c.loadingBay.removeChild(d);c.openRequestCount--;delete c.requestsById[d.id];if(f.type==="load"&&(d.complete||(d.readyState&&d.readyState=="complete"))){c.dispatchCallback("requestcomplete",d)}else{c.dispatchCallback("requesterror",d.src);d.src=null}setTimeout(c.getProcessQueue(),0)}}return this._loadComplete}};b.Layer=function(d,c){this.parent=c||document.createElement("div");this.parent.style.cssText="position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; margin: 0; padding: 0; z-index: 0";this.levels={};this.requestManager=new b.RequestManager();this.requestManager.addCallback("requestcomplete",this.getTileComplete());if(d){this.setProvider(d)}};b.Layer.prototype={map:null,parent:null,tiles:null,levels:null,requestManager:null,tileCacheSize:null,maxTileCacheSize:null,provider:null,recentTiles:null,recentTilesById:{},enablePyramidLoading:false,_tileComplete:null,getTileComplete:function(){if(!this._tileComplete){var c=this;this._tileComplete=function(e,f){c.tiles[f.id]=f;c.tileCacheSize++;var d={id:f.id,lastTouchedTime:new Date().getTime()};c.recentTilesById[f.id]=d;c.recentTiles.push(d);c.positionTile(f)}}return this._tileComplete},draw:function(){var o=Math.round(this.map.coordinate.zoom);var n=this.map.pointCoordinate(new b.Point(0,0)).zoomTo(o).container();var i=this.map.pointCoordinate(this.map.dimensions).zoomTo(o).container().right().down();var k={};var m=this.createOrGetLevel(n.zoom);var h=n.copy();for(h.column=n.column;h.column<=i.column;h.column++){for(h.row=n.row;h.row<=i.row;h.row++){var d=this.inventoryVisibleTile(m,h);while(d.length){k[d.pop()]=true}}}for(var f in this.levels){if(this.levels.hasOwnProperty(f)){var p=parseInt(f,10);if(p>=n.zoom-5&&p<n.zoom+2){continue}var e=this.levels[f];e.style.display="none";var g=this.tileElementsInLevel(e);while(g.length){this.provider.releaseTile(g[0].coord);this.requestManager.clearRequest(g[0].coord.toKey());e.removeChild(g[0]);g.shift()}}}var c=n.zoom-5;var l=n.zoom+2;for(var j=c;j<l;j++){this.adjustVisibleLevel(this.levels[j],j,k)}this.requestManager.clearExcept(k);this.requestManager.processQueue(this.getCenterDistanceCompare());this.checkCache()},inventoryVisibleTile:function(q,d){var i=d.toKey(),e=[i];if(i in this.tiles){var h=this.tiles[i];if(h.parentNode!=q){q.appendChild(h);if("reAddTile" in this.provider){this.provider.reAddTile(i,d,h)}}return e}if(!this.requestManager.hasRequest(i)){var p=this.provider.getTile(d);if(typeof p=="string"){this.addTileImage(i,d,p)}else{if(p){this.addTileElement(i,d,p)}}}var f=false;var n=d.zoom;for(var j=1;j<=n;j++){var c=d.zoomBy(-j).container();var o=c.toKey();if(this.enablePyramidLoading){e.push(o);var m=this.createOrGetLevel(c.zoom);if(o in this.tiles){var l=this.tiles[o];if(l.parentNode!=m){m.appendChild(l)}}else{if(!this.requestManager.hasRequest(o)){var g=this.provider.getTile(c);if(typeof g=="string"){this.addTileImage(o,c,g)}else{this.addTileElement(o,c,g)}}}}else{if(o in this.tiles){e.push(o);f=true;break}}}if(!f&&!this.enablePyramidLoading){var k=d.zoomBy(1);e.push(k.toKey());k.column+=1;e.push(k.toKey());k.row+=1;e.push(k.toKey());k.column-=1;e.push(k.toKey())}return e},tileElementsInLevel:function(e){var c=[];for(var d=e.firstChild;d;d=d.nextSibling){if(d.nodeType==1){c.push(d)}}return c},adjustVisibleLevel:function(d,m,f){var e=new Date().getTime();if(!d){return}var g=1;var l=this.map.coordinate.copy();if(d.childNodes.length>0){d.style.display="block";g=Math.pow(2,this.map.coordinate.zoom-m);l=l.zoomTo(m)}else{d.style.display="none"}var j=this.map.tileSize.x*g;var h=this.map.tileSize.y*g;var c=new b.Point(this.map.dimensions.x/2,this.map.dimensions.y/2);var k=this.tileElementsInLevel(d);while(k.length){var i=k.pop();if(!f[i.id]){this.provider.releaseTile(i.coord);this.requestManager.clearRequest(i.coord.toKey());d.removeChild(i)}else{this.recentTilesById[i.id].lastTouchedTime=e}}b.moveElement(d,{x:-(l.column*256)+c.x,y:-(l.row*256)+c.y,scale:g})},createOrGetLevel:function(c){if(c in this.levels){return this.levels[c]}var d=document.createElement("div");d.id=this.parent.id+"-zoom-"+c;d.style.cssText=this.parent.style.cssText;d.style.zIndex=c;this.parent.appendChild(d);this.levels[c]=d;return d},addTileImage:function(d,e,c){this.requestManager.requestTile(d,e,c)},addTileElement:function(e,f,d){d.id=e;d.coord=f.copy();this.tiles[e]=d;this.tileCacheSize++;var c={id:e,lastTouchedTime:new Date().getTime()};this.recentTilesById[e]=c;this.recentTiles.push(c);this.positionTile(d)},positionTile:function(g){var f=this.map.coordinate.zoomTo(g.coord.zoom);g.style.cssText="position:absolute;-webkit-user-select: none;-webkit-user-drag: none;-moz-user-drag: none;";g.ondragstart=function(){return false};var d=g.coord.column*this.map.tileSize.x;var c=g.coord.row*this.map.tileSize.y;b.moveElement(g,{x:Math.round(d),y:Math.round(c),width:this.map.tileSize.x,height:this.map.tileSize.y});var e=this.levels[g.coord.zoom];e.appendChild(g);g.className="map-tile-loaded";if(Math.round(this.map.coordinate.zoom)==g.coord.zoom){e.style.display="block"}this.requestRedraw()},_redrawTimer:undefined,requestRedraw:function(){if(!this._redrawTimer){this._redrawTimer=setTimeout(this.getRedraw(),1000)}},_redraw:null,getRedraw:function(){if(!this._redraw){var c=this;this._redraw=function(){c.draw();c._redrawTimer=0}}return this._redraw},numTilesOnScreen:function(){var c=0;for(var d in this.levels){if(this.levels.hasOwnProperty(d)){var e=this.levels[d];c+=this.tileElementsInLevel(e).length}}return c},checkCache:function(){var e=Math.max(this.numTilesOnScreen(),this.maxTileCacheSize);if(this.tileCacheSize>e){this.recentTiles.sort(function(h,g){return g.lastTouchedTime<h.lastTouchedTime?-1:g.lastTouchedTime>h.lastTouchedTime?1:0})}while(this.recentTiles.length&&this.tileCacheSize>e){var d=this.recentTiles.pop();var c=new Date().getTime();delete this.recentTilesById[d.id];var f=this.tiles[d.id];if(f.parentNode){alert("Gah: trying to removing cached tile even though it's still in the DOM")}else{delete this.tiles[d.id];this.tileCacheSize--}}},setProvider:function(d){var e=(this.provider===null);if(!e){this.requestManager.clear();for(var c in this.levels){if(this.levels.hasOwnProperty(c)){var f=this.levels[c];while(f.firstChild){this.provider.releaseTile(f.firstChild.coord);f.removeChild(f.firstChild)}}}}this.tiles={};this.tileCacheSize=0;this.maxTileCacheSize=64;this.recentTilesById={};this.recentTiles=[];this.provider=d;if(!e){this.draw()}},getCenterDistanceCompare:function(){var c=this.map.coordinate.zoomTo(Math.round(this.map.coordinate.zoom));return function(f,e){if(f&&e){var h=f.coord;var g=e.coord;if(h.zoom==g.zoom){var d=Math.abs(c.row-h.row-0.5)+Math.abs(c.column-h.column-0.5);var i=Math.abs(c.row-g.row-0.5)+Math.abs(c.column-g.column-0.5);return d<i?1:d>i?-1:0}else{return h.zoom<g.zoom?1:h.zoom>g.zoom?-1:0}}return f?1:e?-1:0}},destroy:function(){this.requestManager.clear();this.requestManager.removeCallback("requestcomplete",this.getTileComplete());this.provider=null;if(this.parent.parentNode){this.parent.parentNode.removeChild(this.parent)}this.map=null}};b.Map=function(g,f,h,k){if(typeof g=="string"){g=document.getElementById(g);if(!g){throw"The ID provided to modest maps could not be found."}}this.parent=g;this.parent.style.padding="0";this.parent.style.overflow="hidden";var c=b.getStyle(this.parent,"position");if(c!="relative"&&c!="absolute"){this.parent.style.position="relative"}this.layers=[];if(!(f instanceof Array)){f=[f]}for(var e=0;e<f.length;e++){this.addLayer(f[e])}this.projection=new b.MercatorProjection(0,b.deriveTransformation(-Math.PI,Math.PI,0,0,Math.PI,Math.PI,1,0,-Math.PI,-Math.PI,0,1));this.tileSize=new b.Point(256,256);this.coordLimits=[new b.Coordinate(0,-Infinity,0),new b.Coordinate(1,Infinity,0).zoomTo(18)];this.coordinate=new b.Coordinate(0.5,0.5,0);if(!h){h=new b.Point(this.parent.offsetWidth,this.parent.offsetHeight);this.autoSize=true;b.addEvent(window,"resize",this.windowResize())}else{this.autoSize=false;this.parent.style.width=Math.round(h.x)+"px";this.parent.style.height=Math.round(h.y)+"px"}this.dimensions=h;this.callbackManager=new b.CallbackManager(this,["zoomed","panned","centered","extentset","resized","drawn"]);if(k===undefined){this.eventHandlers=[new b.MouseHandler(this),new b.TouchHandler(this)]}else{this.eventHandlers=k;if(k instanceof Array){for(var d=0;d<k.length;d++){k[d].init(this)}}}};b.Map.prototype={parent:null,dimensions:null,projection:null,coordinate:null,tileSize:null,coordLimits:null,layers:null,callbackManager:null,eventHandlers:null,autoSize:null,toString:function(){return"Map(#"+this.parent.id+")"},addCallback:function(c,d){this.callbackManager.addCallback(c,d);return this},removeCallback:function(c,d){this.callbackManager.removeCallback(c,d);return this},dispatchCallback:function(d,c){this.callbackManager.dispatchCallback(d,c);return this},windowResize:function(){if(!this._windowResize){var c=this;this._windowResize=function(d){c.dimensions=new b.Point(c.parent.offsetWidth,c.parent.offsetHeight);c.draw();c.dispatchCallback("resized",[c.dimensions])}}return this._windowResize},setZoomRange:function(d,c){this.coordLimits[0]=this.coordLimits[0].zoomTo(d);this.coordLimits[1]=this.coordLimits[1].zoomTo(c)},zoomBy:function(c){this.coordinate=this.enforceLimits(this.coordinate.zoomBy(c));b.getFrame(this.getRedraw());this.dispatchCallback("zoomed",c);return this},zoomIn:function(){return this.zoomBy(1)},zoomOut:function(){return this.zoomBy(-1)},setZoom:function(c){return this.zoomBy(c-this.coordinate.zoom)},zoomByAbout:function(d,c){var f=this.pointLocation(c);this.coordinate=this.enforceLimits(this.coordinate.zoomBy(d));var e=this.locationPoint(f);this.dispatchCallback("zoomed",d);return this.panBy(c.x-e.x,c.y-e.y)},panBy:function(d,c){this.coordinate.column-=d/this.tileSize.x;this.coordinate.row-=c/this.tileSize.y;this.coordinate=this.enforceLimits(this.coordinate);b.getFrame(this.getRedraw());this.dispatchCallback("panned",[d,c]);return this},panLeft:function(){return this.panBy(100,0)},panRight:function(){return this.panBy(-100,0)},panDown:function(){return this.panBy(0,-100)},panUp:function(){return this.panBy(0,100)},setCenter:function(c){return this.setCenterZoom(c,this.coordinate.zoom)},setCenterZoom:function(c,d){this.coordinate=this.projection.locationCoordinate(c).zoomTo(parseFloat(d)||0);b.getFrame(this.getRedraw());this.dispatchCallback("centered",[c,d]);return this},extentCoordinate:function(q,r){if(q instanceof b.Extent){q=q.toArray()}var u,k;for(var l=0;l<q.length;l++){var m=this.projection.locationCoordinate(q[l]);if(u){u.row=Math.min(u.row,m.row);u.column=Math.min(u.column,m.column);u.zoom=Math.min(u.zoom,m.zoom);k.row=Math.max(k.row,m.row);k.column=Math.max(k.column,m.column);k.zoom=Math.max(k.zoom,m.zoom)}else{u=m.copy();k=m.copy()}}var j=this.dimensions.x+1;var h=this.dimensions.y+1;var n=(k.column-u.column)/(j/this.tileSize.x);var s=Math.log(n)/Math.log(2);var o=u.zoom-(r?s:Math.ceil(s));var p=(k.row-u.row)/(h/this.tileSize.y);var e=Math.log(p)/Math.log(2);var f=u.zoom-(r?e:Math.ceil(e));var c=Math.min(o,f);c=Math.min(c,this.coordLimits[1].zoom);c=Math.max(c,this.coordLimits[0].zoom);var d=(u.row+k.row)/2;var t=(u.column+k.column)/2;var g=u.zoom;return new b.Coordinate(d,t,g).zoomTo(c)},setExtent:function(c,d){this.coordinate=this.extentCoordinate(c,d);this.draw();this.dispatchCallback("extentset",c);return this},setSize:function(c){this.dimensions=new b.Point(c.x,c.y);this.parent.style.width=Math.round(this.dimensions.x)+"px";this.parent.style.height=Math.round(this.dimensions.y)+"px";if(this.autoSize){b.removeEvent(window,"resize",this.windowResize());this.autoSize=false}this.draw();this.dispatchCallback("resized",this.dimensions);return this},coordinatePoint:function(d){if(d.zoom!=this.coordinate.zoom){d=d.zoomTo(this.coordinate.zoom)}var c=new b.Point(this.dimensions.x/2,this.dimensions.y/2);c.x+=this.tileSize.x*(d.column-this.coordinate.column);c.y+=this.tileSize.y*(d.row-this.coordinate.row);return c},pointCoordinate:function(c){var d=this.coordinate.copy();d.column+=(c.x-this.dimensions.x/2)/this.tileSize.x;d.row+=(c.y-this.dimensions.y/2)/this.tileSize.y;return d},locationCoordinate:function(c){return this.projection.locationCoordinate(c)},coordinateLocation:function(c){return this.projection.coordinateLocation(c)},locationPoint:function(c){return this.coordinatePoint(this.locationCoordinate(c))},pointLocation:function(c){return this.coordinateLocation(this.pointCoordinate(c))},getExtent:function(){return new b.Extent(this.pointLocation(new b.Point(0,0)),this.pointLocation(this.dimensions))},extent:function(c,d){if(c){return this.setExtent(c,d)}else{return this.getExtent()}},getCenter:function(){return this.projection.coordinateLocation(this.coordinate)},center:function(c){if(c){return this.setCenter(c)}else{return this.getCenter()}},getZoom:function(){return this.coordinate.zoom},zoom:function(c){if(c!==undefined){return this.setZoom(c)}else{return this.getZoom()}},getLayers:function(){return this.layers.slice()},getLayerAt:function(c){return this.layers[c]},addLayer:function(c){this.layers.push(c);this.parent.appendChild(c.parent);c.map=this;return this},removeLayer:function(d){for(var c=0;c<this.layers.length;c++){if(d==this.layers[c]){this.removeLayerAt(c);break}}return this},setLayerAt:function(c,d){if(c<0||c>=this.layers.length){throw new Error("invalid index in setLayerAt(): "+c)}if(this.layers[c]!=d){if(c<this.layers.length){this.layers[c].destroy()}this.layers[c]=d;this.parent.appendChild(d.parent);d.map=this;b.getFrame(this.getRedraw())}return this},insertLayerAt:function(d,e){if(d<0||d>this.layers.length){throw new Error("invalid index in insertLayerAt(): "+d)}if(d==this.layers.length){this.layers.push(e);this.parent.appendChild(e.parent)}else{var c=this.layers[d];this.parent.insertBefore(e.parent,c.parent);this.layers.splice(d,0,e)}e.map=this;b.getFrame(this.getRedraw());return this},removeLayerAt:function(d){if(d<0||d>=this.layers.length){throw new Error("invalid index in removeLayer(): "+d)}var c=this.layers[d];this.layers.splice(d,1);c.destroy();return this},swapLayersAt:function(d,c){if(d<0||d>=this.layers.length||c<0||c>=this.layers.length){throw new Error("invalid index in swapLayersAt(): "+index)}var g=this.layers[d],e=this.layers[c],f=document.createElement("div");this.parent.replaceChild(f,e.parent);this.parent.replaceChild(e.parent,g.parent);this.parent.replaceChild(g.parent,f);this.layers[d]=e;this.layers[c]=g;return this},enforceZoomLimits:function(f){var d=this.coordLimits;if(d){var e=d[0].zoom;var c=d[1].zoom;if(f.zoom<e){f=f.zoomTo(e)}else{if(f.zoom>c){f=f.zoomTo(c)}}}return f},enforcePanLimits:function(g){if(this.coordLimits){g=g.copy();var e=this.coordLimits[0].zoomTo(g.zoom);var c=this.coordLimits[1].zoomTo(g.zoom);var d=this.pointCoordinate(new b.Point(0,0)).zoomTo(g.zoom);var f=this.pointCoordinate(this.dimensions).zoomTo(g.zoom);if(c.row-e.row<f.row-d.row){g.row=(c.row+e.row)/2}else{if(d.row<e.row){g.row+=e.row-d.row}else{if(f.row>c.row){g.row-=f.row-c.row}}}if(c.column-e.column<f.column-d.column){g.column=(c.column+e.column)/2}else{if(d.column<e.column){g.column+=e.column-d.column}else{if(f.column>c.column){g.column-=f.column-c.column}}}}return g},enforceLimits:function(c){return this.enforcePanLimits(this.enforceZoomLimits(c))},draw:function(){this.coordinate=this.enforceLimits(this.coordinate);if(this.dimensions.x<=0||this.dimensions.y<=0){if(this.autoSize){var c=this.parent.offsetWidth,e=this.parent.offsetHeight;this.dimensions=new b.Point(c,e);if(c<=0||e<=0){return}}else{return}}for(var d=0;d<this.layers.length;d++){this.layers[d].draw()}this.dispatchCallback("drawn")},_redrawTimer:undefined,requestRedraw:function(){if(!this._redrawTimer){this._redrawTimer=setTimeout(this.getRedraw(),1000)}},_redraw:null,getRedraw:function(){if(!this._redraw){var c=this;this._redraw=function(){c.draw();c._redrawTimer=0}}return this._redraw},destroy:function(){for(var c=0;c<this.layers.length;c++){this.layers[c].destroy()}this.layers=[];this.projection=null;for(var d=0;d<this.eventHandlers.length;d++){this.eventHandlers[d].remove()}if(this.autoSize){b.removeEvent(window,"resize",this.windowResize())}}};b.mapByCenterZoom=function(e,g,c,f){var d=b.coerceLayer(g),h=new b.Map(e,d,false);h.setCenterZoom(c,f).draw();return h};b.mapByExtent=function(e,g,f,d){var c=b.coerceLayer(g),h=new b.Map(e,c,false);h.setExtent([f,d]).draw();return h};if(typeof module!=="undefined"&&module.exports){module.exports={Point:b.Point,Projection:b.Projection,MercatorProjection:b.MercatorProjection,LinearProjection:b.LinearProjection,Transformation:b.Transformation,Location:b.Location,MapProvider:b.MapProvider,TemplatedMapProvider:b.TemplatedMapProvider,Coordinate:b.Coordinate,deriveTransformation:b.deriveTransformation}}})(MM);
508 mapbox-streets-mm/museums.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
33 mapbox-streets-mm/simplestyle_factory.js
... ... @@ -0,0 +1,33 @@
  1 +function simplestyle_factory(feature) {
  2 +
  3 + var sizes = {
  4 + small: [20, 50],
  5 + medium: [30, 70],
  6 + large: [35, 90]
  7 + };
  8 +
  9 + var fp = feature.properties || {};
  10 +
  11 + var size = fp['marker-size'] || 'medium';
  12 + var symbol = (fp['marker-symbol']) ? '-' + fp['marker-symbol'] : '';
  13 + var color = fp['marker-color'] || '7e7e7e';
  14 + color = color.replace('#', '');
  15 +
  16 + var d = document.createElement('div');
  17 + d.className = 'simplestyle-marker';
  18 + var ds = d.style;
  19 + ds.position = 'absolute';
  20 + ds.width = sizes[size][0] + 'px';
  21 + ds.height = sizes[size][1] + 'px';
  22 + ds.marginTop = -(sizes[size][1] / 2) + 'px';
  23 + ds.marginLeft = -(sizes[size][0] / 2) + 'px';
  24 + ds.cursor = 'pointer';
  25 +
  26 + ds.backgroundImage = 'url(http://a.tiles.mapbox.com/v3/marker/' +
  27 + 'pin-' + size[0] + symbol + '+' + color + '.png)';
  28 +
  29 + ds.textIndent = '-10000px';
  30 + d.innerHTML = fp.title || '';
  31 +
  32 + return d;
  33 +}
2  mapbox-streets-mm/wax.mm.min.js
... ... @@ -0,0 +1,2 @@
  1 +/* wax - 6.0.4 - 1.0.4-572-g5e88957 */!function(a,b,c){typeof module!="undefined"?module.exports=c(a,b):typeof define=="function"&&typeof define.amd=="object"?define(c):b[a]=c(a,b)}("bean",this,function(a,b){var c=window,d=b[a],e=/over|out/,f=/[^\.]*(?=\..*)\.|.*/,g=/\..*/,h="addEventListener",i="attachEvent",j="removeEventListener",k="detachEvent",l=document||{},m=l.documentElement||{},n=m[h],o=n?h:i,p=Array.prototype.slice,q=/click|mouse(?!(.*wheel|scroll))|menu|drag|drop/i,r=/mouse.*(wheel|scroll)/i,s=/^text/i,t=/^touch|^gesture/i,u={one:1},v=function(a,b,c){for(c=0;c<b.length;c++)a[b[c]]=1;return a}({},("click dblclick mouseup mousedown contextmenu mousewheel mousemultiwheel DOMMouseScroll mouseover mouseout mousemove selectstart selectend keydown keypress keyup orientationchange focus blur change reset select submit load unload beforeunload resize move DOMContentLoaded readystatechange error abort scroll "+(n?"show input invalid touchstart touchmove touchend touchcancel gesturestart gesturechange gestureend message readystatechange pageshow pagehide popstate hashchange offline online afterprint beforeprint dragstart dragenter dragover dragleave drag drop dragend loadstart progress suspend emptied stalled loadmetadata loadeddata canplay canplaythrough playing waiting seeking seeked ended durationchange timeupdate play pause ratechange volumechange cuechange checking noupdate downloading cached updateready obsolete ":"")).split(" ")),w=function(){function a(a,b){while((b=b.parentNode)!==null)if(b===a)return!0;return!1}function b(b){var c=b.relatedTarget;return c?c!==this&&c.prefix!=="xul"&&!/document/.test(this.toString())&&!a(this,c):c===null}return{mouseenter:{base:"mouseover",condition:b},mouseleave:{base:"mouseout",condition:b},mousewheel:{base:/Firefox/.test(navigator.userAgent)?"DOMMouseScroll":"mousewheel"}}}(),x=function(){var a="altKey attrChange attrName bubbles cancelable ctrlKey currentTarget detail eventPhase getModifierState isTrusted metaKey relatedNode relatedTarget shiftKey srcElement target timeStamp type view which".split(" "),b=a.concat("button buttons clientX clientY dataTransfer fromElement offsetX offsetY pageX pageY screenX screenY toElement".split(" ")),c=b.concat("wheelDelta wheelDeltaX wheelDeltaY wheelDeltaZ axis".split(" ")),d=a.concat("char charCode key keyCode keyIdentifier keyLocation".split(" ")),f=a.concat(["data"]),g=a.concat("touches targetTouches changedTouches scale rotation".split(" ")),h="preventDefault",i=function(a){return function(){a[h]?a[h]():a.returnValue=!1}},j="stopPropagation",k=function(a){return function(){a[j]?a[j]():a.cancelBubble=!0}},n=function(a){return function(){a[h](),a[j](),a.stopped=!0}},o=function(a,b,c){var d,e;for(d=c.length;d--;)e=c[d],!(e in b)&&e in a&&(b[e]=a[e])};return function(p,u){var v={originalEvent:p,isNative:u};if(!p)return v;var w,x=p.type,y=p.target||p.srcElement;v[h]=i(p),v[j]=k(p),v.stop=n(v),v.target=y&&y.nodeType===3?y.parentNode:y;if(u){if(x.indexOf("key")!==-1)w=d,v.keyCode=p.which||p.keyCode;else if(q.test(x)){w=b,v.rightClick=p.which===3||p.button===2,v.pos={x:0,y:0};if(p.pageX||p.pageY)v.clientX=p.pageX,v.clientY=p.pageY;else if(p.clientX||p.clientY)v.clientX=p.clientX+l.body.scrollLeft+m.scrollLeft,v.clientY=p.clientY+l.body.scrollTop+m.scrollTop;e.test(x)&&(v.relatedTarget=p.relatedTarget||p[(x==="mouseover"?"from":"to")+"Element"])}else t.test(x)?w=g:r.test(x)?w=c:s.test(x)&&(w=f);o(p,v,w||a)}return v}}(),y=function(a,b){return!n&&!b&&(a===l||a===c)?m:a},z=function(){function a(a,b,c,d,e){this.element=a,this.type=b,this.handler=c,this.original=d,this.namespaces=e,this.custom=w[b],this.isNative=v[b]&&a[o],this.eventType=n||this.isNative?b:"propertychange",this.customType=!n&&!this.isNative&&b,this.target=y(a,this.isNative),this.eventSupport=this.target[o]}return a.prototype={inNamespaces:function(a){var b,c;if(!a)return!0;if(!this.namespaces)return!1;for(b=a.length;b--;)for(c=this.namespaces.length;c--;)if(a[b]===this.namespaces[c])return!0;return!1},matches:function(a,b,c){return this.element===a&&(!b||this.original===b)&&(!c||this.handler===c)}},a}(),A=function(){var a={},b=function(c,d,e,f,g){if(!d||d==="*")for(var h in a)h.charAt(0)==="$"&&b(c,h.substr(1),e,f,g);else{var i=0,j,k=a["$"+d],l=c==="*";if(!k)return;for(j=k.length;i<j;i++)if(l||k[i].matches(c,e,f))if(!g(k[i],k,i,d))return}},c=function(b,c,d){var e,f=a["$"+c];if(f)for(e=f.length;e--;)if(f[e].matches(b,d,null))return!0;return!1},d=function(a,c,d){var e=[];return b(a,c,d,null,function(a){return e.push(a)}),e},e=function(b){return(a["$"+b.type]||(a["$"+b.type]=[])).push(b),b},f=function(c){b(c.element,c.type,null,c.handler,function(b,c,d){return c.splice(d,1),c.length===0&&delete a["$"+b.type],!1})},g=function(){var b,c=[];for(b in a)b.charAt(0)==="$"&&(c=c.concat(a[b]));return c};return{has:c,get:d,put:e,del:f,entries:g}}(),B=n?function(a,b,c,d){a[d?h:j](b,c,!1)}:function(a,b,c,d,e){e&&d&&a["_on"+e]===null&&(a["_on"+e]=0),a[d?i:k]("on"+b,c)},C=function(a,b,d){return function(e){return e=x(e||((this.ownerDocument||this.document||this).parentWindow||c).event,!0),b.apply(a,[e].concat(d))}},D=function(a,b,d,e,f,g){return function(h){if(e?e.apply(this,arguments):n?!0:h&&h.propertyName==="_on"+d||!h)h&&(h=x(h||((this.ownerDocument||this.document||this).parentWindow||c).event,g)),b.apply(a,h&&(!f||f.length===0)?arguments:p.call(arguments,h?0:1).concat(f))}},E=function(a,b,c,d,e){return function(){a(b,c,e),d.apply(this,arguments)}},F=function(a,b,c,d){var e,f,h,i=b&&b.replace(g,""),j=A.get(a,i,c);for(e=0,f=j.length;e<f;e++)j[e].inNamespaces(d)&&((h=j[e]).eventSupport&&B(h.target,h.eventType,h.handler,!1,h.type),A.del(h))},G=function(a,b,c,d,e){var h,i=b.replace(g,""),j=b.replace(f,"").split(".");if(A.has(a,i,c))return a;i==="unload"&&(c=E(F,a,i,c,d)),w[i]&&(w[i].condition&&(c=D(a,c,i,w[i].condition,!0)),i=w[i].base||i),h=A.put(new z(a,i,c,d,j[0]&&j)),h.handler=h.isNative?C(a,h.handler,e):D(a,h.handler,i,!1,e,!1),h.eventSupport&&B(h.target,h.eventType,h.handler,!0,h.customType)},H=function(a,b,c){return function(d){var e,f,g=typeof a=="string"?c(a,this):a;for(e=d.target;e&&e!==this;e=e.parentNode)for(f=g.length;f--;)if(g[f]===e)return b.apply(e,arguments)}},I=function(a,b,c){var d,e,h,i,j,k=F,l=b&&typeof b=="string";if(l&&b.indexOf(" ")>0){b=b.split(" ");for(j=b.length;j--;)I(a,b[j],c);return a}h=l&&b.replace(g,""),h&&w[h]&&(h=w[h].type);if(!b||l){if(i=l&&b.replace(f,""))i=i.split(".");k(a,h,c,i)}else if(typeof b=="function")k(a,null,b);else for(d in b)b.hasOwnProperty(d)&&I(a,d,b[d]);return a},J=function(a,b,c,d,e){var f,g,h,i,j=c,k=c&&typeof c=="string";if(b&&!c&&typeof b=="object")for(f in b)b.hasOwnProperty(f)&&J.apply(this,[a,f,b[f]]);else{i=arguments.length>3?p.call(arguments,3):[],g=(k?c:b).split(" "),k&&(c=H(b,j=d,e))&&(i=p.call(i,1)),this===u&&(c=E(I,a,b,c,j));for(h=g.length;h--;)G(a,g[h],c,j,i)}return a},K=function(){return J.apply(u,arguments)},L=n?function(a,b,d){var e=l.createEvent(a?"HTMLEvents":"UIEvents");e[a?"initEvent":"initUIEvent"](b,!0,!0,c,1),d.dispatchEvent(e)}:function(a,b,c){c=y(c,a),a?c.fireEvent("on"+b,l.createEventObject()):c["_on"+b]++},M=function(a,b,c){var d,e,h,i,j,k=b.split(" ");for(d=k.length;d--;){b=k[d].replace(g,"");if(i=k[d].replace(f,""))i=i.split(".");if(!i&&!c&&a[o])L(v[b],b,a);else{j=A.get(a,b),c=[!1].concat(c);for(e=0,h=j.length;e<h;e++)j[e].inNamespaces(i)&&j[e].handler.apply(a,c)}}return a},N=function(a,b,c){var d=0,e=A.get(b,c),f=e.length;for(;d<f;d++)e[d].original&&J(a,e[d].type,e[d].original);return a},O={add:J,one:K,remove:I,clone:N,fire:M,noConflict:function(){return b[a]=d,this}};if(c[i]){var P=function(){var a,b=A.entries();for(a in b)b[a].type&&b[a].type!=="unload"&&I(b[a].element,b[a].type);c[k]("onunload",P),c.CollectGarbage&&c.CollectGarbage()};c[i]("onunload",P)}return O});var html4={};html4.atype={NONE:0,URI:1,URI_FRAGMENT:11,SCRIPT:2,STYLE:3,ID:4,IDREF:5,IDREFS:6,GLOBAL_NAME:7,LOCAL_NAME:8,CLASSES:9,FRAME_TARGET:10},html4.ATTRIBS={"*::class":9,"*::dir":0,"*::id":4,"*::lang":0,"*::onclick":2,"*::ondblclick":2,"*::onkeydown":2,"*::onkeypress":2,"*::onkeyup":2,"*::onload":2,"*::onmousedown":2,"*::onmousemove":2,"*::onmouseout":2,"*::onmouseover":2,"*::onmouseup":2,"*::style":3,"*::title":0,"a::accesskey":0,"a::coords":0,"a::href":1,"a::hreflang":0,"a::name":7,"a::onblur":2,"a::onfocus":2,"a::rel":0,"a::rev":0,"a::shape":0,"a::tabindex":0,"a::target":10,"a::type":0,"area::accesskey":0,"area::alt":0,"area::coords":0,"area::href":1,"area::nohref":0,"area::onblur":2,"area::onfocus":2,"area::shape":0,"area::tabindex":0,"area::target":10,"bdo::dir":0,"blockquote::cite":1,"br::clear":0,"button::accesskey":0,"button::disabled":0,"button::name":8,"button::onblur":2,"button::onfocus":2,"button::tabindex":0,"button::type":0,"button::value":0,"canvas::height":0,"canvas::width":0,"caption::align":0,"col::align":0,"col::char":0,"col::charoff":0,"col::span":0,"col::valign":0,"col::width":0,"colgroup::align":0,"colgroup::char":0,"colgroup::charoff":0,"colgroup::span":0,"colgroup::valign":0,"colgroup::width":0,"del::cite":1,"del::datetime":0,"dir::compact":0,"div::align":0,"dl::compact":0,"font::color":0,"font::face":0,"font::size":0,"form::accept":0,"form::action":1,"form::autocomplete":0,"form::enctype":0,"form::method":0,"form::name":7,"form::onreset":2,"form::onsubmit":2,"form::target":10,"h1::align":0,"h2::align":0,"h3::align":0,"h4::align":0,"h5::align":0,"h6::align":0,"hr::align":0,"hr::noshade":0,"hr::size":0,"hr::width":0,"iframe::align":0,"iframe::frameborder":0,"iframe::height":0,"iframe::marginheight":0,"iframe::marginwidth":0,"iframe::width":0,"img::align":0,"img::alt":0,"img::border":0,"img::height":0,"img::hspace":0,"img::ismap":0,"img::name":7,"img::src":1,"img::usemap":11,"img::vspace":0,"img::width":0,"input::accept":0,"input::accesskey":0,"input::align":0,"input::alt":0,"input::autocomplete":0,"input::checked":0,"input::disabled":0,"input::ismap":0,"input::maxlength":0,"input::name":8,"input::onblur":2,"input::onchange":2,"input::onfocus":2,"input::onselect":2,"input::readonly":0,"input::size":0,"input::src":1,"input::tabindex":0,"input::type":0,"input::usemap":11,"input::value":0,"ins::cite":1,"ins::datetime":0,"label::accesskey":0,"label::for":5,"label::onblur":2,"label::onfocus":2,"legend::accesskey":0,"legend::align":0,"li::type":0,"li::value":0,"map::name":7,"menu::compact":0,"ol::compact":0,"ol::start":0,"ol::type":0,"optgroup::disabled":0,"optgroup::label":0,"option::disabled":0,"option::label":0,"option::selected":0,"option::value":0,"p::align":0,"pre::width":0,"q::cite":1,"select::disabled":0,"select::multiple":0,"select::name":8,"select::onblur":2,"select::onchange":2,"select::onfocus":2,"select::size":0,"select::tabindex":0,"table::align":0,"table::bgcolor":0,"table::border":0,"table::cellpadding":0,"table::cellspacing":0,"table::frame":0,"table::rules":0,"table::summary":0,"table::width":0,"tbody::align":0,"tbody::char":0,"tbody::charoff":0,"tbody::valign":0,"td::abbr":0,"td::align":0,"td::axis":0,"td::bgcolor":0,"td::char":0,"td::charoff":0,"td::colspan":0,"td::headers":6,"td::height":0,"td::nowrap":0,"td::rowspan":0,"td::scope":0,"td::valign":0,"td::width":0,"textarea::accesskey":0,"textarea::cols":0,"textarea::disabled":0,"textarea::name":8,"textarea::onblur":2,"textarea::onchange":2,"textarea::onfocus":2,"textarea::onselect":2,"textarea::readonly":0,"textarea::rows":0,"textarea::tabindex":0,"tfoot::align":0,"tfoot::char":0,"tfoot::charoff":0,"tfoot::valign":0,"th::abbr":0,"th::align":0,"th::axis":0,"th::bgcolor":0,"th::char":0,"th::charoff":0,"th::colspan":0,"th::headers":6,"th::height":0,"th::nowrap":0,"th::rowspan":0,"th::scope":0,"th::valign":0,"th::width":0,"thead::align":0,"thead::char":0,"thead::charoff":0,"thead::valign":0,"tr::align":0,"tr::bgcolor":0,"tr::char":0,"tr::charoff":0,"tr::valign":0,"ul::compact":0,"ul::type":0},html4.eflags={OPTIONAL_ENDTAG:1,EMPTY:2,CDATA:4,RCDATA:8,UNSAFE:16,FOLDABLE:32,SCRIPT:64,STYLE:128},html4.ELEMENTS={a:0,abbr:0,acronym:0,address:0,applet:16,area:2,b:0,base:18,basefont:18,bdo:0,big:0,blockquote:0,body:49,br:2,button:0,canvas:0,caption:0,center:0,cite:0,code:0,col:2,colgroup:1,dd:1,del:0,dfn:0,dir:0,div:0,dl:0,dt:1,em:0,fieldset:0,font:0,form:0,frame:18,frameset:16,h1:0,h2:0,h3:0,h4:0,h5:0,h6:0,head:49,hr:2,html:49,i:0,iframe:4,img:2,input:2,ins:0,isindex:18,kbd:0,label:0,legend:0,li:1,link:18,map:0,menu:0,meta:18,nobr:0,noembed:4,noframes:20,noscript:20,object:16,ol:0,optgroup:0,option:1,p:1,param:18,pre:0,q:0,s:0,samp:0,script:84,select:0,small:0,span:0,strike:0,strong:0,style:148,sub:0,sup:0,table:0,tbody:1,td:1,textarea:8,tfoot:1,th:1,thead:1,title:24,tr:1,tt:0,u:0,ul:0,"var":0},html4.ueffects={NOT_LOADED:0,SAME_DOCUMENT:1,NEW_DOCUMENT:2},html4.URIEFFECTS={"a::href":2,"area::href":2,"blockquote::cite":0,"body::background":1,"del::cite":0,"form::action":2,"img::src":1,"input::src":1,"ins::cite":0,"q::cite":0},html4.ltypes={UNSANDBOXED:2,SANDBOXED:1,DATA:0},html4.LOADERTYPES={"a::href":2,"area::href":2,"blockquote::cite":2,"body::background":1,"del::cite":2,"form::action":2,"img::src":1,"input::src":1,"ins::cite":2,"q::cite":2};var html=function(a){function g(a){a=b(a);if(c.hasOwnProperty(a))return c[a];var d=a.match(e);return d?String.fromCharCode(parseInt(d[1],10)):(d=a.match(f))?String.fromCharCode(parseInt(d[1],16)):""}function h(a,b){return g(b)}function j(a){return a.replace(i,"")}function l(a){return a.replace(k,h)}function s(a){return a.replace(m,"&amp;").replace(o,"&lt;").replace(p,"&gt;").replace(q,"&#34;").replace(r,"&#61;")}function t(a){return a.replace(n,"&amp;$1").replace(o,"&lt;").replace(p,"&gt;")}function w(c){return function d(d,e){d=String(d);var f=null,g=!1,h=[],i=void 0,k=void 0,m=void 0;c.startDoc&&c.startDoc(e);while(d){var n=d.match(g?u:v);d=d.substring(n[0].length);if(g){if(n[1]){var o=b(n[1]),p;if(n[2]){var q=n[3];switch(q.charCodeAt(0)){case 34:case 39:q=q.substring(1,q.length-1)}p=l(j(q))}else p=o;h.push(o,p)}else if(n[4]){k!==void 0&&(m?c.startTag&&c.startTag(i,h,e):c.endTag&&c.endTag(i,e));if(m&&k&(a.eflags.CDATA|a.eflags.RCDATA)){f===null?f=b(d):f=f.substring(f.length-d.length);var r=f.indexOf("</"+i);r<0&&(r=d.length),r&&(k&a.eflags.CDATA?c.cdata&&c.cdata(d.substring(0,r),e):c.rcdata&&c.rcdata(t(d.substring(0,r)),e),d=d.substring(r))}i=k=m=void 0,h.length=0,g=!1}}else if(n[1])c.pcdata&&c.pcdata(n[0],e);else if(n[3])m=!n[2],g=!0,i=b(n[3]),k=a.ELEMENTS.hasOwnProperty(i)?a.ELEMENTS[i]:void 0;else if(n[4])c.pcdata&&c.pcdata(n[4],e);else if(n[5]&&c.pcdata){var s=n[5];c.pcdata(s==="<"?"&lt;":s===">"?"&gt;":"&amp;",e)}}c.endDoc&&c.endDoc(e)}}function x(b){var c,d;return w({startDoc:function(a){c=[],d=!1},startTag:function(e,f,g){if(d)return;if(!a.ELEMENTS.hasOwnProperty(e))return;var h=a.ELEMENTS[e];if(h&a.eflags.FOLDABLE)return;if(h&a.eflags.UNSAFE){d=!(h&a.eflags.EMPTY);return}f=b(e,f);if(f){h&a.eflags.EMPTY||c.push(e),g.push("<",e);for(var i=0,j=f.length;i<j;i+=2){var k=f[i],l=f[i+1];l!==null&&l!==void 0&&g.push(" ",k,'="',s(l),'"')}g.push(">")}},endTag:function(b,e){if(d){d=!1;return}if(!a.ELEMENTS.hasOwnProperty(b))return;var f=a.ELEMENTS[b];if(!(f&(a.eflags.UNSAFE|a.eflags.EMPTY|a.eflags.FOLDABLE))){var g;if(f&a.eflags.OPTIONAL_ENDTAG)for(g=c.length;--g>=0;){var h=c[g];if(h===b)break;if(!(a.ELEMENTS[h]&a.eflags.OPTIONAL_ENDTAG))return}else for(g=c.length;--g>=0;)if(c[g]===b)break;if(g<0)return;for(var i=c.length;--i>g;){var h=c[i];a.ELEMENTS[h]&a.eflags.OPTIONAL_ENDTAG||e.push("</",h,">")}c.length=g,e.push("</",b,">")}},pcdata:function(a,b){d||b.push(a)},rcdata:function(a,b){d||b.push(a)},cdata:function(a,b){d||b.push(a)},endDoc:function(a){for(var b=c.length;--b>=0;)a.push("</",c[b],">");c.length=0}})}function z(b,c,e){var f=[];return x(function g(b,f){for(var g=0;g<f.length;g+=2){var h=f[g],i=f[g+1],j=null,k;if((k=b+"::"+h,a.ATTRIBS.hasOwnProperty(k))||(k="*::"+h,a.ATTRIBS.hasOwnProperty(k)))j=a.ATTRIBS[k];if(j!==null)switch(j){case a.atype.NONE:break;case a.atype.SCRIPT:case a.atype.STYLE:i=null;break;case a.atype.ID:case a.atype.IDREF:case a.atype.IDREFS:case a.atype.GLOBAL_NAME:case a.atype.LOCAL_NAME:case a.atype.CLASSES:i=e?e(i):i;break;case a.atype.URI:var l=(""+i).match(y);l?!l[1]||d.test(l[1])?i=c&&c(i):i=null:i=null;break;case a.atype.URI_FRAGMENT:i&&"#"===i.charAt(0)?(i=e?e(i):i,i&&(i="#"+i)):i=null;break;default:i=null}else i=null;f[g+1]=i}return f})(b,f),f.join("")}var b;"script"==="SCRIPT".toLowerCase()?b=function(a){return a.toLowerCase()}:b=function(a){return a.replace(/[A-Z]/g,function(a){return String.fromCharCode(a.charCodeAt(0)|32)})};var c={lt:"<",gt:">",amp:"&",nbsp:" ",quot:'"',apos:"'"},d=/^(?:https?|mailto|data)$/i,e=/^#(\d+)$/,f=/^#x([0-9A-Fa-f]+)$/,i=/\0/g,k=/&(#\d+|#x[0-9A-Fa-f]+|\w+);/g,m=/&/g,n=/&([^a-z#]|#(?:[^0-9x]|x(?:[^0-9a-f]|$)|$)|$)/gi,o=/</g,p=/>/g,q=/\"/g,r=/\=/g,u=new RegExp("^\\s*(?:(?:([a-z][a-z-]*)(\\s*=\\s*(\"[^\"]*\"|'[^']*'|(?=[a-z][a-z-]*\\s*=)|[^>\"'\\s]*))?)|(/?>)|[\\s\\S][^a-z\\s>]*)","i"),v=new RegExp("^(?:&(\\#[0-9]+|\\#[x][0-9a-f]+|\\w+);|<!--[\\s\\S]*?-->|<!\\w[^>]*>|<\\?[^>*]*>|<(/)?([a-z][a-z0-9]*)|([^<&>]+)|([<&>]))","i"),y=new RegExp("^(?:([^:/?#]+):)?");return{escapeAttrib:s,makeHtmlSanitizer:x,makeSaxParser:w,normalizeRCData:t,sanitize:z,unescapeEntities:l}}(html4),html_sanitize=html.sanitize;typeof window!="undefined"&&(window.html=html,window.html_sanitize=html_sanitize),html4.ATTRIBS["*::style"]=0,html4.ATTRIBS["a::target"]=0,html4.ELEMENTS.style=0;var Mustache=function(){var a={},b=function(){};return b.prototype={otag:"{{",ctag:"}}",pragmas:{},buffer:[],pragmas_implemented:{"IMPLICIT-ITERATOR":!0},context:{},render:function(a,b,c,d){d||(this.context=b,this.buffer=[]);if(!this.includes("",a)){if(d)return a;this.send(a);return}a=this.render_pragmas(a);var e=this.render_section(a,b,c);e===!1&&(e=this.render_tags(a,b,c,d));if(d)return e;this.sendLines(e)},send:function(a){a!==""&&this.buffer.push(a)},sendLines:function(a){if(a){var b=a.split("\n");for(var c=0;c<b.length;c++)this.send(b[c])}},render_pragmas:function(a){if(!this.includes("%",a))return a;var b=this,c=this.getCachedRegex("render_pragmas",function(a,b){return new RegExp(a+"%([\\w-]+) ?([\\w]+=[\\w]+)?"+b,"g")});return a.replace(c,function(a,c,d){if(!b.pragmas_implemented[c])throw{message:"This implementation of mustache doesn't understand the '"+c+"' pragma"};b.pragmas[c]={};if(d){var e=d.split("=");b.pragmas[c][e[0]]=e[1]}return""})},render_partial:function(a,b,c){a=this.trim(a);if(!c||c[a]===undefined)throw{message:"unknown_partial '"+a+"'"};return typeof b[a]!="object"?this.render(c[a],b,c,!0):this.render(c[a],b[a],c,!0)},render_section:function(a,b,c){if(!this.includes("#",a)&&!this.includes("^",a))return!1;var d=this,e=this.getCachedRegex("render_section",function(a,b){return new RegExp("^([\\s\\S]*?)"+a+"(\\^|\\#)\\s*(.+)\\s*"+b+"\n*([\\s\\S]*?)"+a+"\\/\\s*\\3\\s*"+b+"\\s*([\\s\\S]*)$","g")});return a.replace(e,function(a,e,f,g,h,i){var j=e?d.render_tags(e,b,c,!0):"",k=i?d.render(i,b,c,!0):"",l,m=d.find(g,b);return f==="^"?!m||d.is_array(m)&&m.length===0?l=d.render(h,b,c,!0):l="":f==="#"&&(d.is_array(m)?l=d.map(m,function(a){return d.render(h,d.create_context(a),c,!0)}).join(""):d.is_object(m)?l=d.render(h,d.create_context(m),c,!0):typeof m=="function"?l=m.call(b,h,function(a){return d.render(a,b,c,!0)}):m?l=d.render(h,b,c,!0):l=""),j+l+k})},render_tags:function(a,b,c,d){var e=this,f=function(){return e.getCachedRegex("render_tags",function(a,b){return new RegExp(a+"(=|!|>|\\{|%)?([^\\/#\\^]+?)\\1?"+b+"+","g")})},g=f(),h=function(a,d,h){switch(d){case"!":return"";case"=":return e.set_delimiters(h),g=f(),"";case">":return e.render_partial(h,b,c);case"{":return e.find(h,b);default:return e.escape(e.find(h,b))}},i=a.split("\n");for(var j=0;j<i.length;j++)i[j]=i[j].replace(g,h,this),d||this.send(i[j]);if(d)return i.join("\n")},set_delimiters:function(a){var b=a.split(" ");this.otag=this.escape_regex(b[0]),this.ctag=this.escape_regex(b[1])},escape_regex:function(a){if(!arguments.callee.sRE){var b=["/",".","*","+","?","|","(",")","[","]","{","}","\\"];arguments.callee.sRE=new RegExp("(\\"+b.join("|\\")+")","g")}return a.replace(arguments.callee.sRE,"\\$1")},find:function(a,b){function c(a){return a===!1||a===0||a}a=this.trim(a);var d;return c(b[a])?d=b[a]:c(this.context[a])&&(d=this.context[a]),typeof d=="function"?d.apply(b):d!==undefined?d:""},includes:function(a,b){return b.indexOf(this.otag+a)!=-1},escape:function(a){return a=String(a===null?"":a),a.replace(/&(?!\w+;)|["'<>\\]/g,function(a){switch(a){case"&":return"&amp;";case'"':return"&quot;";case"'":return"&#39;";case"<":return"&lt;";case">":return"&gt;";default:return a}})},create_context:function(a){if(this.is_object(a))return a;var b=".";this.pragmas["IMPLICIT-ITERATOR"]&&(b=this.pragmas["IMPLICIT-ITERATOR"].iterator);var c={};return c[b]=a,c},is_object:function(a){return a&&typeof a=="object"},is_array:function(a){return Object.prototype.toString.call(a)==="[object Array]"},trim:function(a){return a.replace(/^\s*|\s*$/g,"")},map:function(a,b){if(typeof a.map=="function")return a.map(b);var c=[],d=a.length;for(var e=0;e<d;e++)c.push(b(a[e]));return c},getCachedRegex:function(b,c){var d=a[this.otag];d||(d=a[this.otag]={});var e=d[this.ctag];e||(e=d[this.ctag]={});var f=e[b];return f||(f=e[b]=c(this.otag,this.ctag)),f}},{name:"mustache.js",version:"0.4.0-dev",to_html:function(a,c,d,e){var f=new b;e&&(f.send=e),f.render(a,c||{},d);if(!e)return f.buffer.join("\n")}}}();!function(context,win){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):"")+"&"}break;case"textarea":return b+"="+enc(a.value)+"&";case"select":return b+"="+enc(a.options[a.selectedIndex].value)+"&"}return""}function enc(a){return encodeURIComponent(a)}function reqwest(a,b){return new Reqwest(a,b)}function init(o,fn){function error(a){o.error&&o.error(a),complete(a)}function success(resp){o.timeout&&clearTimeout(self.timeout)&&(self.timeout=null);var r=resp.responseText;if(r)switch(type){case"json":resp=win.JSON?win.JSON.parse(r):eval("("+r+")");break;case"js":resp=eval(r);break;case"html":resp=r}fn(resp),o.success&&o.success(resp),complete(resp)}function complete(a){o.complete&&o.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 setType(a){return/\.json$/.test(a)?"json":/\.jsonp$/.test(a)?"jsonp":/\.js$/.test(a)?"js":/\.html?$/.test(a)?"html":/\.xml$/.test(a)?"xml":"js"}function Reqwest(a,b){this.o=a,this.fn=b,init.apply(this,arguments)}function getRequest(a,b,c){if(a.type!="jsonp"){var d=xhr();return d.open(a.method||"GET",typeof a=="string"?a:a.url,!0),setHeaders(d,a),d.onreadystatechange=handleReadyState(d,b,c),a.before&&a.before(d),d.send(a.data||null),d}var e=doc.createElement("script"),f=0;win[getCallbackName(a)]=generalCallback,e.type="text/javascript",e.src=a.url,e.async=!0,e.onload=e.onreadystatechange=function(){if(e[readyState]&&e[readyState]!=="complete"&&e[readyState]!=="loaded"||f)return!1;e.onload=e.onreadystatechange=null,a.success&&a.success(lastValue),lastValue=undefined,head.removeChild(e),f=1},head.appendChild(e)}function generalCallback(a){lastValue=a}function getCallbackName(a){var b=a.jsonpCallback||"callback";if(a.url.slice(-(b.length+2))==b+"=?"){var c="reqwest_"+uniqid++;return a.url=a.url.substr(0,a.url.length-1)+c,c}var d=new RegExp(b+"=([\\w]+)");return a.url.match(d)[1]}function setHeaders(a,b){var c=b.headers||{};c.Accept=c.Accept||"text/javascript, text/html, application/xml, text/xml, */*",b.crossOrigin||(c["X-Requested-With"]=c["X-Requested-With"]||"XMLHttpRequest"),c[contentType]=c[contentType]||"application/x-www-form-urlencoded";for(var d in c)c.hasOwnProperty(d)&&a.setRequestHeader(d,c[d],!1)}function handleReadyState(a,b,c){return function(){a&&a[readyState]==4&&(twoHundo.test(a.status)?b(a):c(a))}}var twoHundo=/^20\d$/,doc=document,byTag="getElementsByTagName",readyState="readyState",contentType="Content-Type",head=doc[byTag]("head")[0],uniqid=0,lastValue,xhr="XMLHttpRequest"in win?function(){return new XMLHttpRequest}:function(){return new ActiveXObject("Microsoft.XMLHTTP")};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"),a[byTag]("select"),a[byTag]("textarea")],c=[],d,e;for(d=0,l=b.length;d<l;++d)for(e=0,l2=b[d].length;e<l2;++e)c.push(serial(b[d][e]));return c.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=context.reqwest;reqwest.noConflict=function(){return context.reqwest=old,this},typeof module!="undefined"?module.exports=reqwest:context.reqwest=reqwest}(this,window),wax=wax||{},wax.attribution=function(){function c(a){if(/^(https?:\/\/|data:image)/.test(a))return a}function d(a){return a}var a,b={};return b.content=function(b){return typeof b=="undefined"?a.innerHTML:(a.innerHTML=html_sanitize(b,c,d),this)},b.element=function(){return a},b.init=function(){return a=document.createElement("div"),a.className="wax-attribution",this},b.init()},wax=wax||{},wax.bwdetect=function(a,b){function h(){wax.bw=-1;var a=new Image;a.src=e;var b=!0,f=setTimeout(function(){b&&wax.bw==-1&&(c.bw(0),b=!1)},d);a.onload=function(){b&&wax.bw==-1&&(clearTimeout(f),c.bw(1),b=!1)}}var c={},d=a.threshold||400,e="http://a.tiles.mapbox.com/mapbox/1.0.0/blue-marble-topo-bathy-jul/0/0/0.png?preventcache="+ +(new Date),f=1,g=a.auto===undefined?!0:a.auto;return c.bw=function(a){if(!arguments.length)return f;var c=f;wax.bwlisteners&&wax.bwlisteners.length&&function(){listeners=wax.bwlisteners,wax.bwlisteners=[];for(i=0;i<listeners;i++)listeners[i](a)}(),wax.bw=a,f!=(f=a)&&b(a)},c.add=function(){return g&&h(),this},wax.bw==-1?(wax.bwlisteners=wax.bwlisteners||[],wax.bwlisteners.push(c.bw)):wax.bw!==undefined?c.bw(wax.bw):c.add(),c},wax.formatter=function(x){function urlX(a){if(/^(https?:\/\/|data:image)/.test(a))return a}function idX(a){return a}var formatter={},f;if(x&&typeof x=="string")try{eval("f = "+x)}catch(e){console&&console.log(e)}else x&&typeof x=="function"?f=x:f=function(){};return formatter.format=function(a,b){try{return html_sanitize(f(a,b),urlX,idX)}catch(c){console&&console.log(c)}},formatter},wax.gi=function(a,b){function f(a){return a>=93&&a--,a>=35&&a--,a-=32,a}b=b||{};var c={},d=b.resolution||4,e=b.tileSize||256;return c.grid_tile=function(){return a},c.getKey=function(b,c){if(!a||!a.grid)return;if(c<0||b<0)return;if(Math.floor(c)>=e||Math.floor(b)>=e)return;return f(a.grid[Math.floor(c/d)].charCodeAt(Math.floor(b/d)))},c.gridFeature=function(b,c){var d=this.getKey(b,c),e=a.keys;if(e&&e[d]&&a.data[e[d]])return a.data[e[d]]},c.tileFeature=function(b,c,d){if(!a)return;var e=wax.u.offset(d);return feature=this.gridFeature(b-e.left,c-e.top),feature},c},wax.gm=function(){function g(a){return typeof a=="string"&&(a=[a]),function b(b){if(!b)return;var c=new RegExp("/(\\d+)\\/(\\d+)\\/(\\d+)\\.[\\w\\._]+"),d=c.exec(b);if(!d)return;return a[parseInt(d[2],10)%a.length].replace(/\{z\}/g,d[1]).replace(/\{x\}/g,d[2]).replace(/\{y\}/g,d[3])}}var a=4,b={},c={},d,e,f=function(a){return a.replace(/(\.png|\.jpg|\.jpeg)(\d*)/,".grid.json")};return c.formatter=function(a){return arguments.length?(e=wax.formatter(a),c):e},c.template=function(a){return arguments.length?(e=wax.template(a),c):e},c.gridUrl=function(a){return arguments.length?(f=typeof a=="function"?a:g(a),c):f},c.getGrid=function(b,d){var g=f(b);return!e||!g?d(null,null):(wax.request.get(g,function(b,c){if(b)return d(b,null);d(null,wax.gi(c,{formatter:e,resolution:a}))}),c)},c.tilejson=function(b){return arguments.length?(b.template?c.template(b.template):b.formatter&&c.formatter(b.formatter),b.grids&&c.gridUrl(b.grids),b.resolution&&(a=b.resolution),d=b,c):d},c},wax=wax||{},wax.hash=function(a){function b(){return location.hash.substring(1)}function c(a){var b=window.location;b.replace(b.toString().replace(b.hash,"#"+a))}function g(b){var c=b.split("/");for(var d=0;d<c.length;d++){c[d]=Number(c[d]);if(isNaN(c[d]))return!0}if(c.length<3)return!0;c.length==3&&a.setCenterZoom(c)}function h(){var b=a.getCenterZoom();d!==b&&(d=b,c(d))}function i(a){if(a===d)return;g(d=a)&&h()}a=a||{};var d,e={},f=90-1e-8,j=wax.u.throttle(h,500);return e.add=function(){return i(b()),a.bindChange(j),this},e.remove=function(){return a.unbindChange(j),this},e.add()},wax=wax||{},wax.interaction=function(){function o(a){var b=g();for(var c=0;c<b.length;c++)if(b[c][0]<a.y&&b[c][0]+256>a.y&&b[c][1]<a.x&&b[c][1]+256>a.x)return b[c][2];return!1}function p(){return d?(window.clearTimeout(d),d=null,!0):!1}function q(d){if(c)return;var e=wax.u.eventoffset(d);b.screen_feature(e,function(c){c?bean.fire(b,"on",{parent:j(),data:c,formatter:a.formatter().format,e:d}):bean.fire(b,"off")})}function r(a){if(p())return;c=!0,e=wax.u.eventoffset(a),a.type==="mousedown"?bean.add(document.body,"mouseup",t):a.type==="touchstart"&&a.touches.length===1&&(bean.fire(b,"off"),bean.add(j(),n))}function s(){bean.remove(j(),n),c=!1}function t(a){var g={},h=wax.u.eventoffset(a);c=!1;for(var i in a)g[i]=a[i];return bean.remove(document.body,"mouseup",t),bean.remove(j(),n),a.type==="touchend"?b.click(a,e):Math.round(h.y/f)===Math.round(e.y/f)&&Math.round(h.x/f)===Math.round(e.x/f)&&(d=window.setTimeout(function(){d=null,b.click(g,h)},300)),t}var a=wax.gm(),b={},c=!1,d=!1,e,f=4,g,h,i,j,k,l,m={mousemove:q,touchstart:r,mousedown:r},n={touchend:t,touchmove:t,touchcancel:s};return b.click=function(c,d){b.screen_feature(d,function(d){d&&bean.fire(b,"on",{parent:j(),data:d,formatter:a.formatter().format,e:c})})},b.screen_feature=function(b,c){var d=o(b);d||c(null),a.getGrid(d.src,function(a,e){if(a||!e)return c(null);var f=e.tileFeature(b.x,b.y,d);c(f)})},b.attach=function(a){return arguments.length?(h=a,b):h},b.detach=function(a){return arguments.length?(i=a,b):i},b.map=function(a){return arguments.length?(k=a,h&&h(k),bean.add(j(),m),bean.add(j(),"touchstart",r),b):k},b.grid=function(a){return arguments.length?(g=a,b):g},b.remove=function(a){return i&&i(k),bean.remove(j(),m),bean.fire(b,"remove"),b},b.tilejson=function(c){return arguments.length?(a.tilejson(c),b):a.tilejson()},b.formatter=function(){return a.formatter()},b.on=function(a,c){return bean.add(b,a,c),b},b.off=function(a,c){return bean.remove(b,a,c),b},b.gridmanager=function(c){return arguments.length?(a=c,b):a},b.parent=function(a){return j=a,b},b};var wax=wax||{};wax.legend=function(){function d(a){if(/^(https?:\/\/|data:image)/.test(a))return a}function e(a){return a}var a,b={},c;return b.element=function(){return c},b.content=function(c){return arguments.length?(c?(a.innerHTML=html_sanitize(c,d,e),a.style.display="block"):(a.innerHTML="",a.style.display="none"),b):a.innerHTML},b.add=function(){return c=document.createElement("div"),c.className="wax-legends",a=c.appendChild(document.createElement("div")),a.className="wax-legend",a.style.display="none",b},b.add()};var wax=wax||{};wax.movetip={},wax.movetip=function(){function g(a){var b=wax.u.eventoffset(a);c.height+b.y>d.top+d.height&&d.height>c.height&&(b.y-=c.height,e.className+=" flip-y"),c.width+b.x>d.left+d.width&&(b.x-=c.width,e.className+=" flip-x"),e.style.left=b.x+"px",e.style.top=b.y+"px"}function h(a){var b=document.createElement("div");return b.className="wax-tooltip wax-tooltip-0",b.innerHTML=a,b}function i(){e&&(e.parentNode.removeChild(e),e=null)}function j(b){var j;if(a)return;if(b.e.type==="mousemove"||!b.e.type){j=b.formatter({format:"teaser"},b.data);if(!j)return;i(),f.style.cursor="pointer",e=document.body.appendChild(h(j))}else{j=b.formatter({format:"teaser"},b.data);if(!j)return;i();var k=document.body.appendChild(h(j));k.className+=" wax-popup";var l=k.appendChild(document.createElement("a"));l.href="#close",l.className="close",l.innerHTML="Close",a=!0,e=k,c=wax.u.offset(e),d=wax.u.offset(f),g(b.e),bean.add(l,"click touchend",function(b){b.stop(),i(),a=!1})}e&&(c=wax.u.offset(e),d=wax.u.offset(f),g(b.e))}function k(){f.style.cursor="default",a||i()}var a=!1,b={},c,d,e,f;return b.parent=function(a){return arguments.length?(f=a,b):f},b.events=function(){return{on:j,off:k}},b};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
  2 +[a]=this.promises[a]||[],this.promises[a].push(b);if(this.locks[a])return;var c=this;this.locks[a]=!0,reqwest({url:a+(~a.indexOf("?")?"&":"?")+"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.template=function(a){function c(a){if(/^(https?:\/\/|data:image)/.test(a))return a}function d(a){return a}var b={};return b.format=function(b,e){var f={};for(var g in e)f[g]=e[g];return b.format&&(f["__"+b.format+"__"]=!0),html_sanitize(Mustache.to_html(a,f),c,d)},b};if(!wax)var wax={};wax.tilejson=function(a,b){reqwest({url:a+(~a.indexOf("?")?"&":"?")+"callback=grid",type:"jsonp",jsonpCallback:"callback",success:b,error:b})};var wax=wax||{};wax.tooltip={},wax.tooltip=function(){function h(a){var b=document.createElement("div");return b.className="wax-tooltip wax-tooltip-0",b.innerHTML=a,b}function i(){this.parentNode&&this.parentNode.removeChild(this)}function j(){var a;while(a=d.pop())b&&f?(bean.add(a,f,i),a.className+=" wax-fade"):a.parentNode&&a.parentNode.removeChild(a)}function k(b){var c;if(b.e.type==="mousemove"||!b.e.type){if(!a){c=b.content||b.formatter({format:"teaser"},b.data);if(!c||c==e)return;j(),g.style.cursor="pointer",d.push(g.appendChild(h(c))),e=c}}else{c=b.content||b.formatter({format:"full"},b.data);if(!c){b.e.type&&b.e.type.match(/touch/)&&(c=b.content||b.formatter({format:"teaser"},b.data));if(!c)return}j(),g.style.cursor="pointer";var f=g.appendChild(h(c));f.className+=" wax-popup";var i=f.appendChild(document.createElement("a"));i.href="#close",i.className="close",i.innerHTML="Close",a=!0,d.push(f),bean.add(i,"click touchend",function(b){b.stop(),j(),a=!1})}}function l(){g.style.cursor="default",e=null,a||j()}var a=!1,b=!1,c={},d=[],e,f,g;return document.body.style["-webkit-transition"]!==undefined?f="webkitTransitionEnd":document.body.style.MozTransition!==undefined&&(f="transitionend"),c.parent=function(a){return arguments.length?(g=a,c):g},c.animate=function(a){return arguments.length?(b=a,c):b},c.events=function(){return{on:k,off:l}},c};var wax=wax||{};wax.u={offset:function(a){var b=a.offsetWidth||parseInt(a.style.width,10),c=a.offsetHeight||parseInt(a.style.height,10),d=document.body,e=0,f=0,g=function(a){if(a===d||a===document.documentElement)return;e+=a.offsetTop,f+=a.offsetLeft;var b=a.style.transform||a.style.WebkitTransform||a.style.OTransform||a.style.MozTransform||a.style.msTransform;if(b)if(match=b.match(/translate\((.+)px, (.+)px\)/))e+=parseInt(match[2],10),f+=parseInt(match[1],10);else if(match=b.match(/translate3d\((.+)px, (.+)px, (.+)px\)/))e+=parseInt(match[2],10),f+=parseInt(match[1],10);else if(match=b.match(/matrix3d\(([\-\d,\s]+)\)/)){var c=match[1].split(",");e+=parseInt(c[13],10),f+=parseInt(c[12],10)}else if(match=b.match(/matrix\(.+, .+, .+, .+, (.+), (.+)\)/))e+=parseInt(match[2],10),f+=parseInt(match[1],10)};g(a);try{while(a=a.offsetParent)g(a)}catch(h){}e+=d.offsetTop,f+=d.offsetLeft,e+=d.parentNode.offsetTop,f+=d.parentNode.offsetLeft;var i=document.defaultView?window.getComputedStyle(d.parentNode,null):d.parentNode.currentStyle;return d.parentNode.offsetTop!==parseInt(i.marginTop,10)&&!isNaN(parseInt(i.marginTop,10))&&(e+=parseInt(i.marginTop,10),f+=parseInt(i.marginLeft,10)),{top:e,left:f,height:c,width:b}},$:function(a){return typeof a=="string"?document.getElementById(a):a},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},eventoffset:function(a){var b=0,c=0;a||(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}}if(a.touches&&a.touches.length===1)return{x:a.touches[0].pageX,y:a.touches[0].pageY}},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 this.limit(a,b,!1)}},wax=wax||{},wax.mm=wax.mm||{},wax.mm.attribution=function(a,b){b=b||{};var c,d={};return d.element=function(){return c.element()},d.appendTo=function(a){return wax.u.$(a).appendChild(c.element()),this},d.init=function(){return c=wax.attribution(),c.content(b.attribution),c.element().className="wax-attribution wax-mm",this},d.init()},wax=wax||{},wax.mm=wax.mm||{},wax.mm.boxselector=function(a,b,c){function q(b){var c=new MM.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}function r(b){if(!b.shiftKey)return;return d=e=q(b),j=k=!0,h.left=d.x+"px",h.top=d.y+"px",h.width=h.height=0,m(document,"mousemove",t),m(document,"mouseup",u),a.parent.style.cursor="crosshair",MM.cancelEvent(b)}function s(a){var b=q(a),c={x:parseInt(g.offsetLeft,10),y:parseInt(g.offsetTop,10)},f={x:c.x+parseInt(g.offsetWidth,10),y:c.y+parseInt(g.offsetHeight,10)};j=b.x-c.x<=l||f.x-b.x<=l,k=b.y-c.y<=l||f.y-b.y<=l;if(k||j)return d={x:b.x-c.x<f.x-b.x?f.x:c.x,y:b.y-c.y<f.y-b.y?f.y:c.y},e={x:b.x-c.x<f.x-b.x?c.x:f.x,y:b.y-c.y<f.y-b.y?c.y:f.y},m(document,"mousemove",t),m(document,"mouseup",u),MM.cancelEvent(a)}function t(b){var c=q(b);return h.display="block",j&&(h.left=(c.x<d.x?c.x:d.x)+"px",h.width=Math.abs(c.x-d.x)-2*i+"px"),k&&(h.top=(c.y<d.y?c.y:d.y)+"px",h.height=Math.abs(c.y-d.y)-2*i+"px"),w(c,a.parent),MM.cancelEvent(b)}function u(b){var c=q(b),f=a.pointLocation(new MM.Point(j?c.x:e.x,k?c.y:e.y));l2=a.pointLocation(d),p.extent([new MM.Location(Math.max(f.lat,l2.lat),Math.min(f.lon,l2.lon)),new MM.Location(Math.min(f.lat,l2.lat),Math.max(f.lon,l2.lon))]),n(document,"mousemove",t),n(document,"mouseup",u),a.parent.style.cursor="auto"}function v(a){w(q(a),g)}function w(a,b){var c={x:parseInt(g.offsetLeft,10),y:parseInt(g.offsetTop,10)},d={x:c.x+parseInt(g.offsetWidth,10),y:c.y+parseInt(g.offsetHeight,10)},e="";a.y-c.y<=l?e="n":d.y-a.y<=l&&(e="s"),a.x-c.x<=l?e+="w":d.x-a.x<=l&&(e+="e"),e!==""&&(e+="-resize"),b.style.cursor=e}function x(a,b){if(!g||!o)return;var c=a.locationPoint(o[1]),d=a.locationPoint(o[0]),e=g.style;e.display="block",e.height="auto",e.width="auto",e.left=Math.max(0,d.x)+"px",e.top=Math.max(0,d.y)+"px",e.right=Math.max(0,a.dimensions.x-c.x)+"px",e.bottom=Math.max(0,a.dimensions.y-c.y)+"px"}var d=null,e=null,f=typeof c=="function"?c:c.callback,g,h,i=0,j=!1,k=!1,l=5,m=MM.addEvent,n=MM.removeEvent,o,p={};return p.extent=function(b,c){if(!b)return o;o=[new MM.Location(Math.max(b[0].lat,b[1].lat),Math.min(b[0].lon,b[1].lon)),new MM.Location(Math.min(b[0].lat,b[1].lat),Math.max(b[0].lon,b[1].lon))],x(a),c||f(o)},p.add=function(a){return g=g||document.createElement("div"),g.id=a.parent.id+"-boxselector-box",g.className="boxselector-box",a.parent.appendChild(g),h=g.style,i=parseInt(window.getComputedStyle(g).borderWidth,10),m(a.parent,"mousedown",r),m(g,"mousedown",s),m(a.parent,"mousemove",v),a.addCallback("drawn",x),this},p.remove=function(){a.parent.removeChild(g),n(a.parent,"mousedown",r),n(g,"mousedown",s),n(a.parent,"mousemove",v),a.removeCallback("drawn",x)},p.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax._={},wax.mm.bwdetect=function(a,b){b=b||{};var c=b.png||".png128",d=b.jpg||".jpg70",e=!1;return wax._.bw_png=c,wax._.bw_jpg=d,wax.bwdetect(b,function(b){wax._.bw=!b;for(var c=0;c<a.layers.length;c++)a.getLayerAt(c).provider instanceof wax.mm.connector&&a.getLayerAt(c).setProvider(a.getLayerAt(c).provider)})},wax=wax||{},wax.mm=wax.mm||{},wax.mm.fullscreen=function(a){function g(a){a&&a.stop(),b?c.original():c.full()}function h(b,c){a.dimensions=new MM.Point(b,c),a.parent.style.width=Math.round(a.dimensions.x)+"px",a.parent.style.height=Math.round(a.dimensions.y)+"px",a.dispatchCallback("resized",a.dimensions)}var b=!1,c={},d,e=document.body,f;return c.add=function(a){return d=document.createElement("a"),d.className="wax-fullscreen",d.href="#fullscreen",d.innerHTML="fullscreen",bean.add(d,"click",g),this},c.full=function(){if(b)return;b=!0,f=[a.parent.offsetWidth,a.parent.offsetHeight],a.parent.className+=" wax-fullscreen-map",e.className+=" wax-fullscreen-view",h(a.parent.offsetWidth,a.parent.offsetHeight)},c.original=function(){if(!b)return;b=!1,a.parent.className=a.parent.className.replace(" wax-fullscreen-map",""),e.className=e.className.replace(" wax-fullscreen-view",""),h(f[0],f[1])},c.appendTo=function(a){return wax.u.$(a).appendChild(d),this},c.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.hash=function(a){return wax.hash({getCenterZoom: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("/")},setCenterZoom:function b(b){a.setCenterZoom(new MM.Location(b[1],b[2]),b[0])},bindChange:function(b){a.addCallback("drawn",b)},unbindChange:function(b){a.removeCallback("drawn",b)}})},wax=wax||{},wax.mm=wax.mm||{},wax.mm.interaction=function(){function e(){var d=c.getLayerAt(0).levels[Math.round(c.getZoom())];return!a&&b!==undefined&&b.length?b:(b=function(a){var b=[];for(var c in a)if(a[c].parentNode===d){var e=wax.u.offset(a[c]);b.push([e.top,e.left,a[c]])}return b}(c.getLayerAt(0).tiles),b)}function f(){a=!0}function g(a){if(!arguments.length)return c;c=a;for(var b=0;b<d.length;b++)c.addCallback(d[b],f)}function h(a){for(var b=0;b<d.length;b++)c.removeCallback(d[b],f)}var a=!1,b,c,d=["zoomed","panned","centered","extentset","resized","drawn"];return wax.interaction().attach(g).detach(h).parent(function(){return c.parent}).grid(e)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.latlngtooltip=function(a){function e(b){var c=new MM.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}function f(a){console.log("here"),c=!0}function g(a){c=!1}function h(d){if(!d.shiftKey||c){b.parentNode===a.parent&&a.parent.removeChild(b);return}var f=e(d),g=a.pointLocation(f),h=g.lat.toFixed(2)+", "+g.lon.toFixed(2);b.innerHTML=h,f.scale=f.width=f.height=1,f.x+=10,MM.moveElement(b,f),a.parent.appendChild(b)}var b,c=!1,d={};return d.add=function(){return MM.addEvent(a.parent,"mousemove",h),MM.addEvent(a.parent,"mousedown",f),MM.addEvent(a.parent,"mouseup",g),b=document.createElement("div"),b.className="wax-latlngtooltip",this},d.remove=function(){return MM.removeEvent(a.parent,"mousemove",h),MM.removeEvent(a.parent,"mousedown",f),MM.removeEvent(a.parent,"mouseup",g),this},d.add()},wax=wax||{},wax.mm=wax.mm||{},wax.mm.legend=function(a,b){b=b||{};var c,d={};return d.add=function(){return c=wax.legend().content(b.legend||""),this},d.content=function(a){a&&c.content(a.legend||"")},d.element=function(){return c.element()},d.appendTo=function(a){return wax.u.$(a).appendChild(c.element()),this},d.add()},wax=wax||{},wax.mm=wax.mm||{},wax.mm.pointselector=function(a,b,c){function k(b){var c=wax.u.eventoffset(b),d=new MM.Point(c.x,c.y),e={x:parseFloat(MM.getStyle(document.documentElement,"margin-left")),y:parseFloat(MM.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}function l(a){var b=[];for(var c=0;c<a.length;c++)b.push(new MM.Location(a[c].lat,a[c].lon));return b}function m(){var b=new MM.Point(0,0);for(var c=0;c<i.length;c++){var d=a.locationPoint(i[c]);i[c].pointDiv||(i[c].pointDiv=document.createElement("div"),i[c].pointDiv.className="wax-point-div",i[c].pointDiv.style.position="absolute",i[c].pointDiv.style.display="block",i[c].pointDiv.location=i[c],bean.add(i[c].pointDiv,"mouseup",function(b){var d=i[c];return function(b){MM.removeEvent(a.parent,"mouseup",o),h.deleteLocation(d,b)}}()),a.parent.appendChild(i[c].pointDiv)),i[c].pointDiv.style.left=d.x+"px",i[c].pointDiv.style.top=d.y+"px"}}function n(b){d=k(b),bean.add(a.parent,"mouseup",o)}function o(b){if(!d)return;e=k(b),MM.Point.distance(d,e)<f&&(h.addLocation(a.pointLocation(d)),j(l(i))),d=null}var d=null,e=null,f=5,g,h={},i=[],j=typeof c=="function"?c:c.callback;return h.addLocation=function(a){i.push(a),m(),j(l(i))},h.locations=function(a){return i},h.add=function(a){return bean.add(a.parent,"mousedown",n),a.addCallback("drawn",m),this},h.remove=function(a){bean.remove(a.parent,"mousedown",n),a.removeCallback("drawn",m);for(var b=i.length-1;b>-1;b--)h.deleteLocation(i[b]);return this},h.deleteLocation=function(a,b){if(!b||confirm("Delete this point?"))a.pointDiv.parentNode.removeChild(a.pointDiv),i.splice(wax.u.indexOf(i,a),1),j(l(i))},h.add(a)},wax=wax||{},wax.mm=wax.mm||{},wax.mm.zoombox=function(a){function f(b){var c=new MM.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}function g(b){if(!c)return;c=!1;var h=f(b),j=a.pointLocation(h),k=a.pointLocation(e);a.setExtent([j,k]),d.style.display="none",MM.removeEvent(a.parent,"mousemove",i),MM.removeEvent(a.parent,"mouseup",g),a.parent.style.cursor="auto"}function h(b){if(!b.shiftKey||!!this.drawing)return;return c=!0,e=f(b),d.style.left=e.x+"px",d.style.top=e.y+"px",MM.addEvent(a.parent,"mousemove",i),MM.addEvent(a.parent,"mouseup",g),a.parent.style.cursor="crosshair",MM.cancelEvent(b)}function i(a){if(!c)return;var b=f(a);return d.style.display="block",b.x<e.x?d.style.left=b.x+"px":d.style.left=e.x+"px",d.style.width=Math.abs(b.x-e.x)+"px",b.y<e.y?d.style.top=b.y+"px":d.style.top=e.y+"px",d.style.height=Math.abs(b.y-e.y)+"px",MM.cancelEvent(a)}var b={},c=!1,d,e=null;return b.add=function(a){return d=d||document.createElement("div"),d.id=a.parent.id+"-zoombox-box",d.className="zoombox-box",a.parent.appendChild(d),MM.addEvent(a.parent,"mousedown",h),this},b.remove=function(){a.parent.removeChild(d),MM.removeEvent(a.parent,"mousedown",h)},b.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",bean.add(b,"mousedown dblclick",function(a){a.stop()}),bean.add(b,"click",function(b){b.stop(),a.zoomIn()},!1);var c=document.createElement("a");c.innerHTML="-",c.href="#",c.className="zoomer zoomout",bean.add(c,"mousedown dblclick",function(a){a.stop()}),bean.add(c,"click",function(b){b.stop(),a.zoomOut()});var d={add:function(a){return a.addCallback("drawn",function(a,d){a.coordinate.zoom===a.coordLimits[0].zoom?c.className="zoomer zoomout zoomdisabled":a.coordinate.zoom===a.coordLimits[1].zoom?b.className="zoomer zoomin zoomdisabled":(b.className="zoomer zoomin",c.className="zoomer zoomout")}),this},appendTo:function(a){return wax.u.$(a).appendChild(b),wax.u.$(a).appendChild(c),this}};return d.add(a)};var wax=wax||{};wax.mm=wax.mm||{},wax.mm._provider=function(a){this.options={tiles:a.tiles,scheme:a.scheme||"xyz",minzoom:a.minzoom||0,maxzoom:a.maxzoom||22,bounds:a.bounds||[-180,-90,180,90]}},wax.mm._provider.prototype={outerLimits:function(){return[this.locationCoordinate(new MM.Location(this.options.bounds[0],this.options.bounds[1])).zoomTo(this.options.minzoom),this.locationCoordinate(new MM.Location(this.options.bounds[2],this.options.bounds[3])).zoomTo(this.options.maxzoom)]},getTile:function(a){if(!(coord=this.sourceCoordinate(a)))return null;if(coord.zoom<this.options.minzoom||coord.zoom>this.options.maxzoom)return null;coord.row=this.options.scheme==="tms"?Math.pow(2,coord.zoom)-coord.row-1:coord.row;var b=this.options.tiles[parseInt(Math.pow(2,coord.zoom)*coord.row+coord.column,10)%this.options.tiles.length].replace("{z}",coord.zoom.toFixed(0)).replace("{x}",coord.column.toFixed(0)).replace("{y}",coord.row.toFixed(0));return wax._&&wax._.bw&&(b=b.replace(".png",wax._.bw_png).replace(".jpg",wax._.bw_jpg)),b}},MM&&MM.extend(wax.mm._provider,MM.MapProvider),wax.mm.connector=function(a){var b=new wax.mm._provider(a);return new MM.Layer(b)}

0 comments on commit 7dc7df5

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