diff --git a/Makefile b/Makefile
index 17ed6ce..c674908 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,7 @@ JS_FILES = \
src/GeoJson.js \
src/Dblclick.js \
src/Drag.js \
+ src/Touch.js \
src/Wheel.js \
src/Arrow.js \
src/Hash.js \
diff --git a/examples/touch/map.html b/examples/touch/map.html
new file mode 100644
index 0000000..9685042
--- /dev/null
+++ b/examples/touch/map.html
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/touch/map.js b/examples/touch/map.js
new file mode 100644
index 0000000..193d977
--- /dev/null
+++ b/examples/touch/map.js
@@ -0,0 +1,71 @@
+var po = org.polymaps;
+
+var div = document.getElementById("map");
+
+var map = po.map()
+ .container(div.appendChild(po.svg("svg")))
+ .add(po.touch())
+// .add(po.hash());
+
+/*
+ * Load the "AerialWithLabels" metadata. "Aerial" and "Road" also work. For more
+ * information about the Imagery Metadata service, see
+ * http://msdn.microsoft.com/en-us/library/ff701716.aspx
+ * You should register for your own key at https://www.bingmapsportal.com/.
+ */
+var script = document.createElement("script");
+script.setAttribute("type", "text/javascript");
+script.setAttribute("src", "http://dev.virtualearth.net"
+ + "/REST/V1/Imagery/Metadata/AerialWithLabels"
+ + "?key=AmT-ZC3HPevQq5IBJ7v8qiDUxrojNaqbW1zBsKF0oMNEs53p7Nk5RlAuAmwSG7bg"
+ + "&jsonp=callback");
+document.body.appendChild(script);
+
+function callback(data) {
+
+ /* Display each resource as an image layer. */
+ var resourceSets = data.resourceSets;
+ for (var i = 0; i < resourceSets.length; i++) {
+ var resources = data.resourceSets[i].resources;
+ for (var j = 0; j < resources.length; j++) {
+ var resource = resources[j];
+ map.add(po.image()
+ .url(template(resource.imageUrl, resource.imageUrlSubdomains)))
+ .tileSize({x: resource.imageWidth, y: resource.imageHeight});
+ }
+ }
+
+ /* Display brand logo. */
+ document.getElementById("logo").src = data.brandLogoUri;
+
+ /* Display copyright notice. */
+ document.getElementById("copy").appendChild(document.createTextNode(data.copyright));
+
+ /* Display compass control. */
+ map.add(po.compass()
+ .pan("none"));
+
+}
+
+/** Returns a Bing URL template given a string and a list of subdomains. */
+function template(url, subdomains) {
+ var n = subdomains.length,
+ salt = ~~(Math.random() * n); // per-session salt
+
+ /** Returns the given coordinate formatted as a 'quadkey'. */
+ function quad(column, row, zoom) {
+ var key = "";
+ for (var i = 1; i <= zoom; i++) {
+ key += (((row >> zoom - i) & 1) << 1) | ((column >> zoom - i) & 1);
+ }
+ return key;
+ }
+
+ return function(c) {
+ var quadKey = quad(c.column, c.row, c.zoom),
+ server = Math.abs(salt + c.column + c.row + c.zoom) % n;
+ return url
+ .replace("{quadkey}", quadKey)
+ .replace("{subdomain}", subdomains[server]);
+ };
+}
diff --git a/polymaps.js b/polymaps.js
index 1424d82..167cd17 100644
--- a/polymaps.js
+++ b/polymaps.js
@@ -1543,6 +1543,88 @@ po.drag = function() {
return drag;
};
+po.touch = function() {
+ var touch = {},
+ map,
+ last;
+
+ touch.map = function(x) {
+ if (!arguments.length) return map;
+ if (map) {
+ var container = map.container();
+ container.removeEventListener("touchstart", touchstart, false);
+ container.removeEventListener("touchmove", touchmove, false);
+ container.removeEventListener("touchend", touchend, false);
+ container.removeEventListener("touchcancel", touchend, false);
+ }
+ if (map = x) {
+ var container = map.container();
+ container.addEventListener("touchstart", touchstart, false);
+ container.addEventListener("touchmove", touchmove, false);
+ container.addEventListener("touchend", touchend, false);
+ container.addEventListener("touchcancel", touchend, false);
+ }
+ return touch;
+ }
+
+ function updateMap(last, now) {
+ var delta = {
+ x: now.clientX - last.clientX,
+ y: now.clientY - last.clientY,
+ scale: now.scale - last.scale
+ };
+ if (delta.x || delta.y || delta.scale) {
+ var oldPoint = map.mouse(last),
+ location = map.pointLocation(oldPoint);
+ map.zoomBy(delta.scale, map.mouse(now), location);
+ }
+ }
+
+ function touchstart(e) {
+ if (last) {
+ // if new finger being added, finish current move sequence first
+ touchend();
+ }
+ e.preventDefault();
+
+ last = touchesCenter(e);
+ }
+
+ function touchmove(e) {
+ if (!last) {
+ // if finger was lifted, start new move sequence instead
+ return touchstart(e);
+ }
+ e.preventDefault();
+
+ var now = touchesCenter(e);
+ updateMap(last, now);
+ last = now;
+ }
+
+ function touchend(e) {
+ last = null;
+ }
+
+ function touchesCenter(e) {
+ var touches = e.touches;
+ var sumX = 0, sumY = 0;
+ for (var i = 0; i < touches.length; ++i) {
+ var touch = touches[i];
+ sumX += touch.clientX;
+ sumY += touch.clientY;
+ }
+ return {
+ clientX: sumX / touches.length,
+ pageX: sumX / touches.length,
+ clientY: sumY / touches.length,
+ pageY: sumY / touches.length,
+ scale: e.scale
+ };
+ }
+
+ return touch;
+};
po.wheel = function() {
var wheel = {},
timePrev = 0,
@@ -1763,10 +1845,9 @@ po.hash = function() {
lat = 90 - 1e-8, // allowable latitude range
map;
- var parser = function(s) {
+ var parser = function(map, s) {
var args = s.split("/").map(Number);
- if (args.length < 3 || args.some(isNaN))
- move(); // replace bogus hash
+ if (args.length < 3 || args.some(isNaN)) return true; // replace bogus hash
else {
var size = map.size();
map.zoomBy(args[0] - map.zoom(),
@@ -1791,7 +1872,8 @@ po.hash = function() {
function hashchange() {
if (location.hash === s0) return; // ignore spurious hashchange events
- parser((s0 = location.hash).substring(1));
+ if (parser(map, (s0 = location.hash).substring(1)))
+ move(); // replace bogus hash
}
hash.map = function(x) {
diff --git a/polymaps.min.js b/polymaps.min.js
index 0f7e532..c004d88 100644
--- a/polymaps.min.js
+++ b/polymaps.min.js
@@ -1,62 +1,64 @@
if(!org)var org={};if(!org.polymaps)org.polymaps={};
-(function(s){function fa(e){var f=e.indexOf(":");return f<0?e:{space:s.ns[e.substring(0,f)],local:e.substring(f+1)}}function S(){for(var e=0;ef.row){var c=e;e=f;f=c}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,c,k,h){c=Math.max(c,Math.floor(f.y0));
-k=Math.min(k,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx0,o=f.dx<0;for(c=c;cf.dy){c=g;g=f;f=c}if(g.dy>e.dy){c=g;g=e;e=c}if(f.dy>e.dy){c=f;f=e;e=c}g.dy&&ca(e,g,k,h,a);f.dy&&ca(e,f,k,h,a)}s.version="2.4.0";
-var Y={x:0,y:0};s.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};s.id=function(){var e=0;return function(){return++e}}();s.svg=function(e){return document.createElementNS(s.ns.svg,e)};s.transform=function(e,f,c,k,h,a){var g={},l,o,t;if(!arguments.length){e=1;f=h=c=0;k=1;a=0}g.zoomFraction=function(m){if(!arguments.length)return o;o=m;l=Math.floor(o+Math.log(Math.sqrt(e*e+f*f+c*c+k*k))/Math.log(2));t=Math.pow(2,-l);return g};g.apply=function(m){var j=Math.pow(2,-m.zoom),
-u=Math.pow(2,m.zoom-l);return{column:(e*m.column*j+c*m.row*j+h)*u,row:(f*m.column*j+k*m.row*j+a)*u,zoom:m.zoom-l}};g.unapply=function(m){var j=Math.pow(2,-m.zoom),u=Math.pow(2,m.zoom+l);return{column:(m.column*j*k-m.row*j*c-h*k+a*c)/(e*k-f*c)*u,row:(m.column*j*f-m.row*j*e-h*f+a*e)/(c*f-k*e)*u,zoom:m.zoom+l}};g.toString=function(){return"matrix("+[e*t,f*t,c*t,k*t].join(" ")+" 0 0)"};return g.zoomFraction(0)};s.cache=function(e,f){function c(j){m--;f&&f(j);delete g[j.key];if(j.next)j.next.prev=j.prev;
-else if(o=j.prev)o.next=null;if(j.prev)j.prev.next=j.next;else if(l=j.next)l.prev=null}function k(){for(var j=o;m>t;j=j.prev){if(!j)break;j.lock||c(j)}}var h={},a={},g={},l=null,o=null,t=64,m=0;h.peek=function(j){return g[[j.zoom,j.column,j.row].join("/")]};h.load=function(j,u){var y=[j.zoom,j.column,j.row].join("/"),A=g[y];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else o=A.prev;A.prev=null;A.next=l;l=l.prev=A}A.lock=1;return a[y]=A}A={key:y,column:j.column,row:j.row,zoom:j.zoom,next:l,
-prev:null,lock:1};e.call(null,A,u);a[y]=g[y]=A;if(l)l.prev=A;else o=A;l=A;m++;return A};h.unload=function(j){if(!(j in a))return false;var u=a[j];u.lock=0;delete a[j];u.request&&u.request.abort(false)&&c(u);return u};h.locks=function(){return a};h.size=function(j){if(!arguments.length)return t;t=j;k();return h};h.flush=function(){k();return h};h.clear=function(){for(var j in g){var u=g[j];u.request&&u.request.abort(false);f&&f(g[j]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
-{};g={};l=o=null;m=0;return h};return h};s.url=function(e){function f(k){var h=k.zoom<0?1:1<=a||!k.length)){h++;k.pop()()}}function f(g){for(var l=0;lu[1])t=u[1];m=t-(t=Math.round(t));j=Math.pow(2,m)}function f(){if(n){var d=45/Math.pow(2,t+m-3),r=Math.max(Math.abs(C*g.x+A*g.y),Math.abs(B*g.x+E*g.y)),q=V(K-r*d/l.y);r=V(i+r*d/l.y);o.lat=Math.max(q,Math.min(r,o.lat));q=Math.max(Math.abs(C*g.y+A*g.x),Math.abs(B*g.y+E*g.x));o.lon=Math.max(n[0].lon-q*d/l.x,Math.min(n[1].lon+
-q*d/l.x,o.lon))}}var c={},k,h,a=Y,g=Y,l={x:256,y:256},o={lat:37.76487,lon:-122.41948},t=12,m=0,j=1,u=[1,18],y=0,A=1,C=0,E=1,B=0,K=-180,i=180,n=[{lat:V(K),lon:-Infinity},{lat:V(i),lon:Infinity}];c.locationCoordinate=function(d){d=s.map.locationCoordinate(d);var r=Math.pow(2,t);d.column*=r;d.row*=r;d.zoom+=t;return d};c.coordinateLocation=s.map.coordinateLocation;c.coordinatePoint=function(d,r){var q=Math.pow(2,t-r.zoom),z=Math.pow(2,t-d.zoom),v=(r.column*q-d.column*z)*l.x*j;q=(r.row*q-d.row*z)*l.y*
-j;return{x:g.x+A*v-C*q,y:g.y+C*v+A*q}};c.pointCoordinate=function(d,r){var q=Math.pow(2,t-d.zoom),z=(r.x-g.x)/j,v=(r.y-g.y)/j;return{column:d.column*q+(E*z-B*v)/l.x,row:d.row*q+(B*z+E*v)/l.y,zoom:t}};c.locationPoint=function(d){var r=Math.pow(2,t+m-3)/45,q=(d.lon-o.lon)*r*l.x;d=(W(o.lat)-W(d.lat))*r*l.y;return{x:g.x+A*q-C*d,y:g.y+C*q+A*d}};c.pointLocation=function(d){var r=45/Math.pow(2,t+m-3),q=(d.x-g.x)*r;d=(d.y-g.y)*r;return{lon:o.lon+(E*q-B*d)/l.x,lat:V(W(o.lat)-(B*q+E*d)/l.y)}};var w=s.svg("rect");
-w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(d){if(!arguments.length)return k;k=d;k.setAttribute("class","map");k.appendChild(w);return c.resize()};c.focusableParent=function(){for(var d=k;d;d=d.parentNode)if(d.tabIndex>=0)return d;return window};c.mouse=function(d){var r=(k.ownerSVGElement||k).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var q=document.body.appendChild(s.svg("svg"));q.style.position="absolute";q.style.top=q.style.left=
-"0px";var z=q.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(q)}if($){r.x=d.pageX;r.y=d.pageY}else{r.x=d.clientX;r.y=d.clientY}return r.matrixTransform(k.getScreenCTM().inverse())};c.size=function(d){if(!arguments.length)return a;h=d;return c.resize()};c.resize=function(){if(h){a=h;S.remove(c)}else{w.setAttribute("width","100%");w.setAttribute("height","100%");b=w.getBBox();a={x:b.width,y:b.height};S.add(c)}w.setAttribute("width",a.x);w.setAttribute("height",a.y);g={x:a.x/2,y:a.y/2};f();c.dispatch({type:"resize"});
-return c};c.tileSize=function(d){if(!arguments.length)return l;l=d;c.dispatch({type:"move"});return c};c.center=function(d){if(!arguments.length)return o;o=d;f();c.dispatch({type:"move"});return c};c.panBy=function(d){var r=45/Math.pow(2,t+m-3),q=d.x*r;d=d.y*r;return c.center({lon:o.lon+(B*d-E*q)/l.x,lat:V(W(o.lat)+(B*q+E*d)/l.y)})};c.centerRange=function(d){if(!arguments.length)return n;if(n=d){K=n[0].lat>-90?W(n[0].lat):-Infinity;i=n[0].lat<90?W(n[1].lat):Infinity}else{K=-Infinity;i=Infinity}f();
-c.dispatch({type:"move"});return c};c.zoom=function(d){if(!arguments.length)return t+m;t=d;e();return c.center(o)};c.zoomBy=function(d,r,q){if(arguments.length<2)return c.zoom(t+m+d);if(arguments.length<3)q=c.pointLocation(r);t=t+m+d;e();var z=c.locationPoint(q);return c.panBy({x:r.x-z.x,y:r.y-z.y})};c.zoomRange=function(d){if(!arguments.length)return u;u=d;return c.zoom(t+m)};c.extent=function(d){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var r=c.locationPoint(d[0]),
-q=c.locationPoint(d[1]),z=Math.max((q.x-r.x)/a.x,(r.y-q.y)/a.y);r=c.pointLocation({x:(r.x+q.x)/2,y:(r.y+q.y)/2});t=t+m-Math.log(z)/Math.log(2);e();return c.center(r)};c.angle=function(d){if(!arguments.length)return y;y=d;A=Math.cos(y);C=Math.sin(y);E=Math.cos(-y);B=Math.sin(-y);f();c.dispatch({type:"move"});return c};c.add=function(d){d.map(c);return c};c.remove=function(d){d.map(null);return c};c.dispatch=s.dispatch(c);return c};S.maps=[];S.add=function(e){for(var f=0;fB;A--){u.insertBefore(C[-1],K);u.insertBefore(C[2],C[-4]);for(var i=C[2],n=2;n>-4;)C[n]=C[--n];C[n]=i}}function h(){function B(O){var H=O.zoom,T=H<0?1:1<>Q,row:T>>Q,zoom:U-Q}))&&P.ready){M[P.key]=g.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}M[G.key]=G}}
-var i=a.map(),n=i.zoom(),w=n-(n=Math.round(n)),d=i.size(),r=i.angle(),q=i.tileSize(),z=i.locationCoordinate(i.center());if(A!=n){if(An)k(n);else A=n;for(var v=-4;v<=2;v++){var L=C[v];L.setAttribute("class","zoom"+(v<0?"":"+")+v+" zoom"+(n+v));L.setAttribute("transform","scale("+Math.pow(2,-v)+")")}}u.setAttribute("transform","translate("+d.x/2+","+d.y/2+")"+(r?"rotate("+r/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(y?y.zoomFraction(w):""));var I=i.pointCoordinate(z,Y);
-v=i.pointCoordinate(z,{x:d.x,y:0});n=i.pointCoordinate(z,d);i=i.pointCoordinate(z,{x:0,y:d.y});if(!w&&!r&&!y){z.column=(Math.round(q.x*z.column)+(d.x&1)/2)/q.x;z.row=(Math.round(q.y*z.row)+(d.y&1)/2)/q.y}if(y){I=y.unapply(I);v=y.unapply(v);n=y.unapply(n);i=y.unapply(i);z=y.unapply(z)}var R=t?t(I.zoom)-I.zoom:0;if(R){d=Math.pow(2,R);I.column*=d;I.row*=d;v.column*=d;v.row*=d;n.column*=d;n.row*=d;i.column*=d;i.row*=d;I.zoom=v.zoom=n.zoom=i.zoom+=R}w=g.locks();var M={};for(var F in w)w[F].proxyCount=
-0;if(o&&R>-5&&R<3){r=I.zoom<0?1:1<>v<>v<=1;E--)C[E]=u.appendChild(s.svg("g"));C[0]=u.appendChild(s.svg("g"));a.map=function(B){if(!arguments.length)return j;if(j){if(j==B){u.parentNode.appendChild(u);return a}j.off("move",h).off("resize",
-h);u.parentNode.removeChild(u)}if(j=B){j.container().appendChild(u);a.init&&a.init(u);j.on("move",h).on("resize",h);h()}return a};a.container=function(){return u};a.levels=function(){return C};a.id=function(B){if(!arguments.length)return m;m=B;u.setAttribute("id",B);return a};a.visible=function(B){if(!arguments.length)return o;(o=B)?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden");j&&h();return a};a.transform=function(B){if(!arguments.length)return y;y=B;j&&h();return a};a.zoom=
-function(B){if(!arguments.length)return t;t=typeof B=="function"||B==null?B:function(){return B};j&&h();return a};a.tile=function(B){if(!arguments.length)return l;l=B;j&&h();return a};a.reload=function(){g.clear();j&&h();return a};a.dispatch=s.dispatch(a);a.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var i=B.tile.proxyRefs[K];--i.proxyCount<=0&&g.unload(K)&&i.element.parentNode.removeChild(i.element)}delete B.tile.proxyRefs}});return a};s.image=function(){var e=s.layer(function(c){var k=
-c.element=s.svg("image"),h=e.map().tileSize();k.setAttribute("preserveAspectRatio","none");k.setAttribute("width",h.x);k.setAttribute("height",h.y);if(typeof f=="function"){k.setAttribute("opacity",0);c.request=s.queue.image(k,f(c),function(a){delete c.request;c.ready=true;c.img=a;k.removeAttribute("opacity");e.dispatch({type:"load",tile:c})})}else{c.ready=true;f&&k.setAttributeNS(s.ns.xlink,"href",f);e.dispatch({type:"load",tile:c})}},function(c){c.request&&c.request.abort(true)}),f;e.url=function(c){if(!arguments.length)return f;
-f=typeof c=="string"&&/{.}/.test(c)?s.url(c):c;return e.reload()};return e};s.geoJson=function(e){function f(i){var n={lat:0,lon:0};return function(w){n.lat=w[1];n.lon=w[0];var d=i(n);w.x=d.x;w.y=d.y;return d}}function c(i,n){return i&&i.type in C&&C[i.type](i,n)}function k(i,n,w){return i.type in E&&E[i.type](i,n,w)}function h(){var i=a.map().zoom(),n=a.cache.locks(),w,d,r,q,z,v,L;if(y=="fixed")for(w in n){if((d=n[w]).scale!=i){L="scale("+Math.pow(2,d.zoom-i)+")";q=-1;for(z=(r=d.features).length;++q<
-z;)k((v=r[q]).data.geometry,v.element,L);d.scale=i}}else for(w in n){q=-1;for(z=(r=(d=n[w]).features).length;++q9&&Math.abs(m.wheelDelta)/y>=50)ba=1;h=u}if(ba==1)j*=0.03;if(!a&&j){u=Date.now();if(u-k>200){j=j>0?+1:-1;k=u}else j=0}if(j)switch(g){case "mouse":u=o.mouse(m);l||(l=o.pointLocation(u));o.off("move",e).zoomBy(j,u,l).on("move",e);break;case "location":o.zoomBy(j,o.locationPoint(l),l);break;default:o.zoomBy(j);break}m.preventDefault();return false}var c=
-{},k=0,h=0,a=true,g="mouse",l,o,t;c.smooth=function(m){if(!arguments.length)return a;a=m;return c};c.zoom=function(m,j){if(!arguments.length)return g;g=m;l=j;if(o)g=="mouse"?o.on("move",e):o.off("move",e);return c};c.map=function(m){if(!arguments.length)return o;if(o){t.removeEventListener("mousemove",e,false);t.removeEventListener("mousewheel",f,false);t.removeEventListener("DOMMouseScroll",f,false);t=null;o.off("move",e)}if(o=m){g=="mouse"&&o.on("move",e);t=o.container();t.addEventListener("mousemove",
-e,false);t.addEventListener("mousewheel",f,false);t.addEventListener("DOMMouseScroll",f,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;s.arrow=function(){function e(y){if(!(y.ctrlKey||y.altKey||y.metaKey)){var A=Date.now(),C=0,E=0;switch(y.keyCode){case 37:if(!a.left){g=A;a.left=1;a.right||(C=m)}break;case 39:if(!a.right){g=A;a.right=1;a.left||(C=-m)}break;case 38:if(!a.up){g=A;a.up=1;a.down||(E=m)}break;case 40:if(!a.down){g=A;a.down=1;a.up||(E=-m)}break;default:return}if(C||
-E)j.panBy({x:C,y:E});if(!l&&a.left|a.right|a.up|a.down)l=setInterval(k,t);y.preventDefault()}}function f(y){g=Date.now();switch(y.keyCode){case 37:a.left=0;break;case 39:a.right=0;break;case 38:a.up=0;break;case 40:a.down=0;break;default:return}if(l&&!(a.left|a.right|a.up|a.down))l=clearInterval(l);y.preventDefault()}function c(y){switch(y.charCode){case 45:case 95:j.zoom(Math.ceil(j.zoom())-1);break;case 43:case 61:j.zoom(Math.floor(j.zoom())+1);break;default:return}y.preventDefault()}function k(){if(j)if(!(Date.now()<
-g+o)){var y=(a.left-a.right)*m,A=(a.up-a.down)*m;if(y||A)j.panBy({x:y,y:A})}}var h={},a={left:0,right:0,up:0,down:0},g=0,l,o=250,t=50,m=16,j,u;h.map=function(y){if(!arguments.length)return j;if(j){u.removeEventListener("keypress",c,false);u.removeEventListener("keydown",e,false);u.removeEventListener("keyup",f,false);u=null}if(j=y){u=j.focusableParent();u.addEventListener("keypress",c,false);u.addEventListener("keydown",e,false);u.addEventListener("keyup",f,false)}return h};h.speed=function(y){if(!arguments.length)return m;
-m=y;return h};return h};s.hash=function(){function e(){var l=g(h);if(k!==l)location.replace(k=l)}function f(){if(location.hash!==k)a((k=location.hash).substring(1))}var c={},k,h,a=function(l){l=l.split("/").map(Number);if(l.length<3||l.some(isNaN))e();else{var o=h.size();h.zoomBy(l[0]-h.zoom(),{x:o.x/2,y:o.y/2},{lat:Math.min(89.99999999,Math.max(-89.99999999,l[1])),lon:l[2]})}},g=function(l){var o=l.center();l=l.zoom();var t=Math.max(0,Math.ceil(Math.log(l)/Math.LN2));return"#"+l.toFixed(2)+"/"+o.lat.toFixed(t)+
-"/"+o.lon.toFixed(t)};c.map=function(l){if(!arguments.length)return h;if(h){h.off("move",e);window.removeEventListener("hashchange",f,false)}if(h=l){h.on("move",e);window.addEventListener("hashchange",f,false);location.hash?f():e()}return c};c.parser=function(l){if(!arguments.length)return a;a=l;return c};c.formatter=function(l){if(!arguments.length)return g;g=l;return c};return c};s.interact=function(){var e={},f=s.drag(),c=s.wheel(),k=s.dblclick(),h=s.arrow();e.map=function(a){f.map(a);c.map(a);
-k.map(a);h.map(a);return e};return e};s.compass=function(){function e(x){B.setAttribute("class","compass active");I||(I=setInterval(f,r));R&&H.panBy(R);w=Date.now();return m(x)}function f(){R&&Date.now()>w+d&&H.panBy(R)}function c(x){if(x.shiftKey){F={x0:H.mouse(x)};H.focusableParent().focus();return m(x)}}function k(x){if(F){F.x1=H.mouse(x);O.setAttribute("x",Math.min(F.x0.x,F.x1.x));O.setAttribute("y",Math.min(F.x0.y,F.x1.y));O.setAttribute("width",Math.abs(F.x0.x-F.x1.x));O.setAttribute("height",
-Math.abs(F.x0.y-F.x1.y));O.removeAttribute("display")}}function h(){B.setAttribute("class","compass");if(F){if(F.x1){H.extent([H.pointLocation({x:Math.min(F.x0.x,F.x1.x),y:Math.max(F.x0.y,F.x1.y)}),H.pointLocation({x:Math.max(F.x0.x,F.x1.x),y:Math.min(F.x0.y,F.x1.y)})]);O.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function a(x){return function(){x?this.setAttribute("class","active"):this.removeAttribute("class");R=x}}function g(x){return function(D){B.setAttribute("class","compass active");
-var G=H.zoom();H.zoom(x<0?Math.ceil(G)-1:Math.floor(G)+1);return m(D)}}function l(x){return function(D){H.zoom(x);return m(D)}}function o(){this.setAttribute("class","active")}function t(){this.removeAttribute("class")}function m(x){x.stopPropagation();x.preventDefault();return false}function j(x){var D=Math.SQRT1_2*i,G=i*0.7,J=i*0.2,N=s.svg("g"),P=N.appendChild(s.svg("path")),Q=N.appendChild(s.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d",
-"M0,0L"+D+","+D+"A"+i+","+i+" 0 0,1 "+-D+","+D+"Z");Q.setAttribute("class","chevron");Q.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));Q.setAttribute("pointer-events","none");N.addEventListener("mousedown",e,false);N.addEventListener("mouseover",a(x),false);N.addEventListener("mouseout",a(null),false);N.addEventListener("dblclick",m,false);return N}function u(x){var D=i*0.4,G=D/2,J=s.svg("g"),N=J.appendChild(s.svg("path")),P=J.appendChild(s.svg("path")),Q=J.appendChild(s.svg("path")),
-X=J.appendChild(s.svg("path"));N.setAttribute("class","back");N.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",N.getAttribute("d"));Q.setAttribute("class","chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(x>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",N.getAttribute("d"));J.addEventListener("mousedown",g(x),false);J.addEventListener("mouseover",o,false);J.addEventListener("mouseout",
-t,false);J.addEventListener("dblclick",m,false);return J}function y(x){var D=i*0.2,G=i*0.4,J=s.svg("g"),N=J.appendChild(s.svg("rect")),P=J.appendChild(s.svg("path"));N.setAttribute("pointer-events","all");N.setAttribute("fill","none");N.setAttribute("x",-G);N.setAttribute("y",-0.75*G);N.setAttribute("width",2*G);N.setAttribute("height",1.5*G);P.setAttribute("class","chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",l(x),false);J.addEventListener("dblclick",m,false);return J}
-function A(){var x=i+6,D=x,G=H.size();switch(q){case "top-left":break;case "top-right":x=G.x-x;break;case "bottom-left":D=G.y-D;break;case "bottom-right":x=G.x-x;D=G.y-D;break}x="translate("+x+","+D+")";M&&M.setAttribute("transform",x);v&&v.setAttribute("transform",x);for(var J in K)J==H.zoom()?K[J].setAttribute("class","active"):K[J].removeAttribute("class")}function C(){for(;B.lastChild;)B.removeChild(B.lastChild);B.appendChild(O);if(L!="none"){M=B.appendChild(s.svg("g"));M.setAttribute("class",
-"pan");var x=M.appendChild(s.svg("circle"));x.setAttribute("class","back");x.setAttribute("r",i);M.appendChild(j({x:0,y:-n})).setAttribute("transform","rotate(0)");M.appendChild(j({x:n,y:0})).setAttribute("transform","rotate(90)");M.appendChild(j({x:0,y:n})).setAttribute("transform","rotate(180)");M.appendChild(j({x:-n,y:0})).setAttribute("transform","rotate(270)");x=M.appendChild(s.svg("circle"));x.setAttribute("fill","none");x.setAttribute("class","fore");x.setAttribute("r",i)}else M=null;if(z!=
-"none"){v=B.appendChild(s.svg("g"));v.setAttribute("class","zoom");x=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(x=0;D<=H.zoomRange()[1];D++,x++)(K[D]=v.appendChild(y(D))).setAttribute("transform","translate(0,"+-(x+0.75)*i*0.4+")")}D=L=="none"?0.4:2;v.setAttribute("transform","translate(0,"+i*(/^top-/.test(q)?D+(x+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(x+0.5)*i*0.4+")");v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E=
-{},B=s.svg("g"),K={},i=30,n=16,w=0,d=250,r=50,q="top-left",z="small",v,L="small",I,R,M,F,O=s.svg("rect"),H,T,U;B.setAttribute("class","compass");O.setAttribute("class","back fore");O.setAttribute("pointer-events","none");O.setAttribute("display","none");E.radius=function(x){if(!arguments.length)return i;i=x;H&&C();return E};E.speed=function(x){if(!arguments.length)return i;n=x;return E};E.position=function(x){if(!arguments.length)return q;q=x;H&&C();return E};E.pan=function(x){if(!arguments.length)return L;
-L=x;H&&C();return E};E.zoom=function(x){if(!arguments.length)return z;z=x;H&&C();return E};E.map=function(x){if(!arguments.length)return H;if(H){T.removeEventListener("mousedown",c,false);T.removeChild(B);T=null;U.removeEventListener("mousemove",k,false);U.removeEventListener("mouseup",h,false);U=null;H.off("move",A).off("resize",A)}if(H=x){T=H.container();T.appendChild(B);T.addEventListener("mousedown",c,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",k,false);U.addEventListener("mouseup",
-h,false);H.on("move",A).on("resize",A);C()}return E};return E};s.grid=function(){function e(){var h=k.firstChild,a=c.size(),g=c.pointLocation(Y);c.pointLocation(a);var l=Math.pow(2,4-Math.round(c.zoom()));g.lat=Math.floor(g.lat/l)*l;g.lon=Math.ceil(g.lon/l)*l;for(var o;(o=c.locationPoint(g).x)<=a.x;g.lon+=l){h||(h=k.appendChild(s.svg("line")));h.setAttribute("x1",o);h.setAttribute("x2",o);h.setAttribute("y1",0);h.setAttribute("y2",a.y);h=h.nextSibling}for(;(o=c.locationPoint(g).y)<=a.y;g.lat-=l){h||
-(h=k.appendChild(s.svg("line")));h.setAttribute("y1",o);h.setAttribute("y2",o);h.setAttribute("x1",0);h.setAttribute("x2",a.x);h=h.nextSibling}for(;h;){a=h.nextSibling;k.removeChild(h);h=a}}var f={},c,k=s.svg("g");k.setAttribute("class","grid");f.map=function(h){if(!arguments.length)return c;if(c){k.parentNode.removeChild(k);c.off("move",e).off("resize",e)}if(c=h){c.on("move",e).on("resize",e);c.container().appendChild(k);c.dispatch({type:"move"})}return f};return f};s.stylist=function(){function e(h){var a=
-h.features.length,g=f.length,l=c.length,o,t,m,j,u,y;for(u=0;ug.row){var c=d;d=g;g=c}return{x0:d.column,y0:d.row,x1:g.column,y1:g.row,dx:g.column-d.column,dy:g.row-d.row}}function ca(d,g,c,l,h){c=Math.max(c,Math.floor(g.y0));
+l=Math.min(l,Math.ceil(g.y1));if(d.x0==g.x0&&d.y0==g.y0?d.x0+g.dy/d.dy*d.dx0,n=g.dx<0;for(c=c;cg.dy){c=f;f=g;g=c}if(f.dy>d.dy){c=f;f=d;d=c}if(g.dy>d.dy){c=g;g=d;d=c}f.dy&&ca(d,f,l,h,a);g.dy&&ca(d,g,l,h,a)}t.version="2.4.0";
+var Y={x:0,y:0};t.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};t.id=function(){var d=0;return function(){return++d}}();t.svg=function(d){return document.createElementNS(t.ns.svg,d)};t.transform=function(d,g,c,l,h,a){var f={},i,n,o;if(!arguments.length){d=1;g=h=c=0;l=1;a=0}f.zoomFraction=function(m){if(!arguments.length)return n;n=m;i=Math.floor(n+Math.log(Math.sqrt(d*d+g*g+c*c+l*l))/Math.log(2));o=Math.pow(2,-i);return f};f.apply=function(m){var j=Math.pow(2,-m.zoom),
+u=Math.pow(2,m.zoom-i);return{column:(d*m.column*j+c*m.row*j+h)*u,row:(g*m.column*j+l*m.row*j+a)*u,zoom:m.zoom-i}};f.unapply=function(m){var j=Math.pow(2,-m.zoom),u=Math.pow(2,m.zoom+i);return{column:(m.column*j*l-m.row*j*c-h*l+a*c)/(d*l-g*c)*u,row:(m.column*j*g-m.row*j*d-h*g+a*d)/(c*g-l*d)*u,zoom:m.zoom+i}};f.toString=function(){return"matrix("+[d*o,g*o,c*o,l*o].join(" ")+" 0 0)"};return f.zoomFraction(0)};t.cache=function(d,g){function c(j){m--;g&&g(j);delete f[j.key];if(j.next)j.next.prev=j.prev;
+else if(n=j.prev)n.next=null;if(j.prev)j.prev.next=j.next;else if(i=j.next)i.prev=null}function l(){for(var j=n;m>o;j=j.prev){if(!j)break;j.lock||c(j)}}var h={},a={},f={},i=null,n=null,o=64,m=0;h.peek=function(j){return f[[j.zoom,j.column,j.row].join("/")]};h.load=function(j,u){var y=[j.zoom,j.column,j.row].join("/"),A=f[y];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else n=A.prev;A.prev=null;A.next=i;i=i.prev=A}A.lock=1;return a[y]=A}A={key:y,column:j.column,row:j.row,zoom:j.zoom,next:i,
+prev:null,lock:1};d.call(null,A,u);a[y]=f[y]=A;if(i)i.prev=A;else n=A;i=A;m++;return A};h.unload=function(j){if(!(j in a))return false;var u=a[j];u.lock=0;delete a[j];u.request&&u.request.abort(false)&&c(u);return u};h.locks=function(){return a};h.size=function(j){if(!arguments.length)return o;o=j;l();return h};h.flush=function(){l();return h};h.clear=function(){for(var j in f){var u=f[j];u.request&&u.request.abort(false);g&&g(f[j]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
+{};f={};i=n=null;m=0;return h};return h};t.url=function(d){function g(l){var h=l.zoom<0?1:1<=a||!l.length)){h++;l.pop()()}}function g(f){for(var i=0;iu[1])o=u[1];m=o-(o=Math.round(o));j=Math.pow(2,m)}function g(){if(q){var e=45/Math.pow(2,o+m-3),s=Math.max(Math.abs(C*f.x+A*f.y),Math.abs(B*f.x+E*f.y)),r=V(K-s*e/i.y);s=V(k+s*e/i.y);n.lat=Math.max(r,Math.min(s,n.lat));r=Math.max(Math.abs(C*f.y+A*f.x),Math.abs(B*f.y+E*f.x));n.lon=Math.max(q[0].lon-r*e/i.x,Math.min(q[1].lon+
+r*e/i.x,n.lon))}}var c={},l,h,a=Y,f=Y,i={x:256,y:256},n={lat:37.76487,lon:-122.41948},o=12,m=0,j=1,u=[1,18],y=0,A=1,C=0,E=1,B=0,K=-180,k=180,q=[{lat:V(K),lon:-Infinity},{lat:V(k),lon:Infinity}];c.locationCoordinate=function(e){e=t.map.locationCoordinate(e);var s=Math.pow(2,o);e.column*=s;e.row*=s;e.zoom+=o;return e};c.coordinateLocation=t.map.coordinateLocation;c.coordinatePoint=function(e,s){var r=Math.pow(2,o-s.zoom),z=Math.pow(2,o-e.zoom),v=(s.column*r-e.column*z)*i.x*j;r=(s.row*r-e.row*z)*i.y*
+j;return{x:f.x+A*v-C*r,y:f.y+C*v+A*r}};c.pointCoordinate=function(e,s){var r=Math.pow(2,o-e.zoom),z=(s.x-f.x)/j,v=(s.y-f.y)/j;return{column:e.column*r+(E*z-B*v)/i.x,row:e.row*r+(B*z+E*v)/i.y,zoom:o}};c.locationPoint=function(e){var s=Math.pow(2,o+m-3)/45,r=(e.lon-n.lon)*s*i.x;e=(W(n.lat)-W(e.lat))*s*i.y;return{x:f.x+A*r-C*e,y:f.y+C*r+A*e}};c.pointLocation=function(e){var s=45/Math.pow(2,o+m-3),r=(e.x-f.x)*s;e=(e.y-f.y)*s;return{lon:n.lon+(E*r-B*e)/i.x,lat:V(W(n.lat)-(B*r+E*e)/i.y)}};var w=t.svg("rect");
+w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(e){if(!arguments.length)return l;l=e;l.setAttribute("class","map");l.appendChild(w);return c.resize()};c.focusableParent=function(){for(var e=l;e;e=e.parentNode)if(e.tabIndex>=0)return e;return window};c.mouse=function(e){var s=(l.ownerSVGElement||l).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var r=document.body.appendChild(t.svg("svg"));r.style.position="absolute";r.style.top=r.style.left=
+"0px";var z=r.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(r)}if($){s.x=e.pageX;s.y=e.pageY}else{s.x=e.clientX;s.y=e.clientY}return s.matrixTransform(l.getScreenCTM().inverse())};c.size=function(e){if(!arguments.length)return a;h=e;return c.resize()};c.resize=function(){if(h){a=h;S.remove(c)}else{w.setAttribute("width","100%");w.setAttribute("height","100%");b=w.getBBox();a={x:b.width,y:b.height};S.add(c)}w.setAttribute("width",a.x);w.setAttribute("height",a.y);f={x:a.x/2,y:a.y/2};g();c.dispatch({type:"resize"});
+return c};c.tileSize=function(e){if(!arguments.length)return i;i=e;c.dispatch({type:"move"});return c};c.center=function(e){if(!arguments.length)return n;n=e;g();c.dispatch({type:"move"});return c};c.panBy=function(e){var s=45/Math.pow(2,o+m-3),r=e.x*s;e=e.y*s;return c.center({lon:n.lon+(B*e-E*r)/i.x,lat:V(W(n.lat)+(B*r+E*e)/i.y)})};c.centerRange=function(e){if(!arguments.length)return q;if(q=e){K=q[0].lat>-90?W(q[0].lat):-Infinity;k=q[0].lat<90?W(q[1].lat):Infinity}else{K=-Infinity;k=Infinity}g();
+c.dispatch({type:"move"});return c};c.zoom=function(e){if(!arguments.length)return o+m;o=e;d();return c.center(n)};c.zoomBy=function(e,s,r){if(arguments.length<2)return c.zoom(o+m+e);if(arguments.length<3)r=c.pointLocation(s);o=o+m+e;d();var z=c.locationPoint(r);return c.panBy({x:s.x-z.x,y:s.y-z.y})};c.zoomRange=function(e){if(!arguments.length)return u;u=e;return c.zoom(o+m)};c.extent=function(e){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var s=c.locationPoint(e[0]),
+r=c.locationPoint(e[1]),z=Math.max((r.x-s.x)/a.x,(s.y-r.y)/a.y);s=c.pointLocation({x:(s.x+r.x)/2,y:(s.y+r.y)/2});o=o+m-Math.log(z)/Math.log(2);d();return c.center(s)};c.angle=function(e){if(!arguments.length)return y;y=e;A=Math.cos(y);C=Math.sin(y);E=Math.cos(-y);B=Math.sin(-y);g();c.dispatch({type:"move"});return c};c.add=function(e){e.map(c);return c};c.remove=function(e){e.map(null);return c};c.dispatch=t.dispatch(c);return c};S.maps=[];S.add=function(d){for(var g=0;gB;A--){u.insertBefore(C[-1],K);u.insertBefore(C[2],C[-4]);for(var k=C[2],q=2;q>-4;)C[q]=C[--q];C[q]=k}}function h(){function B(O){var H=O.zoom,T=H<0?1:1<>Q,row:T>>Q,zoom:U-Q}))&&P.ready){M[P.key]=f.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}M[G.key]=G}}
+var k=a.map(),q=k.zoom(),w=q-(q=Math.round(q)),e=k.size(),s=k.angle(),r=k.tileSize(),z=k.locationCoordinate(k.center());if(A!=q){if(Aq)l(q);else A=q;for(var v=-4;v<=2;v++){var L=C[v];L.setAttribute("class","zoom"+(v<0?"":"+")+v+" zoom"+(q+v));L.setAttribute("transform","scale("+Math.pow(2,-v)+")")}}u.setAttribute("transform","translate("+e.x/2+","+e.y/2+")"+(s?"rotate("+s/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(y?y.zoomFraction(w):""));var I=k.pointCoordinate(z,Y);
+v=k.pointCoordinate(z,{x:e.x,y:0});q=k.pointCoordinate(z,e);k=k.pointCoordinate(z,{x:0,y:e.y});if(!w&&!s&&!y){z.column=(Math.round(r.x*z.column)+(e.x&1)/2)/r.x;z.row=(Math.round(r.y*z.row)+(e.y&1)/2)/r.y}if(y){I=y.unapply(I);v=y.unapply(v);q=y.unapply(q);k=y.unapply(k);z=y.unapply(z)}var R=o?o(I.zoom)-I.zoom:0;if(R){e=Math.pow(2,R);I.column*=e;I.row*=e;v.column*=e;v.row*=e;q.column*=e;q.row*=e;k.column*=e;k.row*=e;I.zoom=v.zoom=q.zoom=k.zoom+=R}w=f.locks();var M={};for(var F in w)w[F].proxyCount=
+0;if(n&&R>-5&&R<3){s=I.zoom<0?1:1<>v<>v<=1;E--)C[E]=u.appendChild(t.svg("g"));C[0]=u.appendChild(t.svg("g"));a.map=function(B){if(!arguments.length)return j;if(j){if(j==B){u.parentNode.appendChild(u);return a}j.off("move",h).off("resize",
+h);u.parentNode.removeChild(u)}if(j=B){j.container().appendChild(u);a.init&&a.init(u);j.on("move",h).on("resize",h);h()}return a};a.container=function(){return u};a.levels=function(){return C};a.id=function(B){if(!arguments.length)return m;m=B;u.setAttribute("id",B);return a};a.visible=function(B){if(!arguments.length)return n;(n=B)?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden");j&&h();return a};a.transform=function(B){if(!arguments.length)return y;y=B;j&&h();return a};a.zoom=
+function(B){if(!arguments.length)return o;o=typeof B=="function"||B==null?B:function(){return B};j&&h();return a};a.tile=function(B){if(!arguments.length)return i;i=B;j&&h();return a};a.reload=function(){f.clear();j&&h();return a};a.dispatch=t.dispatch(a);a.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var k=B.tile.proxyRefs[K];--k.proxyCount<=0&&f.unload(K)&&k.element.parentNode.removeChild(k.element)}delete B.tile.proxyRefs}});return a};t.image=function(){var d=t.layer(function(c){var l=
+c.element=t.svg("image"),h=d.map().tileSize();l.setAttribute("preserveAspectRatio","none");l.setAttribute("width",h.x);l.setAttribute("height",h.y);if(typeof g=="function"){l.setAttribute("opacity",0);c.request=t.queue.image(l,g(c),function(a){delete c.request;c.ready=true;c.img=a;l.removeAttribute("opacity");d.dispatch({type:"load",tile:c})})}else{c.ready=true;g&&l.setAttributeNS(t.ns.xlink,"href",g);d.dispatch({type:"load",tile:c})}},function(c){c.request&&c.request.abort(true)}),g;d.url=function(c){if(!arguments.length)return g;
+g=typeof c=="string"&&/{.}/.test(c)?t.url(c):c;return d.reload()};return d};t.geoJson=function(d){function g(k){var q={lat:0,lon:0};return function(w){q.lat=w[1];q.lon=w[0];var e=k(q);w.x=e.x;w.y=e.y;return e}}function c(k,q){return k&&k.type in C&&C[k.type](k,q)}function l(k,q,w){return k.type in E&&E[k.type](k,q,w)}function h(){var k=a.map().zoom(),q=a.cache.locks(),w,e,s,r,z,v,L;if(y=="fixed")for(w in q){if((e=q[w]).scale!=k){L="scale("+Math.pow(2,e.zoom-k)+")";r=-1;for(z=(s=e.features).length;++r<
+z;)l((v=s[r]).data.geometry,v.element,L);e.scale=k}}else for(w in q){r=-1;for(z=(s=(e=q[w]).features).length;++r9&&Math.abs(m.wheelDelta)/y>=50)ba=1;h=u}if(ba==1)j*=0.03;if(!a&&j){u=Date.now();if(u-l>200){j=j>0?+1:-1;l=u}else j=0}if(j)switch(f){case "mouse":u=n.mouse(m);i||(i=n.pointLocation(u));n.off("move",d).zoomBy(j,u,i).on("move",d);break;case "location":n.zoomBy(j,n.locationPoint(i),i);break;default:n.zoomBy(j);break}m.preventDefault();return false}var c={},l=0,h=0,a=true,f="mouse",i,n,o;c.smooth=function(m){if(!arguments.length)return a;
+a=m;return c};c.zoom=function(m,j){if(!arguments.length)return f;f=m;i=j;if(n)f=="mouse"?n.on("move",d):n.off("move",d);return c};c.map=function(m){if(!arguments.length)return n;if(n){o.removeEventListener("mousemove",d,false);o.removeEventListener("mousewheel",g,false);o.removeEventListener("DOMMouseScroll",g,false);o=null;n.off("move",d)}if(n=m){f=="mouse"&&n.on("move",d);o=n.container();o.addEventListener("mousemove",d,false);o.addEventListener("mousewheel",g,false);o.addEventListener("DOMMouseScroll",
+g,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;t.arrow=function(){function d(y){if(!(y.ctrlKey||y.altKey||y.metaKey)){var A=Date.now(),C=0,E=0;switch(y.keyCode){case 37:if(!a.left){f=A;a.left=1;a.right||(C=m)}break;case 39:if(!a.right){f=A;a.right=1;a.left||(C=-m)}break;case 38:if(!a.up){f=A;a.up=1;a.down||(E=m)}break;case 40:if(!a.down){f=A;a.down=1;a.up||(E=-m)}break;default:return}if(C||E)j.panBy({x:C,y:E});if(!i&&a.left|a.right|a.up|a.down)i=setInterval(l,o);
+y.preventDefault()}}function g(y){f=Date.now();switch(y.keyCode){case 37:a.left=0;break;case 39:a.right=0;break;case 38:a.up=0;break;case 40:a.down=0;break;default:return}if(i&&!(a.left|a.right|a.up|a.down))i=clearInterval(i);y.preventDefault()}function c(y){switch(y.charCode){case 45:case 95:j.zoom(Math.ceil(j.zoom())-1);break;case 43:case 61:j.zoom(Math.floor(j.zoom())+1);break;default:return}y.preventDefault()}function l(){if(j)if(!(Date.now()w+e&&H.panBy(R)}function c(x){if(x.shiftKey){F={x0:H.mouse(x)};H.focusableParent().focus();return m(x)}}function l(x){if(F){F.x1=H.mouse(x);O.setAttribute("x",Math.min(F.x0.x,F.x1.x));O.setAttribute("y",Math.min(F.x0.y,F.x1.y));O.setAttribute("width",Math.abs(F.x0.x-F.x1.x));O.setAttribute("height",
+Math.abs(F.x0.y-F.x1.y));O.removeAttribute("display")}}function h(){B.setAttribute("class","compass");if(F){if(F.x1){H.extent([H.pointLocation({x:Math.min(F.x0.x,F.x1.x),y:Math.max(F.x0.y,F.x1.y)}),H.pointLocation({x:Math.max(F.x0.x,F.x1.x),y:Math.min(F.x0.y,F.x1.y)})]);O.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function a(x){return function(){x?this.setAttribute("class","active"):this.removeAttribute("class");R=x}}function f(x){return function(D){B.setAttribute("class","compass active");
+var G=H.zoom();H.zoom(x<0?Math.ceil(G)-1:Math.floor(G)+1);return m(D)}}function i(x){return function(D){H.zoom(x);return m(D)}}function n(){this.setAttribute("class","active")}function o(){this.removeAttribute("class")}function m(x){x.stopPropagation();x.preventDefault();return false}function j(x){var D=Math.SQRT1_2*k,G=k*0.7,J=k*0.2,N=t.svg("g"),P=N.appendChild(t.svg("path")),Q=N.appendChild(t.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d",
+"M0,0L"+D+","+D+"A"+k+","+k+" 0 0,1 "+-D+","+D+"Z");Q.setAttribute("class","chevron");Q.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));Q.setAttribute("pointer-events","none");N.addEventListener("mousedown",d,false);N.addEventListener("mouseover",a(x),false);N.addEventListener("mouseout",a(null),false);N.addEventListener("dblclick",m,false);return N}function u(x){var D=k*0.4,G=D/2,J=t.svg("g"),N=J.appendChild(t.svg("path")),P=J.appendChild(t.svg("path")),Q=J.appendChild(t.svg("path")),
+X=J.appendChild(t.svg("path"));N.setAttribute("class","back");N.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",N.getAttribute("d"));Q.setAttribute("class","chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(x>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",N.getAttribute("d"));J.addEventListener("mousedown",f(x),false);J.addEventListener("mouseover",n,false);J.addEventListener("mouseout",
+o,false);J.addEventListener("dblclick",m,false);return J}function y(x){var D=k*0.2,G=k*0.4,J=t.svg("g"),N=J.appendChild(t.svg("rect")),P=J.appendChild(t.svg("path"));N.setAttribute("pointer-events","all");N.setAttribute("fill","none");N.setAttribute("x",-G);N.setAttribute("y",-0.75*G);N.setAttribute("width",2*G);N.setAttribute("height",1.5*G);P.setAttribute("class","chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",i(x),false);J.addEventListener("dblclick",m,false);return J}
+function A(){var x=k+6,D=x,G=H.size();switch(r){case "top-left":break;case "top-right":x=G.x-x;break;case "bottom-left":D=G.y-D;break;case "bottom-right":x=G.x-x;D=G.y-D;break}x="translate("+x+","+D+")";M&&M.setAttribute("transform",x);v&&v.setAttribute("transform",x);for(var J in K)J==H.zoom()?K[J].setAttribute("class","active"):K[J].removeAttribute("class")}function C(){for(;B.lastChild;)B.removeChild(B.lastChild);B.appendChild(O);if(L!="none"){M=B.appendChild(t.svg("g"));M.setAttribute("class",
+"pan");var x=M.appendChild(t.svg("circle"));x.setAttribute("class","back");x.setAttribute("r",k);M.appendChild(j({x:0,y:-q})).setAttribute("transform","rotate(0)");M.appendChild(j({x:q,y:0})).setAttribute("transform","rotate(90)");M.appendChild(j({x:0,y:q})).setAttribute("transform","rotate(180)");M.appendChild(j({x:-q,y:0})).setAttribute("transform","rotate(270)");x=M.appendChild(t.svg("circle"));x.setAttribute("fill","none");x.setAttribute("class","fore");x.setAttribute("r",k)}else M=null;if(z!=
+"none"){v=B.appendChild(t.svg("g"));v.setAttribute("class","zoom");x=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(x=0;D<=H.zoomRange()[1];D++,x++)(K[D]=v.appendChild(y(D))).setAttribute("transform","translate(0,"+-(x+0.75)*k*0.4+")")}D=L=="none"?0.4:2;v.setAttribute("transform","translate(0,"+k*(/^top-/.test(r)?D+(x+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(x+0.5)*k*0.4+")");v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E=
+{},B=t.svg("g"),K={},k=30,q=16,w=0,e=250,s=50,r="top-left",z="small",v,L="small",I,R,M,F,O=t.svg("rect"),H,T,U;B.setAttribute("class","compass");O.setAttribute("class","back fore");O.setAttribute("pointer-events","none");O.setAttribute("display","none");E.radius=function(x){if(!arguments.length)return k;k=x;H&&C();return E};E.speed=function(x){if(!arguments.length)return k;q=x;return E};E.position=function(x){if(!arguments.length)return r;r=x;H&&C();return E};E.pan=function(x){if(!arguments.length)return L;
+L=x;H&&C();return E};E.zoom=function(x){if(!arguments.length)return z;z=x;H&&C();return E};E.map=function(x){if(!arguments.length)return H;if(H){T.removeEventListener("mousedown",c,false);T.removeChild(B);T=null;U.removeEventListener("mousemove",l,false);U.removeEventListener("mouseup",h,false);U=null;H.off("move",A).off("resize",A)}if(H=x){T=H.container();T.appendChild(B);T.addEventListener("mousedown",c,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",l,false);U.addEventListener("mouseup",
+h,false);H.on("move",A).on("resize",A);C()}return E};return E};t.grid=function(){function d(){var h=l.firstChild,a=c.size(),f=c.pointLocation(Y);c.pointLocation(a);var i=Math.pow(2,4-Math.round(c.zoom()));f.lat=Math.floor(f.lat/i)*i;f.lon=Math.ceil(f.lon/i)*i;for(var n;(n=c.locationPoint(f).x)<=a.x;f.lon+=i){h||(h=l.appendChild(t.svg("line")));h.setAttribute("x1",n);h.setAttribute("x2",n);h.setAttribute("y1",0);h.setAttribute("y2",a.y);h=h.nextSibling}for(;(n=c.locationPoint(f).y)<=a.y;f.lat-=i){h||
+(h=l.appendChild(t.svg("line")));h.setAttribute("y1",n);h.setAttribute("y2",n);h.setAttribute("x1",0);h.setAttribute("x2",a.x);h=h.nextSibling}for(;h;){a=h.nextSibling;l.removeChild(h);h=a}}var g={},c,l=t.svg("g");l.setAttribute("class","grid");g.map=function(h){if(!arguments.length)return c;if(c){l.parentNode.removeChild(l);c.off("move",d).off("resize",d)}if(c=h){c.on("move",d).on("resize",d);c.container().appendChild(l);c.dispatch({type:"move"})}return g};return g};t.stylist=function(){function d(h){var a=
+h.features.length,f=g.length,i=c.length,n,o,m,j,u,y;for(u=0;u