Skip to content
Browse files

Fix bug in compass zoom positioning.

  • Loading branch information...
1 parent 41e4780 commit 7c33adec97335464ed7d243268bd78c819e3751f @mbostock mbostock committed
Showing with 36 additions and 38 deletions.
  1. +2 −3 polymaps.js
  2. +32 −32 polymaps.min.js
  3. +2 −3 src/Compass.js
View
5 polymaps.js
@@ -2028,9 +2028,8 @@ po.compass = function() {
case "bottom-left": y = size.y - y; break;
case "bottom-right": x = size.x - x; y = size.y - y; break;
}
- var tx = "translate(" + x + "," + y + ")";
- if (panContainer) panContainer.setAttribute("transform", tx);
- if (zoomContainer) zoomContainer.setAttribute("transform", tx);
+ g.setAttribute("transform", "translate(" + x + "," + y + ")");
+ dragRect.setAttribute("transform", "translate(" + -x + "," + -y + ")");
for (var i in ticks) {
i == map.zoom()
? ticks[i].setAttribute("class", "active")
View
64 polymaps.min.js
@@ -3,60 +3,60 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={};
k=Math.min(k,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 f=h.dx/h.dy,m=d.dx>0,q=h.dx<0;for(c=c;c<k;c++){var t=a*Math.max(0,Math.min(d.dy,c+m-d.y0))+d.x0;g(Math.floor(f*Math.max(0,Math.min(h.dy,c+q-h.y0))+h.x0),Math.ceil(t),c)}}function da(d,h,c,k,g,a){var f=Z(d,h);h=Z(h,c);d=Z(c,d);if(f.dy>h.dy){c=f;f=h;h=c}if(f.dy>d.dy){c=f;f=d;d=c}if(h.dy>d.dy){c=h;h=d;d=c}f.dy&&ca(d,f,k,g,a);h.dy&&ca(d,h,k,g,a)}s.version="2.3+1.0+1";
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 d=0;return function(){return++d}}();s.svg=function(d){return document.createElementNS(s.ns.svg,d)};s.transform=function(d,h,c,k,g,a){var f={},m,q,t;if(!arguments.length){d=1;h=g=c=0;k=1;a=0}f.zoomFraction=function(l){if(!arguments.length)return q;q=l;m=Math.floor(q+Math.log(Math.sqrt(d*d+h*h+c*c+k*k))/Math.log(2));t=Math.pow(2,-m);return f};f.apply=function(l){var i=Math.pow(2,-l.zoom),
u=Math.pow(2,l.zoom-m);return{column:(d*l.column*i+c*l.row*i+g)*u,row:(h*l.column*i+k*l.row*i+a)*u,zoom:l.zoom-m}};f.unapply=function(l){var i=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+m);return{column:(l.column*i*k-l.row*i*c-g*k+a*c)/(d*k-h*c)*u,row:(l.column*i*h-l.row*i*d-g*h+a*d)/(c*h-k*d)*u,zoom:l.zoom+m}};f.toString=function(){return"matrix("+[d*t,h*t,c*t,k*t].join(" ")+" 0 0)"};return f.zoomFraction(0)};s.cache=function(d,h){function c(i){l--;h&&h(i);delete f[i.key];if(i.next)i.next.prev=i.prev;
-else if(q=i.prev)q.next=null;if(i.prev)i.prev.next=i.next;else if(m=i.next)m.prev=null}function k(){for(var i=q;l>t;i=i.prev){if(!i)break;i.lock||c(i)}}var g={},a={},f={},m=null,q=null,t=64,l=0;g.peek=function(i){return f[[i.zoom,i.column,i.row].join("/")]};g.load=function(i,u){var y=[i.zoom,i.column,i.row].join("/"),A=f[y];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else q=A.prev;A.prev=null;A.next=m;m=m.prev=A}A.lock=1;return a[y]=A}A={key:y,column:i.column,row:i.row,zoom:i.zoom,next:m,
-prev:null,lock:1};d.call(null,A,u);a[y]=f[y]=A;if(m)m.prev=A;else q=A;m=A;l++;return A};g.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};g.locks=function(){return a};g.size=function(i){if(!arguments.length)return t;t=i;k();return g};g.flush=function(){k();return g};g.clear=function(){for(var i in f){var u=f[i];u.request&&u.request.abort(false);h&&h(f[i]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
+else if(q=i.prev)q.next=null;if(i.prev)i.prev.next=i.next;else if(m=i.next)m.prev=null}function k(){for(var i=q;l>t;i=i.prev){if(!i)break;i.lock||c(i)}}var g={},a={},f={},m=null,q=null,t=64,l=0;g.peek=function(i){return f[[i.zoom,i.column,i.row].join("/")]};g.load=function(i,u){var x=[i.zoom,i.column,i.row].join("/"),A=f[x];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else q=A.prev;A.prev=null;A.next=m;m=m.prev=A}A.lock=1;return a[x]=A}A={key:x,column:i.column,row:i.row,zoom:i.zoom,next:m,
+prev:null,lock:1};d.call(null,A,u);a[x]=f[x]=A;if(m)m.prev=A;else q=A;m=A;l++;return A};g.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};g.locks=function(){return a};g.size=function(i){if(!arguments.length)return t;t=i;k();return g};g.flush=function(){k();return g};g.clear=function(){for(var i in f){var u=f[i];u.request&&u.request.abort(false);h&&h(f[i]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
{};f={};m=q=null;l=0;return g};return g};s.url=function(d){function h(g){var a=g.zoom<0?1:1<<g.zoom,f=g.column;if(k){f=g.column%a;if(f<0)f+=a}else if(f<0||f>=a)return null;return d.replace(/{(.)}/g,function(m,q){switch(q){case "S":return c[(Math.abs(g.zoom)+g.row+f)%c.length];case "Z":return g.zoom;case "X":return f;case "Y":return g.row;case "B":var t=s.map.coordinateLocation({row:g.row,column:f,zoom:g.zoom}),l=s.map.coordinateLocation({row:g.row+1,column:f+1,zoom:g.zoom}),i=Math.ceil(Math.log(g.zoom)/
Math.LN2);return l.lat.toFixed(i)+","+t.lon.toFixed(i)+","+t.lat.toFixed(i)+","+l.lon.toFixed(i)}return q})}var c=[],k=true;h.template=function(g){if(!arguments.length)return d;d=g;return h};h.hosts=function(g){if(!arguments.length)return c;c=g;return h};h.repeat=function(g){if(!arguments.length)return k;k=g;return h};return h};s.dispatch=function(d){var h={};d.on=function(c,k){for(var g=h[c]||(h[c]=[]),a=0;a<g.length;a++)if(g[a].handler==k)return d;g.push({handler:k,on:true});return d};d.off=function(c,
k){var g=h[c];if(g)for(var a=0;a<g.length;a++){var f=g[a];if(f.handler==k){f.on=false;g.splice(a,1);break}}return d};return function(c){var k=h[c.type];if(k){k=k.slice();for(var g=0;g<k.length;g++){var a=k[g];a.on&&a.handler.call(d,c)}}}};s.queue=function(){function d(){if(!(g>=a||!k.length)){g++;k.pop()()}}function h(f){for(var m=0;m<k.length;m++)if(k[m]==f){k.splice(m,1);return true}return false}function c(f,m,q){function t(){l=new XMLHttpRequest;q&&l.overrideMimeType(q);l.open("GET",f,true);l.onreadystatechange=
function(){if(l.readyState==4){g--;l.status<300&&m(l);d()}};l.send(null)}var l;k.push(t);d();return{abort:function(i){if(h(t))return true;if(i&&l){l.abort();return true}return false}}}var k=[],g=0,a=6;return{text:function(f,m,q){return c(f,function(t){t.responseText&&m(t.responseText)},q)},xml:function(f,m){return c(f,function(q){q.responseXML&&m(q.responseXML)},"application/xml")},json:function(f,m){return c(f,function(q){q.responseText&&m(JSON.parse(q.responseText))},"application/json")},image:function(f,
m,q){function t(){l=document.createElement("img");l.onerror=function(){g--;d()};l.onload=function(){g--;q(l);d()};l.src=m;f.setAttributeNS(s.ns.xlink,"href",m)}var l;k.push(t);d();return{abort:function(i){if(h(t))return true;if(i&&l){l.src="about:";return true}return false}}}}}();s.map=function(){function d(){if(u)if(t<u[0])t=u[0];else if(t>u[1])t=u[1];l=t-(t=Math.round(t));i=Math.pow(2,l)}function h(){if(n){var e=45/Math.pow(2,t+l-3),r=Math.max(Math.abs(C*f.x+A*f.y),Math.abs(B*f.x+E*f.y)),o=V(K-
-r*e/m.y);r=V(j+r*e/m.y);q.lat=Math.max(o,Math.min(r,q.lat));o=Math.max(Math.abs(C*f.y+A*f.x),Math.abs(B*f.y+E*f.x));q.lon=Math.max(n[0].lon-o*e/m.x,Math.min(n[1].lon+o*e/m.x,q.lon))}}var c={},k,g,a=Y,f=Y,m={x:256,y:256},q={lat:37.76487,lon:-122.41948},t=12,l=0,i=1,u=[1,18],y=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=s.map.locationCoordinate(e);var r=Math.pow(2,t);e.column*=r;e.row*=r;e.zoom+=t;return e};c.coordinateLocation=
+r*e/m.y);r=V(j+r*e/m.y);q.lat=Math.max(o,Math.min(r,q.lat));o=Math.max(Math.abs(C*f.y+A*f.x),Math.abs(B*f.y+E*f.x));q.lon=Math.max(n[0].lon-o*e/m.x,Math.min(n[1].lon+o*e/m.x,q.lon))}}var c={},k,g,a=Y,f=Y,m={x:256,y:256},q={lat:37.76487,lon:-122.41948},t=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=s.map.locationCoordinate(e);var r=Math.pow(2,t);e.column*=r;e.row*=r;e.zoom+=t;return e};c.coordinateLocation=
s.map.coordinateLocation;c.coordinatePoint=function(e,r){var o=Math.pow(2,t-r.zoom),z=Math.pow(2,t-e.zoom),v=(r.column*o-e.column*z)*m.x*i;o=(r.row*o-e.row*z)*m.y*i;return{x:f.x+A*v-C*o,y:f.y+C*v+A*o}};c.pointCoordinate=function(e,r){var o=Math.pow(2,t-e.zoom),z=(r.x-f.x)/i,v=(r.y-f.y)/i;return{column:e.column*o+(E*z-B*v)/m.x,row:e.row*o+(B*z+E*v)/m.y,zoom:t}};c.locationPoint=function(e){var r=Math.pow(2,t+l-3)/45,o=(e.lon-q.lon)*r*m.x;e=(W(q.lat)-W(e.lat))*r*m.y;return{x:f.x+A*o-C*e,y:f.y+C*o+A*
e}};c.pointLocation=function(e){var r=45/Math.pow(2,t+l-3),o=(e.x-f.x)*r;e=(e.y-f.y)*r;return{lon:q.lon+(E*o-B*e)/m.x,lat:V(W(q.lat)-(B*o+E*e)/m.y)}};var w=s.svg("rect");w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(e){if(!arguments.length)return k;k=e;k.setAttribute("class","map");k.appendChild(w);return c.resize()};c.focusableParent=function(){for(var e=k;e;e=e.parentNode)if(e.tabIndex>=0)return e;return window};c.mouse=function(e){var r=(k.ownerSVGElement||
k).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var o=document.body.appendChild(s.svg("svg"));o.style.position="absolute";o.style.top=o.style.left="0px";var z=o.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(o)}if($){r.x=e.pageX;r.y=e.pageY}else{r.x=e.clientX;r.y=e.clientY}return r.matrixTransform(k.getScreenCTM().inverse())};c.size=function(e){if(!arguments.length)return a;g=e;return c.resize()};c.resize=function(){if(g){a=g;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};h();c.dispatch({type:"resize"});return c};c.tileSize=function(e){if(!arguments.length)return m;m=e;c.dispatch({type:"move"});return c};c.center=function(e){if(!arguments.length)return q;q=e;h();c.dispatch({type:"move"});return c};c.panBy=function(e){var r=45/Math.pow(2,t+l-3),o=e.x*r;e=e.y*r;return c.center({lon:q.lon+(B*e-E*o)/m.x,lat:V(W(q.lat)+(B*o+E*e)/m.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 t+l;t=e;d();return c.center(q)};c.zoomBy=function(e,r,o){if(arguments.length<2)return c.zoom(t+l+e);if(arguments.length<3)o=c.pointLocation(r);t=t+l+e;d();var z=c.locationPoint(o);return c.panBy({x:r.x-z.x,y:r.y-z.y})};c.zoomRange=function(e){if(!arguments.length)return u;
-u=e;return c.zoom(t+l)};c.extent=function(e){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var r=c.locationPoint(e[0]),o=c.locationPoint(e[1]),z=Math.max((o.x-r.x)/a.x,(r.y-o.y)/a.y);r=c.pointLocation({x:(r.x+o.x)/2,y:(r.y+o.y)/2});t=t+l-Math.log(z)/Math.log(2);d();return c.center(r)};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);h();c.dispatch({type:"move"});return c};c.add=function(e){e.map(c);
+u=e;return c.zoom(t+l)};c.extent=function(e){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var r=c.locationPoint(e[0]),o=c.locationPoint(e[1]),z=Math.max((o.x-r.x)/a.x,(r.y-o.y)/a.y);r=c.pointLocation({x:(r.x+o.x)/2,y:(r.y+o.y)/2});t=t+l-Math.log(z)/Math.log(2);d();return c.center(r)};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=s.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);s.map.locationCoordinate=function(d){var h=1/360;return{column:(d.lon+180)*h,row:(180-W(d.lat))*h,zoom:0}};s.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;s.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 k(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 g(){function B(O){var H=O.zoom,T=H<0?1:1<<H,U=O.column%T,x=O.row;
-if(U<0)U+=T;return{locationPoint:function(D){D=s.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:o.x*(G*D.column-U),y:o.y*(G*D.row-x)}}}}function K(O,H,T){var U=I.zoom,x=2-R,D=4+R;for(O=O;O<H;O++){var G=f.load({column:O,row:T,zoom:U},B);if(!G.ready&&!(G.key in M)){G.proxyRefs={};for(var J,N,P,Q=1;Q<=x;Q++){N=true;for(var X=0,ea=1<<Q;X<=ea;X++)for(var aa=0;aa<=ea;aa++)if((P=f.peek(J={column:(O<<Q)+aa,row:(T<<Q)+X,zoom:U+Q}))&&P.ready){M[P.key]=f.load(J);P.proxyCount++;G.proxyRefs[P.key]=
-P}else N=false;if(N)break}if(!N)for(Q=1;Q<=D;Q++)if((P=f.peek(J={column:O>>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 j=a.map(),n=j.zoom(),w=n-(n=Math.round(n)),e=j.size(),r=j.angle(),o=j.tileSize(),z=j.locationCoordinate(j.center());if(A!=n){if(A<n)c(n);else if(A>n)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("+e.x/2+","+e.y/2+")"+(r?"rotate("+r/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(y?y.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&&!r&&!y){z.column=(Math.round(o.x*z.column)+(e.x&1)/2)/o.x;z.row=(Math.round(o.y*z.row)+(e.y&1)/2)/o.y}if(y){I=y.unapply(I);v=y.unapply(v);n=y.unapply(n);j=y.unapply(j);z=y.unapply(z)}var R=t?t(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=f.locks();var M={};for(var F in w)w[F].proxyCount=0;if(q&&R>-5&&R<3){r=I.zoom<0?1:1<<I.zoom;if(m){da(I,v,n,0,r,K);da(n,j,I,0,r,K)}else{e=Math.floor((I.column+n.column)/2);r=Math.max(0,Math.min(r-1,Math.floor((v.row+j.row)/2)));v=Math.min(4,I.zoom);e=e>>v<<v;r=r>>v<<v;K(e,e+1,r)}}for(F in M){v=M[F];e=Math.pow(2,v.level=v.zoom-z.zoom);v.element.setAttribute("transform","translate("+(v.x=o.x*(v.column-
-z.column*e))+","+(v.y=o.y*(v.row-z.row*e))+")")}for(F in w)if(!(F in M)){v=f.unload(F);v.element.parentNode.removeChild(v.element);delete v.proxyRefs}for(F in M){v=M[F];if(v.element.parentNode!=C[v.level]){C[v.level].appendChild(v.element);a.show&&a.show(v)}}f.flush();a.dispatch({type:"move"})}var a={},f=a.cache=s.cache(d,h).size(512),m=true,q=true,t,l,i,u=s.svg("g"),y,A,C={};u.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=u.appendChild(s.svg("g"));for(E=2;E>=1;E--)C[E]=u.appendChild(s.svg("g"));
+return{lon:h*d.column-180,lat:V(180-h*d.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;s.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 k(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 g(){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=s.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:o.x*(G*D.column-U),y:o.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=f.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=f.peek(J={column:(N<<Q)+aa,row:(T<<Q)+X,zoom:U+Q}))&&P.ready){O[P.key]=f.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=f.peek(J={column:N>>Q,row:T>>Q,zoom:U-Q}))&&P.ready){O[P.key]=f.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(),r=j.angle(),o=j.tileSize(),z=j.locationCoordinate(j.center());if(A!=n){if(A<n)c(n);else if(A>n)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("+e.x/2+","+e.y/2+")"+(r?"rotate("+r/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&&!r&&!x){z.column=(Math.round(o.x*z.column)+(e.x&1)/2)/o.x;z.row=(Math.round(o.y*z.row)+(e.y&1)/2)/o.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=t?t(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=f.locks();var O={};for(var F in w)w[F].proxyCount=0;if(q&&R>-5&&R<3){r=I.zoom<0?1:1<<I.zoom;if(m){da(I,v,n,0,r,K);da(n,j,I,0,r,K)}else{e=Math.floor((I.column+n.column)/2);r=Math.max(0,Math.min(r-1,Math.floor((v.row+j.row)/2)));v=Math.min(4,I.zoom);e=e>>v<<v;r=r>>v<<v;K(e,e+1,r)}}for(F in O){v=O[F];e=Math.pow(2,v.level=v.zoom-z.zoom);v.element.setAttribute("transform","translate("+(v.x=o.x*(v.column-
+z.column*e))+","+(v.y=o.y*(v.row-z.row*e))+")")}for(F in w)if(!(F in O)){v=f.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)}}f.flush();a.dispatch({type:"move"})}var a={},f=a.cache=s.cache(d,h).size(512),m=true,q=true,t,l,i,u=s.svg("g"),x,A,C={};u.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=u.appendChild(s.svg("g"));for(E=2;E>=1;E--)C[E]=u.appendChild(s.svg("g"));
C[0]=u.appendChild(s.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",g).off("resize",g);u.parentNode.removeChild(u)}if(i=B){i.container().appendChild(u);a.init&&a.init(u);i.on("move",g).on("resize",g);g()}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 q;(q=B)?u.removeAttribute("visibility"):
-u.setAttribute("visibility","hidden");i&&g();return a};a.transform=function(B){if(!arguments.length)return y;y=B;i&&g();return a};a.zoom=function(B){if(!arguments.length)return t;t=typeof B=="function"||B==null?B:function(){return B};i&&g();return a};a.tile=function(B){if(!arguments.length)return m;m=B;i&&g();return a};a.reload=function(){f.clear();i&&g();return a};a.dispatch=s.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<=
+u.setAttribute("visibility","hidden");i&&g();return a};a.transform=function(B){if(!arguments.length)return x;x=B;i&&g();return a};a.zoom=function(B){if(!arguments.length)return t;t=typeof B=="function"||B==null?B:function(){return B};i&&g();return a};a.tile=function(B){if(!arguments.length)return m;m=B;i&&g();return a};a.reload=function(){f.clear();i&&g();return a};a.dispatch=s.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&&f.unload(K)&&j.element.parentNode.removeChild(j.element)}delete B.tile.proxyRefs}});return a};s.image=function(){var d=s.layer(function(c){var k=c.element=s.svg("image"),g=d.map().tileSize();k.setAttribute("preserveAspectRatio","none");k.setAttribute("width",g.x);k.setAttribute("height",g.y);if(typeof h=="function"){k.setAttribute("opacity",0);g=h(c);if(g!=null)c.request=s.queue.image(k,g,function(a){delete c.request;c.ready=true;c.img=a;k.removeAttribute("opacity");d.dispatch({type:"load",tile:c})});
else{c.ready=true;d.dispatch({type:"load",tile:c})}}else{c.ready=true;h!=null&&k.setAttributeNS(s.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)?s.url(c):c;return d.reload()};return d};s.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 k(j,n,w){return j.type in E&&E[j.type](j,n,w)}function g(){var j=a.map().zoom(),n=a.cache.locks(),w,e,r,o,z,v,L;if(y=="fixed")for(w in n){if((e=n[w]).scale!=j){L="scale("+Math.pow(2,e.zoom-j)+")";o=-1;for(z=(r=e.features).length;++o<z;)k((v=r[o]).data.geometry,v.element,L);e.scale=j}}else for(w in n){o=-1;for(z=(r=(e=n[w]).features).length;++o<z;)k((v=r[o]).data.geometry,v.element,"");delete e.scale}}var a=s.layer(function(j,n){function w(r){var o=[];if(r.next)j.request=d(r.next.href,
+n)}function k(j,n,w){return j.type in E&&E[j.type](j,n,w)}function g(){var j=a.map().zoom(),n=a.cache.locks(),w,e,r,o,z,v,L;if(x=="fixed")for(w in n){if((e=n[w]).scale!=j){L="scale("+Math.pow(2,e.zoom-j)+")";o=-1;for(z=(r=e.features).length;++o<z;)k((v=r[o]).data.geometry,v.element,L);e.scale=j}}else for(w in n){o=-1;for(z=(r=(e=n[w]).features).length;++o<z;)k((v=r[o]).data.geometry,v.element,"");delete e.scale}}var a=s.layer(function(j,n){function w(r){var o=[];if(r.next)j.request=d(r.next.href,
w);switch(r.type){case "FeatureCollection":for(var z=0;z<r.features.length;z++){var v=r.features[z],L=c(v.geometry,n);L&&o.push({element:e.appendChild(L),data:v})}break;case "Feature":(L=c(r.geometry,n))&&o.push({element:e.appendChild(L),data:r});break;default:(L=c(r,n))&&o.push({element:e.appendChild(L),data:{type:"Feature",geometry:r}});break}j.ready=true;o.push.apply(j.features,o);a.dispatch({type:"load",tile:j,features:o})}var e=j.element=s.svg("g");j.features=[];n=h(n(j).locationPoint);if(m!=
-null)j.request=d(typeof m=="function"?m(j):m,w);else w({type:"FeatureCollection",features:A||[]})},function(j){j.request&&j.request.abort(true)}),f=a.container(),m,q=true,t="org.polymaps."+s.id(),l="url(#"+t+")",i=f.insertBefore(s.svg("clipPath"),f.firstChild),u=i.appendChild(s.svg("rect")),y="auto",A;f.setAttribute("fill-rule","evenodd");i.setAttribute("id",t);if(!arguments.length)d=s.queue.json;var C={Point:function(j,n){var w=n(j.coordinates),e=s.svg("circle");e.setAttribute("r",4.5);e.setAttribute("transform",
+null)j.request=d(typeof m=="function"?m(j):m,w);else w({type:"FeatureCollection",features:A||[]})},function(j){j.request&&j.request.abort(true)}),f=a.container(),m,q=true,t="org.polymaps."+s.id(),l="url(#"+t+")",i=f.insertBefore(s.svg("clipPath"),f.firstChild),u=i.appendChild(s.svg("rect")),x="auto",A;f.setAttribute("fill-rule","evenodd");i.setAttribute("id",t);if(!arguments.length)d=s.queue.json;var C={Point:function(j,n){var w=n(j.coordinates),e=s.svg("circle");e.setAttribute("r",4.5);e.setAttribute("transform",
"translate("+w.x+","+w.y+")");return e},MultiPoint:function(j,n){for(var w=s.svg("g"),e=j.coordinates,r,o,z=-1,v=e.length;++z<v;){o=w.appendChild(s.svg("circle"));o.setAttribute("r",4.5);o.setAttribute("transform","translate("+(r=n(e[z])).x+","+r.y+")")}return w},LineString:function(j,n){for(var w=s.svg("path"),e=["M"],r=j.coordinates,o,z=-1,v=r.length;++z<v;)e.push((o=n(r[z])).x,",",o.y,"L");e.pop();if(e.length){w.setAttribute("d",e.join(""));return w}},MultiLineString:function(j,n){for(var w=s.svg("path"),
e=[],r=j.coordinates,o,z=-1,v,L=r.length,I;++z<L;){o=r[z];v=-1;I=o.length;for(e.push("M");++v<I;)e.push((p=n(o[v])).x,",",p.y,"L");e.pop()}if(e.length){w.setAttribute("d",e.join(""));return w}},Polygon:function(j,n){for(var w=s.svg("path"),e=[],r=j.coordinates,o,z=-1,v,L=r.length,I;++z<L;){o=r[z];v=-1;I=o.length-1;for(e.push("M");++v<I;)e.push((p=n(o[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=s.svg("path"),e=[],
-r=j.coordinates,o,z,v=-1,L,I,R=r.length,M,F;++v<R;){o=r[v];L=-1;for(M=o.length;++L<M;){z=o[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=s.svg("g"),e=-1,r=j.geometries,o=r.length,z;++e<o;)(z=c(r[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,
+r=j.coordinates,o,z,v=-1,L,I,R=r.length,O,F;++v<R;){o=r[v];L=-1;for(O=o.length;++L<O;){z=o[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=s.svg("g"),e=-1,r=j.geometries,o=r.length,z;++e<o;)(z=c(r[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,r=o.length;n=n.firstChild;for(var o;++e<r;){o=j[e];n.setAttribute("transform","translate("+o.x+","+o.y+")"+w);n=n.nextSibling}}};a.url=function(j){if(!arguments.length)return m;m=typeof j=="string"&&/{.}/.test(j)?s.url(j):j;if(m!=null)A=null;typeof m=="string"&&a.tile(false);return a.reload()};a.features=function(j){if(!arguments.length)return A;if(A=j){m=null;a.tile(false)}return a.reload()};a.clip=function(j){if(!arguments.length)return q;q&&f.removeChild(i);if(q=j)f.insertBefore(i,
-f.firstChild);var n=a.cache.locks();for(var w in n)q?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 y;(y=j)?a.on("move",g):a.off("move",g);a.map()&&g();return a};a.show=function(j){q?
+f.firstChild);var n=a.cache.locks();for(var w in n)q?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",g):a.off("move",g);a.map()&&g();return a};a.show=function(j){q?
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};s.dblclick=function(){function d(a){var f=k.zoom();f=a.shiftKey?Math.ceil(f)-f-1:1-f+Math.floor(f);c==="mouse"?k.zoomBy(f,k.mouse(a)):k.zoomBy(f)}var h={},c="mouse",k,g;h.zoom=function(a){if(!arguments.length)return c;c=a;return h};h.map=function(a){if(!arguments.length)return k;
if(k){g.removeEventListener("dblclick",d,false);g=null}if(k=a){g=k.container();g.addEventListener("dblclick",d,false)}return h};return h};s.drag=function(){function d(f){if(!f.shiftKey){a={x:f.clientX,y:f.clientY};k.focusableParent().focus();f.preventDefault();document.body.style.setProperty("cursor","move",null)}}function h(f){if(a){k.panBy({x:f.clientX-a.x,y:f.clientY-a.y});a.x=f.clientX;a.y=f.clientY}}var c={},k,g,a;c.map=function(f){if(!arguments.length)return k;if(k){g.removeEventListener("mousedown",
-d,false);g=null}if(k=f){g=k.container();g.addEventListener("mousedown",d,false)}return c};window.addEventListener("mousemove",h,false);window.addEventListener("mouseup",function(f){if(a){h(f);a=null;document.body.style.removeProperty("cursor")}},false);return c};s.wheel=function(){function d(){m=null}function h(l){var i=(l.wheelDelta/120||-l.detail)*0.1,u;if(ba<0){u=Date.now();var y=u-g;if(y>9&&Math.abs(l.wheelDelta)/y>=50)ba=1;g=u}if(ba==1)i*=0.03;if(!a&&i){u=Date.now();if(u-k>200){i=i>0?+1:-1;k=
+d,false);g=null}if(k=f){g=k.container();g.addEventListener("mousedown",d,false)}return c};window.addEventListener("mousemove",h,false);window.addEventListener("mouseup",function(f){if(a){h(f);a=null;document.body.style.removeProperty("cursor")}},false);return c};s.wheel=function(){function d(){m=null}function h(l){var i=(l.wheelDelta/120||-l.detail)*0.1,u;if(ba<0){u=Date.now();var x=u-g;if(x>9&&Math.abs(l.wheelDelta)/x>=50)ba=1;g=u}if(ba==1)i*=0.03;if(!a&&i){u=Date.now();if(u-k>200){i=i>0?+1:-1;k=
u}else i=0}if(i)switch(f){case "mouse":u=q.mouse(l);m||(m=q.pointLocation(u));q.off("move",d).zoomBy(i,u,m).on("move",d);break;case "location":q.zoomBy(i,q.locationPoint(m),m);break;default:q.zoomBy(i);break}l.preventDefault();return false}var c={},k=0,g=0,a=true,f="mouse",m,q,t;c.smooth=function(l){if(!arguments.length)return a;a=l;return c};c.zoom=function(l,i){if(!arguments.length)return f;f=l;m=i;if(q)f=="mouse"?q.on("move",d):q.off("move",d);return c};c.map=function(l){if(!arguments.length)return q;
-if(q){t.removeEventListener("mousemove",d,false);t.removeEventListener("mousewheel",h,false);t.removeEventListener("DOMMouseScroll",h,false);t=null;q.off("move",d)}if(q=l){f=="mouse"&&q.on("move",d);t=q.container();t.addEventListener("mousemove",d,false);t.addEventListener("mousewheel",h,false);t.addEventListener("DOMMouseScroll",h,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;s.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=l)}break;case 39:if(!a.right){f=A;a.right=1;a.left||(C=-l)}break;case 38:if(!a.up){f=A;a.up=1;a.down||(E=l)}break;case 40:if(!a.down){f=A;a.down=1;a.up||(E=-l)}break;default:return}if(C||E)i.panBy({x:C,y:E});if(!m&&a.left|a.right|a.up|a.down)m=setInterval(k,t);y.preventDefault()}}function h(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(m&&
-!(a.left|a.right|a.up|a.down))m=clearInterval(m);y.preventDefault()}function c(y){switch(y.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}y.preventDefault()}function k(){if(i)if(!(Date.now()<f+q)){var y=(a.left-a.right)*l,A=(a.up-a.down)*l;if(y||A)i.panBy({x:y,y:A})}}var g={},a={left:0,right:0,up:0,down:0},f=0,m,q=250,t=50,l=16,i,u;g.map=function(y){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=y){u=i.focusableParent();u.addEventListener("keypress",c,false);u.addEventListener("keydown",d,false);u.addEventListener("keyup",h,false)}return g};g.speed=function(y){if(!arguments.length)return l;l=y;return g};return g};s.hash=function(){function d(){var f=a.center(),m=a.zoom(),q=Math.max(0,Math.ceil(Math.log(m)/Math.LN2));f="#"+m.toFixed(2)+"/"+f.lat.toFixed(q)+"/"+f.lon.toFixed(q);if(k!==f)location.replace(k=
+if(q){t.removeEventListener("mousemove",d,false);t.removeEventListener("mousewheel",h,false);t.removeEventListener("DOMMouseScroll",h,false);t=null;q.off("move",d)}if(q=l){f=="mouse"&&q.on("move",d);t=q.container();t.addEventListener("mousemove",d,false);t.addEventListener("mousewheel",h,false);t.addEventListener("DOMMouseScroll",h,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;s.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){f=A;a.left=1;a.right||(C=l)}break;case 39:if(!a.right){f=A;a.right=1;a.left||(C=-l)}break;case 38:if(!a.up){f=A;a.up=1;a.down||(E=l)}break;case 40:if(!a.down){f=A;a.down=1;a.up||(E=-l)}break;default:return}if(C||E)i.panBy({x:C,y:E});if(!m&&a.left|a.right|a.up|a.down)m=setInterval(k,t);x.preventDefault()}}function h(x){f=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(m&&
+!(a.left|a.right|a.up|a.down))m=clearInterval(m);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 k(){if(i)if(!(Date.now()<f+q)){var x=(a.left-a.right)*l,A=(a.up-a.down)*l;if(x||A)i.panBy({x:x,y:A})}}var g={},a={left:0,right:0,up:0,down:0},f=0,m,q=250,t=50,l=16,i,u;g.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 g};g.speed=function(x){if(!arguments.length)return l;l=x;return g};return g};s.hash=function(){function d(){var f=a.center(),m=a.zoom(),q=Math.max(0,Math.ceil(Math.log(m)/Math.LN2));f="#"+m.toFixed(2)+"/"+f.lat.toFixed(q)+"/"+f.lon.toFixed(q);if(k!==f)location.replace(k=
f)}function h(){if(location.hash!==k){var f=(k=location.hash).substring(1).split("/").map(Number);if(f.length<3||f.some(isNaN))d();else{var m=a.size();a.zoomBy(f[0]-a.zoom(),{x:m.x/2,y:m.y/2},{lat:Math.min(g,Math.max(-g,f[1])),lon:f[2]})}}}var c={},k,g=89.99999999,a;c.map=function(f){if(!arguments.length)return a;if(a){a.off("move",d);window.removeEventListener("hashchange",h,false)}if(a=f){a.on("move",d);window.addEventListener("hashchange",h,false);location.hash?h():d()}return c};return c};s.interact=
-function(){var d={},h=s.drag(),c=s.wheel(),k=s.dblclick(),g=s.arrow();d.map=function(a){h.map(a);c.map(a);k.map(a);g.map(a);return d};return d};s.compass=function(){function d(x){B.setAttribute("class","compass active");I||(I=setInterval(h,r));R&&H.panBy(R);w=Date.now();return l(x)}function h(){R&&Date.now()>w+e&&H.panBy(R)}function c(x){if(x.shiftKey){F={x0:H.mouse(x)};H.focusableParent().focus();return l(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 g(){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 l(D)}}function m(x){return function(D){H.zoom(x);return l(D)}}function q(){this.setAttribute("class","active")}function t(){this.removeAttribute("class")}function l(x){x.stopPropagation();x.preventDefault();return false}function i(x){var D=Math.SQRT1_2*j,G=j*0.7,J=j*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"+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");N.addEventListener("mousedown",d,false);N.addEventListener("mouseover",a(x),false);N.addEventListener("mouseout",a(null),false);N.addEventListener("dblclick",l,false);return N}function u(x){var D=j*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",f(x),false);J.addEventListener("mouseover",q,false);J.addEventListener("mouseout",t,false);J.addEventListener("dblclick",l,false);return J}function y(x){var D=j*0.2,G=j*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",m(x),false);J.addEventListener("dblclick",l,false);return J}function A(){var x=j+6,D=x,G=H.size();switch(o){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",j);M.appendChild(i({x:0,y:-n})).setAttribute("transform","rotate(0)");M.appendChild(i({x:n,y:0})).setAttribute("transform","rotate(90)");M.appendChild(i({x:0,y:n})).setAttribute("transform","rotate(180)");M.appendChild(i({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",j)}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)*j*0.4+")")}D=L=="none"?0.4:2;v.setAttribute("transform","translate(0,"+j*(/^top-/.test(o)?D+(x+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(x+0.5)*j*0.4+")");
-v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E={},B=s.svg("g"),K={},j=30,n=16,w=0,e=250,r=50,o="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 j;j=x;H&&C();return E};E.speed=function(x){if(!arguments.length)return j;n=x;return E};E.position=function(x){if(!arguments.length)return o;
-o=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",g,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;
+function(){var d={},h=s.drag(),c=s.wheel(),k=s.dblclick(),g=s.arrow();d.map=function(a){h.map(a);c.map(a);k.map(a);g.map(a);return d};return d};s.compass=function(){function d(y){B.setAttribute("class","compass active");I||(I=setInterval(h,r));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 k(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 g(){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 f(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 m(y){return function(D){H.zoom(y);return l(D)}}function q(){this.setAttribute("class","active")}function t(){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=s.svg("g"),P=M.appendChild(s.svg("path")),Q=M.appendChild(s.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=s.svg("g"),
+M=J.appendChild(s.svg("path")),P=J.appendChild(s.svg("path")),Q=J.appendChild(s.svg("path")),X=J.appendChild(s.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",f(y),false);J.addEventListener("mouseover",q,false);J.addEventListener("mouseout",t,false);J.addEventListener("dblclick",l,false);return J}function x(y){var D=j*0.2,G=j*0.4,J=s.svg("g"),M=J.appendChild(s.svg("rect")),P=J.appendChild(s.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",m(y),false);J.addEventListener("dblclick",l,false);return J}function A(){var y=j+6,D=y,G=H.size();switch(o){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(s.svg("g"));O.setAttribute("class","pan");var y=O.appendChild(s.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(s.svg("circle"));y.setAttribute("fill",
+"none");y.setAttribute("class","fore");y.setAttribute("r",j)}else O=null;if(z!="none"){v=B.appendChild(s.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(o)?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=s.svg("g"),K={},j=30,n=16,w=0,e=250,r=50,o="top-left",z="small",v,L="small",I,R,O,F,N=s.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 o;
+o=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",k,false);U.removeEventListener("mouseup",g,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",k,false);U.addEventListener("mouseup",g,false);H.on("move",A).on("resize",A);C()}return E};return E};s.grid=function(){function d(){var g=k.firstChild,a=c.size(),f=c.pointLocation(Y);c.pointLocation(a);var m=Math.pow(2,4-Math.round(c.zoom()));f.lat=Math.floor(f.lat/m)*m;f.lon=Math.ceil(f.lon/m)*m;for(var q;(q=c.locationPoint(f).x)<=a.x;f.lon+=m){g||(g=k.appendChild(s.svg("line")));g.setAttribute("x1",q);g.setAttribute("x2",q);g.setAttribute("y1",0);g.setAttribute("y2",
a.y);g=g.nextSibling}for(;(q=c.locationPoint(f).y)<=a.y;f.lat-=m){g||(g=k.appendChild(s.svg("line")));g.setAttribute("y1",q);g.setAttribute("y2",q);g.setAttribute("x1",0);g.setAttribute("x2",a.x);g=g.nextSibling}for(;g;){a=g.nextSibling;k.removeChild(g);g=a}}var h={},c,k=s.svg("g");k.setAttribute("class","grid");h.map=function(g){if(!arguments.length)return c;if(c){k.parentNode.removeChild(k);c.off("move",d).off("resize",d)}if(c=g){c.on("move",d).on("resize",d);c.container().appendChild(k);c.dispatch({type:"move"})}return h};
-return h};s.stylist=function(){function d(g){var a=g.features.length,f=h.length,m=c.length,q,t,l,i,u,y;for(u=0;u<a;++u)if(t=(q=g.features[u]).element){q=q.data;for(y=0;y<f;++y){i=(l=h[y]).value;if(typeof i==="function")i=i.call(null,q);i==null?l.name.local?t.removeAttributeNS(l.name.space,l.name.local):t.removeAttribute(l.name):l.name.local?t.setAttributeNS(l.name.space,l.name.local,i):t.setAttribute(l.name,i)}for(y=0;y<m;++y){i=(l=c[y]).value;if(typeof i==="function")i=i.call(null,q);i==null?t.style.removeProperty(l.name):
+return h};s.stylist=function(){function d(g){var a=g.features.length,f=h.length,m=c.length,q,t,l,i,u,x;for(u=0;u<a;++u)if(t=(q=g.features[u]).element){q=q.data;for(x=0;x<f;++x){i=(l=h[x]).value;if(typeof i==="function")i=i.call(null,q);i==null?l.name.local?t.removeAttributeNS(l.name.space,l.name.local):t.removeAttribute(l.name):l.name.local?t.setAttributeNS(l.name.space,l.name.local,i):t.setAttribute(l.name,i)}for(x=0;x<m;++x){i=(l=c[x]).value;if(typeof i==="function")i=i.call(null,q);i==null?t.style.removeProperty(l.name):
t.style.setProperty(l.name,i,l.priority)}if(i=k){if(typeof i==="function")i=i.call(null,q);for(;t.lastChild;)t.removeChild(t.lastChild);i!=null&&t.appendChild(s.svg("title")).appendChild(document.createTextNode(i))}}}var h=[],c=[],k;d.attr=function(g,a){h.push({name:fa(g),value:a});return d};d.style=function(g,a,f){c.push({name:g,value:a,priority:arguments.length<3?null:f});return d};d.title=function(g){k=g;return d};return d}})(org.polymaps);
View
5 src/Compass.js
@@ -189,9 +189,8 @@ po.compass = function() {
case "bottom-left": y = size.y - y; break;
case "bottom-right": x = size.x - x; y = size.y - y; break;
}
- var tx = "translate(" + x + "," + y + ")";
- if (panContainer) panContainer.setAttribute("transform", tx);
- if (zoomContainer) zoomContainer.setAttribute("transform", tx);
+ g.setAttribute("transform", "translate(" + x + "," + y + ")");
+ dragRect.setAttribute("transform", "translate(" + -x + "," + -y + ")");
for (var i in ticks) {
i == map.zoom()
? ticks[i].setAttribute("class", "active")

0 comments on commit 7c33ade

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