Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Touch support!

This adds basic touch support, including single touch (pan) and double touch
(pan and zoom). In a future change, I'd also like to support rotation for double
touch, and double-tap to snap to the nearest integer zoom level. This commit
also includes a simple example that shows how to specify 2x resolution tiles for
the iPhone 4's retina display.
  • Loading branch information...
commit 2035dacf2cc3387873f004a2d70cf3e1475e14fd 1 parent b756f5a
Mike Bostock mbostock authored
1  Makefile
View
@@ -17,6 +17,7 @@ JS_FILES = \
src/Wheel.js \
src/Arrow.js \
src/Hash.js \
+ src/Touch.js \
src/Interact.js \
src/Compass.js \
src/Grid.js \
21 examples/iphone4/iphone4.html
View
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
+ <script type="text/javascript" src="../../polymaps.js"></script>
+ <style type="text/css">
+
+@import url("../example.css");
+
+ </style>
+ </head>
+ <body id="map">
+ <script type="text/javascript" src="iphone4.js"></script>
+ <span id="copy">
+ &copy; 2011
+ <a href="http://www.cloudmade.com/">CloudMade</a>,
+ <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors,
+ <a href="http://creativecommons.org/licenses/by-sa/2.0/">CCBYSA</a>.
+ </span>
+ </body>
+</html>
15 examples/iphone4/iphone4.js
View
@@ -0,0 +1,15 @@
+var po = org.polymaps;
+
+var map = po.map()
+ .container(document.getElementById("map").appendChild(po.svg("svg")))
+ .add(po.interact()); // built-in touch support
+
+map.add(po.image()
+ .url(po.url("http://{S}tile.cloudmade.com"
+ + "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register
+ + "/998/256/{Z}/{X}/{Y}.png")
+ .repeat(false)
+ .hosts(["a.", "b.", "c.", ""]))
+ .zoom(function(z) { return z + 1; })); // use 2x resolution tiles
+
+// no compass! pinch-to-zoom ftw
72 polymaps.js
View
@@ -1840,18 +1840,90 @@ po.hash = function() {
return hash;
};
+po.touch = function() {
+ var touch = {},
+ map,
+ container,
+ locations = {}; // touch identifier -> location
+
+ window.addEventListener("touchmove", touchmove, false);
+ window.addEventListener("touchend", touchend, false);
+
+ function touchstart(e) {
+ var i = -1,
+ n = e.touches.length,
+ t;
+ while (++i < n) {
+ t = e.touches[i];
+ locations[t.identifier] = map.pointLocation(map.mouse(t));
+ }
+ e.preventDefault();
+ }
+
+ function touchmove(e) {
+ switch (e.touches.length) {
+ case 1: {
+ var t0 = e.touches[0];
+ map.zoomBy(0, map.mouse(t0), locations[t0.identifier]);
+ break;
+ }
+ case 2: { // TODO rotation!
+ var t0 = e.touches[0],
+ t1 = e.touches[1],
+ p0 = map.mouse(t0),
+ p1 = map.mouse(t1),
+ p2 = {x: (p0.x + p1.x) / 2, y: (p0.y + p1.y) / 2}, // center point
+ c0 = po.map.locationCoordinate(locations[t0.identifier]),
+ c1 = po.map.locationCoordinate(locations[t1.identifier]),
+ c2 = {row: (c0.row + c1.row) / 2, column: (c0.column + c1.column) / 2, zoom: 0},
+ l2 = po.map.coordinateLocation(c2), // center location
+ px = p0.x - p1.x,
+ py = p0.y - p1.y,
+ dp = Math.sqrt(px * px + py * py) / 256,
+ cx = c0.column - c1.column,
+ cy = c0.row - c1.row,
+ dc = Math.sqrt(cx * cx + cy * cy),
+ z2 = Math.log(dp / dc) / Math.log(2); // zoom level
+ map.zoomBy(z2 - map.zoom(), p2, l2);
+ break;
+ }
+ }
+ e.preventDefault();
+ }
+
+ function touchend(e) {
+ e.preventDefault();
+ }
+
+ touch.map = function(x) {
+ if (!arguments.length) return map;
+ if (map) {
+ container.removeEventListener("touchstart", touchstart, false);
+ container = null;
+ }
+ if (map = x) {
+ container = map.container();
+ container.addEventListener("touchstart", touchstart, false);
+ }
+ return touch;
+ };
+
+ return touch;
+};
// Default map controls.
po.interact = function() {
var interact = {},
drag = po.drag(),
wheel = po.wheel(),
dblclick = po.dblclick(),
+ touch = po.touch(),
arrow = po.arrow();
interact.map = function(x) {
drag.map(x);
wheel.map(x);
dblclick.map(x);
+ touch.map(x);
arrow.map(x);
return interact;
};
126 polymaps.min.js
View
@@ -1,63 +1,65 @@
if(!org)var org={};if(!org.polymaps)org.polymaps={};
-(function(t){function fa(d){var h=d.indexOf(":");return h<0?d:{space:t.ns[d.substring(0,h)],local:d.substring(h+1)}}function S(){for(var d=0;d<S.maps.length;d++)S.maps[d].resize()}function V(d){return 360/Math.PI*Math.atan(Math.exp(d*Math.PI/180))-90}function W(d){return 180/Math.PI*Math.log(Math.tan(Math.PI/4+d*Math.PI/360))}function Z(d,h){if(d.row>h.row){var c=d;d=h;h=c}return{x0:d.column,y0:d.row,x1:h.column,y1:h.row,dx:h.column-d.column,dy:h.row-d.row}}function ca(d,h,c,m,f){c=Math.max(c,Math.floor(h.y0));
-m=Math.min(m,Math.ceil(h.y1));if(d.x0==h.x0&&d.y0==h.y0?d.x0+h.dy/d.dy*d.dx<h.x1:d.x1-h.dy/d.dy*d.dx<h.x0){var a=d;d=h;h=a}a=d.dx/d.dy;var g=h.dx/h.dy,k=d.dx>0,o=h.dx<0;for(c=c;c<m;c++){var q=a*Math.max(0,Math.min(d.dy,c+k-d.y0))+d.x0;f(Math.floor(g*Math.max(0,Math.min(h.dy,c+o-h.y0))+h.x0),Math.ceil(q),c)}}function da(d,h,c,m,f,a){var g=Z(d,h);h=Z(h,c);d=Z(c,d);if(g.dy>h.dy){c=g;g=h;h=c}if(g.dy>d.dy){c=g;g=d;d=c}if(h.dy>d.dy){c=h;h=d;d=c}g.dy&&ca(d,g,m,f,a);h.dy&&ca(d,h,m,f,a)}t.version="2.4.0+1";
-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,h,c,m,f,a){var g={},k,o,q;if(!arguments.length){d=1;h=f=c=0;m=1;a=0}g.zoomFraction=function(l){if(!arguments.length)return o;o=l;k=Math.floor(o+Math.log(Math.sqrt(d*d+h*h+c*c+m*m))/Math.log(2));q=Math.pow(2,-k);return g};g.apply=function(l){var i=Math.pow(2,-l.zoom),
-u=Math.pow(2,l.zoom-k);return{column:(d*l.column*i+c*l.row*i+f)*u,row:(h*l.column*i+m*l.row*i+a)*u,zoom:l.zoom-k}};g.unapply=function(l){var i=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+k);return{column:(l.column*i*m-l.row*i*c-f*m+a*c)/(d*m-h*c)*u,row:(l.column*i*h-l.row*i*d-f*h+a*d)/(c*h-m*d)*u,zoom:l.zoom+k}};g.toString=function(){return"matrix("+[d*q,h*q,c*q,m*q].join(" ")+" 0 0)"};return g.zoomFraction(0)};t.cache=function(d,h){function c(i){l--;h&&h(i);delete g[i.key];if(i.next)i.next.prev=i.prev;
-else if(o=i.prev)o.next=null;if(i.prev)i.prev.next=i.next;else if(k=i.next)k.prev=null}function m(){for(var i=o;l>q;i=i.prev){if(!i)break;i.lock||c(i)}}var f={},a={},g={},k=null,o=null,q=64,l=0;f.peek=function(i){return g[[i.zoom,i.column,i.row].join("/")]};f.load=function(i,u){var x=[i.zoom,i.column,i.row].join("/"),A=g[x];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=k;k=k.prev=A}A.lock=1;return a[x]=A}A={key:x,column:i.column,row:i.row,zoom:i.zoom,next:k,
-prev:null,lock:1};d.call(null,A,u);a[x]=g[x]=A;if(k)k.prev=A;else o=A;k=A;l++;return A};f.unload=function(i){if(!(i in a))return false;var u=a[i];u.lock=0;delete a[i];u.request&&u.request.abort(false)&&c(u);return u};f.locks=function(){return a};f.size=function(i){if(!arguments.length)return q;q=i;m();return f};f.flush=function(){m();return f};f.clear=function(){for(var i in g){var u=g[i];u.request&&u.request.abort(false);h&&h(g[i]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
-{};g={};k=o=null;l=0;return f};return f};t.url=function(d){function h(f){var a=f.zoom<0?1:1<<f.zoom,g=f.column;if(m){g=f.column%a;if(g<0)g+=a}else if(g<0||g>=a)return null;return d.replace(/{(.)}/g,function(k,o){switch(o){case "S":return c[(Math.abs(f.zoom)+f.row+g)%c.length];case "Z":return f.zoom;case "X":return g;case "Y":return f.row;case "B":var q=t.map.coordinateLocation({row:f.row,column:g,zoom:f.zoom}),l=t.map.coordinateLocation({row:f.row+1,column:g+1,zoom:f.zoom}),i=Math.ceil(Math.log(f.zoom)/
-Math.LN2);return l.lat.toFixed(i)+","+q.lon.toFixed(i)+","+q.lat.toFixed(i)+","+l.lon.toFixed(i)}return o})}var c=[],m=true;h.template=function(f){if(!arguments.length)return d;d=f;return h};h.hosts=function(f){if(!arguments.length)return c;c=f;return h};h.repeat=function(f){if(!arguments.length)return m;m=f;return h};return h};t.dispatch=function(d){var h={};d.on=function(c,m){for(var f=h[c]||(h[c]=[]),a=0;a<f.length;a++)if(f[a].handler==m)return d;f.push({handler:m,on:true});return d};d.off=function(c,
-m){var f=h[c];if(f)for(var a=0;a<f.length;a++){var g=f[a];if(g.handler==m){g.on=false;f.splice(a,1);break}}return d};return function(c){var m=h[c.type];if(m){m=m.slice();for(var f=0;f<m.length;f++){var a=m[f];a.on&&a.handler.call(d,c)}}}};t.queue=function(){function d(){if(!(f>=a||!m.length)){f++;m.pop()()}}function h(g){for(var k=0;k<m.length;k++)if(m[k]==g){m.splice(k,1);return true}return false}function c(g,k,o){function q(){l=new XMLHttpRequest;o&&l.overrideMimeType(o);l.open("GET",g,true);l.onreadystatechange=
-function(){if(l.readyState==4){f--;l.status<300&&k(l);d()}};l.send(null)}var l;m.push(q);d();return{abort:function(i){if(h(q))return true;if(i&&l){l.abort();return true}return false}}}var m=[],f=0,a=6;return{text:function(g,k,o){return c(g,function(q){q.responseText&&k(q.responseText)},o)},xml:function(g,k){return c(g,function(o){o.responseXML&&k(o.responseXML)},"application/xml")},json:function(g,k){return c(g,function(o){o.responseText&&k(JSON.parse(o.responseText))},"application/json")},image:function(g,
-k,o){function q(){l=document.createElement("img");l.onerror=function(){f--;d()};l.onload=function(){f--;o(l);d()};l.src=k;g.setAttributeNS(t.ns.xlink,"href",k)}var l;m.push(q);d();return{abort:function(i){if(h(q))return true;if(i&&l){l.src="about:";return true}return false}}}}}();t.map=function(){function d(){if(u)if(q<u[0])q=u[0];else if(q>u[1])q=u[1];l=q-(q=Math.round(q));i=Math.pow(2,l)}function h(){if(n){var e=45/Math.pow(2,q+l-3),s=Math.max(Math.abs(C*g.x+A*g.y),Math.abs(B*g.x+E*g.y)),r=V(K-
-s*e/k.y);s=V(j+s*e/k.y);o.lat=Math.max(r,Math.min(s,o.lat));r=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-r*e/k.x,Math.min(n[1].lon+r*e/k.x,o.lon))}}var c={},m,f,a=Y,g=Y,k={x:256,y:256},o={lat:37.76487,lon:-122.41948},q=12,l=0,i=1,u=[1,18],x=0,A=1,C=0,E=1,B=0,K=-180,j=180,n=[{lat:V(K),lon:-Infinity},{lat:V(j),lon:Infinity}];c.locationCoordinate=function(e){e=t.map.locationCoordinate(e);var s=Math.pow(2,q);e.column*=s;e.row*=s;e.zoom+=q;return e};c.coordinateLocation=
-t.map.coordinateLocation;c.coordinatePoint=function(e,s){var r=Math.pow(2,q-s.zoom),z=Math.pow(2,q-e.zoom),v=(s.column*r-e.column*z)*k.x*i;r=(s.row*r-e.row*z)*k.y*i;return{x:g.x+A*v-C*r,y:g.y+C*v+A*r}};c.pointCoordinate=function(e,s){var r=Math.pow(2,q-e.zoom),z=(s.x-g.x)/i,v=(s.y-g.y)/i;return{column:e.column*r+(E*z-B*v)/k.x,row:e.row*r+(B*z+E*v)/k.y,zoom:q}};c.locationPoint=function(e){var s=Math.pow(2,q+l-3)/45,r=(e.lon-o.lon)*s*k.x;e=(W(o.lat)-W(e.lat))*s*k.y;return{x:g.x+A*r-C*e,y:g.y+C*r+A*
-e}};c.pointLocation=function(e){var s=45/Math.pow(2,q+l-3),r=(e.x-g.x)*s;e=(e.y-g.y)*s;return{lon:o.lon+(E*r-B*e)/k.x,lat:V(W(o.lat)-(B*r+E*e)/k.y)}};var w=t.svg("rect");w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(e){if(!arguments.length)return m;m=e;m.setAttribute("class","map");m.appendChild(w);return c.resize()};c.focusableParent=function(){for(var e=m;e;e=e.parentNode)if(e.tabIndex>=0)return e;return window};c.mouse=function(e){var s=(m.ownerSVGElement||
-m).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(m.getScreenCTM().inverse())};c.size=function(e){if(!arguments.length)return a;f=e;return c.resize()};c.resize=function(){if(f){a=f;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};h();c.dispatch({type:"resize"});return c};c.tileSize=function(e){if(!arguments.length)return k;k=e;c.dispatch({type:"move"});return c};c.center=function(e){if(!arguments.length)return o;o=e;h();c.dispatch({type:"move"});return c};c.panBy=function(e){var s=45/Math.pow(2,q+l-3),r=e.x*s;e=e.y*s;return c.center({lon:o.lon+(B*e-E*r)/k.x,lat:V(W(o.lat)+(B*r+E*e)/k.y)})};c.centerRange=
-function(e){if(!arguments.length)return n;if(n=e){K=n[0].lat>-90?W(n[0].lat):-Infinity;j=n[0].lat<90?W(n[1].lat):Infinity}else{K=-Infinity;j=Infinity}h();c.dispatch({type:"move"});return c};c.zoom=function(e){if(!arguments.length)return q+l;q=e;d();return c.center(o)};c.zoomBy=function(e,s,r){if(arguments.length<2)return c.zoom(q+l+e);if(arguments.length<3)r=c.pointLocation(s);q=q+l+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(q+l)};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});q=q+l-Math.log(z)/Math.log(2);d();return c.center(s)};c.angle=function(e){if(!arguments.length)return x;x=e;A=Math.cos(x);C=Math.sin(x);E=Math.cos(-x);B=Math.sin(-x);h();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 h=0;h<S.maps.length;h++)if(S.maps[h]==d)return;S.maps.push(d)};S.remove=function(d){for(var h=0;h<S.maps.length;h++)if(S.maps[h]==d){S.maps.splice(h,1);return}};window.addEventListener("resize",S,false);t.map.locationCoordinate=function(d){var h=1/360;return{column:(d.lon+180)*h,row:(180-W(d.lat))*h,zoom:0}};t.map.coordinateLocation=function(d){var h=45/Math.pow(2,d.zoom-3);
-return{lon:h*d.column-180,lat:V(180-h*d.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;t.layer=function(d,h){function c(B){for(var K=C[0].nextSibling;A<B;A++){u.insertBefore(C[-4],K);u.insertBefore(C[2],K);u.insertBefore(C[1],K);for(var j=C[-4],n=-4;n<2;)C[n]=C[++n];C[n]=j}}function m(B){for(var K=C[0].nextSibling;A>B;A--){u.insertBefore(C[-1],K);u.insertBefore(C[2],C[-4]);for(var j=C[2],n=2;n>-4;)C[n]=C[--n];C[n]=j}}function f(){function B(N){var H=N.zoom,T=H<0?1:1<<H,U=N.column%T,y=N.row;
-if(U<0)U+=T;return{locationPoint:function(D){D=t.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:r.x*(G*D.column-U),y:r.y*(G*D.row-y)}}}}function K(N,H,T){var U=I.zoom,y=2-R,D=4+R;for(N=N;N<H;N++){var G=g.load({column:N,row:T,zoom:U},B);if(!G.ready&&!(G.key in O)){G.proxyRefs={};for(var J,M,P,Q=1;Q<=y;Q++){M=true;for(var X=0,ea=1<<Q;X<=ea;X++)for(var aa=0;aa<=ea;aa++)if((P=g.peek(J={column:(N<<Q)+aa,row:(T<<Q)+X,zoom:U+Q}))&&P.ready){O[P.key]=g.load(J);P.proxyCount++;G.proxyRefs[P.key]=
-P}else M=false;if(M)break}if(!M)for(Q=1;Q<=D;Q++)if((P=g.peek(J={column:N>>Q,row:T>>Q,zoom:U-Q}))&&P.ready){O[P.key]=g.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}O[G.key]=G}}var j=a.map(),n=j.zoom(),w=n-(n=Math.round(n)),e=j.size(),s=j.angle(),r=j.tileSize(),z=j.locationCoordinate(j.center());if(A!=n){if(A<n)c(n);else if(A>n)m(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("+e.x/2+","+e.y/2+")"+(s?"rotate("+s/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(x?x.zoomFraction(w):""));var I=j.pointCoordinate(z,Y);v=j.pointCoordinate(z,{x:e.x,y:0});n=j.pointCoordinate(z,e);j=j.pointCoordinate(z,{x:0,y:e.y});if(!w&&!s&&!x){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(x){I=x.unapply(I);v=x.unapply(v);n=x.unapply(n);j=x.unapply(j);z=x.unapply(z)}var R=q?q(I.zoom)-I.zoom:0;if(R){e=Math.pow(2,R);I.column*=
-e;I.row*=e;v.column*=e;v.row*=e;n.column*=e;n.row*=e;j.column*=e;j.row*=e;I.zoom=v.zoom=n.zoom=j.zoom+=R}w=g.locks();var O={};for(var F in w)w[F].proxyCount=0;if(o&&R>-5&&R<3){s=I.zoom<0?1:1<<I.zoom;if(k){da(I,v,n,0,s,K);da(n,j,I,0,s,K)}else{e=Math.floor((I.column+n.column)/2);s=Math.max(0,Math.min(s-1,Math.floor((v.row+j.row)/2)));v=Math.min(4,I.zoom);e=e>>v<<v;s=s>>v<<v;K(e,e+1,s)}}for(F in O){v=O[F];e=Math.pow(2,v.level=v.zoom-z.zoom);v.element.setAttribute("transform","translate("+(v.x=r.x*(v.column-
-z.column*e))+","+(v.y=r.y*(v.row-z.row*e))+")")}for(F in w)if(!(F in O)){v=g.unload(F);v.element.parentNode.removeChild(v.element);delete v.proxyRefs}for(F in O){v=O[F];if(v.element.parentNode!=C[v.level]){C[v.level].appendChild(v.element);a.show&&a.show(v)}}g.flush();a.dispatch({type:"move"})}var a={},g=a.cache=t.cache(d,h).size(512),k=true,o=true,q,l,i,u=t.svg("g"),x,A,C={};u.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=u.appendChild(t.svg("g"));for(E=2;E>=1;E--)C[E]=u.appendChild(t.svg("g"));
-C[0]=u.appendChild(t.svg("g"));a.map=function(B){if(!arguments.length)return i;if(i){if(i==B){u.parentNode.appendChild(u);return a}i.off("move",f).off("resize",f);u.parentNode.removeChild(u)}if(i=B){i.container().appendChild(u);a.init&&a.init(u);i.on("move",f).on("resize",f);f()}return a};a.container=function(){return u};a.levels=function(){return C};a.id=function(B){if(!arguments.length)return l;l=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");i&&f();return a};a.transform=function(B){if(!arguments.length)return x;x=B;i&&f();return a};a.zoom=function(B){if(!arguments.length)return q;q=typeof B=="function"||B==null?B:function(){return B};i&&f();return a};a.tile=function(B){if(!arguments.length)return k;k=B;i&&f();return a};a.reload=function(){g.clear();i&&f();return a};a.dispatch=t.dispatch(a);a.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var j=B.tile.proxyRefs[K];--j.proxyCount<=
-0&&g.unload(K)&&j.element.parentNode.removeChild(j.element)}delete B.tile.proxyRefs}});return a};t.image=function(){var d=t.layer(function(c){var m=c.element=t.svg("image"),f=d.map().tileSize();m.setAttribute("preserveAspectRatio","none");m.setAttribute("width",f.x);m.setAttribute("height",f.y);if(typeof h=="function"){m.setAttribute("opacity",0);f=h(c);if(f!=null)c.request=t.queue.image(m,f,function(a){delete c.request;c.ready=true;c.img=a;m.removeAttribute("opacity");d.dispatch({type:"load",tile:c})});
-else{c.ready=true;d.dispatch({type:"load",tile:c})}}else{c.ready=true;h!=null&&m.setAttributeNS(t.ns.xlink,"href",h);d.dispatch({type:"load",tile:c})}},function(c){c.request&&c.request.abort(true)}),h;d.url=function(c){if(!arguments.length)return h;h=typeof c=="string"&&/{.}/.test(c)?t.url(c):c;return d.reload()};return d};t.geoJson=function(d){function h(j){var n={lat:0,lon:0};return function(w){n.lat=w[1];n.lon=w[0];var e=j(n);w.x=e.x;w.y=e.y;return e}}function c(j,n){return j&&j.type in C&&C[j.type](j,
-n)}function m(j,n,w){return j.type in E&&E[j.type](j,n,w)}function f(){var j=a.map().zoom(),n=a.cache.locks(),w,e,s,r,z,v,L;if(x=="fixed")for(w in n){if((e=n[w]).scale!=j){L="scale("+Math.pow(2,e.zoom-j)+")";r=-1;for(z=(s=e.features).length;++r<z;)m((v=s[r]).data.geometry,v.element,L);e.scale=j}}else for(w in n){r=-1;for(z=(s=(e=n[w]).features).length;++r<z;)m((v=s[r]).data.geometry,v.element,"");delete e.scale}}var a=t.layer(function(j,n){function w(s){var r=[];if(s.next)j.request=d(s.next.href,
-w);switch(s.type){case "FeatureCollection":for(var z=0;z<s.features.length;z++){var v=s.features[z],L=c(v.geometry,n);L&&r.push({element:e.appendChild(L),data:v})}break;case "Feature":(L=c(s.geometry,n))&&r.push({element:e.appendChild(L),data:s});break;default:(L=c(s,n))&&r.push({element:e.appendChild(L),data:{type:"Feature",geometry:s}});break}j.ready=true;r.push.apply(j.features,r);a.dispatch({type:"load",tile:j,features:r})}var e=j.element=t.svg("g");j.features=[];n=h(n(j).locationPoint);if(k!=
-null)j.request=d(typeof k=="function"?k(j):k,w);else w({type:"FeatureCollection",features:A||[]})},function(j){j.request&&j.request.abort(true)}),g=a.container(),k,o=true,q="org.polymaps."+t.id(),l="url(#"+q+")",i=g.insertBefore(t.svg("clipPath"),g.firstChild),u=i.appendChild(t.svg("rect")),x="auto",A;g.setAttribute("fill-rule","evenodd");i.setAttribute("id",q);if(!arguments.length)d=t.queue.json;var C={Point:function(j,n){var w=n(j.coordinates),e=t.svg("circle");e.setAttribute("r",4.5);e.setAttribute("transform",
-"translate("+w.x+","+w.y+")");return e},MultiPoint:function(j,n){for(var w=t.svg("g"),e=j.coordinates,s,r,z=-1,v=e.length;++z<v;){r=w.appendChild(t.svg("circle"));r.setAttribute("r",4.5);r.setAttribute("transform","translate("+(s=n(e[z])).x+","+s.y+")")}return w},LineString:function(j,n){for(var w=t.svg("path"),e=["M"],s=j.coordinates,r,z=-1,v=s.length;++z<v;)e.push((r=n(s[z])).x,",",r.y,"L");e.pop();if(e.length){w.setAttribute("d",e.join(""));return w}},MultiLineString:function(j,n){for(var w=t.svg("path"),
-e=[],s=j.coordinates,r,z=-1,v,L=s.length,I;++z<L;){r=s[z];v=-1;I=r.length;for(e.push("M");++v<I;)e.push((p=n(r[v])).x,",",p.y,"L");e.pop()}if(e.length){w.setAttribute("d",e.join(""));return w}},Polygon:function(j,n){for(var w=t.svg("path"),e=[],s=j.coordinates,r,z=-1,v,L=s.length,I;++z<L;){r=s[z];v=-1;I=r.length-1;for(e.push("M");++v<I;)e.push((p=n(r[v])).x,",",p.y,"L");e[e.length-1]="Z"}if(e.length){w.setAttribute("d",e.join(""));return w}},MultiPolygon:function(j,n){for(var w=t.svg("path"),e=[],
-s=j.coordinates,r,z,v=-1,L,I,R=s.length,O,F;++v<R;){r=s[v];L=-1;for(O=r.length;++L<O;){z=r[L];I=-1;F=z.length-1;for(e.push("M");++I<F;)e.push((p=n(z[I])).x,",",p.y,"L");e[e.length-1]="Z"}}if(e.length){w.setAttribute("d",e.join(""));return w}},GeometryCollection:function(j,n){for(var w=t.svg("g"),e=-1,s=j.geometries,r=s.length,z;++e<r;)(z=c(s[e],n))&&w.appendChild(z);return w}},E={Point:function(j,n,w){j=j.coordinates;n.setAttribute("transform","translate("+j.x+","+j.y+")"+w)},MultiPoint:function(j,
-n,w){j=j.coordinates;var e=-1,s=r.length;n=n.firstChild;for(var r;++e<s;){r=j[e];n.setAttribute("transform","translate("+r.x+","+r.y+")"+w);n=n.nextSibling}}};a.url=function(j){if(!arguments.length)return k;k=typeof j=="string"&&/{.}/.test(j)?t.url(j):j;if(k!=null)A=null;typeof k=="string"&&a.tile(false);return a.reload()};a.features=function(j){if(!arguments.length)return A;if(A=j){k=null;a.tile(false)}return a.reload()};a.clip=function(j){if(!arguments.length)return o;o&&g.removeChild(i);if(o=j)g.insertBefore(i,
-g.firstChild);var n=a.cache.locks();for(var w in n)o?n[w].element.setAttribute("clip-path",l):n[w].element.removeAttribute("clip-path");return a};var B=a.tile;a.tile=function(j){arguments.length&&!j&&a.clip(j);return B.apply(a,arguments)};var K=a.map;a.map=function(j){if(j&&u){var n=j.tileSize();u.setAttribute("width",n.x);u.setAttribute("height",n.y)}return K.apply(a,arguments)};a.scale=function(j){if(!arguments.length)return x;(x=j)?a.on("move",f):a.off("move",f);a.map()&&f();return a};a.show=function(j){o?
-j.element.setAttribute("clip-path",l):j.element.removeAttribute("clip-path");a.dispatch({type:"show",tile:j,features:j.features});return a};a.reshow=function(){var j=a.cache.locks();for(var n in j)a.show(j[n]);return a};return a};t.dblclick=function(){function d(a){var g=m.zoom();g=a.shiftKey?Math.ceil(g)-g-1:1-g+Math.floor(g);c==="mouse"?m.zoomBy(g,m.mouse(a)):m.zoomBy(g)}var h={},c="mouse",m,f;h.zoom=function(a){if(!arguments.length)return c;c=a;return h};h.map=function(a){if(!arguments.length)return m;
-if(m){f.removeEventListener("dblclick",d,false);f=null}if(m=a){f=m.container();f.addEventListener("dblclick",d,false)}return h};return h};t.drag=function(){function d(g){if(!g.shiftKey){a={x:g.clientX,y:g.clientY};m.focusableParent().focus();g.preventDefault();document.body.style.setProperty("cursor","move",null)}}function h(g){if(a){m.panBy({x:g.clientX-a.x,y:g.clientY-a.y});a.x=g.clientX;a.y=g.clientY}}var c={},m,f,a;c.map=function(g){if(!arguments.length)return m;if(m){f.removeEventListener("mousedown",
-d,false);f=null}if(m=g){f=m.container();f.addEventListener("mousedown",d,false)}return c};window.addEventListener("mousemove",h,false);window.addEventListener("mouseup",function(g){if(a){h(g);a=null;document.body.style.removeProperty("cursor")}},false);return c};t.wheel=function(){function d(){k=null}function h(l){var i=(l.wheelDelta/120||-l.detail)*0.1,u;if(ba<0){u=Date.now();var x=u-f;if(x>9&&Math.abs(l.wheelDelta)/x>=50)ba=1;f=u}if(ba==1)i*=0.03;if(!a&&i){u=Date.now();if(u-m>200){i=i>0?+1:-1;m=
-u}else i=0}if(i)switch(g){case "mouse":u=o.mouse(l);k||(k=o.pointLocation(u));o.off("move",d).zoomBy(i,u,k).on("move",d);break;case "location":o.zoomBy(i,o.locationPoint(k),k);break;default:o.zoomBy(i);break}l.preventDefault();return false}var c={},m=0,f=0,a=true,g="mouse",k,o,q;c.smooth=function(l){if(!arguments.length)return a;a=l;return c};c.zoom=function(l,i){if(!arguments.length)return g;g=l;k=i;if(o)g=="mouse"?o.on("move",d):o.off("move",d);return c};c.map=function(l){if(!arguments.length)return o;
-if(o){q.removeEventListener("mousemove",d,false);q.removeEventListener("mousewheel",h,false);q.removeEventListener("DOMMouseScroll",h,false);q=null;o.off("move",d)}if(o=l){g=="mouse"&&o.on("move",d);q=o.container();q.addEventListener("mousemove",d,false);q.addEventListener("mousewheel",h,false);q.addEventListener("DOMMouseScroll",h,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;t.arrow=function(){function d(x){if(!(x.ctrlKey||x.altKey||x.metaKey)){var A=Date.now(),
-C=0,E=0;switch(x.keyCode){case 37:if(!a.left){g=A;a.left=1;a.right||(C=l)}break;case 39:if(!a.right){g=A;a.right=1;a.left||(C=-l)}break;case 38:if(!a.up){g=A;a.up=1;a.down||(E=l)}break;case 40:if(!a.down){g=A;a.down=1;a.up||(E=-l)}break;default:return}if(C||E)i.panBy({x:C,y:E});if(!k&&a.left|a.right|a.up|a.down)k=setInterval(m,q);x.preventDefault()}}function h(x){g=Date.now();switch(x.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(k&&
-!(a.left|a.right|a.up|a.down))k=clearInterval(k);x.preventDefault()}function c(x){switch(x.charCode){case 45:case 95:i.zoom(Math.ceil(i.zoom())-1);break;case 43:case 61:i.zoom(Math.floor(i.zoom())+1);break;default:return}x.preventDefault()}function m(){if(i)if(!(Date.now()<g+o)){var x=(a.left-a.right)*l,A=(a.up-a.down)*l;if(x||A)i.panBy({x:x,y:A})}}var f={},a={left:0,right:0,up:0,down:0},g=0,k,o=250,q=50,l=16,i,u;f.map=function(x){if(!arguments.length)return i;if(i){u.removeEventListener("keypress",
-c,false);u.removeEventListener("keydown",d,false);u.removeEventListener("keyup",h,false);u=null}if(i=x){u=i.focusableParent();u.addEventListener("keypress",c,false);u.addEventListener("keydown",d,false);u.addEventListener("keyup",h,false)}return f};f.speed=function(x){if(!arguments.length)return l;l=x;return f};return f};t.hash=function(){function d(){var k=g(f);if(m!==k)location.replace(m=k)}function h(){if(location.hash!==m)if(a(f,(m=location.hash).substring(1)))d()}var c={},m,f,a=function(k,o){var q=
-o.split("/").map(Number);if(q.length<3||q.some(isNaN))return true;else{var l=k.size();k.zoomBy(q[0]-k.zoom(),{x:l.x/2,y:l.y/2},{lat:Math.min(89.99999999,Math.max(-89.99999999,q[1])),lon:q[2]})}},g=function(k){var o=k.center();k=k.zoom();var q=Math.max(0,Math.ceil(Math.log(k)/Math.LN2));return"#"+k.toFixed(2)+"/"+o.lat.toFixed(q)+"/"+o.lon.toFixed(q)};c.map=function(k){if(!arguments.length)return f;if(f){f.off("move",d);window.removeEventListener("hashchange",h,false)}if(f=k){f.on("move",d);window.addEventListener("hashchange",
-h,false);location.hash?h():d()}return c};c.parser=function(k){if(!arguments.length)return a;a=k;return c};c.formatter=function(k){if(!arguments.length)return g;g=k;return c};return c};t.interact=function(){var d={},h=t.drag(),c=t.wheel(),m=t.dblclick(),f=t.arrow();d.map=function(a){h.map(a);c.map(a);m.map(a);f.map(a);return d};return d};t.compass=function(){function d(y){B.setAttribute("class","compass active");I||(I=setInterval(h,s));R&&H.panBy(R);w=Date.now();return l(y)}function h(){R&&Date.now()>
-w+e&&H.panBy(R)}function c(y){if(y.shiftKey){F={x0:H.mouse(y)};H.focusableParent().focus();return l(y)}}function m(y){if(F){F.x1=H.mouse(y);N.setAttribute("x",Math.min(F.x0.x,F.x1.x));N.setAttribute("y",Math.min(F.x0.y,F.x1.y));N.setAttribute("width",Math.abs(F.x0.x-F.x1.x));N.setAttribute("height",Math.abs(F.x0.y-F.x1.y));N.removeAttribute("display")}}function f(){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)})]);N.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function a(y){return function(){y?this.setAttribute("class","active"):this.removeAttribute("class");R=y}}function g(y){return function(D){B.setAttribute("class","compass active");var G=H.zoom();H.zoom(y<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function k(y){return function(D){H.zoom(y);return l(D)}}function o(){this.setAttribute("class","active")}function q(){this.removeAttribute("class")}
-function l(y){y.stopPropagation();y.preventDefault();return false}function i(y){var D=Math.SQRT1_2*j,G=j*0.7,J=j*0.2,M=t.svg("g"),P=M.appendChild(t.svg("path")),Q=M.appendChild(t.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d","M0,0L"+D+","+D+"A"+j+","+j+" 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");M.addEventListener("mousedown",
-d,false);M.addEventListener("mouseover",a(y),false);M.addEventListener("mouseout",a(null),false);M.addEventListener("dblclick",l,false);return M}function u(y){var D=j*0.4,G=D/2,J=t.svg("g"),M=J.appendChild(t.svg("path")),P=J.appendChild(t.svg("path")),Q=J.appendChild(t.svg("path")),X=J.appendChild(t.svg("path"));M.setAttribute("class","back");M.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",M.getAttribute("d"));Q.setAttribute("class",
-"chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(y>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",M.getAttribute("d"));J.addEventListener("mousedown",g(y),false);J.addEventListener("mouseover",o,false);J.addEventListener("mouseout",q,false);J.addEventListener("dblclick",l,false);return J}function x(y){var D=j*0.2,G=j*0.4,J=t.svg("g"),M=J.appendChild(t.svg("rect")),P=J.appendChild(t.svg("path"));M.setAttribute("pointer-events","all");M.setAttribute("fill",
-"none");M.setAttribute("x",-G);M.setAttribute("y",-0.75*G);M.setAttribute("width",2*G);M.setAttribute("height",1.5*G);P.setAttribute("class","chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",k(y),false);J.addEventListener("dblclick",l,false);return J}function A(){var y=j+6,D=y,G=H.size();switch(r){case "top-left":break;case "top-right":y=G.x-y;break;case "bottom-left":D=G.y-D;break;case "bottom-right":y=G.x-y;D=G.y-D;break}B.setAttribute("transform","translate("+y+","+D+
-")");N.setAttribute("transform","translate("+-y+","+-D+")");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(N);if(L!="none"){O=B.appendChild(t.svg("g"));O.setAttribute("class","pan");var y=O.appendChild(t.svg("circle"));y.setAttribute("class","back");y.setAttribute("r",j);O.appendChild(i({x:0,y:-n})).setAttribute("transform","rotate(0)");O.appendChild(i({x:n,y:0})).setAttribute("transform",
-"rotate(90)");O.appendChild(i({x:0,y:n})).setAttribute("transform","rotate(180)");O.appendChild(i({x:-n,y:0})).setAttribute("transform","rotate(270)");y=O.appendChild(t.svg("circle"));y.setAttribute("fill","none");y.setAttribute("class","fore");y.setAttribute("r",j)}else O=null;if(z!="none"){v=B.appendChild(t.svg("g"));v.setAttribute("class","zoom");y=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(y=0;D<=H.zoomRange()[1];D++,y++)(K[D]=v.appendChild(x(D))).setAttribute("transform","translate(0,"+
--(y+0.75)*j*0.4+")")}D=L=="none"?0.4:2;v.setAttribute("transform","translate(0,"+j*(/^top-/.test(r)?D+(y+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(y+0.5)*j*0.4+")");v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E={},B=t.svg("g"),K={},j=30,n=16,w=0,e=250,s=50,r="top-left",z="small",v,L="small",I,R,O,F,N=t.svg("rect"),H,T,U;B.setAttribute("class","compass");N.setAttribute("class","back fore");N.setAttribute("pointer-events","none");
-N.setAttribute("display","none");E.radius=function(y){if(!arguments.length)return j;j=y;H&&C();return E};E.speed=function(y){if(!arguments.length)return j;n=y;return E};E.position=function(y){if(!arguments.length)return r;r=y;H&&C();return E};E.pan=function(y){if(!arguments.length)return L;L=y;H&&C();return E};E.zoom=function(y){if(!arguments.length)return z;z=y;H&&C();return E};E.map=function(y){if(!arguments.length)return H;if(H){T.removeEventListener("mousedown",c,false);T.removeChild(B);T=null;
-U.removeEventListener("mousemove",m,false);U.removeEventListener("mouseup",f,false);U=null;H.off("move",A).off("resize",A)}if(H=y){T=H.container();T.appendChild(B);T.addEventListener("mousedown",c,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",m,false);U.addEventListener("mouseup",f,false);H.on("move",A).on("resize",A);C()}return E};return E};t.grid=function(){function d(){var f=m.firstChild,a=c.size(),g=c.pointLocation(Y);c.pointLocation(a);var k=Math.pow(2,4-Math.round(c.zoom()));
-g.lat=Math.floor(g.lat/k)*k;g.lon=Math.ceil(g.lon/k)*k;for(var o;(o=c.locationPoint(g).x)<=a.x;g.lon+=k){f||(f=m.appendChild(t.svg("line")));f.setAttribute("x1",o);f.setAttribute("x2",o);f.setAttribute("y1",0);f.setAttribute("y2",a.y);f=f.nextSibling}for(;(o=c.locationPoint(g).y)<=a.y;g.lat-=k){f||(f=m.appendChild(t.svg("line")));f.setAttribute("y1",o);f.setAttribute("y2",o);f.setAttribute("x1",0);f.setAttribute("x2",a.x);f=f.nextSibling}for(;f;){a=f.nextSibling;m.removeChild(f);f=a}}var h={},c,m=
-t.svg("g");m.setAttribute("class","grid");h.map=function(f){if(!arguments.length)return c;if(c){m.parentNode.removeChild(m);c.off("move",d).off("resize",d)}if(c=f){c.on("move",d).on("resize",d);c.container().appendChild(m);c.dispatch({type:"move"})}return h};return h};t.stylist=function(){function d(f){var a=f.features.length,g=h.length,k=c.length,o,q,l,i,u,x;for(u=0;u<a;++u)if(q=(o=f.features[u]).element){o=o.data;for(x=0;x<g;++x){i=(l=h[x]).value;if(typeof i==="function")i=i.call(null,o);i==null?
-l.name.local?q.removeAttributeNS(l.name.space,l.name.local):q.removeAttribute(l.name):l.name.local?q.setAttributeNS(l.name.space,l.name.local,i):q.setAttribute(l.name,i)}for(x=0;x<k;++x){i=(l=c[x]).value;if(typeof i==="function")i=i.call(null,o);i==null?q.style.removeProperty(l.name):q.style.setProperty(l.name,i,l.priority)}if(i=m){if(typeof i==="function")i=i.call(null,o);for(;q.lastChild;)q.removeChild(q.lastChild);i!=null&&q.appendChild(t.svg("title")).appendChild(document.createTextNode(i))}}}
-var h=[],c=[],m;d.attr=function(f,a){h.push({name:fa(f),value:a});return d};d.style=function(f,a,g){c.push({name:f,value:a,priority:arguments.length<3?null:g});return d};d.title=function(f){m=f;return d};return d}})(org.polymaps);
+(function(r){function fa(e){var h=e.indexOf(":");return h<0?e:{space:r.ns[e.substring(0,h)],local:e.substring(h+1)}}function S(){for(var e=0;e<S.maps.length;e++)S.maps[e].resize()}function V(e){return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function W(e){return 180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360))}function Z(e,h){if(e.row>h.row){var c=e;e=h;h=c}return{x0:e.column,y0:e.row,x1:h.column,y1:h.row,dx:h.column-e.column,dy:h.row-e.row}}function ca(e,h,c,l,f){c=Math.max(c,Math.floor(h.y0));
+l=Math.min(l,Math.ceil(h.y1));if(e.x0==h.x0&&e.y0==h.y0?e.x0+h.dy/e.dy*e.dx<h.x1:e.x1-h.dy/e.dy*e.dx<h.x0){var a=e;e=h;h=a}a=e.dx/e.dy;var d=h.dx/h.dy,k=e.dx>0,n=h.dx<0;for(c=c;c<l;c++){var o=a*Math.max(0,Math.min(e.dy,c+k-e.y0))+e.x0;f(Math.floor(d*Math.max(0,Math.min(h.dy,c+n-h.y0))+h.x0),Math.ceil(o),c)}}function da(e,h,c,l,f,a){var d=Z(e,h);h=Z(h,c);e=Z(c,e);if(d.dy>h.dy){c=d;d=h;h=c}if(d.dy>e.dy){c=d;d=e;e=c}if(h.dy>e.dy){c=h;h=e;e=c}d.dy&&ca(e,d,l,f,a);h.dy&&ca(e,h,l,f,a)}r.version="2.4.0+1";
+var Y={x:0,y:0};r.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};r.id=function(){var e=0;return function(){return++e}}();r.svg=function(e){return document.createElementNS(r.ns.svg,e)};r.transform=function(e,h,c,l,f,a){var d={},k,n,o;if(!arguments.length){e=1;h=f=c=0;l=1;a=0}d.zoomFraction=function(m){if(!arguments.length)return n;n=m;k=Math.floor(n+Math.log(Math.sqrt(e*e+h*h+c*c+l*l))/Math.log(2));o=Math.pow(2,-k);return d};d.apply=function(m){var i=Math.pow(2,-m.zoom),
+u=Math.pow(2,m.zoom-k);return{column:(e*m.column*i+c*m.row*i+f)*u,row:(h*m.column*i+l*m.row*i+a)*u,zoom:m.zoom-k}};d.unapply=function(m){var i=Math.pow(2,-m.zoom),u=Math.pow(2,m.zoom+k);return{column:(m.column*i*l-m.row*i*c-f*l+a*c)/(e*l-h*c)*u,row:(m.column*i*h-m.row*i*e-f*h+a*e)/(c*h-l*e)*u,zoom:m.zoom+k}};d.toString=function(){return"matrix("+[e*o,h*o,c*o,l*o].join(" ")+" 0 0)"};return d.zoomFraction(0)};r.cache=function(e,h){function c(i){m--;h&&h(i);delete d[i.key];if(i.next)i.next.prev=i.prev;
+else if(n=i.prev)n.next=null;if(i.prev)i.prev.next=i.next;else if(k=i.next)k.prev=null}function l(){for(var i=n;m>o;i=i.prev){if(!i)break;i.lock||c(i)}}var f={},a={},d={},k=null,n=null,o=64,m=0;f.peek=function(i){return d[[i.zoom,i.column,i.row].join("/")]};f.load=function(i,u){var x=[i.zoom,i.column,i.row].join("/"),A=d[x];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=k;k=k.prev=A}A.lock=1;return a[x]=A}A={key:x,column:i.column,row:i.row,zoom:i.zoom,next:k,
+prev:null,lock:1};e.call(null,A,u);a[x]=d[x]=A;if(k)k.prev=A;else n=A;k=A;m++;return A};f.unload=function(i){if(!(i in a))return false;var u=a[i];u.lock=0;delete a[i];u.request&&u.request.abort(false)&&c(u);return u};f.locks=function(){return a};f.size=function(i){if(!arguments.length)return o;o=i;l();return f};f.flush=function(){l();return f};f.clear=function(){for(var i in d){var u=d[i];u.request&&u.request.abort(false);h&&h(d[i]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
+{};d={};k=n=null;m=0;return f};return f};r.url=function(e){function h(f){var a=f.zoom<0?1:1<<f.zoom,d=f.column;if(l){d=f.column%a;if(d<0)d+=a}else if(d<0||d>=a)return null;return e.replace(/{(.)}/g,function(k,n){switch(n){case "S":return c[(Math.abs(f.zoom)+f.row+d)%c.length];case "Z":return f.zoom;case "X":return d;case "Y":return f.row;case "B":var o=r.map.coordinateLocation({row:f.row,column:d,zoom:f.zoom}),m=r.map.coordinateLocation({row:f.row+1,column:d+1,zoom:f.zoom}),i=Math.ceil(Math.log(f.zoom)/
+Math.LN2);return m.lat.toFixed(i)+","+o.lon.toFixed(i)+","+o.lat.toFixed(i)+","+m.lon.toFixed(i)}return n})}var c=[],l=true;h.template=function(f){if(!arguments.length)return e;e=f;return h};h.hosts=function(f){if(!arguments.length)return c;c=f;return h};h.repeat=function(f){if(!arguments.length)return l;l=f;return h};return h};r.dispatch=function(e){var h={};e.on=function(c,l){for(var f=h[c]||(h[c]=[]),a=0;a<f.length;a++)if(f[a].handler==l)return e;f.push({handler:l,on:true});return e};e.off=function(c,
+l){var f=h[c];if(f)for(var a=0;a<f.length;a++){var d=f[a];if(d.handler==l){d.on=false;f.splice(a,1);break}}return e};return function(c){var l=h[c.type];if(l){l=l.slice();for(var f=0;f<l.length;f++){var a=l[f];a.on&&a.handler.call(e,c)}}}};r.queue=function(){function e(){if(!(f>=a||!l.length)){f++;l.pop()()}}function h(d){for(var k=0;k<l.length;k++)if(l[k]==d){l.splice(k,1);return true}return false}function c(d,k,n){function o(){m=new XMLHttpRequest;n&&m.overrideMimeType(n);m.open("GET",d,true);m.onreadystatechange=
+function(){if(m.readyState==4){f--;m.status<300&&k(m);e()}};m.send(null)}var m;l.push(o);e();return{abort:function(i){if(h(o))return true;if(i&&m){m.abort();return true}return false}}}var l=[],f=0,a=6;return{text:function(d,k,n){return c(d,function(o){o.responseText&&k(o.responseText)},n)},xml:function(d,k){return c(d,function(n){n.responseXML&&k(n.responseXML)},"application/xml")},json:function(d,k){return c(d,function(n){n.responseText&&k(JSON.parse(n.responseText))},"application/json")},image:function(d,
+k,n){function o(){m=document.createElement("img");m.onerror=function(){f--;e()};m.onload=function(){f--;n(m);e()};m.src=k;d.setAttributeNS(r.ns.xlink,"href",k)}var m;l.push(o);e();return{abort:function(i){if(h(o))return true;if(i&&m){m.src="about:";return true}return false}}}}}();r.map=function(){function e(){if(u)if(o<u[0])o=u[0];else if(o>u[1])o=u[1];m=o-(o=Math.round(o));i=Math.pow(2,m)}function h(){if(q){var g=45/Math.pow(2,o+m-3),t=Math.max(Math.abs(C*d.x+A*d.y),Math.abs(B*d.x+E*d.y)),s=V(K-
+t*g/k.y);t=V(j+t*g/k.y);n.lat=Math.max(s,Math.min(t,n.lat));s=Math.max(Math.abs(C*d.y+A*d.x),Math.abs(B*d.y+E*d.x));n.lon=Math.max(q[0].lon-s*g/k.x,Math.min(q[1].lon+s*g/k.x,n.lon))}}var c={},l,f,a=Y,d=Y,k={x:256,y:256},n={lat:37.76487,lon:-122.41948},o=12,m=0,i=1,u=[1,18],x=0,A=1,C=0,E=1,B=0,K=-180,j=180,q=[{lat:V(K),lon:-Infinity},{lat:V(j),lon:Infinity}];c.locationCoordinate=function(g){g=r.map.locationCoordinate(g);var t=Math.pow(2,o);g.column*=t;g.row*=t;g.zoom+=o;return g};c.coordinateLocation=
+r.map.coordinateLocation;c.coordinatePoint=function(g,t){var s=Math.pow(2,o-t.zoom),z=Math.pow(2,o-g.zoom),v=(t.column*s-g.column*z)*k.x*i;s=(t.row*s-g.row*z)*k.y*i;return{x:d.x+A*v-C*s,y:d.y+C*v+A*s}};c.pointCoordinate=function(g,t){var s=Math.pow(2,o-g.zoom),z=(t.x-d.x)/i,v=(t.y-d.y)/i;return{column:g.column*s+(E*z-B*v)/k.x,row:g.row*s+(B*z+E*v)/k.y,zoom:o}};c.locationPoint=function(g){var t=Math.pow(2,o+m-3)/45,s=(g.lon-n.lon)*t*k.x;g=(W(n.lat)-W(g.lat))*t*k.y;return{x:d.x+A*s-C*g,y:d.y+C*s+A*
+g}};c.pointLocation=function(g){var t=45/Math.pow(2,o+m-3),s=(g.x-d.x)*t;g=(g.y-d.y)*t;return{lon:n.lon+(E*s-B*g)/k.x,lat:V(W(n.lat)-(B*s+E*g)/k.y)}};var w=r.svg("rect");w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(g){if(!arguments.length)return l;l=g;l.setAttribute("class","map");l.appendChild(w);return c.resize()};c.focusableParent=function(){for(var g=l;g;g=g.parentNode)if(g.tabIndex>=0)return g;return window};c.mouse=function(g){var t=(l.ownerSVGElement||
+l).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var s=document.body.appendChild(r.svg("svg"));s.style.position="absolute";s.style.top=s.style.left="0px";var z=s.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(s)}if($){t.x=g.pageX;t.y=g.pageY}else{t.x=g.clientX;t.y=g.clientY}return t.matrixTransform(l.getScreenCTM().inverse())};c.size=function(g){if(!arguments.length)return a;f=g;return c.resize()};c.resize=function(){if(f){a=f;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);d={x:a.x/2,y:a.y/2};h();c.dispatch({type:"resize"});return c};c.tileSize=function(g){if(!arguments.length)return k;k=g;c.dispatch({type:"move"});return c};c.center=function(g){if(!arguments.length)return n;n=g;h();c.dispatch({type:"move"});return c};c.panBy=function(g){var t=45/Math.pow(2,o+m-3),s=g.x*t;g=g.y*t;return c.center({lon:n.lon+(B*g-E*s)/k.x,lat:V(W(n.lat)+(B*s+E*g)/k.y)})};c.centerRange=
+function(g){if(!arguments.length)return q;if(q=g){K=q[0].lat>-90?W(q[0].lat):-Infinity;j=q[0].lat<90?W(q[1].lat):Infinity}else{K=-Infinity;j=Infinity}h();c.dispatch({type:"move"});return c};c.zoom=function(g){if(!arguments.length)return o+m;o=g;e();return c.center(n)};c.zoomBy=function(g,t,s){if(arguments.length<2)return c.zoom(o+m+g);if(arguments.length<3)s=c.pointLocation(t);o=o+m+g;e();var z=c.locationPoint(s);return c.panBy({x:t.x-z.x,y:t.y-z.y})};c.zoomRange=function(g){if(!arguments.length)return u;
+u=g;return c.zoom(o+m)};c.extent=function(g){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var t=c.locationPoint(g[0]),s=c.locationPoint(g[1]),z=Math.max((s.x-t.x)/a.x,(t.y-s.y)/a.y);t=c.pointLocation({x:(t.x+s.x)/2,y:(t.y+s.y)/2});o=o+m-Math.log(z)/Math.log(2);e();return c.center(t)};c.angle=function(g){if(!arguments.length)return x;x=g;A=Math.cos(x);C=Math.sin(x);E=Math.cos(-x);B=Math.sin(-x);h();c.dispatch({type:"move"});return c};c.add=function(g){g.map(c);
+return c};c.remove=function(g){g.map(null);return c};c.dispatch=r.dispatch(c);return c};S.maps=[];S.add=function(e){for(var h=0;h<S.maps.length;h++)if(S.maps[h]==e)return;S.maps.push(e)};S.remove=function(e){for(var h=0;h<S.maps.length;h++)if(S.maps[h]==e){S.maps.splice(h,1);return}};window.addEventListener("resize",S,false);r.map.locationCoordinate=function(e){var h=1/360;return{column:(e.lon+180)*h,row:(180-W(e.lat))*h,zoom:0}};r.map.coordinateLocation=function(e){var h=45/Math.pow(2,e.zoom-3);
+return{lon:h*e.column-180,lat:V(180-h*e.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;r.layer=function(e,h){function c(B){for(var K=C[0].nextSibling;A<B;A++){u.insertBefore(C[-4],K);u.insertBefore(C[2],K);u.insertBefore(C[1],K);for(var j=C[-4],q=-4;q<2;)C[q]=C[++q];C[q]=j}}function l(B){for(var K=C[0].nextSibling;A>B;A--){u.insertBefore(C[-1],K);u.insertBefore(C[2],C[-4]);for(var j=C[2],q=2;q>-4;)C[q]=C[--q];C[q]=j}}function f(){function B(N){var H=N.zoom,T=H<0?1:1<<H,U=N.column%T,y=N.row;
+if(U<0)U+=T;return{locationPoint:function(D){D=r.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:s.x*(G*D.column-U),y:s.y*(G*D.row-y)}}}}function K(N,H,T){var U=I.zoom,y=2-R,D=4+R;for(N=N;N<H;N++){var G=d.load({column:N,row:T,zoom:U},B);if(!G.ready&&!(G.key in O)){G.proxyRefs={};for(var J,M,P,Q=1;Q<=y;Q++){M=true;for(var X=0,ea=1<<Q;X<=ea;X++)for(var aa=0;aa<=ea;aa++)if((P=d.peek(J={column:(N<<Q)+aa,row:(T<<Q)+X,zoom:U+Q}))&&P.ready){O[P.key]=d.load(J);P.proxyCount++;G.proxyRefs[P.key]=
+P}else M=false;if(M)break}if(!M)for(Q=1;Q<=D;Q++)if((P=d.peek(J={column:N>>Q,row:T>>Q,zoom:U-Q}))&&P.ready){O[P.key]=d.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}O[G.key]=G}}var j=a.map(),q=j.zoom(),w=q-(q=Math.round(q)),g=j.size(),t=j.angle(),s=j.tileSize(),z=j.locationCoordinate(j.center());if(A!=q){if(A<q)c(q);else if(A>q)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("+g.x/2+","+g.y/2+")"+(t?"rotate("+t/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(x?x.zoomFraction(w):""));var I=j.pointCoordinate(z,Y);v=j.pointCoordinate(z,{x:g.x,y:0});q=j.pointCoordinate(z,g);j=j.pointCoordinate(z,{x:0,y:g.y});if(!w&&!t&&!x){z.column=(Math.round(s.x*z.column)+(g.x&1)/2)/s.x;z.row=(Math.round(s.y*z.row)+(g.y&1)/2)/s.y}if(x){I=x.unapply(I);v=x.unapply(v);q=x.unapply(q);j=x.unapply(j);z=x.unapply(z)}var R=o?o(I.zoom)-I.zoom:0;if(R){g=Math.pow(2,R);I.column*=
+g;I.row*=g;v.column*=g;v.row*=g;q.column*=g;q.row*=g;j.column*=g;j.row*=g;I.zoom=v.zoom=q.zoom=j.zoom+=R}w=d.locks();var O={};for(var F in w)w[F].proxyCount=0;if(n&&R>-5&&R<3){t=I.zoom<0?1:1<<I.zoom;if(k){da(I,v,q,0,t,K);da(q,j,I,0,t,K)}else{g=Math.floor((I.column+q.column)/2);t=Math.max(0,Math.min(t-1,Math.floor((v.row+j.row)/2)));v=Math.min(4,I.zoom);g=g>>v<<v;t=t>>v<<v;K(g,g+1,t)}}for(F in O){v=O[F];g=Math.pow(2,v.level=v.zoom-z.zoom);v.element.setAttribute("transform","translate("+(v.x=s.x*(v.column-
+z.column*g))+","+(v.y=s.y*(v.row-z.row*g))+")")}for(F in w)if(!(F in O)){v=d.unload(F);v.element.parentNode.removeChild(v.element);delete v.proxyRefs}for(F in O){v=O[F];if(v.element.parentNode!=C[v.level]){C[v.level].appendChild(v.element);a.show&&a.show(v)}}d.flush();a.dispatch({type:"move"})}var a={},d=a.cache=r.cache(e,h).size(512),k=true,n=true,o,m,i,u=r.svg("g"),x,A,C={};u.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=u.appendChild(r.svg("g"));for(E=2;E>=1;E--)C[E]=u.appendChild(r.svg("g"));
+C[0]=u.appendChild(r.svg("g"));a.map=function(B){if(!arguments.length)return i;if(i){if(i==B){u.parentNode.appendChild(u);return a}i.off("move",f).off("resize",f);u.parentNode.removeChild(u)}if(i=B){i.container().appendChild(u);a.init&&a.init(u);i.on("move",f).on("resize",f);f()}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");i&&f();return a};a.transform=function(B){if(!arguments.length)return x;x=B;i&&f();return a};a.zoom=function(B){if(!arguments.length)return o;o=typeof B=="function"||B==null?B:function(){return B};i&&f();return a};a.tile=function(B){if(!arguments.length)return k;k=B;i&&f();return a};a.reload=function(){d.clear();i&&f();return a};a.dispatch=r.dispatch(a);a.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var j=B.tile.proxyRefs[K];--j.proxyCount<=
+0&&d.unload(K)&&j.element.parentNode.removeChild(j.element)}delete B.tile.proxyRefs}});return a};r.image=function(){var e=r.layer(function(c){var l=c.element=r.svg("image"),f=e.map().tileSize();l.setAttribute("preserveAspectRatio","none");l.setAttribute("width",f.x);l.setAttribute("height",f.y);if(typeof h=="function"){l.setAttribute("opacity",0);f=h(c);if(f!=null)c.request=r.queue.image(l,f,function(a){delete c.request;c.ready=true;c.img=a;l.removeAttribute("opacity");e.dispatch({type:"load",tile:c})});
+else{c.ready=true;e.dispatch({type:"load",tile:c})}}else{c.ready=true;h!=null&&l.setAttributeNS(r.ns.xlink,"href",h);e.dispatch({type:"load",tile:c})}},function(c){c.request&&c.request.abort(true)}),h;e.url=function(c){if(!arguments.length)return h;h=typeof c=="string"&&/{.}/.test(c)?r.url(c):c;return e.reload()};return e};r.geoJson=function(e){function h(j){var q={lat:0,lon:0};return function(w){q.lat=w[1];q.lon=w[0];var g=j(q);w.x=g.x;w.y=g.y;return g}}function c(j,q){return j&&j.type in C&&C[j.type](j,
+q)}function l(j,q,w){return j.type in E&&E[j.type](j,q,w)}function f(){var j=a.map().zoom(),q=a.cache.locks(),w,g,t,s,z,v,L;if(x=="fixed")for(w in q){if((g=q[w]).scale!=j){L="scale("+Math.pow(2,g.zoom-j)+")";s=-1;for(z=(t=g.features).length;++s<z;)l((v=t[s]).data.geometry,v.element,L);g.scale=j}}else for(w in q){s=-1;for(z=(t=(g=q[w]).features).length;++s<z;)l((v=t[s]).data.geometry,v.element,"");delete g.scale}}var a=r.layer(function(j,q){function w(t){var s=[];if(t.next)j.request=e(t.next.href,
+w);switch(t.type){case "FeatureCollection":for(var z=0;z<t.features.length;z++){var v=t.features[z],L=c(v.geometry,q);L&&s.push({element:g.appendChild(L),data:v})}break;case "Feature":(L=c(t.geometry,q))&&s.push({element:g.appendChild(L),data:t});break;default:(L=c(t,q))&&s.push({element:g.appendChild(L),data:{type:"Feature",geometry:t}});break}j.ready=true;s.push.apply(j.features,s);a.dispatch({type:"load",tile:j,features:s})}var g=j.element=r.svg("g");j.features=[];q=h(q(j).locationPoint);if(k!=
+null)j.request=e(typeof k=="function"?k(j):k,w);else w({type:"FeatureCollection",features:A||[]})},function(j){j.request&&j.request.abort(true)}),d=a.container(),k,n=true,o="org.polymaps."+r.id(),m="url(#"+o+")",i=d.insertBefore(r.svg("clipPath"),d.firstChild),u=i.appendChild(r.svg("rect")),x="auto",A;d.setAttribute("fill-rule","evenodd");i.setAttribute("id",o);if(!arguments.length)e=r.queue.json;var C={Point:function(j,q){var w=q(j.coordinates),g=r.svg("circle");g.setAttribute("r",4.5);g.setAttribute("transform",
+"translate("+w.x+","+w.y+")");return g},MultiPoint:function(j,q){for(var w=r.svg("g"),g=j.coordinates,t,s,z=-1,v=g.length;++z<v;){s=w.appendChild(r.svg("circle"));s.setAttribute("r",4.5);s.setAttribute("transform","translate("+(t=q(g[z])).x+","+t.y+")")}return w},LineString:function(j,q){for(var w=r.svg("path"),g=["M"],t=j.coordinates,s,z=-1,v=t.length;++z<v;)g.push((s=q(t[z])).x,",",s.y,"L");g.pop();if(g.length){w.setAttribute("d",g.join(""));return w}},MultiLineString:function(j,q){for(var w=r.svg("path"),
+g=[],t=j.coordinates,s,z=-1,v,L=t.length,I;++z<L;){s=t[z];v=-1;I=s.length;for(g.push("M");++v<I;)g.push((p=q(s[v])).x,",",p.y,"L");g.pop()}if(g.length){w.setAttribute("d",g.join(""));return w}},Polygon:function(j,q){for(var w=r.svg("path"),g=[],t=j.coordinates,s,z=-1,v,L=t.length,I;++z<L;){s=t[z];v=-1;I=s.length-1;for(g.push("M");++v<I;)g.push((p=q(s[v])).x,",",p.y,"L");g[g.length-1]="Z"}if(g.length){w.setAttribute("d",g.join(""));return w}},MultiPolygon:function(j,q){for(var w=r.svg("path"),g=[],
+t=j.coordinates,s,z,v=-1,L,I,R=t.length,O,F;++v<R;){s=t[v];L=-1;for(O=s.length;++L<O;){z=s[L];I=-1;F=z.length-1;for(g.push("M");++I<F;)g.push((p=q(z[I])).x,",",p.y,"L");g[g.length-1]="Z"}}if(g.length){w.setAttribute("d",g.join(""));return w}},GeometryCollection:function(j,q){for(var w=r.svg("g"),g=-1,t=j.geometries,s=t.length,z;++g<s;)(z=c(t[g],q))&&w.appendChild(z);return w}},E={Point:function(j,q,w){j=j.coordinates;q.setAttribute("transform","translate("+j.x+","+j.y+")"+w)},MultiPoint:function(j,
+q,w){j=j.coordinates;var g=-1,t=s.length;q=q.firstChild;for(var s;++g<t;){s=j[g];q.setAttribute("transform","translate("+s.x+","+s.y+")"+w);q=q.nextSibling}}};a.url=function(j){if(!arguments.length)return k;k=typeof j=="string"&&/{.}/.test(j)?r.url(j):j;if(k!=null)A=null;typeof k=="string"&&a.tile(false);return a.reload()};a.features=function(j){if(!arguments.length)return A;if(A=j){k=null;a.tile(false)}return a.reload()};a.clip=function(j){if(!arguments.length)return n;n&&d.removeChild(i);if(n=j)d.insertBefore(i,
+d.firstChild);var q=a.cache.locks();for(var w in q)n?q[w].element.setAttribute("clip-path",m):q[w].element.removeAttribute("clip-path");return a};var B=a.tile;a.tile=function(j){arguments.length&&!j&&a.clip(j);return B.apply(a,arguments)};var K=a.map;a.map=function(j){if(j&&u){var q=j.tileSize();u.setAttribute("width",q.x);u.setAttribute("height",q.y)}return K.apply(a,arguments)};a.scale=function(j){if(!arguments.length)return x;(x=j)?a.on("move",f):a.off("move",f);a.map()&&f();return a};a.show=function(j){n?
+j.element.setAttribute("clip-path",m):j.element.removeAttribute("clip-path");a.dispatch({type:"show",tile:j,features:j.features});return a};a.reshow=function(){var j=a.cache.locks();for(var q in j)a.show(j[q]);return a};return a};r.dblclick=function(){function e(a){var d=l.zoom();d=a.shiftKey?Math.ceil(d)-d-1:1-d+Math.floor(d);c==="mouse"?l.zoomBy(d,l.mouse(a)):l.zoomBy(d)}var h={},c="mouse",l,f;h.zoom=function(a){if(!arguments.length)return c;c=a;return h};h.map=function(a){if(!arguments.length)return l;
+if(l){f.removeEventListener("dblclick",e,false);f=null}if(l=a){f=l.container();f.addEventListener("dblclick",e,false)}return h};return h};r.drag=function(){function e(d){if(!d.shiftKey){a={x:d.clientX,y:d.clientY};l.focusableParent().focus();d.preventDefault();document.body.style.setProperty("cursor","move",null)}}function h(d){if(a){l.panBy({x:d.clientX-a.x,y:d.clientY-a.y});a.x=d.clientX;a.y=d.clientY}}var c={},l,f,a;c.map=function(d){if(!arguments.length)return l;if(l){f.removeEventListener("mousedown",
+e,false);f=null}if(l=d){f=l.container();f.addEventListener("mousedown",e,false)}return c};window.addEventListener("mousemove",h,false);window.addEventListener("mouseup",function(d){if(a){h(d);a=null;document.body.style.removeProperty("cursor")}},false);return c};r.wheel=function(){function e(){k=null}function h(m){var i=(m.wheelDelta/120||-m.detail)*0.1,u;if(ba<0){u=Date.now();var x=u-f;if(x>9&&Math.abs(m.wheelDelta)/x>=50)ba=1;f=u}if(ba==1)i*=0.03;if(!a&&i){u=Date.now();if(u-l>200){i=i>0?+1:-1;l=
+u}else i=0}if(i)switch(d){case "mouse":u=n.mouse(m);k||(k=n.pointLocation(u));n.off("move",e).zoomBy(i,u,k).on("move",e);break;case "location":n.zoomBy(i,n.locationPoint(k),k);break;default:n.zoomBy(i);break}m.preventDefault();return false}var c={},l=0,f=0,a=true,d="mouse",k,n,o;c.smooth=function(m){if(!arguments.length)return a;a=m;return c};c.zoom=function(m,i){if(!arguments.length)return d;d=m;k=i;if(n)d=="mouse"?n.on("move",e):n.off("move",e);return c};c.map=function(m){if(!arguments.length)return n;
+if(n){o.removeEventListener("mousemove",e,false);o.removeEventListener("mousewheel",h,false);o.removeEventListener("DOMMouseScroll",h,false);o=null;n.off("move",e)}if(n=m){d=="mouse"&&n.on("move",e);o=n.container();o.addEventListener("mousemove",e,false);o.addEventListener("mousewheel",h,false);o.addEventListener("DOMMouseScroll",h,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;r.arrow=function(){function e(x){if(!(x.ctrlKey||x.altKey||x.metaKey)){var A=Date.now(),
+C=0,E=0;switch(x.keyCode){case 37:if(!a.left){d=A;a.left=1;a.right||(C=m)}break;case 39:if(!a.right){d=A;a.right=1;a.left||(C=-m)}break;case 38:if(!a.up){d=A;a.up=1;a.down||(E=m)}break;case 40:if(!a.down){d=A;a.down=1;a.up||(E=-m)}break;default:return}if(C||E)i.panBy({x:C,y:E});if(!k&&a.left|a.right|a.up|a.down)k=setInterval(l,o);x.preventDefault()}}function h(x){d=Date.now();switch(x.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(k&&
+!(a.left|a.right|a.up|a.down))k=clearInterval(k);x.preventDefault()}function c(x){switch(x.charCode){case 45:case 95:i.zoom(Math.ceil(i.zoom())-1);break;case 43:case 61:i.zoom(Math.floor(i.zoom())+1);break;default:return}x.preventDefault()}function l(){if(i)if(!(Date.now()<d+n)){var x=(a.left-a.right)*m,A=(a.up-a.down)*m;if(x||A)i.panBy({x:x,y:A})}}var f={},a={left:0,right:0,up:0,down:0},d=0,k,n=250,o=50,m=16,i,u;f.map=function(x){if(!arguments.length)return i;if(i){u.removeEventListener("keypress",
+c,false);u.removeEventListener("keydown",e,false);u.removeEventListener("keyup",h,false);u=null}if(i=x){u=i.focusableParent();u.addEventListener("keypress",c,false);u.addEventListener("keydown",e,false);u.addEventListener("keyup",h,false)}return f};f.speed=function(x){if(!arguments.length)return m;m=x;return f};return f};r.hash=function(){function e(){var k=d(f);if(l!==k)location.replace(l=k)}function h(){if(location.hash!==l)if(a(f,(l=location.hash).substring(1)))e()}var c={},l,f,a=function(k,n){var o=
+n.split("/").map(Number);if(o.length<3||o.some(isNaN))return true;else{var m=k.size();k.zoomBy(o[0]-k.zoom(),{x:m.x/2,y:m.y/2},{lat:Math.min(89.99999999,Math.max(-89.99999999,o[1])),lon:o[2]})}},d=function(k){var n=k.center();k=k.zoom();var o=Math.max(0,Math.ceil(Math.log(k)/Math.LN2));return"#"+k.toFixed(2)+"/"+n.lat.toFixed(o)+"/"+n.lon.toFixed(o)};c.map=function(k){if(!arguments.length)return f;if(f){f.off("move",e);window.removeEventListener("hashchange",h,false)}if(f=k){f.on("move",e);window.addEventListener("hashchange",
+h,false);location.hash?h():e()}return c};c.parser=function(k){if(!arguments.length)return a;a=k;return c};c.formatter=function(k){if(!arguments.length)return d;d=k;return c};return c};r.touch=function(){function e(a){for(var d=-1,k=a.touches.length,n;++d<k;){n=a.touches[d];f[n.identifier]=c.pointLocation(c.mouse(n))}a.preventDefault()}var h={},c,l,f={};window.addEventListener("touchmove",function(a){switch(a.touches.length){case 1:var d=a.touches[0];c.zoomBy(0,c.mouse(d),f[d.identifier]);break;case 2:d=
+a.touches[0];var k=a.touches[1],n=c.mouse(d),o=c.mouse(k),m={x:(n.x+o.x)/2,y:(n.y+o.y)/2};d=r.map.locationCoordinate(f[d.identifier]);var i=r.map.locationCoordinate(f[k.identifier]);k=r.map.coordinateLocation({row:(d.row+i.row)/2,column:(d.column+i.column)/2,zoom:0});var u=n.x-o.x;n=n.y-o.y;o=d.column-i.column;d=d.row-i.row;c.zoomBy(Math.log(Math.sqrt(u*u+n*n)/256/Math.sqrt(o*o+d*d))/Math.log(2)-c.zoom(),m,k);break}a.preventDefault()},false);window.addEventListener("touchend",function(a){a.preventDefault()},
+false);h.map=function(a){if(!arguments.length)return c;if(c){l.removeEventListener("touchstart",e,false);l=null}if(c=a){l=c.container();l.addEventListener("touchstart",e,false)}return h};return h};r.interact=function(){var e={},h=r.drag(),c=r.wheel(),l=r.dblclick(),f=r.touch(),a=r.arrow();e.map=function(d){h.map(d);c.map(d);l.map(d);f.map(d);a.map(d);return e};return e};r.compass=function(){function e(y){B.setAttribute("class","compass active");I||(I=setInterval(h,t));R&&H.panBy(R);w=Date.now();return m(y)}
+function h(){R&&Date.now()>w+g&&H.panBy(R)}function c(y){if(y.shiftKey){F={x0:H.mouse(y)};H.focusableParent().focus();return m(y)}}function l(y){if(F){F.x1=H.mouse(y);N.setAttribute("x",Math.min(F.x0.x,F.x1.x));N.setAttribute("y",Math.min(F.x0.y,F.x1.y));N.setAttribute("width",Math.abs(F.x0.x-F.x1.x));N.setAttribute("height",Math.abs(F.x0.y-F.x1.y));N.removeAttribute("display")}}function f(){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)})]);N.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function a(y){return function(){y?this.setAttribute("class","active"):this.removeAttribute("class");R=y}}function d(y){return function(D){B.setAttribute("class","compass active");var G=H.zoom();H.zoom(y<0?Math.ceil(G)-1:Math.floor(G)+1);return m(D)}}function k(y){return function(D){H.zoom(y);return m(D)}}function n(){this.setAttribute("class","active")}
+function o(){this.removeAttribute("class")}function m(y){y.stopPropagation();y.preventDefault();return false}function i(y){var D=Math.SQRT1_2*j,G=j*0.7,J=j*0.2,M=r.svg("g"),P=M.appendChild(r.svg("path")),Q=M.appendChild(r.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d","M0,0L"+D+","+D+"A"+j+","+j+" 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");M.addEventListener("mousedown",e,false);M.addEventListener("mouseover",a(y),false);M.addEventListener("mouseout",a(null),false);M.addEventListener("dblclick",m,false);return M}function u(y){var D=j*0.4,G=D/2,J=r.svg("g"),M=J.appendChild(r.svg("path")),P=J.appendChild(r.svg("path")),Q=J.appendChild(r.svg("path")),X=J.appendChild(r.svg("path"));M.setAttribute("class","back");M.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",
+M.getAttribute("d"));Q.setAttribute("class","chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(y>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",M.getAttribute("d"));J.addEventListener("mousedown",d(y),false);J.addEventListener("mouseover",n,false);J.addEventListener("mouseout",o,false);J.addEventListener("dblclick",m,false);return J}function x(y){var D=j*0.2,G=j*0.4,J=r.svg("g"),M=J.appendChild(r.svg("rect")),P=J.appendChild(r.svg("path"));
+M.setAttribute("pointer-events","all");M.setAttribute("fill","none");M.setAttribute("x",-G);M.setAttribute("y",-0.75*G);M.setAttribute("width",2*G);M.setAttribute("height",1.5*G);P.setAttribute("class","chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",k(y),false);J.addEventListener("dblclick",m,false);return J}function A(){var y=j+6,D=y,G=H.size();switch(s){case "top-left":break;case "top-right":y=G.x-y;break;case "bottom-left":D=G.y-D;break;case "bottom-right":y=G.x-y;
+D=G.y-D;break}B.setAttribute("transform","translate("+y+","+D+")");N.setAttribute("transform","translate("+-y+","+-D+")");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(N);if(L!="none"){O=B.appendChild(r.svg("g"));O.setAttribute("class","pan");var y=O.appendChild(r.svg("circle"));y.setAttribute("class","back");y.setAttribute("r",j);O.appendChild(i({x:0,y:-q})).setAttribute("transform",
+"rotate(0)");O.appendChild(i({x:q,y:0})).setAttribute("transform","rotate(90)");O.appendChild(i({x:0,y:q})).setAttribute("transform","rotate(180)");O.appendChild(i({x:-q,y:0})).setAttribute("transform","rotate(270)");y=O.appendChild(r.svg("circle"));y.setAttribute("fill","none");y.setAttribute("class","fore");y.setAttribute("r",j)}else O=null;if(z!="none"){v=B.appendChild(r.svg("g"));v.setAttribute("class","zoom");y=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(y=0;D<=H.zoomRange()[1];D++,y++)(K[D]=
+v.appendChild(x(D))).setAttribute("transform","translate(0,"+-(y+0.75)*j*0.4+")")}D=L=="none"?0.4:2;v.setAttribute("transform","translate(0,"+j*(/^top-/.test(s)?D+(y+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(y+0.5)*j*0.4+")");v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E={},B=r.svg("g"),K={},j=30,q=16,w=0,g=250,t=50,s="top-left",z="small",v,L="small",I,R,O,F,N=r.svg("rect"),H,T,U;B.setAttribute("class","compass");N.setAttribute("class",
+"back fore");N.setAttribute("pointer-events","none");N.setAttribute("display","none");E.radius=function(y){if(!arguments.length)return j;j=y;H&&C();return E};E.speed=function(y){if(!arguments.length)return j;q=y;return E};E.position=function(y){if(!arguments.length)return s;s=y;H&&C();return E};E.pan=function(y){if(!arguments.length)return L;L=y;H&&C();return E};E.zoom=function(y){if(!arguments.length)return z;z=y;H&&C();return E};E.map=function(y){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",f,false);U=null;H.off("move",A).off("resize",A)}if(H=y){T=H.container();T.appendChild(B);T.addEventListener("mousedown",c,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",l,false);U.addEventListener("mouseup",f,false);H.on("move",A).on("resize",A);C()}return E};return E};r.grid=function(){function e(){var f=l.firstChild,a=c.size(),d=c.pointLocation(Y);c.pointLocation(a);var k=
+Math.pow(2,4-Math.round(c.zoom()));d.lat=Math.floor(d.lat/k)*k;d.lon=Math.ceil(d.lon/k)*k;for(var n;(n=c.locationPoint(d).x)<=a.x;d.lon+=k){f||(f=l.appendChild(r.svg("line")));f.setAttribute("x1",n);f.setAttribute("x2",n);f.setAttribute("y1",0);f.setAttribute("y2",a.y);f=f.nextSibling}for(;(n=c.locationPoint(d).y)<=a.y;d.lat-=k){f||(f=l.appendChild(r.svg("line")));f.setAttribute("y1",n);f.setAttribute("y2",n);f.setAttribute("x1",0);f.setAttribute("x2",a.x);f=f.nextSibling}for(;f;){a=f.nextSibling;
+l.removeChild(f);f=a}}var h={},c,l=r.svg("g");l.setAttribute("class","grid");h.map=function(f){if(!arguments.length)return c;if(c){l.parentNode.removeChild(l);c.off("move",e).off("resize",e)}if(c=f){c.on("move",e).on("resize",e);c.container().appendChild(l);c.dispatch({type:"move"})}return h};return h};r.stylist=function(){function e(f){var a=f.features.length,d=h.length,k=c.length,n,o,m,i,u,x;for(u=0;u<a;++u)if(o=(n=f.features[u]).element){n=n.data;for(x=0;x<d;++x){i=(m=h[x]).value;if(typeof i===
+"function")i=i.call(null,n);i==null?m.name.local?o.removeAttributeNS(m.name.space,m.name.local):o.removeAttribute(m.name):m.name.local?o.setAttributeNS(m.name.space,m.name.local,i):o.setAttribute(m.name,i)}for(x=0;x<k;++x){i=(m=c[x]).value;if(typeof i==="function")i=i.call(null,n);i==null?o.style.removeProperty(m.name):o.style.setProperty(m.name,i,m.priority)}if(i=l){if(typeof i==="function")i=i.call(null,n);for(;o.lastChild;)o.removeChild(o.lastChild);i!=null&&o.appendChild(r.svg("title")).appendChild(document.createTextNode(i))}}}
+var h=[],c=[],l;e.attr=function(f,a){h.push({name:fa(f),value:a});return e};e.style=function(f,a,d){c.push({name:f,value:a,priority:arguments.length<3?null:d});return e};e.title=function(f){l=f;return e};return e}})(org.polymaps);
2  src/Interact.js
View
@@ -4,12 +4,14 @@ po.interact = function() {
drag = po.drag(),
wheel = po.wheel(),
dblclick = po.dblclick(),
+ touch = po.touch(),
arrow = po.arrow();
interact.map = function(x) {
drag.map(x);
wheel.map(x);
dblclick.map(x);
+ touch.map(x);
arrow.map(x);
return interact;
};
70 src/Touch.js
View
@@ -0,0 +1,70 @@
+po.touch = function() {
+ var touch = {},
+ map,
+ container,
+ locations = {}; // touch identifier -> location
+
+ window.addEventListener("touchmove", touchmove, false);
+ window.addEventListener("touchend", touchend, false);
+
+ function touchstart(e) {
+ var i = -1,
+ n = e.touches.length,
+ t;
+ while (++i < n) {
+ t = e.touches[i];
+ locations[t.identifier] = map.pointLocation(map.mouse(t));
+ }
+ e.preventDefault();
+ }
+
+ function touchmove(e) {
+ switch (e.touches.length) {
+ case 1: {
+ var t0 = e.touches[0];
+ map.zoomBy(0, map.mouse(t0), locations[t0.identifier]);
+ break;
+ }
+ case 2: { // TODO rotation!
+ var t0 = e.touches[0],
+ t1 = e.touches[1],
+ p0 = map.mouse(t0),
+ p1 = map.mouse(t1),
+ p2 = {x: (p0.x + p1.x) / 2, y: (p0.y + p1.y) / 2}, // center point
+ c0 = po.map.locationCoordinate(locations[t0.identifier]),
+ c1 = po.map.locationCoordinate(locations[t1.identifier]),
+ c2 = {row: (c0.row + c1.row) / 2, column: (c0.column + c1.column) / 2, zoom: 0},
+ l2 = po.map.coordinateLocation(c2), // center location
+ px = p0.x - p1.x,
+ py = p0.y - p1.y,
+ dp = Math.sqrt(px * px + py * py) / 256,
+ cx = c0.column - c1.column,
+ cy = c0.row - c1.row,
+ dc = Math.sqrt(cx * cx + cy * cy),
+ z2 = Math.log(dp / dc) / Math.log(2); // zoom level
+ map.zoomBy(z2 - map.zoom(), p2, l2);
+ break;
+ }
+ }
+ e.preventDefault();
+ }
+
+ function touchend(e) {
+ e.preventDefault();
+ }
+
+ touch.map = function(x) {
+ if (!arguments.length) return map;
+ if (map) {
+ container.removeEventListener("touchstart", touchstart, false);
+ container = null;
+ }
+ if (map = x) {
+ container = map.container();
+ container.addEventListener("touchstart", touchstart, false);
+ }
+ return touch;
+ };
+
+ return touch;
+};
Please sign in to comment.
Something went wrong with that request. Please try again.