From a9137c1f6aaa8c3db1b0a4b5cab326a75a3e43e2 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Tue, 31 Aug 2010 09:09:59 -0700 Subject: [PATCH 1/9] Use keypress events for arrow zooming. The plus and minus key codes are not consistent across browsers. The char codes appear to be more consistent, so we use those; note that this also has the side-effect of enabling repeated zooming if the plus or minus key is held down. This makes zooming more consistent with the current (custom repeating) pan behavior. --- polymaps.js | 40 +++++++------------ polymaps.min.js | 101 ++++++++++++++++++++++++------------------------ src/Arrow.js | 40 +++++++------------ src/start.js | 2 +- 4 files changed, 79 insertions(+), 104 deletions(-) diff --git a/polymaps.js b/polymaps.js index 1ce798b..a1169b6 100644 --- a/polymaps.js +++ b/polymaps.js @@ -1351,7 +1351,7 @@ po.wheel = function() { var bug40441 = /WebKit\/533/.test(navigator.userAgent) ? -1 : 0; po.arrow = function() { var arrow = {}, - key = {left: 0, right: 0, up: 0, down: 0, plus: 0, minus: 0}, + key = {left: 0, right: 0, up: 0, down: 0}, last = 0, repeatTimer, repeatDelay = 250, @@ -1362,7 +1362,7 @@ po.arrow = function() { function keydown(e) { if (e.ctrlKey || e.altKey || e.metaKey) return; - var now = Date.now(), dx = 0, dy = 0, dz = 0; + var now = Date.now(), dx = 0, dy = 0; switch (e.keyCode) { case 37: { if (!key.left) { @@ -1396,30 +1396,9 @@ po.arrow = function() { } break; } - case 109: case 189: { - if (!key.plus) { - last = now; - key.plus = 1; - if (!key.minus) dz = -1; - } - break; - } - case 61: case 187: { - if (!key.minus) { - last = now; - key.minus = 1; - if (!key.plus) dz = 1; - } - break; - } default: return; } - if (dz) { - var z = map.zoom(); - map.zoom(dz < 0 ? Math.ceil(z) - 1 : Math.floor(z) + 1); - } else if (dx || dy) { - map.panBy({x: dx, y: dy}); - } + if (dx || dy) map.panBy({x: dx, y: dy}); if (!repeatTimer && (key.left | key.right | key.up | key.down)) { repeatTimer = setInterval(repeat, repeatInterval); } @@ -1433,8 +1412,6 @@ po.arrow = function() { case 39: key.right = 0; break; case 38: key.up = 0; break; case 40: key.down = 0; break; - case 109: case 189: key.plus = 0; break; - case 61: case 187: key.minus = 0; break; default: return; } if (repeatTimer && !(key.left | key.right | key.up | key.down)) { @@ -1443,6 +1420,15 @@ po.arrow = function() { e.preventDefault(); } + function keypress(e) { + switch (e.charCode) { + case 45: case 95: map.zoom(Math.ceil(map.zoom()) - 1); break; + case 43: case 61: map.zoom(Math.floor(map.zoom()) + 1); break; + default: return; + } + e.preventDefault(); + } + function repeat() { if (!map) return; if (Date.now() < last + repeatDelay) return; @@ -1454,12 +1440,14 @@ po.arrow = function() { arrow.map = function(x) { if (!arguments.length) return map; if (map) { + parent.removeEventListener("keypress", keypress, false); parent.removeEventListener("keydown", keydown, false); parent.removeEventListener("keyup", keyup, false); parent = null; } if (map = x) { parent = map.focusableParent(); + parent.addEventListener("keypress", keypress, false); parent.addEventListener("keydown", keydown, false); parent.addEventListener("keyup", keyup, false); } diff --git a/polymaps.min.js b/polymaps.min.js index 06a7352..33b88c1 100644 --- a/polymaps.min.js +++ b/polymaps.min.js @@ -1,52 +1,51 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={}; -(function(s){function M(){for(var d=0;da.row){var f=d;d=a;a=f}return{x0:d.column,y0:d.row,x1:a.column,y1:a.row,dx:a.column-d.column,dy:a.row-d.row}}function Z(d,a,f,e,c){f=Math.max(f,Math.floor(a.y0));e=Math.min(e,Math.ceil(a.y1));if(d.x0==a.x0&&d.y0==a.y0?d.x0+a.dy/d.dy*d.dx0,o=a.dx<0;for(f=f;fa.dy){f=i;i=a;a=f}if(i.dy>d.dy){f=i;i=d;d=f}if(a.dy>d.dy){f=a;a=d;d=f}i.dy&&Z(d,i,e,c,g);a.dy&&Z(d,a,e,c,g)}s.version="2.0.2+6";var S={x:0,y:0};s.id=function(){var d=0;return function(){return++d}}();s.svg=function(d){return document.createElementNS(s.ns.svg, -d)};s.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};s.transform=function(d,a,f,e,c,g){var i={},j,o,t;if(!arguments.length){d=1;a=c=f=0;e=1;g=0}i.zoomFraction=function(l){if(!arguments.length)return o;o=l;j=Math.floor(o+Math.log(Math.sqrt(d*d+a*a+f*f+e*e))/Math.log(2));t=Math.pow(2,-j);return i};i.apply=function(l){var r=Math.pow(2,-l.zoom),h=Math.pow(2,l.zoom-j);return{column:(d*l.column*r+f*l.row*r+c)*h,row:(a*l.column*r+e*l.row*r+g)*h,zoom:l.zoom-j}};i.unapply=function(l){var r= -Math.pow(2,-l.zoom),h=Math.pow(2,l.zoom+j);return{column:(l.column*r*e-l.row*r*f-c*e+g*f)/(d*e-a*f)*h,row:(l.column*r*a-l.row*r*d-c*a+g*d)/(f*a-e*d)*h,zoom:l.zoom+j}};i.toString=function(){return"matrix("+[d*t,a*t,f*t,e*t].join(" ")+" 0 0)"};return i.zoomFraction(0)};s.cache=function(d,a){function f(r){l--;a&&a(r);delete i[r.key];if(r.next)r.next.prev=r.prev;else if(o=r.prev)o.next=null;if(r.prev)r.prev.next=r.next;else if(j=r.next)j.prev=null}function e(){for(var r=o;l>t;r=r.prev){if(!r)break;r.lock|| -f(r)}}var c={},g={},i={},j=null,o=null,t=64,l=0;c.peek=function(r){return i[[r.zoom,r.column,r.row].join("/")]};c.load=function(r,h){var m=[r.zoom,r.column,r.row].join("/"),q=i[m];if(q){if(q.prev){if(q.prev.next=q.next)q.next.prev=q.prev;else o=q.prev;q.prev=null;q.next=j;j=j.prev=q}q.lock=1;return g[m]=q}q={key:m,column:r.column,row:r.row,zoom:r.zoom,next:j,prev:null,lock:1};d.call(null,q,h);g[m]=i[m]=q;if(j)j.prev=q;else o=q;j=q;l++;e();return q};c.unload=function(r){if(!(r in g))return false;var h= -g[r];h.lock=0;delete g[r];h.request&&h.request.abort(false)?f(h):e();return h};c.locks=function(){return g};c.size=function(r){if(!arguments.length)return t;t=r;e();return c};return c};s.url=function(d){function a(e){var c=1<=g||!e.length)){c++;e.pop()()}}function a(i){for(var j=0;j=0)return k;return window};a.mouse=function(k){var u=(f.ownerSVGElement||f).createSVGPoint();if(V<0&&(window.scrollX||window.scrollY)){var y=document.body.appendChild(s.svg("svg")); -y.style.position="absolute";y.style.top=y.style.left="0px";var B=y.getScreenCTM();V=!(B.f||B.e);document.body.removeChild(y)}if(V){u.x=k.pageX;u.y=k.pageY}else{u.x=k.clientX;u.y=k.clientY}return u.matrixTransform(f.getScreenCTM().inverse())};a.size=function(k){if(!arguments.length)return c;e=k;return a.resize()};a.resize=function(){if(e){c=e;M.remove(a)}else{var k=f.ownerSVGElement||f;if(k.offsetWidth==null){D.setAttribute("width","100%");D.setAttribute("height","100%");k=D}b=k.getBoundingClientRect(); -c={x:b.width,y:b.height};M.add(a)}D.setAttribute("width",c.x);D.setAttribute("height",c.y);g={x:c.x/2,y:c.y/2};d();a.dispatch({type:"resize"});return a};a.tileSize=function(k){if(!arguments.length)return i;i=k;a.dispatch({type:"move"});return a};a.center=function(k){if(!arguments.length)return j;j=k;d();a.dispatch({type:"move"});return a};a.panBy=function(k){var u=45/Math.pow(2,o+t-3),y=k.x*u;k=k.y*u;return a.center({lon:j.lon+(w*k-n*y)/i.x,lat:Q(R(j.lat)+(w*y+n*k)/i.y)})};a.centerRange=function(k){if(!arguments.length)return H; -if(H=k){x=H[0].lat>-90?R(H[0].lat):-Infinity;G=H[0].lat<90?R(H[1].lat):Infinity}else{x=-Infinity;G=Infinity}d();a.dispatch({type:"move"});return a};a.zoom=function(k){if(!arguments.length)return o+t;o=Math.max(r[0],Math.min(r[1],k));t=o-(o=Math.round(o));l=Math.pow(2,t);return a.center(j)};a.zoomBy=function(k,u,y){if(arguments.length<2)return a.zoom(o+t+k);if(arguments.length<3)y=a.pointLocation(u);o=Math.max(r[0],Math.min(r[1],o+t+k));t=o-(o=Math.round(o));l=Math.pow(2,t);var B=a.locationPoint(y); -return a.panBy({x:u.x-B.x,y:u.y-B.y})};a.zoomRange=function(k){if(!arguments.length)return r;r=k;return a.zoom(o+t)};a.angle=function(k){if(!arguments.length)return h;h=k;m=Math.cos(h);q=Math.sin(h);n=Math.cos(-h);w=Math.sin(-h);d();a.dispatch({type:"move"});return a};a.add=function(k){k.map(a);return a};a.remove=function(k){k.map(null);return a};a.dispatch=s.dispatch(a);return a};M.maps=[];M.add=function(d){for(var a=0;a>O,row:A>>O,zoom:C-O}))&&N.ready){L[N.key]=c.load(P);N.proxyCount++;K.proxyRefs[N.key]=N;break}}L[K.key]=K}}var n=e.map(),w=n.zoom(),x=w-(w=Math.round(w)),G=n.size(),H=n.angle(),D=n.tileSize(),k=n.locationCoordinate(n.center());i?l.removeAttribute("visibility"):l.setAttribute("visibility","hidden");for(var u=-4;u<=2;u++)h[u].setAttribute("class","zoom"+(u<0?"":"+")+u+" zoom"+(w+u));l.setAttribute("transform","translate("+G.x/2+","+G.y/2+")"+(H?"rotate("+H/Math.PI*180+")":"")+(x? -"scale("+Math.pow(2,x)+")":"")+(r?r.zoomFraction(x):""));var y=n.pointCoordinate(k,S);u=n.pointCoordinate(k,{x:G.x,y:0});var B=n.pointCoordinate(k,G);n=n.pointCoordinate(k,{x:0,y:G.y});if(!x&&!H&&!r){k.column=(Math.round(D.x*k.column)+(G.x&1)/2)/D.x;k.row=(Math.round(D.y*k.row)+(G.y&1)/2)/D.y}var I=j?j(w)-w:0;if(I){x=Math.pow(2,I);y.column*=x;y.row*=x;u.column*=x;u.row*=x;B.column*=x;B.row*=x;n.column*=x;n.row*=x;y.zoom=u.zoom=B.zoom=n.zoom+=I}if(r){y=r.unapply(y);u=r.unapply(u);B=r.unapply(B);n= -r.unapply(n);k=r.unapply(k)}w=c.locks();var L={};for(var E in w)w[E].proxyCount=0;if(i&&I>-5&&I<3){x=1<>u<>u<=1;q--)(h[q]=l.appendChild(s.svg("g"))).setAttribute("transform","scale("+Math.pow(2,-q)+")");h[0]=l.appendChild(s.svg("g"));e.init&&e.init(l);t.on("move",f).on("resize",f);f()}return e};e.container=function(){return l};e.id=function(m){if(!arguments.length)return o;o=m;return e};e.visible=function(m){if(!arguments.length)return i;i=m;t&&f();return e};e.transform=function(m){if(!arguments.length)return r; -r=m;t&&f();return e};e.zoom=function(m){if(!arguments.length)return j;j=typeof m=="function"||m==null?m:function(){return m};return e};e.tile=function(m){if(!arguments.length)return g;g=m;return e};e.dispatch=s.dispatch(e);e.on("load",function(m){if(m.tile.proxyRefs){for(var q in m.tile.proxyRefs){var n=m.tile.proxyRefs[q];--n.proxyCount<=0&&c.unload(q)&&n.element.parentNode.removeChild(n.element)}delete m.tile.proxyRefs}});return e};s.image=function(){var d=s.layer(function(f){var e=f.element=s.svg("image"), -c=d.map().tileSize();e.setAttribute("preserveAspectRatio","none");e.setAttribute("width",c.x);e.setAttribute("height",c.y);e.setAttribute("opacity",0);if(typeof a=="function")f.request=s.queue.image(e,a(f),function(){delete f.request;f.ready=true;e.removeAttribute("opacity");d.dispatch({type:"load",tile:f})});else{f.ready=true;e.setAttributeNS(s.ns.xlink,"href",a);d.dispatch({type:"load",tile:f})}},function(f){f.request&&f.request.abort(true)}),a="about:blank";d.url=function(f){if(!arguments.length)return a; -a=typeof f=="string"&&/{.}/.test(f)?s.url(f):f;return d};return d};s.geoJson=function(d){function a(h,m){var q=m({lat:h[1],lon:h[0]}),n=s.svg("circle");n.setAttribute("r",4.5);n.setAttribute("cx",q.x);n.setAttribute("cy",q.y);return n}function f(h,m,q,n){n.push("M");for(var w=0;w9&&Math.abs(t.wheelDelta)/m>=50)Y=1;c=h}if(Y==1)l*=0.03;i||(i=j.pointLocation(r));j.off("move",d);if(g)j.zoomBy(l,r,i);else if(l){h=Date.now();if(h-e>200){j.zoomBy(l>0?+1:-1,r,i);e=h}}j.on("move",d);t.preventDefault();return false}var f={},e=0,c=0,g=true,i,j,o;f.smooth=function(t){if(!arguments.length)return g;g=t;return f};f.map=function(t){if(!arguments.length)return j;if(j){o.removeEventListener("mousemove",d,false);o.removeEventListener("mousewheel",a,false); -o.removeEventListener("DOMMouseScroll",a,false);o=null;j.off("move",d)}if(j=t){j.on("move",d);o=j.container();o.addEventListener("mousemove",d,false);o.addEventListener("mousewheel",a,false);o.addEventListener("DOMMouseScroll",a,false)}return f};return f};var Y=/WebKit\/533/.test(navigator.userAgent)?-1:0;s.arrow=function(){function d(h){if(!(h.ctrlKey||h.altKey||h.metaKey)){var m=Date.now(),q=0,n=0,w=0;switch(h.keyCode){case 37:if(!c.left){g=m;c.left=1;c.right||(q=t)}break;case 39:if(!c.right){g= -m;c.right=1;c.left||(q=-t)}break;case 38:if(!c.up){g=m;c.up=1;c.down||(n=t)}break;case 40:if(!c.down){g=m;c.down=1;c.up||(n=-t)}break;case 109:case 189:if(!c.plus){g=m;c.plus=1;c.minus||(w=-1)}break;case 61:case 187:if(!c.minus){g=m;c.minus=1;c.plus||(w=1)}break;default:return}if(w){m=l.zoom();l.zoom(w<0?Math.ceil(m)-1:Math.floor(m)+1)}else if(q||n)l.panBy({x:q,y:n});if(!i&&c.left|c.right|c.up|c.down)i=setInterval(f,o);h.preventDefault()}}function a(h){g=Date.now();switch(h.keyCode){case 37:c.left= -0;break;case 39:c.right=0;break;case 38:c.up=0;break;case 40:c.down=0;break;case 109:case 189:c.plus=0;break;case 61:case 187:c.minus=0;break;default:return}if(i&&!(c.left|c.right|c.up|c.down))i=clearInterval(i);h.preventDefault()}function f(){if(l)if(!(Date.now()H+D&&E.panBy(L)}function f(){n.setAttribute("class","compass");if(I){clearInterval(I);I=0}}function e(v){return function(){v?this.setAttribute("class","active"):this.removeAttribute("class");L=v}}function c(v){return function(z){n.setAttribute("class","compass active");var A=E.zoom();E.zoom(v< -0?Math.ceil(A)-1:Math.floor(A)+1);return o(z)}}function g(v){return function(z){E.zoom(v);return o(z)}}function i(){this.setAttribute("class","active")}function j(){this.removeAttribute("class")}function o(v){v.stopPropagation();v.preventDefault();return false}function t(v){var z=Math.SQRT1_2*x,A=x*0.7,C=x*0.2,F=s.svg("g"),J=F.appendChild(s.svg("path")),K=F.appendChild(s.svg("path"));J.setAttribute("class","direction");J.setAttribute("pointer-events","all");J.setAttribute("d","M0,0L"+z+","+z+"A"+ -x+","+x+" 0 0,1 "+-z+","+z+"Z");K.setAttribute("class","chevron");K.setAttribute("d","M"+C+","+(A-C)+"L0,"+A+" "+-C+","+(A-C));K.setAttribute("pointer-events","none");F.addEventListener("mousedown",d,false);F.addEventListener("mouseover",e(v),false);F.addEventListener("mouseout",e(null),false);F.addEventListener("dblclick",o,false);return F}function l(v){var z=x*0.4,A=z/2,C=s.svg("g"),F=C.appendChild(s.svg("path")),J=C.appendChild(s.svg("path")),K=C.appendChild(s.svg("path")),P=C.appendChild(s.svg("path")); -F.setAttribute("class","back");F.setAttribute("d","M"+-z+",0V"+-z+"A"+z+","+z+" 0 1,1 "+z+","+-z+"V0Z");J.setAttribute("class","direction");J.setAttribute("d",F.getAttribute("d"));K.setAttribute("class","chevron");K.setAttribute("d","M"+-A+","+-z+"H"+A+(v>0?"M0,"+(-z-A)+"V"+-A:""));P.setAttribute("class","fore");P.setAttribute("fill","none");P.setAttribute("d",F.getAttribute("d"));C.addEventListener("mousedown",c(v),false);C.addEventListener("mouseover",i,false);C.addEventListener("mouseout",j,false); -C.addEventListener("dblclick",o,false);return C}function r(v){var z=x*0.2,A=x*0.4,C=s.svg("g"),F=C.appendChild(s.svg("rect")),J=C.appendChild(s.svg("path"));F.setAttribute("pointer-events","all");F.setAttribute("fill","none");F.setAttribute("x",-A);F.setAttribute("y",-0.75*A);F.setAttribute("width",2*A);F.setAttribute("height",1.5*A);J.setAttribute("class","chevron");J.setAttribute("d","M"+-z+",0H"+z);C.addEventListener("mousedown",g(v),false);C.addEventListener("dblclick",o,false);return C}function h(){var v= -x+6,z=v,A=E.size();switch(u){case "top-left":break;case "top-right":v=A.x-v;break;case "bottom-left":z=A.y-z;break;case "bottom-right":v=A.x-v;z=A.y-z;break}n.setAttribute("transform","translate("+v+","+z+")");for(var C in w)C==E.zoom()?w[C].setAttribute("class","active"):w[C].removeAttribute("class")}function m(){for(;n.lastChild;)n.removeChild(n.lastChild);if(B!="none"){var v=n.appendChild(s.svg("g"));v.setAttribute("class","pan");var z=v.appendChild(s.svg("circle"));z.setAttribute("class","back"); -z.setAttribute("r",x);v.appendChild(t({x:0,y:-G})).setAttribute("transform","rotate(0)");v.appendChild(t({x:G,y:0})).setAttribute("transform","rotate(90)");v.appendChild(t({x:0,y:G})).setAttribute("transform","rotate(180)");v.appendChild(t({x:-G,y:0})).setAttribute("transform","rotate(270)");v=v.appendChild(s.svg("circle"));v.setAttribute("fill","none");v.setAttribute("class","fore");v.setAttribute("r",x)}if(y!="none"){v=n.appendChild(s.svg("g"));v.setAttribute("class","zoom");z=-0.5;if(y=="big"){w= -{};var A=E.zoomRange()[0];for(z=0;A<=E.zoomRange()[1];A++,z++)(w[A]=v.appendChild(r(A))).setAttribute("transform","translate(0,"+-(z+0.75)*x*0.4+")")}A=B=="none"?0.4:2;v.setAttribute("transform","translate(0,"+x*(/^top-/.test(u)?A+(z+0.5)*0.4:-A)+")");v.appendChild(l(+1)).setAttribute("transform","translate(0,"+-(z+0.5)*x*0.4+")");v.appendChild(l(-1)).setAttribute("transform","scale(-1)")}h()}var q={},n=s.svg("g"),w={},x=30,G=16,H=0,D=250,k=50,u="top-left",y="small",B="small",I,L,E;n.setAttribute("class", -"compass");q.radius=function(v){if(!arguments.length)return x;x=v;E&&m();return q};q.speed=function(v){if(!arguments.length)return x;G=v;return q};q.position=function(v){if(!arguments.length)return u;u=v;E&&m();return q};q.pan=function(v){if(!arguments.length)return B;B=v;E&&m();return q};q.zoom=function(v){if(!arguments.length)return y;y=v;E&&m();return q};q.map=function(v){if(!arguments.length)return E;if(E){n.parentNode.removeChild(n);E.off("move",h).off("resize",h);window.removeEventListener("mouseup", -f,false)}if(E=v){window.addEventListener("mouseup",f,false);E.on("move",h).on("resize",h);E.container().appendChild(n);m()}return q};return q};s.grid=function(){function d(){var c=e.firstChild,g=f.size(),i=f.pointLocation(S);f.pointLocation(g);var j=Math.pow(2,4-Math.round(f.zoom()));i.lat=Math.floor(i.lat/j)*j;i.lon=Math.ceil(i.lon/j)*j;for(var o;(o=f.locationPoint(i).x)<=g.x;i.lon+=j){c||(c=e.appendChild(s.svg("line")));c.setAttribute("x1",o);c.setAttribute("x2",o);c.setAttribute("y1",0);c.setAttribute("y2", -g.y);c=c.nextSibling}for(;(o=f.locationPoint(i).y)<=g.y;i.lat-=j){c||(c=e.appendChild(s.svg("line")));c.setAttribute("y1",o);c.setAttribute("y2",o);c.setAttribute("x1",0);c.setAttribute("x2",g.x);c=c.nextSibling}for(;c;){g=c.nextSibling;e.removeChild(c);c=g}}var a={},f,e=s.svg("g");e.setAttribute("class","grid");a.map=function(c){if(!arguments.length)return f;if(f){e.parentNode.removeChild(e);f.off("move",d).off("resize",d)}if(f=c){f.on("move",d).on("resize",d);f.container().appendChild(e);f.dispatch({type:"move"})}return a}; -return a}})(org.polymaps); +(function(s){function M(){for(var d=0;da.row){var e=d;d=a;a=e}return{x0:d.column,y0:d.row,x1:a.column,y1:a.row,dx:a.column-d.column,dy:a.row-d.row}}function Z(d,a,e,f,h){e=Math.max(e,Math.floor(a.y0));f=Math.min(f,Math.ceil(a.y1));if(d.x0==a.x0&&d.y0==a.y0?d.x0+a.dy/d.dy*d.dx0,r=a.dx<0;for(e=e;ea.dy){e=i;i=a;a=e}if(i.dy>d.dy){e=i;i=d;d=e}if(a.dy>d.dy){e=a;a=d;d=e}i.dy&&Z(d,i,f,h,c);a.dy&&Z(d,a,f,h,c)}s.version="2.0.2+6";var S={x:0,y:0};s.id=function(){var d=0;return function(){return++d}}();s.svg=function(d){return document.createElementNS(s.ns.svg, +d)};s.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};s.transform=function(d,a,e,f,h,c){var i={},j,r,u;if(!arguments.length){d=1;a=h=e=0;f=1;c=0}i.zoomFraction=function(m){if(!arguments.length)return r;r=m;j=Math.floor(r+Math.log(Math.sqrt(d*d+a*a+e*e+f*f))/Math.log(2));u=Math.pow(2,-j);return i};i.apply=function(m){var o=Math.pow(2,-m.zoom),g=Math.pow(2,m.zoom-j);return{column:(d*m.column*o+e*m.row*o+h)*g,row:(a*m.column*o+f*m.row*o+c)*g,zoom:m.zoom-j}};i.unapply=function(m){var o= +Math.pow(2,-m.zoom),g=Math.pow(2,m.zoom+j);return{column:(m.column*o*f-m.row*o*e-h*f+c*e)/(d*f-a*e)*g,row:(m.column*o*a-m.row*o*d-h*a+c*d)/(e*a-f*d)*g,zoom:m.zoom+j}};i.toString=function(){return"matrix("+[d*u,a*u,e*u,f*u].join(" ")+" 0 0)"};return i.zoomFraction(0)};s.cache=function(d,a){function e(o){m--;a&&a(o);delete i[o.key];if(o.next)o.next.prev=o.prev;else if(r=o.prev)r.next=null;if(o.prev)o.prev.next=o.next;else if(j=o.next)j.prev=null}function f(){for(var o=r;m>u;o=o.prev){if(!o)break;o.lock|| +e(o)}}var h={},c={},i={},j=null,r=null,u=64,m=0;h.peek=function(o){return i[[o.zoom,o.column,o.row].join("/")]};h.load=function(o,g){var k=[o.zoom,o.column,o.row].join("/"),q=i[k];if(q){if(q.prev){if(q.prev.next=q.next)q.next.prev=q.prev;else r=q.prev;q.prev=null;q.next=j;j=j.prev=q}q.lock=1;return c[k]=q}q={key:k,column:o.column,row:o.row,zoom:o.zoom,next:j,prev:null,lock:1};d.call(null,q,g);c[k]=i[k]=q;if(j)j.prev=q;else r=q;j=q;m++;f();return q};h.unload=function(o){if(!(o in c))return false;var g= +c[o];g.lock=0;delete c[o];g.request&&g.request.abort(false)?e(g):f();return g};h.locks=function(){return c};h.size=function(o){if(!arguments.length)return u;u=o;f();return h};return h};s.url=function(d){function a(f){var h=1<=c||!f.length)){h++;f.pop()()}}function a(i){for(var j=0;j=0)return l;return window};a.mouse=function(l){var t=(e.ownerSVGElement||e).createSVGPoint();if(V<0&&(window.scrollX||window.scrollY)){var y=document.body.appendChild(s.svg("svg")); +y.style.position="absolute";y.style.top=y.style.left="0px";var B=y.getScreenCTM();V=!(B.f||B.e);document.body.removeChild(y)}if(V){t.x=l.pageX;t.y=l.pageY}else{t.x=l.clientX;t.y=l.clientY}return t.matrixTransform(e.getScreenCTM().inverse())};a.size=function(l){if(!arguments.length)return h;f=l;return a.resize()};a.resize=function(){if(f){h=f;M.remove(a)}else{var l=e.ownerSVGElement||e;if(l.offsetWidth==null){D.setAttribute("width","100%");D.setAttribute("height","100%");l=D}b=l.getBoundingClientRect(); +h={x:b.width,y:b.height};M.add(a)}D.setAttribute("width",h.x);D.setAttribute("height",h.y);c={x:h.x/2,y:h.y/2};d();a.dispatch({type:"resize"});return a};a.tileSize=function(l){if(!arguments.length)return i;i=l;a.dispatch({type:"move"});return a};a.center=function(l){if(!arguments.length)return j;j=l;d();a.dispatch({type:"move"});return a};a.panBy=function(l){var t=45/Math.pow(2,r+u-3),y=l.x*t;l=l.y*t;return a.center({lon:j.lon+(w*l-n*y)/i.x,lat:Q(R(j.lat)+(w*y+n*l)/i.y)})};a.centerRange=function(l){if(!arguments.length)return H; +if(H=l){x=H[0].lat>-90?R(H[0].lat):-Infinity;G=H[0].lat<90?R(H[1].lat):Infinity}else{x=-Infinity;G=Infinity}d();a.dispatch({type:"move"});return a};a.zoom=function(l){if(!arguments.length)return r+u;r=Math.max(o[0],Math.min(o[1],l));u=r-(r=Math.round(r));m=Math.pow(2,u);return a.center(j)};a.zoomBy=function(l,t,y){if(arguments.length<2)return a.zoom(r+u+l);if(arguments.length<3)y=a.pointLocation(t);r=Math.max(o[0],Math.min(o[1],r+u+l));u=r-(r=Math.round(r));m=Math.pow(2,u);var B=a.locationPoint(y); +return a.panBy({x:t.x-B.x,y:t.y-B.y})};a.zoomRange=function(l){if(!arguments.length)return o;o=l;return a.zoom(r+u)};a.angle=function(l){if(!arguments.length)return g;g=l;k=Math.cos(g);q=Math.sin(g);n=Math.cos(-g);w=Math.sin(-g);d();a.dispatch({type:"move"});return a};a.add=function(l){l.map(a);return a};a.remove=function(l){l.map(null);return a};a.dispatch=s.dispatch(a);return a};M.maps=[];M.add=function(d){for(var a=0;a>O,row:A>>O,zoom:C-O}))&&N.ready){L[N.key]=h.load(P);N.proxyCount++;K.proxyRefs[N.key]=N;break}}L[K.key]=K}}var n=f.map(),w=n.zoom(),x=w-(w=Math.round(w)),G=n.size(),H=n.angle(),D=n.tileSize(),l=n.locationCoordinate(n.center());i?m.removeAttribute("visibility"):m.setAttribute("visibility","hidden");for(var t=-4;t<=2;t++)g[t].setAttribute("class","zoom"+(t<0?"":"+")+t+" zoom"+(w+t));m.setAttribute("transform","translate("+G.x/2+","+G.y/2+")"+(H?"rotate("+H/Math.PI*180+")":"")+(x? +"scale("+Math.pow(2,x)+")":"")+(o?o.zoomFraction(x):""));var y=n.pointCoordinate(l,S);t=n.pointCoordinate(l,{x:G.x,y:0});var B=n.pointCoordinate(l,G);n=n.pointCoordinate(l,{x:0,y:G.y});if(!x&&!H&&!o){l.column=(Math.round(D.x*l.column)+(G.x&1)/2)/D.x;l.row=(Math.round(D.y*l.row)+(G.y&1)/2)/D.y}var I=j?j(w)-w:0;if(I){x=Math.pow(2,I);y.column*=x;y.row*=x;t.column*=x;t.row*=x;B.column*=x;B.row*=x;n.column*=x;n.row*=x;y.zoom=t.zoom=B.zoom=n.zoom+=I}if(o){y=o.unapply(y);t=o.unapply(t);B=o.unapply(B);n= +o.unapply(n);l=o.unapply(l)}w=h.locks();var L={};for(var E in w)w[E].proxyCount=0;if(i&&I>-5&&I<3){x=1<>t<>t<=1;q--)(g[q]=m.appendChild(s.svg("g"))).setAttribute("transform","scale("+Math.pow(2,-q)+")");g[0]=m.appendChild(s.svg("g"));f.init&&f.init(m);u.on("move",e).on("resize",e);e()}return f};f.container=function(){return m};f.id=function(k){if(!arguments.length)return r;r=k;return f};f.visible=function(k){if(!arguments.length)return i;i=k;u&&e();return f};f.transform=function(k){if(!arguments.length)return o; +o=k;u&&e();return f};f.zoom=function(k){if(!arguments.length)return j;j=typeof k=="function"||k==null?k:function(){return k};return f};f.tile=function(k){if(!arguments.length)return c;c=k;return f};f.dispatch=s.dispatch(f);f.on("load",function(k){if(k.tile.proxyRefs){for(var q in k.tile.proxyRefs){var n=k.tile.proxyRefs[q];--n.proxyCount<=0&&h.unload(q)&&n.element.parentNode.removeChild(n.element)}delete k.tile.proxyRefs}});return f};s.image=function(){var d=s.layer(function(e){var f=e.element=s.svg("image"), +h=d.map().tileSize();f.setAttribute("preserveAspectRatio","none");f.setAttribute("width",h.x);f.setAttribute("height",h.y);f.setAttribute("opacity",0);if(typeof a=="function")e.request=s.queue.image(f,a(e),function(){delete e.request;e.ready=true;f.removeAttribute("opacity");d.dispatch({type:"load",tile:e})});else{e.ready=true;f.setAttributeNS(s.ns.xlink,"href",a);d.dispatch({type:"load",tile:e})}},function(e){e.request&&e.request.abort(true)}),a="about:blank";d.url=function(e){if(!arguments.length)return a; +a=typeof e=="string"&&/{.}/.test(e)?s.url(e):e;return d};return d};s.geoJson=function(d){function a(g,k){var q=k({lat:g[1],lon:g[0]}),n=s.svg("circle");n.setAttribute("r",4.5);n.setAttribute("cx",q.x);n.setAttribute("cy",q.y);return n}function e(g,k,q,n){n.push("M");for(var w=0;w9&&Math.abs(u.wheelDelta)/k>=50)Y=1;h=g}if(Y==1)m*=0.03;i||(i=j.pointLocation(o));j.off("move",d);if(c)j.zoomBy(m,o,i);else if(m){g=Date.now();if(g-f>200){j.zoomBy(m>0?+1:-1,o,i);f=g}}j.on("move",d);u.preventDefault();return false}var e={},f=0,h=0,c=true,i,j,r;e.smooth=function(u){if(!arguments.length)return c;c=u;return e};e.map=function(u){if(!arguments.length)return j;if(j){r.removeEventListener("mousemove",d,false);r.removeEventListener("mousewheel",a,false); +r.removeEventListener("DOMMouseScroll",a,false);r=null;j.off("move",d)}if(j=u){j.on("move",d);r=j.container();r.addEventListener("mousemove",d,false);r.addEventListener("mousewheel",a,false);r.addEventListener("DOMMouseScroll",a,false)}return e};return e};var Y=/WebKit\/533/.test(navigator.userAgent)?-1:0;s.arrow=function(){function d(k){if(!(k.ctrlKey||k.altKey||k.metaKey)){var q=Date.now(),n=0,w=0;switch(k.keyCode){case 37:if(!c.left){i=q;c.left=1;c.right||(n=m)}break;case 39:if(!c.right){i=q;c.right= +1;c.left||(n=-m)}break;case 38:if(!c.up){i=q;c.up=1;c.down||(w=m)}break;case 40:if(!c.down){i=q;c.down=1;c.up||(w=-m)}break;default:return}if(n||w)o.panBy({x:n,y:w});if(!j&&c.left|c.right|c.up|c.down)j=setInterval(f,u);k.preventDefault()}}function a(k){i=Date.now();switch(k.keyCode){case 37:c.left=0;break;case 39:c.right=0;break;case 38:c.up=0;break;case 40:c.down=0;break;default:return}if(j&&!(c.left|c.right|c.up|c.down))j=clearInterval(j);k.preventDefault()}function e(k){switch(k.charCode){case 45:case 95:o.zoom(Math.ceil(o.zoom())- +1);break;case 43:case 61:o.zoom(Math.floor(o.zoom())+1);break;default:return}k.preventDefault()}function f(){if(o)if(!(Date.now()H+D&&E.panBy(L)}function e(){n.setAttribute("class","compass");if(I){clearInterval(I);I=0}}function f(v){return function(){v?this.setAttribute("class","active"):this.removeAttribute("class");L=v}}function h(v){return function(z){n.setAttribute("class","compass active");var A=E.zoom();E.zoom(v<0?Math.ceil(A)-1:Math.floor(A)+1);return r(z)}} +function c(v){return function(z){E.zoom(v);return r(z)}}function i(){this.setAttribute("class","active")}function j(){this.removeAttribute("class")}function r(v){v.stopPropagation();v.preventDefault();return false}function u(v){var z=Math.SQRT1_2*x,A=x*0.7,C=x*0.2,F=s.svg("g"),J=F.appendChild(s.svg("path")),K=F.appendChild(s.svg("path"));J.setAttribute("class","direction");J.setAttribute("pointer-events","all");J.setAttribute("d","M0,0L"+z+","+z+"A"+x+","+x+" 0 0,1 "+-z+","+z+"Z");K.setAttribute("class", +"chevron");K.setAttribute("d","M"+C+","+(A-C)+"L0,"+A+" "+-C+","+(A-C));K.setAttribute("pointer-events","none");F.addEventListener("mousedown",d,false);F.addEventListener("mouseover",f(v),false);F.addEventListener("mouseout",f(null),false);F.addEventListener("dblclick",r,false);return F}function m(v){var z=x*0.4,A=z/2,C=s.svg("g"),F=C.appendChild(s.svg("path")),J=C.appendChild(s.svg("path")),K=C.appendChild(s.svg("path")),P=C.appendChild(s.svg("path"));F.setAttribute("class","back");F.setAttribute("d", +"M"+-z+",0V"+-z+"A"+z+","+z+" 0 1,1 "+z+","+-z+"V0Z");J.setAttribute("class","direction");J.setAttribute("d",F.getAttribute("d"));K.setAttribute("class","chevron");K.setAttribute("d","M"+-A+","+-z+"H"+A+(v>0?"M0,"+(-z-A)+"V"+-A:""));P.setAttribute("class","fore");P.setAttribute("fill","none");P.setAttribute("d",F.getAttribute("d"));C.addEventListener("mousedown",h(v),false);C.addEventListener("mouseover",i,false);C.addEventListener("mouseout",j,false);C.addEventListener("dblclick",r,false);return C} +function o(v){var z=x*0.2,A=x*0.4,C=s.svg("g"),F=C.appendChild(s.svg("rect")),J=C.appendChild(s.svg("path"));F.setAttribute("pointer-events","all");F.setAttribute("fill","none");F.setAttribute("x",-A);F.setAttribute("y",-0.75*A);F.setAttribute("width",2*A);F.setAttribute("height",1.5*A);J.setAttribute("class","chevron");J.setAttribute("d","M"+-z+",0H"+z);C.addEventListener("mousedown",c(v),false);C.addEventListener("dblclick",r,false);return C}function g(){var v=x+6,z=v,A=E.size();switch(t){case "top-left":break; +case "top-right":v=A.x-v;break;case "bottom-left":z=A.y-z;break;case "bottom-right":v=A.x-v;z=A.y-z;break}n.setAttribute("transform","translate("+v+","+z+")");for(var C in w)C==E.zoom()?w[C].setAttribute("class","active"):w[C].removeAttribute("class")}function k(){for(;n.lastChild;)n.removeChild(n.lastChild);if(B!="none"){var v=n.appendChild(s.svg("g"));v.setAttribute("class","pan");var z=v.appendChild(s.svg("circle"));z.setAttribute("class","back");z.setAttribute("r",x);v.appendChild(u({x:0,y:-G})).setAttribute("transform", +"rotate(0)");v.appendChild(u({x:G,y:0})).setAttribute("transform","rotate(90)");v.appendChild(u({x:0,y:G})).setAttribute("transform","rotate(180)");v.appendChild(u({x:-G,y:0})).setAttribute("transform","rotate(270)");v=v.appendChild(s.svg("circle"));v.setAttribute("fill","none");v.setAttribute("class","fore");v.setAttribute("r",x)}if(y!="none"){v=n.appendChild(s.svg("g"));v.setAttribute("class","zoom");z=-0.5;if(y=="big"){w={};var A=E.zoomRange()[0];for(z=0;A<=E.zoomRange()[1];A++,z++)(w[A]=v.appendChild(o(A))).setAttribute("transform", +"translate(0,"+-(z+0.75)*x*0.4+")")}A=B=="none"?0.4:2;v.setAttribute("transform","translate(0,"+x*(/^top-/.test(t)?A+(z+0.5)*0.4:-A)+")");v.appendChild(m(+1)).setAttribute("transform","translate(0,"+-(z+0.5)*x*0.4+")");v.appendChild(m(-1)).setAttribute("transform","scale(-1)")}g()}var q={},n=s.svg("g"),w={},x=30,G=16,H=0,D=250,l=50,t="top-left",y="small",B="small",I,L,E;n.setAttribute("class","compass");q.radius=function(v){if(!arguments.length)return x;x=v;E&&k();return q};q.speed=function(v){if(!arguments.length)return x; +G=v;return q};q.position=function(v){if(!arguments.length)return t;t=v;E&&k();return q};q.pan=function(v){if(!arguments.length)return B;B=v;E&&k();return q};q.zoom=function(v){if(!arguments.length)return y;y=v;E&&k();return q};q.map=function(v){if(!arguments.length)return E;if(E){n.parentNode.removeChild(n);E.off("move",g).off("resize",g);window.removeEventListener("mouseup",e,false)}if(E=v){window.addEventListener("mouseup",e,false);E.on("move",g).on("resize",g);E.container().appendChild(n);k()}return q}; +return q};s.grid=function(){function d(){var h=f.firstChild,c=e.size(),i=e.pointLocation(S);e.pointLocation(c);var j=Math.pow(2,4-Math.round(e.zoom()));i.lat=Math.floor(i.lat/j)*j;i.lon=Math.ceil(i.lon/j)*j;for(var r;(r=e.locationPoint(i).x)<=c.x;i.lon+=j){h||(h=f.appendChild(s.svg("line")));h.setAttribute("x1",r);h.setAttribute("x2",r);h.setAttribute("y1",0);h.setAttribute("y2",c.y);h=h.nextSibling}for(;(r=e.locationPoint(i).y)<=c.y;i.lat-=j){h||(h=f.appendChild(s.svg("line")));h.setAttribute("y1", +r);h.setAttribute("y2",r);h.setAttribute("x1",0);h.setAttribute("x2",c.x);h=h.nextSibling}for(;h;){c=h.nextSibling;f.removeChild(h);h=c}}var a={},e,f=s.svg("g");f.setAttribute("class","grid");a.map=function(h){if(!arguments.length)return e;if(e){f.parentNode.removeChild(f);e.off("move",d).off("resize",d)}if(e=h){e.on("move",d).on("resize",d);e.container().appendChild(f);e.dispatch({type:"move"})}return a};return a}})(org.polymaps); diff --git a/src/Arrow.js b/src/Arrow.js index 7dacbfd..37fce88 100644 --- a/src/Arrow.js +++ b/src/Arrow.js @@ -1,6 +1,6 @@ po.arrow = function() { var arrow = {}, - key = {left: 0, right: 0, up: 0, down: 0, plus: 0, minus: 0}, + key = {left: 0, right: 0, up: 0, down: 0}, last = 0, repeatTimer, repeatDelay = 250, @@ -11,7 +11,7 @@ po.arrow = function() { function keydown(e) { if (e.ctrlKey || e.altKey || e.metaKey) return; - var now = Date.now(), dx = 0, dy = 0, dz = 0; + var now = Date.now(), dx = 0, dy = 0; switch (e.keyCode) { case 37: { if (!key.left) { @@ -45,30 +45,9 @@ po.arrow = function() { } break; } - case 109: case 189: { - if (!key.plus) { - last = now; - key.plus = 1; - if (!key.minus) dz = -1; - } - break; - } - case 61: case 187: { - if (!key.minus) { - last = now; - key.minus = 1; - if (!key.plus) dz = 1; - } - break; - } default: return; } - if (dz) { - var z = map.zoom(); - map.zoom(dz < 0 ? Math.ceil(z) - 1 : Math.floor(z) + 1); - } else if (dx || dy) { - map.panBy({x: dx, y: dy}); - } + if (dx || dy) map.panBy({x: dx, y: dy}); if (!repeatTimer && (key.left | key.right | key.up | key.down)) { repeatTimer = setInterval(repeat, repeatInterval); } @@ -82,8 +61,6 @@ po.arrow = function() { case 39: key.right = 0; break; case 38: key.up = 0; break; case 40: key.down = 0; break; - case 109: case 189: key.plus = 0; break; - case 61: case 187: key.minus = 0; break; default: return; } if (repeatTimer && !(key.left | key.right | key.up | key.down)) { @@ -92,6 +69,15 @@ po.arrow = function() { e.preventDefault(); } + function keypress(e) { + switch (e.charCode) { + case 45: case 95: map.zoom(Math.ceil(map.zoom()) - 1); break; // - _ + case 43: case 61: map.zoom(Math.floor(map.zoom()) + 1); break; // = + + default: return; + } + e.preventDefault(); + } + function repeat() { if (!map) return; if (Date.now() < last + repeatDelay) return; @@ -103,12 +89,14 @@ po.arrow = function() { arrow.map = function(x) { if (!arguments.length) return map; if (map) { + parent.removeEventListener("keypress", keypress, false); parent.removeEventListener("keydown", keydown, false); parent.removeEventListener("keyup", keyup, false); parent = null; } if (map = x) { parent = map.focusableParent(); + parent.addEventListener("keypress", keypress, false); parent.addEventListener("keydown", keydown, false); parent.addEventListener("keyup", keyup, false); } diff --git a/src/start.js b/src/start.js index 1dfc3bf..1d468a2 100644 --- a/src/start.js +++ b/src/start.js @@ -2,6 +2,6 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0.2+6"; // This fork not semver! + po.version = "2.0.3+1"; // This fork not semver! var zero = {x: 0, y: 0}; From 1a11ff26bb83c23a3489431632ff0857a17099c5 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Tue, 31 Aug 2010 23:29:13 -0700 Subject: [PATCH 2/9] Zoom methods for wheel and dblclick. The zoom method can now be set to "center", which causes these controls to zoom around the center point rather than the mouse location. The default is "mouse" which is the previous behavior. --- polymaps.js | 23 +++++++++-- polymaps.min.js | 103 ++++++++++++++++++++++++------------------------ src/Dblclick.js | 9 ++++- src/Wheel.js | 12 +++++- src/start.js | 2 +- 5 files changed, 90 insertions(+), 59 deletions(-) diff --git a/polymaps.js b/polymaps.js index 9dae860..3e5d4c6 100644 --- a/polymaps.js +++ b/polymaps.js @@ -2,7 +2,7 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0.3+1"; // This fork not semver! + po.version = "2.0+1.3+1"; // This fork not semver! var zero = {x: 0, y: 0}; po.id = (function() { @@ -1229,6 +1229,7 @@ po.geoJson = function(fetch) { }; po.dblclick = function() { var dblclick = {}, + zoom = "mouse", map, container; @@ -1236,9 +1237,15 @@ po.dblclick = function() { var z = map.zoom(); if (e.shiftKey) z = Math.ceil(z) - z - 1; else z = 1 - z + Math.floor(z); - map.zoomBy(z, map.mouse(e)); + zoom === "mouse" ? map.zoomBy(z, map.mouse(e)) : map.zoomBy(z); } + dblclick.zoom = function(x) { + if (!arguments.length) return zoom; + zoom = x; + return dblclick; + }; + dblclick.map = function(x) { if (!arguments.length) return map; if (map) { @@ -1309,6 +1316,7 @@ po.wheel = function() { timePrev = 0, last = 0, smooth = true, + zoom = "mouse", location, map, container; @@ -1332,11 +1340,12 @@ po.wheel = function() { if (!location) location = map.pointLocation(point); map.off("move", move); if (smooth) { - map.zoomBy(delta, point, location); + zoom === "mouse" ? map.zoomBy(delta, point, location) : map.zoomBy(delta); } else if (delta) { var timeNow = Date.now(); if (timeNow - timePrev > 200) { - map.zoomBy(delta > 0 ? +1 : -1, point, location); + delta = delta > 0 ? +1 : -1; + zoom === "mouse" ? map.zoomBy(delta, point, location) : map.zoomBy(delta); timePrev = timeNow; } } @@ -1351,6 +1360,12 @@ po.wheel = function() { return wheel; }; + wheel.zoom = function(x) { + if (!arguments.length) return zoom; + zoom = x; + return wheel; + }; + wheel.map = function(x) { if (!arguments.length) return map; if (map) { diff --git a/polymaps.min.js b/polymaps.min.js index 3cd902e..972e11c 100644 --- a/polymaps.min.js +++ b/polymaps.min.js @@ -1,52 +1,53 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={}; -(function(o){function M(){for(var d=0;dh.row){var a=d;d=h;h=a}return{x0:d.column,y0:d.row,x1:h.column,y1:h.row,dx:h.column-d.column,dy:h.row-d.row}}function Z(d,h,a,c,k){a=Math.max(a,Math.floor(h.y0));c=Math.min(c,Math.ceil(h.y1));if(d.x0==h.x0&&d.y0==h.y0?d.x0+h.dy/d.dy*d.dx0,q=h.dx<0;for(a=a;ah.dy){a=f;f=h;h=a}if(f.dy>d.dy){a=f;f=d;d=a}if(h.dy>d.dy){a=h;h=d;d=a}f.dy&&Z(d,f,c,k,g);h.dy&&Z(d,h,c,k,g)}o.version="2.0.3+1";var S={x:0,y:0};o.id=function(){var d=0;return function(){return++d}}();o.svg=function(d){return document.createElementNS(o.ns.svg, -d)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(d,h,a,c,k,g){var f={},j,q,r;if(!arguments.length){d=1;h=k=a=0;c=1;g=0}f.zoomFraction=function(m){if(!arguments.length)return q;q=m;j=Math.floor(q+Math.log(Math.sqrt(d*d+h*h+a*a+c*c))/Math.log(2));r=Math.pow(2,-j);return f};f.apply=function(m){var n=Math.pow(2,-m.zoom),w=Math.pow(2,m.zoom-j);return{column:(d*m.column*n+a*m.row*n+k)*w,row:(h*m.column*n+c*m.row*n+g)*w,zoom:m.zoom-j}};f.unapply=function(m){var n= -Math.pow(2,-m.zoom),w=Math.pow(2,m.zoom+j);return{column:(m.column*n*c-m.row*n*a-k*c+g*a)/(d*c-h*a)*w,row:(m.column*n*h-m.row*n*d-k*h+g*d)/(a*h-c*d)*w,zoom:m.zoom+j}};f.toString=function(){return"matrix("+[d*r,h*r,a*r,c*r].join(" ")+" 0 0)"};return f.zoomFraction(0)};o.cache=function(d,h){function a(n){m--;h&&h(n);delete f[n.key];if(n.next)n.next.prev=n.prev;else if(q=n.prev)q.next=null;if(n.prev)n.prev.next=n.next;else if(j=n.next)j.prev=null}function c(){for(var n=q;m>r;n=n.prev){if(!n)break;n.lock|| -a(n)}}var k={},g={},f={},j=null,q=null,r=64,m=0;k.peek=function(n){return f[[n.zoom,n.column,n.row].join("/")]};k.load=function(n,w){var e=[n.zoom,n.column,n.row].join("/"),l=f[e];if(l){if(l.prev){if(l.prev.next=l.next)l.next.prev=l.prev;else q=l.prev;l.prev=null;l.next=j;j=j.prev=l}l.lock=1;return g[e]=l}l={key:e,column:n.column,row:n.row,zoom:n.zoom,next:j,prev:null,lock:1};d.call(null,l,w);g[e]=f[e]=l;if(j)j.prev=l;else q=l;j=l;m++;c();return l};k.unload=function(n){if(!(n in g))return false;var w= -g[n];w.lock=0;delete g[n];w.request&&w.request.abort(false)?a(w):c();return w};k.locks=function(){return g};k.size=function(n){if(!arguments.length)return r;r=n;c();return k};return k};o.url=function(d){function h(c){var k=c.zoom<0?1:1<=g||!c.length)){k++;c.pop()()}}function h(f){for(var j=0;jw[1])r=w[1];m=r-(r=Math.round(r));n=Math.pow(2,m)}function h(){if(G){var i=45/Math.pow(2,r+m-3),y=Math.max(Math.abs(s*f.x+ -l*f.y),Math.abs(t*f.x+v*f.y)),x=Q(D-y*i/j.y);y=Q(L+y*i/j.y);q.lat=Math.max(x,Math.min(y,q.lat));x=Math.max(Math.abs(s*f.y+l*f.x),Math.abs(t*f.y+v*f.x));q.lon=Math.max(G[0].lon-x*i/j.x,Math.min(G[1].lon+x*i/j.x,q.lon))}}var a={},c,k,g=S,f=S,j={x:256,y:256},q={lat:37.76487,lon:-122.41948},r=12,m=0,n=1,w=[1,18],e=0,l=1,s=0,v=1,t=0,D=-180,L=180,G=[{lat:Q(D),lon:-Infinity},{lat:Q(L),lon:Infinity}];a.locationCoordinate=function(i){i=o.map.locationCoordinate(i);var y=Math.pow(2,r);i.column*=y;i.row*=y;i.zoom+= -r;return i};a.coordinateLocation=o.map.coordinateLocation;a.coordinatePoint=function(i,y){var x=Math.pow(2,r-y.zoom),F=Math.pow(2,r-i.zoom),I=(y.column*x-i.column*F)*j.x*n;x=(y.row*x-i.row*F)*j.y*n;return{x:f.x+l*I-s*x,y:f.y+s*I+l*x}};a.pointCoordinate=function(i,y){var x=Math.pow(2,r-i.zoom),F=(y.x-f.x)/n,I=(y.y-f.y)/n;return{column:i.column*x+(v*F-t*I)/j.x,row:i.row*x+(t*F+v*I)/j.y,zoom:r}};a.locationPoint=function(i){var y=Math.pow(2,r+m-3)/45,x=(i.lon-q.lon)*y*j.x;i=(R(q.lat)-R(i.lat))*y*j.y; -return{x:f.x+l*x-s*i,y:f.y+s*x+l*i}};a.pointLocation=function(i){var y=45/Math.pow(2,r+m-3),x=(i.x-f.x)*y;i=(i.y-f.y)*y;return{lon:q.lon+(v*x-t*i)/j.x,lat:Q(R(q.lat)-(t*x+v*i)/j.y)}};var C=o.svg("rect");C.setAttribute("visibility","hidden");C.setAttribute("pointer-events","all");a.container=function(i){if(!arguments.length)return c;c=i;c.setAttribute("class","map");c.appendChild(C);return a.resize()};a.focusableParent=function(){for(var i=c;i;i=i.parentNode)if(i.tabIndex>=0)return i;return window}; -a.mouse=function(i){var y=(c.ownerSVGElement||c).createSVGPoint();if(V<0&&(window.scrollX||window.scrollY)){var x=document.body.appendChild(o.svg("svg"));x.style.position="absolute";x.style.top=x.style.left="0px";var F=x.getScreenCTM();V=!(F.f||F.e);document.body.removeChild(x)}if(V){y.x=i.pageX;y.y=i.pageY}else{y.x=i.clientX;y.y=i.clientY}return y.matrixTransform(c.getScreenCTM().inverse())};a.size=function(i){if(!arguments.length)return g;k=i;return a.resize()};a.resize=function(){if(k){g=k;M.remove(a)}else{var i= -c.ownerSVGElement||c;if(i.offsetWidth==null){C.setAttribute("width","100%");C.setAttribute("height","100%");i=C}b=i.getBoundingClientRect();g={x:b.width,y:b.height};M.add(a)}C.setAttribute("width",g.x);C.setAttribute("height",g.y);f={x:g.x/2,y:g.y/2};h();a.dispatch({type:"resize"});return a};a.tileSize=function(i){if(!arguments.length)return j;j=i;a.dispatch({type:"move"});return a};a.center=function(i){if(!arguments.length)return q;q=i;h();a.dispatch({type:"move"});return a};a.panBy=function(i){var y= -45/Math.pow(2,r+m-3),x=i.x*y;i=i.y*y;return a.center({lon:q.lon+(t*i-v*x)/j.x,lat:Q(R(q.lat)+(t*x+v*i)/j.y)})};a.centerRange=function(i){if(!arguments.length)return G;if(G=i){D=G[0].lat>-90?R(G[0].lat):-Infinity;L=G[0].lat<90?R(G[1].lat):Infinity}else{D=-Infinity;L=Infinity}h();a.dispatch({type:"move"});return a};a.zoom=function(i){if(!arguments.length)return r+m;r=i;d();return a.center(q)};a.zoomBy=function(i,y,x){if(arguments.length<2)return a.zoom(r+m+i);if(arguments.length<3)x=a.pointLocation(y); -r=r+m+i;d();var F=a.locationPoint(x);return a.panBy({x:y.x-F.x,y:y.y-F.y})};a.zoomRange=function(i){if(!arguments.length)return w;w=i;return a.zoom(r+m)};a.angle=function(i){if(!arguments.length)return e;e=i;l=Math.cos(e);s=Math.sin(e);v=Math.cos(-e);t=Math.sin(-e);h();a.dispatch({type:"move"});return a};a.add=function(i){i.map(a);return a};a.remove=function(i){i.map(null);return a};a.dispatch=o.dispatch(a);return a};M.maps=[];M.add=function(d){for(var h=0;h>O,row:A>>O,zoom:B-O}))&&N.ready){I[N.key]=k.load(P);N.proxyCount++;K.proxyRefs[N.key]=N;break}}I[K.key]=K}}var s=c.map(),v=s.zoom(),t=v-(v=Math.round(v)),D=s.size(),L=s.angle(),G=s.tileSize(),C=s.locationCoordinate(s.center());f?m.removeAttribute("visibility"):m.setAttribute("visibility","hidden");for(var i=-4;i<=2;i++)w[i].setAttribute("class","zoom"+(i<0?"":"+")+i+" zoom"+(v+i));m.setAttribute("transform","translate("+D.x/ -2+","+D.y/2+")"+(L?"rotate("+L/Math.PI*180+")":"")+(t?"scale("+Math.pow(2,t)+")":"")+(n?n.zoomFraction(t):""));var y=s.pointCoordinate(C,S);i=s.pointCoordinate(C,{x:D.x,y:0});var x=s.pointCoordinate(C,D);s=s.pointCoordinate(C,{x:0,y:D.y});if(!t&&!L&&!n){C.column=(Math.round(G.x*C.column)+(D.x&1)/2)/G.x;C.row=(Math.round(G.y*C.row)+(D.y&1)/2)/G.y}var F=j?j(v)-v:0;if(F){t=Math.pow(2,F);y.column*=t;y.row*=t;i.column*=t;i.row*=t;x.column*=t;x.row*=t;s.column*=t;s.row*=t;y.zoom=i.zoom=x.zoom=s.zoom+=F}if(n){y= -n.unapply(y);i=n.unapply(i);x=n.unapply(x);s=n.unapply(s);C=n.unapply(C)}v=k.locks();var I={};for(var E in v)v[E].proxyCount=0;if(f&&F>-5&&F<3){t=y.zoom<0?1:1<>i<>i<=1;l--)(w[l]=m.appendChild(o.svg("g"))).setAttribute("transform","scale("+Math.pow(2,-l)+")");w[0]=m.appendChild(o.svg("g"));c.init&&c.init(m);r.on("move",a).on("resize",a);a()}return c};c.container=function(){return m};c.id=function(e){if(!arguments.length)return q;q=e;return c};c.visible=function(e){if(!arguments.length)return f; -f=e;r&&a();return c};c.transform=function(e){if(!arguments.length)return n;n=e;r&&a();return c};c.zoom=function(e){if(!arguments.length)return j;j=typeof e=="function"||e==null?e:function(){return e};return c};c.tile=function(e){if(!arguments.length)return g;g=e;return c};c.dispatch=o.dispatch(c);c.on("load",function(e){if(e.tile.proxyRefs){for(var l in e.tile.proxyRefs){var s=e.tile.proxyRefs[l];--s.proxyCount<=0&&k.unload(l)&&s.element.parentNode.removeChild(s.element)}delete e.tile.proxyRefs}}); -return c};o.image=function(){var d=o.layer(function(a){var c=a.element=o.svg("image"),k=d.map().tileSize();c.setAttribute("preserveAspectRatio","none");c.setAttribute("width",k.x);c.setAttribute("height",k.y);c.setAttribute("opacity",0);if(typeof h=="function")a.request=o.queue.image(c,h(a),function(){delete a.request;a.ready=true;c.removeAttribute("opacity");d.dispatch({type:"load",tile:a})});else{a.ready=true;c.setAttributeNS(o.ns.xlink,"href",h);d.dispatch({type:"load",tile:a})}},function(a){a.request&& -a.request.abort(true)}),h="about:blank";d.url=function(a){if(!arguments.length)return h;h=typeof a=="string"&&/{.}/.test(a)?o.url(a):a;return d};return d};o.geoJson=function(d){function h(e,l){return e&&e.type in w&&w[e.type](e,l)}function a(e,l){var s=l({lat:e[1],lon:e[0]}),v=o.svg("circle");v.setAttribute("r",4.5);v.setAttribute("cx",s.x);v.setAttribute("cy",s.y);return v}function c(e,l,s,v){v.push("M");for(var t=0;t9&&Math.abs(r.wheelDelta)/e>=50)Y=1;k=w}if(Y==1)m*=0.03;f||(f=j.pointLocation(n));j.off("move",d);if(g)j.zoomBy(m, -n,f);else if(m){w=Date.now();if(w-c>200){j.zoomBy(m>0?+1:-1,n,f);c=w}}j.on("move",d);r.preventDefault();return false}var a={},c=0,k=0,g=true,f,j,q;a.smooth=function(r){if(!arguments.length)return g;g=r;return a};a.map=function(r){if(!arguments.length)return j;if(j){q.removeEventListener("mousemove",d,false);q.removeEventListener("mousewheel",h,false);q.removeEventListener("DOMMouseScroll",h,false);q=null;j.off("move",d)}if(j=r){j.on("move",d);q=j.container();q.addEventListener("mousemove",d,false); -q.addEventListener("mousewheel",h,false);q.addEventListener("DOMMouseScroll",h,false)}return a};return a};var Y=/WebKit\/533/.test(navigator.userAgent)?-1:0;o.arrow=function(){function d(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){var l=Date.now(),s=0,v=0;switch(e.keyCode){case 37:if(!g.left){f=l;g.left=1;g.right||(s=m)}break;case 39:if(!g.right){f=l;g.right=1;g.left||(s=-m)}break;case 38:if(!g.up){f=l;g.up=1;g.down||(v=m)}break;case 40:if(!g.down){f=l;g.down=1;g.up||(v=-m)}break;default:return}if(s|| -v)n.panBy({x:s,y:v});if(!j&&g.left|g.right|g.up|g.down)j=setInterval(c,r);e.preventDefault()}}function h(e){f=Date.now();switch(e.keyCode){case 37:g.left=0;break;case 39:g.right=0;break;case 38:g.up=0;break;case 40:g.down=0;break;default:return}if(j&&!(g.left|g.right|g.up|g.down))j=clearInterval(j);e.preventDefault()}function a(e){switch(e.charCode){case 45:case 95:n.zoom(Math.ceil(n.zoom())-1);break;case 43:case 61:n.zoom(Math.floor(n.zoom())+1);break;default:return}e.preventDefault()}function c(){if(n)if(!(Date.now()< -f+q)){var e=(g.left-g.right)*m,l=(g.up-g.down)*m;if(e||l)n.panBy({x:e,y:l})}}var k={},g={left:0,right:0,up:0,down:0},f=0,j,q=250,r=50,m=16,n,w;k.map=function(e){if(!arguments.length)return n;if(n){w.removeEventListener("keypress",a,false);w.removeEventListener("keydown",d,false);w.removeEventListener("keyup",h,false);w=null}if(n=e){w=n.focusableParent();w.addEventListener("keypress",a,false);w.addEventListener("keydown",d,false);w.addEventListener("keyup",h,false)}return k};k.speed=function(e){if(!arguments.length)return m; -m=e;return k};return k};o.hash=function(){function d(){var f=g.center(),j=g.zoom(),q=Math.max(0,Math.ceil(Math.log(j)/Math.LN2));f="#"+j.toFixed(2)+"/"+f.lat.toFixed(q)+"/"+f.lon.toFixed(q);if(c!==f)location.replace(c=f)}function h(){if(location.hash!==c){var f=(c=location.hash).substring(1).split("/").map(Number);if(f.length<3||f.some(isNaN))d();else{var j=g.size();g.zoomBy(f[0]-g.zoom(),{x:j.x/2,y:j.y/2},{lat:Math.min(k,Math.max(-k,f[1])),lon:f[2]})}}}var a={},c,k=89.99999999,g;a.map=function(f){if(!arguments.length)return g; -if(g){g.off("move",d);window.removeEventListener("hashchange",h,false)}if(g=f){g.on("move",d);window.addEventListener("hashchange",h,false);location.hash?h():d()}return a};return a};o.interact=function(){var d={},h=o.drag(),a=o.wheel(),c=o.dblclick(),k=o.arrow();d.map=function(g){h.map(g);a.map(g);c.map(g);k.map(g);return d};return d};o.compass=function(){function d(u){s.setAttribute("class","compass active");F||(F=setInterval(h,C));I&&E.panBy(I);L=Date.now();return q(u)}function h(){I&&Date.now()> -L+G&&E.panBy(I)}function a(){s.setAttribute("class","compass");if(F){clearInterval(F);F=0}}function c(u){return function(){u?this.setAttribute("class","active"):this.removeAttribute("class");I=u}}function k(u){return function(z){s.setAttribute("class","compass active");var A=E.zoom();E.zoom(u<0?Math.ceil(A)-1:Math.floor(A)+1);return q(z)}}function g(u){return function(z){E.zoom(u);return q(z)}}function f(){this.setAttribute("class","active")}function j(){this.removeAttribute("class")}function q(u){u.stopPropagation(); -u.preventDefault();return false}function r(u){var z=Math.SQRT1_2*t,A=t*0.7,B=t*0.2,H=o.svg("g"),J=H.appendChild(o.svg("path")),K=H.appendChild(o.svg("path"));J.setAttribute("class","direction");J.setAttribute("pointer-events","all");J.setAttribute("d","M0,0L"+z+","+z+"A"+t+","+t+" 0 0,1 "+-z+","+z+"Z");K.setAttribute("class","chevron");K.setAttribute("d","M"+B+","+(A-B)+"L0,"+A+" "+-B+","+(A-B));K.setAttribute("pointer-events","none");H.addEventListener("mousedown",d,false);H.addEventListener("mouseover", -c(u),false);H.addEventListener("mouseout",c(null),false);H.addEventListener("dblclick",q,false);return H}function m(u){var z=t*0.4,A=z/2,B=o.svg("g"),H=B.appendChild(o.svg("path")),J=B.appendChild(o.svg("path")),K=B.appendChild(o.svg("path")),P=B.appendChild(o.svg("path"));H.setAttribute("class","back");H.setAttribute("d","M"+-z+",0V"+-z+"A"+z+","+z+" 0 1,1 "+z+","+-z+"V0Z");J.setAttribute("class","direction");J.setAttribute("d",H.getAttribute("d"));K.setAttribute("class","chevron");K.setAttribute("d", -"M"+-A+","+-z+"H"+A+(u>0?"M0,"+(-z-A)+"V"+-A:""));P.setAttribute("class","fore");P.setAttribute("fill","none");P.setAttribute("d",H.getAttribute("d"));B.addEventListener("mousedown",k(u),false);B.addEventListener("mouseover",f,false);B.addEventListener("mouseout",j,false);B.addEventListener("dblclick",q,false);return B}function n(u){var z=t*0.2,A=t*0.4,B=o.svg("g"),H=B.appendChild(o.svg("rect")),J=B.appendChild(o.svg("path"));H.setAttribute("pointer-events","all");H.setAttribute("fill","none");H.setAttribute("x", --A);H.setAttribute("y",-0.75*A);H.setAttribute("width",2*A);H.setAttribute("height",1.5*A);J.setAttribute("class","chevron");J.setAttribute("d","M"+-z+",0H"+z);B.addEventListener("mousedown",g(u),false);B.addEventListener("dblclick",q,false);return B}function w(){var u=t+6,z=u,A=E.size();switch(i){case "top-left":break;case "top-right":u=A.x-u;break;case "bottom-left":z=A.y-z;break;case "bottom-right":u=A.x-u;z=A.y-z;break}s.setAttribute("transform","translate("+u+","+z+")");for(var B in v)B==E.zoom()? -v[B].setAttribute("class","active"):v[B].removeAttribute("class")}function e(){for(;s.lastChild;)s.removeChild(s.lastChild);if(x!="none"){var u=s.appendChild(o.svg("g"));u.setAttribute("class","pan");var z=u.appendChild(o.svg("circle"));z.setAttribute("class","back");z.setAttribute("r",t);u.appendChild(r({x:0,y:-D})).setAttribute("transform","rotate(0)");u.appendChild(r({x:D,y:0})).setAttribute("transform","rotate(90)");u.appendChild(r({x:0,y:D})).setAttribute("transform","rotate(180)");u.appendChild(r({x:-D, -y:0})).setAttribute("transform","rotate(270)");u=u.appendChild(o.svg("circle"));u.setAttribute("fill","none");u.setAttribute("class","fore");u.setAttribute("r",t)}if(y!="none"){u=s.appendChild(o.svg("g"));u.setAttribute("class","zoom");z=-0.5;if(y=="big"){v={};var A=E.zoomRange()[0];for(z=0;A<=E.zoomRange()[1];A++,z++)(v[A]=u.appendChild(n(A))).setAttribute("transform","translate(0,"+-(z+0.75)*t*0.4+")")}A=x=="none"?0.4:2;u.setAttribute("transform","translate(0,"+t*(/^top-/.test(i)?A+(z+0.5)*0.4: --A)+")");u.appendChild(m(+1)).setAttribute("transform","translate(0,"+-(z+0.5)*t*0.4+")");u.appendChild(m(-1)).setAttribute("transform","scale(-1)")}w()}var l={},s=o.svg("g"),v={},t=30,D=16,L=0,G=250,C=50,i="top-left",y="small",x="small",F,I,E;s.setAttribute("class","compass");l.radius=function(u){if(!arguments.length)return t;t=u;E&&e();return l};l.speed=function(u){if(!arguments.length)return t;D=u;return l};l.position=function(u){if(!arguments.length)return i;i=u;E&&e();return l};l.pan=function(u){if(!arguments.length)return x; -x=u;E&&e();return l};l.zoom=function(u){if(!arguments.length)return y;y=u;E&&e();return l};l.map=function(u){if(!arguments.length)return E;if(E){s.parentNode.removeChild(s);E.off("move",w).off("resize",w);window.removeEventListener("mouseup",a,false)}if(E=u){window.addEventListener("mouseup",a,false);E.on("move",w).on("resize",w);E.container().appendChild(s);e()}return l};return l};o.grid=function(){function d(){var k=c.firstChild,g=a.size(),f=a.pointLocation(S);a.pointLocation(g);var j=Math.pow(2, -4-Math.round(a.zoom()));f.lat=Math.floor(f.lat/j)*j;f.lon=Math.ceil(f.lon/j)*j;for(var q;(q=a.locationPoint(f).x)<=g.x;f.lon+=j){k||(k=c.appendChild(o.svg("line")));k.setAttribute("x1",q);k.setAttribute("x2",q);k.setAttribute("y1",0);k.setAttribute("y2",g.y);k=k.nextSibling}for(;(q=a.locationPoint(f).y)<=g.y;f.lat-=j){k||(k=c.appendChild(o.svg("line")));k.setAttribute("y1",q);k.setAttribute("y2",q);k.setAttribute("x1",0);k.setAttribute("x2",g.x);k=k.nextSibling}for(;k;){g=k.nextSibling;c.removeChild(k); -k=g}}var h={},a,c=o.svg("g");c.setAttribute("class","grid");h.map=function(k){if(!arguments.length)return a;if(a){c.parentNode.removeChild(c);a.off("move",d).off("resize",d)}if(a=k){a.on("move",d).on("resize",d);a.container().appendChild(c);a.dispatch({type:"move"})}return h};return h}})(org.polymaps); +(function(q){function M(){for(var d=0;dg.row){var a=d;d=g;g=a}return{x0:d.column,y0:d.row,x1:g.column,y1:g.row,dx:g.column-d.column,dy:g.row-d.row}}function Z(d,g,a,c,j){a=Math.max(a,Math.floor(g.y0));c=Math.min(c,Math.ceil(g.y1));if(d.x0==g.x0&&d.y0==g.y0?d.x0+g.dy/d.dy*d.dx0,o=g.dx<0;for(a=a;ag.dy){a=f;f=g;g=a}if(f.dy>d.dy){a=f;f=d;d=a}if(g.dy>d.dy){a=g;g=d;d=a}f.dy&&Z(d,f,c,j,h);g.dy&&Z(d,g,c,j,h)}q.version="2.0+1.3+1";var S={x:0,y:0};q.id=function(){var d=0;return function(){return++d}}();q.svg=function(d){return document.createElementNS(q.ns.svg, +d)};q.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};q.transform=function(d,g,a,c,j,h){var f={},k,o,r;if(!arguments.length){d=1;g=j=a=0;c=1;h=0}f.zoomFraction=function(m){if(!arguments.length)return o;o=m;k=Math.floor(o+Math.log(Math.sqrt(d*d+g*g+a*a+c*c))/Math.log(2));r=Math.pow(2,-k);return f};f.apply=function(m){var n=Math.pow(2,-m.zoom),w=Math.pow(2,m.zoom-k);return{column:(d*m.column*n+a*m.row*n+j)*w,row:(g*m.column*n+c*m.row*n+h)*w,zoom:m.zoom-k}};f.unapply=function(m){var n= +Math.pow(2,-m.zoom),w=Math.pow(2,m.zoom+k);return{column:(m.column*n*c-m.row*n*a-j*c+h*a)/(d*c-g*a)*w,row:(m.column*n*g-m.row*n*d-j*g+h*d)/(a*g-c*d)*w,zoom:m.zoom+k}};f.toString=function(){return"matrix("+[d*r,g*r,a*r,c*r].join(" ")+" 0 0)"};return f.zoomFraction(0)};q.cache=function(d,g){function a(n){m--;g&&g(n);delete f[n.key];if(n.next)n.next.prev=n.prev;else if(o=n.prev)o.next=null;if(n.prev)n.prev.next=n.next;else if(k=n.next)k.prev=null}function c(){for(var n=o;m>r;n=n.prev){if(!n)break;n.lock|| +a(n)}}var j={},h={},f={},k=null,o=null,r=64,m=0;j.peek=function(n){return f[[n.zoom,n.column,n.row].join("/")]};j.load=function(n,w){var e=[n.zoom,n.column,n.row].join("/"),l=f[e];if(l){if(l.prev){if(l.prev.next=l.next)l.next.prev=l.prev;else o=l.prev;l.prev=null;l.next=k;k=k.prev=l}l.lock=1;return h[e]=l}l={key:e,column:n.column,row:n.row,zoom:n.zoom,next:k,prev:null,lock:1};d.call(null,l,w);h[e]=f[e]=l;if(k)k.prev=l;else o=l;k=l;m++;c();return l};j.unload=function(n){if(!(n in h))return false;var w= +h[n];w.lock=0;delete h[n];w.request&&w.request.abort(false)?a(w):c();return w};j.locks=function(){return h};j.size=function(n){if(!arguments.length)return r;r=n;c();return j};return j};q.url=function(d){function g(c){var j=c.zoom<0?1:1<=h||!c.length)){j++;c.pop()()}}function g(f){for(var k=0;kw[1])r=w[1];m=r-(r=Math.round(r));n=Math.pow(2,m)}function g(){if(G){var i=45/Math.pow(2,r+m-3),y=Math.max(Math.abs(s*f.x+ +l*f.y),Math.abs(t*f.x+v*f.y)),x=Q(D-y*i/k.y);y=Q(L+y*i/k.y);o.lat=Math.max(x,Math.min(y,o.lat));x=Math.max(Math.abs(s*f.y+l*f.x),Math.abs(t*f.y+v*f.x));o.lon=Math.max(G[0].lon-x*i/k.x,Math.min(G[1].lon+x*i/k.x,o.lon))}}var a={},c,j,h=S,f=S,k={x:256,y:256},o={lat:37.76487,lon:-122.41948},r=12,m=0,n=1,w=[1,18],e=0,l=1,s=0,v=1,t=0,D=-180,L=180,G=[{lat:Q(D),lon:-Infinity},{lat:Q(L),lon:Infinity}];a.locationCoordinate=function(i){i=q.map.locationCoordinate(i);var y=Math.pow(2,r);i.column*=y;i.row*=y;i.zoom+= +r;return i};a.coordinateLocation=q.map.coordinateLocation;a.coordinatePoint=function(i,y){var x=Math.pow(2,r-y.zoom),F=Math.pow(2,r-i.zoom),I=(y.column*x-i.column*F)*k.x*n;x=(y.row*x-i.row*F)*k.y*n;return{x:f.x+l*I-s*x,y:f.y+s*I+l*x}};a.pointCoordinate=function(i,y){var x=Math.pow(2,r-i.zoom),F=(y.x-f.x)/n,I=(y.y-f.y)/n;return{column:i.column*x+(v*F-t*I)/k.x,row:i.row*x+(t*F+v*I)/k.y,zoom:r}};a.locationPoint=function(i){var y=Math.pow(2,r+m-3)/45,x=(i.lon-o.lon)*y*k.x;i=(R(o.lat)-R(i.lat))*y*k.y; +return{x:f.x+l*x-s*i,y:f.y+s*x+l*i}};a.pointLocation=function(i){var y=45/Math.pow(2,r+m-3),x=(i.x-f.x)*y;i=(i.y-f.y)*y;return{lon:o.lon+(v*x-t*i)/k.x,lat:Q(R(o.lat)-(t*x+v*i)/k.y)}};var C=q.svg("rect");C.setAttribute("visibility","hidden");C.setAttribute("pointer-events","all");a.container=function(i){if(!arguments.length)return c;c=i;c.setAttribute("class","map");c.appendChild(C);return a.resize()};a.focusableParent=function(){for(var i=c;i;i=i.parentNode)if(i.tabIndex>=0)return i;return window}; +a.mouse=function(i){var y=(c.ownerSVGElement||c).createSVGPoint();if(V<0&&(window.scrollX||window.scrollY)){var x=document.body.appendChild(q.svg("svg"));x.style.position="absolute";x.style.top=x.style.left="0px";var F=x.getScreenCTM();V=!(F.f||F.e);document.body.removeChild(x)}if(V){y.x=i.pageX;y.y=i.pageY}else{y.x=i.clientX;y.y=i.clientY}return y.matrixTransform(c.getScreenCTM().inverse())};a.size=function(i){if(!arguments.length)return h;j=i;return a.resize()};a.resize=function(){if(j){h=j;M.remove(a)}else{var i= +c.ownerSVGElement||c;if(i.offsetWidth==null){C.setAttribute("width","100%");C.setAttribute("height","100%");i=C}b=i.getBoundingClientRect();h={x:b.width,y:b.height};M.add(a)}C.setAttribute("width",h.x);C.setAttribute("height",h.y);f={x:h.x/2,y:h.y/2};g();a.dispatch({type:"resize"});return a};a.tileSize=function(i){if(!arguments.length)return k;k=i;a.dispatch({type:"move"});return a};a.center=function(i){if(!arguments.length)return o;o=i;g();a.dispatch({type:"move"});return a};a.panBy=function(i){var y= +45/Math.pow(2,r+m-3),x=i.x*y;i=i.y*y;return a.center({lon:o.lon+(t*i-v*x)/k.x,lat:Q(R(o.lat)+(t*x+v*i)/k.y)})};a.centerRange=function(i){if(!arguments.length)return G;if(G=i){D=G[0].lat>-90?R(G[0].lat):-Infinity;L=G[0].lat<90?R(G[1].lat):Infinity}else{D=-Infinity;L=Infinity}g();a.dispatch({type:"move"});return a};a.zoom=function(i){if(!arguments.length)return r+m;r=i;d();return a.center(o)};a.zoomBy=function(i,y,x){if(arguments.length<2)return a.zoom(r+m+i);if(arguments.length<3)x=a.pointLocation(y); +r=r+m+i;d();var F=a.locationPoint(x);return a.panBy({x:y.x-F.x,y:y.y-F.y})};a.zoomRange=function(i){if(!arguments.length)return w;w=i;return a.zoom(r+m)};a.angle=function(i){if(!arguments.length)return e;e=i;l=Math.cos(e);s=Math.sin(e);v=Math.cos(-e);t=Math.sin(-e);g();a.dispatch({type:"move"});return a};a.add=function(i){i.map(a);return a};a.remove=function(i){i.map(null);return a};a.dispatch=q.dispatch(a);return a};M.maps=[];M.add=function(d){for(var g=0;g>O,row:A>>O,zoom:B-O}))&&N.ready){I[N.key]=j.load(P);N.proxyCount++;K.proxyRefs[N.key]=N;break}}I[K.key]=K}}var s=c.map(),v=s.zoom(),t=v-(v=Math.round(v)),D=s.size(),L=s.angle(),G=s.tileSize(),C=s.locationCoordinate(s.center());f?m.removeAttribute("visibility"):m.setAttribute("visibility","hidden");for(var i=-4;i<=2;i++)w[i].setAttribute("class","zoom"+(i<0?"":"+")+i+" zoom"+(v+i));m.setAttribute("transform","translate("+D.x/ +2+","+D.y/2+")"+(L?"rotate("+L/Math.PI*180+")":"")+(t?"scale("+Math.pow(2,t)+")":"")+(n?n.zoomFraction(t):""));var y=s.pointCoordinate(C,S);i=s.pointCoordinate(C,{x:D.x,y:0});var x=s.pointCoordinate(C,D);s=s.pointCoordinate(C,{x:0,y:D.y});if(!t&&!L&&!n){C.column=(Math.round(G.x*C.column)+(D.x&1)/2)/G.x;C.row=(Math.round(G.y*C.row)+(D.y&1)/2)/G.y}var F=k?k(v)-v:0;if(F){t=Math.pow(2,F);y.column*=t;y.row*=t;i.column*=t;i.row*=t;x.column*=t;x.row*=t;s.column*=t;s.row*=t;y.zoom=i.zoom=x.zoom=s.zoom+=F}if(n){y= +n.unapply(y);i=n.unapply(i);x=n.unapply(x);s=n.unapply(s);C=n.unapply(C)}v=j.locks();var I={};for(var E in v)v[E].proxyCount=0;if(f&&F>-5&&F<3){t=y.zoom<0?1:1<>i<>i<=1;l--)(w[l]=m.appendChild(q.svg("g"))).setAttribute("transform","scale("+Math.pow(2,-l)+")");w[0]=m.appendChild(q.svg("g"));c.init&&c.init(m);r.on("move",a).on("resize",a);a()}return c};c.container=function(){return m};c.id=function(e){if(!arguments.length)return o;o=e;return c};c.visible=function(e){if(!arguments.length)return f; +f=e;r&&a();return c};c.transform=function(e){if(!arguments.length)return n;n=e;r&&a();return c};c.zoom=function(e){if(!arguments.length)return k;k=typeof e=="function"||e==null?e:function(){return e};return c};c.tile=function(e){if(!arguments.length)return h;h=e;return c};c.dispatch=q.dispatch(c);c.on("load",function(e){if(e.tile.proxyRefs){for(var l in e.tile.proxyRefs){var s=e.tile.proxyRefs[l];--s.proxyCount<=0&&j.unload(l)&&s.element.parentNode.removeChild(s.element)}delete e.tile.proxyRefs}}); +return c};q.image=function(){var d=q.layer(function(a){var c=a.element=q.svg("image"),j=d.map().tileSize();c.setAttribute("preserveAspectRatio","none");c.setAttribute("width",j.x);c.setAttribute("height",j.y);c.setAttribute("opacity",0);if(typeof g=="function")a.request=q.queue.image(c,g(a),function(){delete a.request;a.ready=true;c.removeAttribute("opacity");d.dispatch({type:"load",tile:a})});else{a.ready=true;c.setAttributeNS(q.ns.xlink,"href",g);d.dispatch({type:"load",tile:a})}},function(a){a.request&& +a.request.abort(true)}),g="about:blank";d.url=function(a){if(!arguments.length)return g;g=typeof a=="string"&&/{.}/.test(a)?q.url(a):a;return d};return d};q.geoJson=function(d){function g(e,l){return e&&e.type in w&&w[e.type](e,l)}function a(e,l){var s=l({lat:e[1],lon:e[0]}),v=q.svg("circle");v.setAttribute("r",4.5);v.setAttribute("cx",s.x);v.setAttribute("cy",s.y);return v}function c(e,l,s,v){v.push("M");for(var t=0;t +9&&Math.abs(m.wheelDelta)/l>=50)Y=1;j=e}if(Y==1)n*=0.03;k||(k=o.pointLocation(w));o.off("move",d);if(h)f==="mouse"?o.zoomBy(n,w,k):o.zoomBy(n);else if(n){e=Date.now();if(e-c>200){n=n>0?+1:-1;f==="mouse"?o.zoomBy(n,w,k):o.zoomBy(n);c=e}}o.on("move",d);m.preventDefault();return false}var a={},c=0,j=0,h=true,f="mouse",k,o,r;a.smooth=function(m){if(!arguments.length)return h;h=m;return a};a.zoom=function(m){if(!arguments.length)return f;f=m;return a};a.map=function(m){if(!arguments.length)return o;if(o){r.removeEventListener("mousemove", +d,false);r.removeEventListener("mousewheel",g,false);r.removeEventListener("DOMMouseScroll",g,false);r=null;o.off("move",d)}if(o=m){o.on("move",d);r=o.container();r.addEventListener("mousemove",d,false);r.addEventListener("mousewheel",g,false);r.addEventListener("DOMMouseScroll",g,false)}return a};return a};var Y=/WebKit\/533/.test(navigator.userAgent)?-1:0;q.arrow=function(){function d(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){var l=Date.now(),s=0,v=0;switch(e.keyCode){case 37:if(!h.left){f=l;h.left= +1;h.right||(s=m)}break;case 39:if(!h.right){f=l;h.right=1;h.left||(s=-m)}break;case 38:if(!h.up){f=l;h.up=1;h.down||(v=m)}break;case 40:if(!h.down){f=l;h.down=1;h.up||(v=-m)}break;default:return}if(s||v)n.panBy({x:s,y:v});if(!k&&h.left|h.right|h.up|h.down)k=setInterval(c,r);e.preventDefault()}}function g(e){f=Date.now();switch(e.keyCode){case 37:h.left=0;break;case 39:h.right=0;break;case 38:h.up=0;break;case 40:h.down=0;break;default:return}if(k&&!(h.left|h.right|h.up|h.down))k=clearInterval(k); +e.preventDefault()}function a(e){switch(e.charCode){case 45:case 95:n.zoom(Math.ceil(n.zoom())-1);break;case 43:case 61:n.zoom(Math.floor(n.zoom())+1);break;default:return}e.preventDefault()}function c(){if(n)if(!(Date.now()L+G&&E.panBy(I)}function a(){s.setAttribute("class","compass");if(F){clearInterval(F);F=0}}function c(u){return function(){u?this.setAttribute("class","active"):this.removeAttribute("class");I=u}}function j(u){return function(z){s.setAttribute("class", +"compass active");var A=E.zoom();E.zoom(u<0?Math.ceil(A)-1:Math.floor(A)+1);return o(z)}}function h(u){return function(z){E.zoom(u);return o(z)}}function f(){this.setAttribute("class","active")}function k(){this.removeAttribute("class")}function o(u){u.stopPropagation();u.preventDefault();return false}function r(u){var z=Math.SQRT1_2*t,A=t*0.7,B=t*0.2,H=q.svg("g"),J=H.appendChild(q.svg("path")),K=H.appendChild(q.svg("path"));J.setAttribute("class","direction");J.setAttribute("pointer-events","all"); +J.setAttribute("d","M0,0L"+z+","+z+"A"+t+","+t+" 0 0,1 "+-z+","+z+"Z");K.setAttribute("class","chevron");K.setAttribute("d","M"+B+","+(A-B)+"L0,"+A+" "+-B+","+(A-B));K.setAttribute("pointer-events","none");H.addEventListener("mousedown",d,false);H.addEventListener("mouseover",c(u),false);H.addEventListener("mouseout",c(null),false);H.addEventListener("dblclick",o,false);return H}function m(u){var z=t*0.4,A=z/2,B=q.svg("g"),H=B.appendChild(q.svg("path")),J=B.appendChild(q.svg("path")),K=B.appendChild(q.svg("path")), +P=B.appendChild(q.svg("path"));H.setAttribute("class","back");H.setAttribute("d","M"+-z+",0V"+-z+"A"+z+","+z+" 0 1,1 "+z+","+-z+"V0Z");J.setAttribute("class","direction");J.setAttribute("d",H.getAttribute("d"));K.setAttribute("class","chevron");K.setAttribute("d","M"+-A+","+-z+"H"+A+(u>0?"M0,"+(-z-A)+"V"+-A:""));P.setAttribute("class","fore");P.setAttribute("fill","none");P.setAttribute("d",H.getAttribute("d"));B.addEventListener("mousedown",j(u),false);B.addEventListener("mouseover",f,false);B.addEventListener("mouseout", +k,false);B.addEventListener("dblclick",o,false);return B}function n(u){var z=t*0.2,A=t*0.4,B=q.svg("g"),H=B.appendChild(q.svg("rect")),J=B.appendChild(q.svg("path"));H.setAttribute("pointer-events","all");H.setAttribute("fill","none");H.setAttribute("x",-A);H.setAttribute("y",-0.75*A);H.setAttribute("width",2*A);H.setAttribute("height",1.5*A);J.setAttribute("class","chevron");J.setAttribute("d","M"+-z+",0H"+z);B.addEventListener("mousedown",h(u),false);B.addEventListener("dblclick",o,false);return B} +function w(){var u=t+6,z=u,A=E.size();switch(i){case "top-left":break;case "top-right":u=A.x-u;break;case "bottom-left":z=A.y-z;break;case "bottom-right":u=A.x-u;z=A.y-z;break}s.setAttribute("transform","translate("+u+","+z+")");for(var B in v)B==E.zoom()?v[B].setAttribute("class","active"):v[B].removeAttribute("class")}function e(){for(;s.lastChild;)s.removeChild(s.lastChild);if(x!="none"){var u=s.appendChild(q.svg("g"));u.setAttribute("class","pan");var z=u.appendChild(q.svg("circle"));z.setAttribute("class", +"back");z.setAttribute("r",t);u.appendChild(r({x:0,y:-D})).setAttribute("transform","rotate(0)");u.appendChild(r({x:D,y:0})).setAttribute("transform","rotate(90)");u.appendChild(r({x:0,y:D})).setAttribute("transform","rotate(180)");u.appendChild(r({x:-D,y:0})).setAttribute("transform","rotate(270)");u=u.appendChild(q.svg("circle"));u.setAttribute("fill","none");u.setAttribute("class","fore");u.setAttribute("r",t)}if(y!="none"){u=s.appendChild(q.svg("g"));u.setAttribute("class","zoom");z=-0.5;if(y== +"big"){v={};var A=E.zoomRange()[0];for(z=0;A<=E.zoomRange()[1];A++,z++)(v[A]=u.appendChild(n(A))).setAttribute("transform","translate(0,"+-(z+0.75)*t*0.4+")")}A=x=="none"?0.4:2;u.setAttribute("transform","translate(0,"+t*(/^top-/.test(i)?A+(z+0.5)*0.4:-A)+")");u.appendChild(m(+1)).setAttribute("transform","translate(0,"+-(z+0.5)*t*0.4+")");u.appendChild(m(-1)).setAttribute("transform","scale(-1)")}w()}var l={},s=q.svg("g"),v={},t=30,D=16,L=0,G=250,C=50,i="top-left",y="small",x="small",F,I,E;s.setAttribute("class", +"compass");l.radius=function(u){if(!arguments.length)return t;t=u;E&&e();return l};l.speed=function(u){if(!arguments.length)return t;D=u;return l};l.position=function(u){if(!arguments.length)return i;i=u;E&&e();return l};l.pan=function(u){if(!arguments.length)return x;x=u;E&&e();return l};l.zoom=function(u){if(!arguments.length)return y;y=u;E&&e();return l};l.map=function(u){if(!arguments.length)return E;if(E){s.parentNode.removeChild(s);E.off("move",w).off("resize",w);window.removeEventListener("mouseup", +a,false)}if(E=u){window.addEventListener("mouseup",a,false);E.on("move",w).on("resize",w);E.container().appendChild(s);e()}return l};return l};q.grid=function(){function d(){var j=c.firstChild,h=a.size(),f=a.pointLocation(S);a.pointLocation(h);var k=Math.pow(2,4-Math.round(a.zoom()));f.lat=Math.floor(f.lat/k)*k;f.lon=Math.ceil(f.lon/k)*k;for(var o;(o=a.locationPoint(f).x)<=h.x;f.lon+=k){j||(j=c.appendChild(q.svg("line")));j.setAttribute("x1",o);j.setAttribute("x2",o);j.setAttribute("y1",0);j.setAttribute("y2", +h.y);j=j.nextSibling}for(;(o=a.locationPoint(f).y)<=h.y;f.lat-=k){j||(j=c.appendChild(q.svg("line")));j.setAttribute("y1",o);j.setAttribute("y2",o);j.setAttribute("x1",0);j.setAttribute("x2",h.x);j=j.nextSibling}for(;j;){h=j.nextSibling;c.removeChild(j);j=h}}var g={},a,c=q.svg("g");c.setAttribute("class","grid");g.map=function(j){if(!arguments.length)return a;if(a){c.parentNode.removeChild(c);a.off("move",d).off("resize",d)}if(a=j){a.on("move",d).on("resize",d);a.container().appendChild(c);a.dispatch({type:"move"})}return g}; +return g}})(org.polymaps); diff --git a/src/Dblclick.js b/src/Dblclick.js index 227e03f..a9e439a 100644 --- a/src/Dblclick.js +++ b/src/Dblclick.js @@ -1,5 +1,6 @@ po.dblclick = function() { var dblclick = {}, + zoom = "mouse", map, container; @@ -7,9 +8,15 @@ po.dblclick = function() { var z = map.zoom(); if (e.shiftKey) z = Math.ceil(z) - z - 1; else z = 1 - z + Math.floor(z); - map.zoomBy(z, map.mouse(e)); + zoom === "mouse" ? map.zoomBy(z, map.mouse(e)) : map.zoomBy(z); } + dblclick.zoom = function(x) { + if (!arguments.length) return zoom; + zoom = x; + return dblclick; + }; + dblclick.map = function(x) { if (!arguments.length) return map; if (map) { diff --git a/src/Wheel.js b/src/Wheel.js index e4952f5..3dd9cb1 100644 --- a/src/Wheel.js +++ b/src/Wheel.js @@ -3,6 +3,7 @@ po.wheel = function() { timePrev = 0, last = 0, smooth = true, + zoom = "mouse", location, map, container; @@ -26,11 +27,12 @@ po.wheel = function() { if (!location) location = map.pointLocation(point); map.off("move", move); if (smooth) { - map.zoomBy(delta, point, location); + zoom === "mouse" ? map.zoomBy(delta, point, location) : map.zoomBy(delta); } else if (delta) { var timeNow = Date.now(); if (timeNow - timePrev > 200) { - map.zoomBy(delta > 0 ? +1 : -1, point, location); + delta = delta > 0 ? +1 : -1; + zoom === "mouse" ? map.zoomBy(delta, point, location) : map.zoomBy(delta); timePrev = timeNow; } } @@ -45,6 +47,12 @@ po.wheel = function() { return wheel; }; + wheel.zoom = function(x) { + if (!arguments.length) return zoom; + zoom = x; + return wheel; + }; + wheel.map = function(x) { if (!arguments.length) return map; if (map) { diff --git a/src/start.js b/src/start.js index 1d468a2..148f403 100644 --- a/src/start.js +++ b/src/start.js @@ -2,6 +2,6 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0.3+1"; // This fork not semver! + po.version = "2.0+1.3+1"; // This fork not semver! var zero = {x: 0, y: 0}; From a376a47c497896fb58191a4203808b106f796a2c Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Wed, 1 Sep 2010 10:36:38 -0700 Subject: [PATCH 3/9] Stash a reference to the (HTML) Image object. It appears that even if you have a reference to an SVG image object, the browser can discard the image from the cache. If we store a reference to the HTML image object on the tile, then the browser is forced to keep the image in memory, which avoids flickering. --- src/Image.js | 3 ++- src/start.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Image.js b/src/Image.js index 6eadfe9..a282d27 100644 --- a/src/Image.js +++ b/src/Image.js @@ -10,9 +10,10 @@ po.image = function() { element.setAttribute("opacity", 0); if (typeof url == "function") { - tile.request = po.queue.image(element, url(tile), function() { + tile.request = po.queue.image(element, url(tile), function(img) { delete tile.request; tile.ready = true; + tile.img = img; element.removeAttribute("opacity"); image.dispatch({type: "load", tile: tile}); }); diff --git a/src/start.js b/src/start.js index 148f403..f5c7ff6 100644 --- a/src/start.js +++ b/src/start.js @@ -2,6 +2,6 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+1.3+1"; // This fork not semver! + po.version = "2.0+1.3+2"; // This fork not semver! var zero = {x: 0, y: 0}; From e14c4d2794ed0aa9b732436d69592e5fffe791d7 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Wed, 1 Sep 2010 20:12:44 -0700 Subject: [PATCH 4/9] More efficient zoom level transitions. Previously, zooming in by one caused all the currently-displayed tiles in level 0 to be re-added to the layer's -1 group element. We can avoid these adds (and similarly on zooming out) if we rename the level 0 group to be the new level -1 group; however, we have to be careful to reorder the levels to maintain the relative order: -4, -3, -2, -1, +2, +1, 0. In addition to being more efficient, this will hopefully avoid some image flickering that occurs when changing zoom levels. It appears that the SVG client discards images when they are re-added; by avoiding the re-add on both the image tiles and the level 0 group element, we can hopefully avoid any flicker! This commit also changes the layer implementation to initialize its container (and levels) upon construction, rather than waiting until the map is specified. This simplifies some of the startup logic and paves the way for eliminating the init hook. --- polymaps.js | 104 ++++++++++++++++++++++++++++++++++-------------- polymaps.min.js | 104 ++++++++++++++++++++++++------------------------ src/GeoJson.js | 31 ++++++++++----- src/Layer.js | 68 ++++++++++++++++++++++--------- 4 files changed, 199 insertions(+), 108 deletions(-) diff --git a/polymaps.js b/polymaps.js index 3e5d4c6..19a9686 100644 --- a/polymaps.js +++ b/polymaps.js @@ -2,7 +2,7 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+1.3+1"; // This fork not semver! + po.version = "2.0+1.3+2"; // This fork not semver! var zero = {x: 0, y: 0}; po.id = (function() { @@ -672,9 +672,47 @@ po.layer = function(load, unload) { zoom, id, map, - container, + container = po.svg("g"), transform, - levels; + levelZoom, + levels = {}; + + container.setAttribute("class", "layer"); + for (var i = -4; i <= -1; i++) levels[i] = container.appendChild(po.svg("g")); + for (var i = 2; i >= 1; i--) levels[i] = container.appendChild(po.svg("g")); + levels[0] = container.appendChild(po.svg("g")); + + function zoomIn(z) { + var end = levels[0].nextSibling; + for (; levelZoom < z; levelZoom++) { + // -4, -3, -2, -1, +2, +1, =0 // current order + // -3, -2, -1, +2, +1, =0, -4 // insertBefore(-4, end) + // -3, -2, -1, +1, =0, -4, +2 // insertBefore(+2, end) + // -3, -2, -1, =0, -4, +2, +1 // insertBefore(+1, end) + // -4, -3, -2, -1, +2, +1, =0 // relabel + container.insertBefore(levels[-4], end); + container.insertBefore(levels[2], end); + container.insertBefore(levels[1], end); + var t = levels[-4]; + for (var dz = -4; dz < 2;) levels[dz] = levels[++dz]; + levels[dz] = t; + } + } + + function zoomOut(z) { + var end = levels[0].nextSibling; + for (; levelZoom > z; levelZoom--) { + // -4, -3, -2, -1, +2, +1, =0 // current order + // -4, -3, -2, +2, +1, =0, -1 // insertBefore(-1, end) + // +2, -4, -3, -2, +1, =0, -1 // insertBefore(+2, -4) + // -4, -3, -2, -1, +2, +1, =0 // relabel + container.insertBefore(levels[-1], end); + container.insertBefore(levels[2], levels[-4]); + var t = levels[2]; + for (var dz = 2; dz > -4;) levels[dz] = levels[--dz]; + levels[dz] = t; + } + } function move() { var map = layer.map(), // in case the layer is removed @@ -691,8 +729,15 @@ po.layer = function(load, unload) { : container.setAttribute("visibility", "hidden"); // set the layer zoom levels - for (var z = -4; z <= 2; z++) { - levels[z].setAttribute("class", "zoom" + (z < 0 ? "" : "+") + z + " zoom" + (mapZoom + z)); + if (levelZoom != mapZoom) { + if (levelZoom < mapZoom) zoomIn(mapZoom); + else if (levelZoom > mapZoom) zoomOut(mapZoom); + else levelZoom = mapZoom; + for (var z = -4; z <= 2; z++) { + var l = levels[z]; + l.setAttribute("class", "zoom" + (z < 0 ? "" : "+") + z + " zoom" + (mapZoom + z)); + l.setAttribute("transform", "scale(" + Math.pow(2, -z) + ")"); + } } // set the layer transform @@ -882,23 +927,10 @@ po.layer = function(load, unload) { } map.off("move", move).off("resize", move); container.parentNode.removeChild(container); - container = levels = null; } map = x; if (map) { - container = map.container().appendChild(po.svg("g")); - if (id) container.setAttribute("id", id); - container.setAttribute("class", "layer"); - levels = {}; - for (var i = -4; i <= -1; i++) { - (levels[i] = container.appendChild(po.svg("g"))) - .setAttribute("transform", "scale(" + Math.pow(2, -i) + ")"); - } - for (var i = 2; i >= 1; i--) { - (levels[i] = container.appendChild(po.svg("g"))) - .setAttribute("transform", "scale(" + Math.pow(2, -i) + ")"); - } - levels[0] = container.appendChild(po.svg("g")); + map.container().appendChild(container); if (layer.init) layer.init(container); map.on("move", move).on("resize", move); move(); @@ -1012,9 +1044,10 @@ po.image = function() { element.setAttribute("opacity", 0); if (typeof url == "function") { - tile.request = po.queue.image(element, url(tile), function() { + tile.request = po.queue.image(element, url(tile), function(img) { delete tile.request; tile.ready = true; + tile.img = img; element.removeAttribute("opacity"); image.dispatch({type: "load", tile: tile}); }); @@ -1039,13 +1072,18 @@ po.image = function() { }; po.geoJson = function(fetch) { var geoJson = po.layer(load, unload), + container = geoJson.container(), url = "about:blank", clip = true, clipId, + clipPath, + clipRect, zoom = null, tiles = {}, features; + container.setAttribute("fill-rule", "evenodd"); + if (!arguments.length) fetch = po.queue.json; function geometry(o, proj) { @@ -1204,16 +1242,24 @@ po.geoJson = function(fetch) { return geoJson; }; - geoJson.init = function(g) { - if (clip && geoJson.tile()) { - var size = geoJson.map().tileSize(), - clipPath = g.insertBefore(po.svg("clipPath"), g.firstChild), - rect = clipPath.appendChild(po.svg("rect")); - clipPath.setAttribute("id", clipId = "org.polymaps." + po.id()); - rect.setAttribute("width", size.x); - rect.setAttribute("height", size.y); + var __map__ = geoJson.map; + geoJson.map = function(x) { + if (x) { + if (clip && geoJson.tile()) { + if (!clipPath) { + clipPath = container.insertBefore(po.svg("clipPath"), container.firstChild); + clipRect = clipPath.appendChild(po.svg("rect")); + clipPath.setAttribute("id", clipId = "org.polymaps." + po.id()); + } + var size = x.tileSize(); + clipRect.setAttribute("width", size.x); + clipRect.setAttribute("height", size.y); + } else if (clipPath) { + container.removeChild(clipPath); + clipPath = clipRect = clipId = null; + } } - g.setAttribute("fill-rule", "evenodd"); + return __map__.apply(this, arguments); }; geoJson.show = function(tile) { diff --git a/polymaps.min.js b/polymaps.min.js index 972e11c..01bf97a 100644 --- a/polymaps.min.js +++ b/polymaps.min.js @@ -1,53 +1,53 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={}; -(function(q){function M(){for(var d=0;dg.row){var a=d;d=g;g=a}return{x0:d.column,y0:d.row,x1:g.column,y1:g.row,dx:g.column-d.column,dy:g.row-d.row}}function Z(d,g,a,c,j){a=Math.max(a,Math.floor(g.y0));c=Math.min(c,Math.ceil(g.y1));if(d.x0==g.x0&&d.y0==g.y0?d.x0+g.dy/d.dy*d.dx0,o=g.dx<0;for(a=a;ag.dy){a=f;f=g;g=a}if(f.dy>d.dy){a=f;f=d;d=a}if(g.dy>d.dy){a=g;g=d;d=a}f.dy&&Z(d,f,c,j,h);g.dy&&Z(d,g,c,j,h)}q.version="2.0+1.3+1";var S={x:0,y:0};q.id=function(){var d=0;return function(){return++d}}();q.svg=function(d){return document.createElementNS(q.ns.svg, -d)};q.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};q.transform=function(d,g,a,c,j,h){var f={},k,o,r;if(!arguments.length){d=1;g=j=a=0;c=1;h=0}f.zoomFraction=function(m){if(!arguments.length)return o;o=m;k=Math.floor(o+Math.log(Math.sqrt(d*d+g*g+a*a+c*c))/Math.log(2));r=Math.pow(2,-k);return f};f.apply=function(m){var n=Math.pow(2,-m.zoom),w=Math.pow(2,m.zoom-k);return{column:(d*m.column*n+a*m.row*n+j)*w,row:(g*m.column*n+c*m.row*n+h)*w,zoom:m.zoom-k}};f.unapply=function(m){var n= -Math.pow(2,-m.zoom),w=Math.pow(2,m.zoom+k);return{column:(m.column*n*c-m.row*n*a-j*c+h*a)/(d*c-g*a)*w,row:(m.column*n*g-m.row*n*d-j*g+h*d)/(a*g-c*d)*w,zoom:m.zoom+k}};f.toString=function(){return"matrix("+[d*r,g*r,a*r,c*r].join(" ")+" 0 0)"};return f.zoomFraction(0)};q.cache=function(d,g){function a(n){m--;g&&g(n);delete f[n.key];if(n.next)n.next.prev=n.prev;else if(o=n.prev)o.next=null;if(n.prev)n.prev.next=n.next;else if(k=n.next)k.prev=null}function c(){for(var n=o;m>r;n=n.prev){if(!n)break;n.lock|| -a(n)}}var j={},h={},f={},k=null,o=null,r=64,m=0;j.peek=function(n){return f[[n.zoom,n.column,n.row].join("/")]};j.load=function(n,w){var e=[n.zoom,n.column,n.row].join("/"),l=f[e];if(l){if(l.prev){if(l.prev.next=l.next)l.next.prev=l.prev;else o=l.prev;l.prev=null;l.next=k;k=k.prev=l}l.lock=1;return h[e]=l}l={key:e,column:n.column,row:n.row,zoom:n.zoom,next:k,prev:null,lock:1};d.call(null,l,w);h[e]=f[e]=l;if(k)k.prev=l;else o=l;k=l;m++;c();return l};j.unload=function(n){if(!(n in h))return false;var w= -h[n];w.lock=0;delete h[n];w.request&&w.request.abort(false)?a(w):c();return w};j.locks=function(){return h};j.size=function(n){if(!arguments.length)return r;r=n;c();return j};return j};q.url=function(d){function g(c){var j=c.zoom<0?1:1<=h||!c.length)){j++;c.pop()()}}function g(f){for(var k=0;kw[1])r=w[1];m=r-(r=Math.round(r));n=Math.pow(2,m)}function g(){if(G){var i=45/Math.pow(2,r+m-3),y=Math.max(Math.abs(s*f.x+ -l*f.y),Math.abs(t*f.x+v*f.y)),x=Q(D-y*i/k.y);y=Q(L+y*i/k.y);o.lat=Math.max(x,Math.min(y,o.lat));x=Math.max(Math.abs(s*f.y+l*f.x),Math.abs(t*f.y+v*f.x));o.lon=Math.max(G[0].lon-x*i/k.x,Math.min(G[1].lon+x*i/k.x,o.lon))}}var a={},c,j,h=S,f=S,k={x:256,y:256},o={lat:37.76487,lon:-122.41948},r=12,m=0,n=1,w=[1,18],e=0,l=1,s=0,v=1,t=0,D=-180,L=180,G=[{lat:Q(D),lon:-Infinity},{lat:Q(L),lon:Infinity}];a.locationCoordinate=function(i){i=q.map.locationCoordinate(i);var y=Math.pow(2,r);i.column*=y;i.row*=y;i.zoom+= -r;return i};a.coordinateLocation=q.map.coordinateLocation;a.coordinatePoint=function(i,y){var x=Math.pow(2,r-y.zoom),F=Math.pow(2,r-i.zoom),I=(y.column*x-i.column*F)*k.x*n;x=(y.row*x-i.row*F)*k.y*n;return{x:f.x+l*I-s*x,y:f.y+s*I+l*x}};a.pointCoordinate=function(i,y){var x=Math.pow(2,r-i.zoom),F=(y.x-f.x)/n,I=(y.y-f.y)/n;return{column:i.column*x+(v*F-t*I)/k.x,row:i.row*x+(t*F+v*I)/k.y,zoom:r}};a.locationPoint=function(i){var y=Math.pow(2,r+m-3)/45,x=(i.lon-o.lon)*y*k.x;i=(R(o.lat)-R(i.lat))*y*k.y; -return{x:f.x+l*x-s*i,y:f.y+s*x+l*i}};a.pointLocation=function(i){var y=45/Math.pow(2,r+m-3),x=(i.x-f.x)*y;i=(i.y-f.y)*y;return{lon:o.lon+(v*x-t*i)/k.x,lat:Q(R(o.lat)-(t*x+v*i)/k.y)}};var C=q.svg("rect");C.setAttribute("visibility","hidden");C.setAttribute("pointer-events","all");a.container=function(i){if(!arguments.length)return c;c=i;c.setAttribute("class","map");c.appendChild(C);return a.resize()};a.focusableParent=function(){for(var i=c;i;i=i.parentNode)if(i.tabIndex>=0)return i;return window}; -a.mouse=function(i){var y=(c.ownerSVGElement||c).createSVGPoint();if(V<0&&(window.scrollX||window.scrollY)){var x=document.body.appendChild(q.svg("svg"));x.style.position="absolute";x.style.top=x.style.left="0px";var F=x.getScreenCTM();V=!(F.f||F.e);document.body.removeChild(x)}if(V){y.x=i.pageX;y.y=i.pageY}else{y.x=i.clientX;y.y=i.clientY}return y.matrixTransform(c.getScreenCTM().inverse())};a.size=function(i){if(!arguments.length)return h;j=i;return a.resize()};a.resize=function(){if(j){h=j;M.remove(a)}else{var i= -c.ownerSVGElement||c;if(i.offsetWidth==null){C.setAttribute("width","100%");C.setAttribute("height","100%");i=C}b=i.getBoundingClientRect();h={x:b.width,y:b.height};M.add(a)}C.setAttribute("width",h.x);C.setAttribute("height",h.y);f={x:h.x/2,y:h.y/2};g();a.dispatch({type:"resize"});return a};a.tileSize=function(i){if(!arguments.length)return k;k=i;a.dispatch({type:"move"});return a};a.center=function(i){if(!arguments.length)return o;o=i;g();a.dispatch({type:"move"});return a};a.panBy=function(i){var y= -45/Math.pow(2,r+m-3),x=i.x*y;i=i.y*y;return a.center({lon:o.lon+(t*i-v*x)/k.x,lat:Q(R(o.lat)+(t*x+v*i)/k.y)})};a.centerRange=function(i){if(!arguments.length)return G;if(G=i){D=G[0].lat>-90?R(G[0].lat):-Infinity;L=G[0].lat<90?R(G[1].lat):Infinity}else{D=-Infinity;L=Infinity}g();a.dispatch({type:"move"});return a};a.zoom=function(i){if(!arguments.length)return r+m;r=i;d();return a.center(o)};a.zoomBy=function(i,y,x){if(arguments.length<2)return a.zoom(r+m+i);if(arguments.length<3)x=a.pointLocation(y); -r=r+m+i;d();var F=a.locationPoint(x);return a.panBy({x:y.x-F.x,y:y.y-F.y})};a.zoomRange=function(i){if(!arguments.length)return w;w=i;return a.zoom(r+m)};a.angle=function(i){if(!arguments.length)return e;e=i;l=Math.cos(e);s=Math.sin(e);v=Math.cos(-e);t=Math.sin(-e);g();a.dispatch({type:"move"});return a};a.add=function(i){i.map(a);return a};a.remove=function(i){i.map(null);return a};a.dispatch=q.dispatch(a);return a};M.maps=[];M.add=function(d){for(var g=0;g>O,row:A>>O,zoom:B-O}))&&N.ready){I[N.key]=j.load(P);N.proxyCount++;K.proxyRefs[N.key]=N;break}}I[K.key]=K}}var s=c.map(),v=s.zoom(),t=v-(v=Math.round(v)),D=s.size(),L=s.angle(),G=s.tileSize(),C=s.locationCoordinate(s.center());f?m.removeAttribute("visibility"):m.setAttribute("visibility","hidden");for(var i=-4;i<=2;i++)w[i].setAttribute("class","zoom"+(i<0?"":"+")+i+" zoom"+(v+i));m.setAttribute("transform","translate("+D.x/ -2+","+D.y/2+")"+(L?"rotate("+L/Math.PI*180+")":"")+(t?"scale("+Math.pow(2,t)+")":"")+(n?n.zoomFraction(t):""));var y=s.pointCoordinate(C,S);i=s.pointCoordinate(C,{x:D.x,y:0});var x=s.pointCoordinate(C,D);s=s.pointCoordinate(C,{x:0,y:D.y});if(!t&&!L&&!n){C.column=(Math.round(G.x*C.column)+(D.x&1)/2)/G.x;C.row=(Math.round(G.y*C.row)+(D.y&1)/2)/G.y}var F=k?k(v)-v:0;if(F){t=Math.pow(2,F);y.column*=t;y.row*=t;i.column*=t;i.row*=t;x.column*=t;x.row*=t;s.column*=t;s.row*=t;y.zoom=i.zoom=x.zoom=s.zoom+=F}if(n){y= -n.unapply(y);i=n.unapply(i);x=n.unapply(x);s=n.unapply(s);C=n.unapply(C)}v=j.locks();var I={};for(var E in v)v[E].proxyCount=0;if(f&&F>-5&&F<3){t=y.zoom<0?1:1<>i<>i<=1;l--)(w[l]=m.appendChild(q.svg("g"))).setAttribute("transform","scale("+Math.pow(2,-l)+")");w[0]=m.appendChild(q.svg("g"));c.init&&c.init(m);r.on("move",a).on("resize",a);a()}return c};c.container=function(){return m};c.id=function(e){if(!arguments.length)return o;o=e;return c};c.visible=function(e){if(!arguments.length)return f; -f=e;r&&a();return c};c.transform=function(e){if(!arguments.length)return n;n=e;r&&a();return c};c.zoom=function(e){if(!arguments.length)return k;k=typeof e=="function"||e==null?e:function(){return e};return c};c.tile=function(e){if(!arguments.length)return h;h=e;return c};c.dispatch=q.dispatch(c);c.on("load",function(e){if(e.tile.proxyRefs){for(var l in e.tile.proxyRefs){var s=e.tile.proxyRefs[l];--s.proxyCount<=0&&j.unload(l)&&s.element.parentNode.removeChild(s.element)}delete e.tile.proxyRefs}}); -return c};q.image=function(){var d=q.layer(function(a){var c=a.element=q.svg("image"),j=d.map().tileSize();c.setAttribute("preserveAspectRatio","none");c.setAttribute("width",j.x);c.setAttribute("height",j.y);c.setAttribute("opacity",0);if(typeof g=="function")a.request=q.queue.image(c,g(a),function(){delete a.request;a.ready=true;c.removeAttribute("opacity");d.dispatch({type:"load",tile:a})});else{a.ready=true;c.setAttributeNS(q.ns.xlink,"href",g);d.dispatch({type:"load",tile:a})}},function(a){a.request&& -a.request.abort(true)}),g="about:blank";d.url=function(a){if(!arguments.length)return g;g=typeof a=="string"&&/{.}/.test(a)?q.url(a):a;return d};return d};q.geoJson=function(d){function g(e,l){return e&&e.type in w&&w[e.type](e,l)}function a(e,l){var s=l({lat:e[1],lon:e[0]}),v=q.svg("circle");v.setAttribute("r",4.5);v.setAttribute("cx",s.x);v.setAttribute("cy",s.y);return v}function c(e,l,s,v){v.push("M");for(var t=0;t -9&&Math.abs(m.wheelDelta)/l>=50)Y=1;j=e}if(Y==1)n*=0.03;k||(k=o.pointLocation(w));o.off("move",d);if(h)f==="mouse"?o.zoomBy(n,w,k):o.zoomBy(n);else if(n){e=Date.now();if(e-c>200){n=n>0?+1:-1;f==="mouse"?o.zoomBy(n,w,k):o.zoomBy(n);c=e}}o.on("move",d);m.preventDefault();return false}var a={},c=0,j=0,h=true,f="mouse",k,o,r;a.smooth=function(m){if(!arguments.length)return h;h=m;return a};a.zoom=function(m){if(!arguments.length)return f;f=m;return a};a.map=function(m){if(!arguments.length)return o;if(o){r.removeEventListener("mousemove", -d,false);r.removeEventListener("mousewheel",g,false);r.removeEventListener("DOMMouseScroll",g,false);r=null;o.off("move",d)}if(o=m){o.on("move",d);r=o.container();r.addEventListener("mousemove",d,false);r.addEventListener("mousewheel",g,false);r.addEventListener("DOMMouseScroll",g,false)}return a};return a};var Y=/WebKit\/533/.test(navigator.userAgent)?-1:0;q.arrow=function(){function d(e){if(!(e.ctrlKey||e.altKey||e.metaKey)){var l=Date.now(),s=0,v=0;switch(e.keyCode){case 37:if(!h.left){f=l;h.left= -1;h.right||(s=m)}break;case 39:if(!h.right){f=l;h.right=1;h.left||(s=-m)}break;case 38:if(!h.up){f=l;h.up=1;h.down||(v=m)}break;case 40:if(!h.down){f=l;h.down=1;h.up||(v=-m)}break;default:return}if(s||v)n.panBy({x:s,y:v});if(!k&&h.left|h.right|h.up|h.down)k=setInterval(c,r);e.preventDefault()}}function g(e){f=Date.now();switch(e.keyCode){case 37:h.left=0;break;case 39:h.right=0;break;case 38:h.up=0;break;case 40:h.down=0;break;default:return}if(k&&!(h.left|h.right|h.up|h.down))k=clearInterval(k); -e.preventDefault()}function a(e){switch(e.charCode){case 45:case 95:n.zoom(Math.ceil(n.zoom())-1);break;case 43:case 61:n.zoom(Math.floor(n.zoom())+1);break;default:return}e.preventDefault()}function c(){if(n)if(!(Date.now()L+G&&E.panBy(I)}function a(){s.setAttribute("class","compass");if(F){clearInterval(F);F=0}}function c(u){return function(){u?this.setAttribute("class","active"):this.removeAttribute("class");I=u}}function j(u){return function(z){s.setAttribute("class", -"compass active");var A=E.zoom();E.zoom(u<0?Math.ceil(A)-1:Math.floor(A)+1);return o(z)}}function h(u){return function(z){E.zoom(u);return o(z)}}function f(){this.setAttribute("class","active")}function k(){this.removeAttribute("class")}function o(u){u.stopPropagation();u.preventDefault();return false}function r(u){var z=Math.SQRT1_2*t,A=t*0.7,B=t*0.2,H=q.svg("g"),J=H.appendChild(q.svg("path")),K=H.appendChild(q.svg("path"));J.setAttribute("class","direction");J.setAttribute("pointer-events","all"); -J.setAttribute("d","M0,0L"+z+","+z+"A"+t+","+t+" 0 0,1 "+-z+","+z+"Z");K.setAttribute("class","chevron");K.setAttribute("d","M"+B+","+(A-B)+"L0,"+A+" "+-B+","+(A-B));K.setAttribute("pointer-events","none");H.addEventListener("mousedown",d,false);H.addEventListener("mouseover",c(u),false);H.addEventListener("mouseout",c(null),false);H.addEventListener("dblclick",o,false);return H}function m(u){var z=t*0.4,A=z/2,B=q.svg("g"),H=B.appendChild(q.svg("path")),J=B.appendChild(q.svg("path")),K=B.appendChild(q.svg("path")), -P=B.appendChild(q.svg("path"));H.setAttribute("class","back");H.setAttribute("d","M"+-z+",0V"+-z+"A"+z+","+z+" 0 1,1 "+z+","+-z+"V0Z");J.setAttribute("class","direction");J.setAttribute("d",H.getAttribute("d"));K.setAttribute("class","chevron");K.setAttribute("d","M"+-A+","+-z+"H"+A+(u>0?"M0,"+(-z-A)+"V"+-A:""));P.setAttribute("class","fore");P.setAttribute("fill","none");P.setAttribute("d",H.getAttribute("d"));B.addEventListener("mousedown",j(u),false);B.addEventListener("mouseover",f,false);B.addEventListener("mouseout", -k,false);B.addEventListener("dblclick",o,false);return B}function n(u){var z=t*0.2,A=t*0.4,B=q.svg("g"),H=B.appendChild(q.svg("rect")),J=B.appendChild(q.svg("path"));H.setAttribute("pointer-events","all");H.setAttribute("fill","none");H.setAttribute("x",-A);H.setAttribute("y",-0.75*A);H.setAttribute("width",2*A);H.setAttribute("height",1.5*A);J.setAttribute("class","chevron");J.setAttribute("d","M"+-z+",0H"+z);B.addEventListener("mousedown",h(u),false);B.addEventListener("dblclick",o,false);return B} -function w(){var u=t+6,z=u,A=E.size();switch(i){case "top-left":break;case "top-right":u=A.x-u;break;case "bottom-left":z=A.y-z;break;case "bottom-right":u=A.x-u;z=A.y-z;break}s.setAttribute("transform","translate("+u+","+z+")");for(var B in v)B==E.zoom()?v[B].setAttribute("class","active"):v[B].removeAttribute("class")}function e(){for(;s.lastChild;)s.removeChild(s.lastChild);if(x!="none"){var u=s.appendChild(q.svg("g"));u.setAttribute("class","pan");var z=u.appendChild(q.svg("circle"));z.setAttribute("class", -"back");z.setAttribute("r",t);u.appendChild(r({x:0,y:-D})).setAttribute("transform","rotate(0)");u.appendChild(r({x:D,y:0})).setAttribute("transform","rotate(90)");u.appendChild(r({x:0,y:D})).setAttribute("transform","rotate(180)");u.appendChild(r({x:-D,y:0})).setAttribute("transform","rotate(270)");u=u.appendChild(q.svg("circle"));u.setAttribute("fill","none");u.setAttribute("class","fore");u.setAttribute("r",t)}if(y!="none"){u=s.appendChild(q.svg("g"));u.setAttribute("class","zoom");z=-0.5;if(y== -"big"){v={};var A=E.zoomRange()[0];for(z=0;A<=E.zoomRange()[1];A++,z++)(v[A]=u.appendChild(n(A))).setAttribute("transform","translate(0,"+-(z+0.75)*t*0.4+")")}A=x=="none"?0.4:2;u.setAttribute("transform","translate(0,"+t*(/^top-/.test(i)?A+(z+0.5)*0.4:-A)+")");u.appendChild(m(+1)).setAttribute("transform","translate(0,"+-(z+0.5)*t*0.4+")");u.appendChild(m(-1)).setAttribute("transform","scale(-1)")}w()}var l={},s=q.svg("g"),v={},t=30,D=16,L=0,G=250,C=50,i="top-left",y="small",x="small",F,I,E;s.setAttribute("class", -"compass");l.radius=function(u){if(!arguments.length)return t;t=u;E&&e();return l};l.speed=function(u){if(!arguments.length)return t;D=u;return l};l.position=function(u){if(!arguments.length)return i;i=u;E&&e();return l};l.pan=function(u){if(!arguments.length)return x;x=u;E&&e();return l};l.zoom=function(u){if(!arguments.length)return y;y=u;E&&e();return l};l.map=function(u){if(!arguments.length)return E;if(E){s.parentNode.removeChild(s);E.off("move",w).off("resize",w);window.removeEventListener("mouseup", -a,false)}if(E=u){window.addEventListener("mouseup",a,false);E.on("move",w).on("resize",w);E.container().appendChild(s);e()}return l};return l};q.grid=function(){function d(){var j=c.firstChild,h=a.size(),f=a.pointLocation(S);a.pointLocation(h);var k=Math.pow(2,4-Math.round(a.zoom()));f.lat=Math.floor(f.lat/k)*k;f.lon=Math.ceil(f.lon/k)*k;for(var o;(o=a.locationPoint(f).x)<=h.x;f.lon+=k){j||(j=c.appendChild(q.svg("line")));j.setAttribute("x1",o);j.setAttribute("x2",o);j.setAttribute("y1",0);j.setAttribute("y2", -h.y);j=j.nextSibling}for(;(o=a.locationPoint(f).y)<=h.y;f.lat-=k){j||(j=c.appendChild(q.svg("line")));j.setAttribute("y1",o);j.setAttribute("y2",o);j.setAttribute("x1",0);j.setAttribute("x2",h.x);j=j.nextSibling}for(;j;){h=j.nextSibling;c.removeChild(j);j=h}}var g={},a,c=q.svg("g");c.setAttribute("class","grid");g.map=function(j){if(!arguments.length)return a;if(a){c.parentNode.removeChild(c);a.off("move",d).off("resize",d)}if(a=j){a.on("move",d).on("resize",d);a.container().appendChild(c);a.dispatch({type:"move"})}return g}; -return g}})(org.polymaps); +(function(o){function L(){for(var e=0;ef.row){var a=e;e=f;f=a}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,a,h,i){a=Math.max(a,Math.floor(f.y0));h=Math.min(h,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,h,i,c);f.dy&&ca(e,f,h,i,c)}o.version="2.0+1.3+2";var U={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, +e)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(e,f,a,h,i,c){var d={},j,n,q;if(!arguments.length){e=1;f=i=a=0;h=1;c=0}d.zoomFraction=function(m){if(!arguments.length)return n;n=m;j=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+h*h))/Math.log(2));q=Math.pow(2,-j);return d};d.apply=function(m){var l=Math.pow(2,-m.zoom),u=Math.pow(2,m.zoom-j);return{column:(e*m.column*l+a*m.row*l+i)*u,row:(f*m.column*l+h*m.row*l+c)*u,zoom:m.zoom-j}};d.unapply=function(m){var l= +Math.pow(2,-m.zoom),u=Math.pow(2,m.zoom+j);return{column:(m.column*l*h-m.row*l*a-i*h+c*a)/(e*h-f*a)*u,row:(m.column*l*f-m.row*l*e-i*f+c*e)/(a*f-h*e)*u,zoom:m.zoom+j}};d.toString=function(){return"matrix("+[e*q,f*q,a*q,h*q].join(" ")+" 0 0)"};return d.zoomFraction(0)};o.cache=function(e,f){function a(l){m--;f&&f(l);delete d[l.key];if(l.next)l.next.prev=l.prev;else if(n=l.prev)n.next=null;if(l.prev)l.prev.next=l.next;else if(j=l.next)j.prev=null}function h(){for(var l=n;m>q;l=l.prev){if(!l)break;l.lock|| +a(l)}}var i={},c={},d={},j=null,n=null,q=64,m=0;i.peek=function(l){return d[[l.zoom,l.column,l.row].join("/")]};i.load=function(l,u){var v=[l.zoom,l.column,l.row].join("/"),t=d[v];if(t){if(t.prev){if(t.prev.next=t.next)t.next.prev=t.prev;else n=t.prev;t.prev=null;t.next=j;j=j.prev=t}t.lock=1;return c[v]=t}t={key:v,column:l.column,row:l.row,zoom:l.zoom,next:j,prev:null,lock:1};e.call(null,t,u);c[v]=d[v]=t;if(j)j.prev=t;else n=t;j=t;m++;h();return t};i.unload=function(l){if(!(l in c))return false;var u= +c[l];u.lock=0;delete c[l];u.request&&u.request.abort(false)?a(u):h();return u};i.locks=function(){return c};i.size=function(l){if(!arguments.length)return q;q=l;h();return i};return i};o.url=function(e){function f(h){var i=h.zoom<0?1:1<=c||!h.length)){i++;h.pop()()}}function f(d){for(var j=0;ju[1])q=u[1];m=q-(q=Math.round(q));l=Math.pow(2,m)}function f(){if(r){var k=45/Math.pow(2,q+m-3),C=Math.max(Math.abs(z*d.x+ +t*d.y),Math.abs(g*d.x+J*d.y)),A=R(w-C*k/j.y);C=R(x+C*k/j.y);n.lat=Math.max(A,Math.min(C,n.lat));A=Math.max(Math.abs(z*d.y+t*d.x),Math.abs(g*d.y+J*d.x));n.lon=Math.max(r[0].lon-A*k/j.x,Math.min(r[1].lon+A*k/j.x,n.lon))}}var a={},h,i,c=U,d=U,j={x:256,y:256},n={lat:37.76487,lon:-122.41948},q=12,m=0,l=1,u=[1,18],v=0,t=1,z=0,J=1,g=0,w=-180,x=180,r=[{lat:R(w),lon:-Infinity},{lat:R(x),lon:Infinity}];a.locationCoordinate=function(k){k=o.map.locationCoordinate(k);var C=Math.pow(2,q);k.column*=C;k.row*=C;k.zoom+= +q;return k};a.coordinateLocation=o.map.coordinateLocation;a.coordinatePoint=function(k,C){var A=Math.pow(2,q-C.zoom),F=Math.pow(2,q-k.zoom),B=(C.column*A-k.column*F)*j.x*l;A=(C.row*A-k.row*F)*j.y*l;return{x:d.x+t*B-z*A,y:d.y+z*B+t*A}};a.pointCoordinate=function(k,C){var A=Math.pow(2,q-k.zoom),F=(C.x-d.x)/l,B=(C.y-d.y)/l;return{column:k.column*A+(J*F-g*B)/j.x,row:k.row*A+(g*F+J*B)/j.y,zoom:q}};a.locationPoint=function(k){var C=Math.pow(2,q+m-3)/45,A=(k.lon-n.lon)*C*j.x;k=(S(n.lat)-S(k.lat))*C*j.y; +return{x:d.x+t*A-z*k,y:d.y+z*A+t*k}};a.pointLocation=function(k){var C=45/Math.pow(2,q+m-3),A=(k.x-d.x)*C;k=(k.y-d.y)*C;return{lon:n.lon+(J*A-g*k)/j.x,lat:R(S(n.lat)-(g*A+J*k)/j.y)}};var y=o.svg("rect");y.setAttribute("visibility","hidden");y.setAttribute("pointer-events","all");a.container=function(k){if(!arguments.length)return h;h=k;h.setAttribute("class","map");h.appendChild(y);return a.resize()};a.focusableParent=function(){for(var k=h;k;k=k.parentNode)if(k.tabIndex>=0)return k;return window}; +a.mouse=function(k){var C=(h.ownerSVGElement||h).createSVGPoint();if(Y<0&&(window.scrollX||window.scrollY)){var A=document.body.appendChild(o.svg("svg"));A.style.position="absolute";A.style.top=A.style.left="0px";var F=A.getScreenCTM();Y=!(F.f||F.e);document.body.removeChild(A)}if(Y){C.x=k.pageX;C.y=k.pageY}else{C.x=k.clientX;C.y=k.clientY}return C.matrixTransform(h.getScreenCTM().inverse())};a.size=function(k){if(!arguments.length)return c;i=k;return a.resize()};a.resize=function(){if(i){c=i;L.remove(a)}else{var k= +h.ownerSVGElement||h;if(k.offsetWidth==null){y.setAttribute("width","100%");y.setAttribute("height","100%");k=y}b=k.getBoundingClientRect();c={x:b.width,y:b.height};L.add(a)}y.setAttribute("width",c.x);y.setAttribute("height",c.y);d={x:c.x/2,y:c.y/2};f();a.dispatch({type:"resize"});return a};a.tileSize=function(k){if(!arguments.length)return j;j=k;a.dispatch({type:"move"});return a};a.center=function(k){if(!arguments.length)return n;n=k;f();a.dispatch({type:"move"});return a};a.panBy=function(k){var C= +45/Math.pow(2,q+m-3),A=k.x*C;k=k.y*C;return a.center({lon:n.lon+(g*k-J*A)/j.x,lat:R(S(n.lat)+(g*A+J*k)/j.y)})};a.centerRange=function(k){if(!arguments.length)return r;if(r=k){w=r[0].lat>-90?S(r[0].lat):-Infinity;x=r[0].lat<90?S(r[1].lat):Infinity}else{w=-Infinity;x=Infinity}f();a.dispatch({type:"move"});return a};a.zoom=function(k){if(!arguments.length)return q+m;q=k;e();return a.center(n)};a.zoomBy=function(k,C,A){if(arguments.length<2)return a.zoom(q+m+k);if(arguments.length<3)A=a.pointLocation(C); +q=q+m+k;e();var F=a.locationPoint(A);return a.panBy({x:C.x-F.x,y:C.y-F.y})};a.zoomRange=function(k){if(!arguments.length)return u;u=k;return a.zoom(q+m)};a.angle=function(k){if(!arguments.length)return v;v=k;t=Math.cos(v);z=Math.sin(v);J=Math.cos(-v);g=Math.sin(-v);f();a.dispatch({type:"move"});return a};a.add=function(k){k.map(a);return a};a.remove=function(k){k.map(null);return a};a.dispatch=o.dispatch(a);return a};L.maps=[];L.add=function(e){for(var f=0;fg;t--){u.insertBefore(z[-1],w);u.insertBefore(z[2],z[-4]);for(var x=z[2],r=2;r>-4;)z[r]=z[--r];z[r]=x}}function i(){function g(I){var K=I.zoom,M=K<0?1:1<>O,row:M>>O,zoom:P-O}))&&N.ready){E[N.key]=d.load(V);N.proxyCount++;Q.proxyRefs[N.key]=N;break}}E[Q.key]=Q}} +var x=c.map(),r=x.zoom(),y=r-(r=Math.round(r)),k=x.size(),C=x.angle(),A=x.tileSize(),F=x.locationCoordinate(x.center());n?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden");if(t!=r){if(tr)h(r);else t=r;for(var B=-4;B<=2;B++){var G=z[B];G.setAttribute("class","zoom"+(B<0?"":"+")+B+" zoom"+(r+B));G.setAttribute("transform","scale("+Math.pow(2,-B)+")")}}u.setAttribute("transform","translate("+k.x/2+","+k.y/2+")"+(C?"rotate("+C/Math.PI*180+")":"")+(y?"scale("+Math.pow(2, +y)+")":"")+(v?v.zoomFraction(y):""));var s=x.pointCoordinate(F,U);B=x.pointCoordinate(F,{x:k.x,y:0});G=x.pointCoordinate(F,k);x=x.pointCoordinate(F,{x:0,y:k.y});if(!y&&!C&&!v){F.column=(Math.round(A.x*F.column)+(k.x&1)/2)/A.x;F.row=(Math.round(A.y*F.row)+(k.y&1)/2)/A.y}var D=q?q(r)-r:0;if(D){y=Math.pow(2,D);s.column*=y;s.row*=y;B.column*=y;B.row*=y;G.column*=y;G.row*=y;x.column*=y;x.row*=y;s.zoom=B.zoom=G.zoom=x.zoom+=D}if(v){s=v.unapply(s);B=v.unapply(B);G=v.unapply(G);x=v.unapply(x);F=v.unapply(F)}r= +d.locks();var E={};for(var H in r)r[H].proxyCount=0;if(n&&D>-5&&D<3){y=s.zoom<0?1:1<>B<>B<=1;J--)z[J]=u.appendChild(o.svg("g"));z[0]=u.appendChild(o.svg("g"));c.map=function(g){if(!arguments.length)return l;if(l){if(l==g){u.parentNode.appendChild(u);return c}l.off("move",i).off("resize", +i);u.parentNode.removeChild(u)}if(l=g){l.container().appendChild(u);c.init&&c.init(u);l.on("move",i).on("resize",i);i()}return c};c.container=function(){return u};c.id=function(g){if(!arguments.length)return m;m=g;return c};c.visible=function(g){if(!arguments.length)return n;n=g;l&&i();return c};c.transform=function(g){if(!arguments.length)return v;v=g;l&&i();return c};c.zoom=function(g){if(!arguments.length)return q;q=typeof g=="function"||g==null?g:function(){return g};return c};c.tile=function(g){if(!arguments.length)return j; +j=g;return c};c.dispatch=o.dispatch(c);c.on("load",function(g){if(g.tile.proxyRefs){for(var w in g.tile.proxyRefs){var x=g.tile.proxyRefs[w];--x.proxyCount<=0&&d.unload(w)&&x.element.parentNode.removeChild(x.element)}delete g.tile.proxyRefs}});return c};o.image=function(){var e=o.layer(function(a){var h=a.element=o.svg("image"),i=e.map().tileSize();h.setAttribute("preserveAspectRatio","none");h.setAttribute("width",i.x);h.setAttribute("height",i.y);h.setAttribute("opacity",0);if(typeof f=="function")a.request= +o.queue.image(h,f(a),function(c){delete a.request;a.ready=true;a.img=c;h.removeAttribute("opacity");e.dispatch({type:"load",tile:a})});else{a.ready=true;h.setAttributeNS(o.ns.xlink,"href",f);e.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),f="about:blank";e.url=function(a){if(!arguments.length)return f;f=typeof a=="string"&&/{.}/.test(a)?o.url(a):a;return e};return e};o.geoJson=function(e){function f(g,w){return g&&g.type in z&&z[g.type](g,w)}function a(g,w){var x= +w({lat:g[1],lon:g[0]}),r=o.svg("circle");r.setAttribute("r",4.5);r.setAttribute("cx",x.x);r.setAttribute("cy",x.y);return r}function h(g,w,x,r){r.push("M");for(var y=0;y9&&Math.abs(m.wheelDelta)/t>=50)ba=1;i=v}if(ba==1)l*=0.03;j||(j=n.pointLocation(u));n.off("move",e);if(c)d==="mouse"?n.zoomBy(l,u,j):n.zoomBy(l);else if(l){v= +Date.now();if(v-h>200){l=l>0?+1:-1;d==="mouse"?n.zoomBy(l,u,j):n.zoomBy(l);h=v}}n.on("move",e);m.preventDefault();return false}var a={},h=0,i=0,c=true,d="mouse",j,n,q;a.smooth=function(m){if(!arguments.length)return c;c=m;return a};a.zoom=function(m){if(!arguments.length)return d;d=m;return a};a.map=function(m){if(!arguments.length)return n;if(n){q.removeEventListener("mousemove",e,false);q.removeEventListener("mousewheel",f,false);q.removeEventListener("DOMMouseScroll",f,false);q=null;n.off("move", +e)}if(n=m){n.on("move",e);q=n.container();q.addEventListener("mousemove",e,false);q.addEventListener("mousewheel",f,false);q.addEventListener("DOMMouseScroll",f,false)}return a};return a};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;o.arrow=function(){function e(v){if(!(v.ctrlKey||v.altKey||v.metaKey)){var t=Date.now(),z=0,J=0;switch(v.keyCode){case 37:if(!c.left){d=t;c.left=1;c.right||(z=m)}break;case 39:if(!c.right){d=t;c.right=1;c.left||(z=-m)}break;case 38:if(!c.up){d=t;c.up=1;c.down|| +(J=m)}break;case 40:if(!c.down){d=t;c.down=1;c.up||(J=-m)}break;default:return}if(z||J)l.panBy({x:z,y:J});if(!j&&c.left|c.right|c.up|c.down)j=setInterval(h,q);v.preventDefault()}}function f(v){d=Date.now();switch(v.keyCode){case 37:c.left=0;break;case 39:c.right=0;break;case 38:c.up=0;break;case 40:c.down=0;break;default:return}if(j&&!(c.left|c.right|c.up|c.down))j=clearInterval(j);v.preventDefault()}function a(v){switch(v.charCode){case 45:case 95:l.zoom(Math.ceil(l.zoom())-1);break;case 43:case 61:l.zoom(Math.floor(l.zoom())+ +1);break;default:return}v.preventDefault()}function h(){if(l)if(!(Date.now()x+r&&G.panBy(B)}function a(){z.setAttribute("class","compass");if(F){clearInterval(F);F=0}}function h(s){return function(){s?this.setAttribute("class","active"):this.removeAttribute("class");B=s}}function i(s){return function(D){z.setAttribute("class","compass active");var E=G.zoom();G.zoom(s<0?Math.ceil(E)-1:Math.floor(E)+1);return n(D)}}function c(s){return function(D){G.zoom(s);return n(D)}} +function d(){this.setAttribute("class","active")}function j(){this.removeAttribute("class")}function n(s){s.stopPropagation();s.preventDefault();return false}function q(s){var D=Math.SQRT1_2*g,E=g*0.7,H=g*0.2,I=o.svg("g"),K=I.appendChild(o.svg("path")),M=I.appendChild(o.svg("path"));K.setAttribute("class","direction");K.setAttribute("pointer-events","all");K.setAttribute("d","M0,0L"+D+","+D+"A"+g+","+g+" 0 0,1 "+-D+","+D+"Z");M.setAttribute("class","chevron");M.setAttribute("d","M"+H+","+(E-H)+"L0,"+ +E+" "+-H+","+(E-H));M.setAttribute("pointer-events","none");I.addEventListener("mousedown",e,false);I.addEventListener("mouseover",h(s),false);I.addEventListener("mouseout",h(null),false);I.addEventListener("dblclick",n,false);return I}function m(s){var D=g*0.4,E=D/2,H=o.svg("g"),I=H.appendChild(o.svg("path")),K=H.appendChild(o.svg("path")),M=H.appendChild(o.svg("path")),P=H.appendChild(o.svg("path"));I.setAttribute("class","back");I.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+ +"V0Z");K.setAttribute("class","direction");K.setAttribute("d",I.getAttribute("d"));M.setAttribute("class","chevron");M.setAttribute("d","M"+-E+","+-D+"H"+E+(s>0?"M0,"+(-D-E)+"V"+-E:""));P.setAttribute("class","fore");P.setAttribute("fill","none");P.setAttribute("d",I.getAttribute("d"));H.addEventListener("mousedown",i(s),false);H.addEventListener("mouseover",d,false);H.addEventListener("mouseout",j,false);H.addEventListener("dblclick",n,false);return H}function l(s){var D=g*0.2,E=g*0.4,H=o.svg("g"), +I=H.appendChild(o.svg("rect")),K=H.appendChild(o.svg("path"));I.setAttribute("pointer-events","all");I.setAttribute("fill","none");I.setAttribute("x",-E);I.setAttribute("y",-0.75*E);I.setAttribute("width",2*E);I.setAttribute("height",1.5*E);K.setAttribute("class","chevron");K.setAttribute("d","M"+-D+",0H"+D);H.addEventListener("mousedown",c(s),false);H.addEventListener("dblclick",n,false);return H}function u(){var s=g+6,D=s,E=G.size();switch(k){case "top-left":break;case "top-right":s=E.x-s;break; +case "bottom-left":D=E.y-D;break;case "bottom-right":s=E.x-s;D=E.y-D;break}z.setAttribute("transform","translate("+s+","+D+")");for(var H in J)H==G.zoom()?J[H].setAttribute("class","active"):J[H].removeAttribute("class")}function v(){for(;z.lastChild;)z.removeChild(z.lastChild);if(A!="none"){var s=z.appendChild(o.svg("g"));s.setAttribute("class","pan");var D=s.appendChild(o.svg("circle"));D.setAttribute("class","back");D.setAttribute("r",g);s.appendChild(q({x:0,y:-w})).setAttribute("transform","rotate(0)"); +s.appendChild(q({x:w,y:0})).setAttribute("transform","rotate(90)");s.appendChild(q({x:0,y:w})).setAttribute("transform","rotate(180)");s.appendChild(q({x:-w,y:0})).setAttribute("transform","rotate(270)");s=s.appendChild(o.svg("circle"));s.setAttribute("fill","none");s.setAttribute("class","fore");s.setAttribute("r",g)}if(C!="none"){s=z.appendChild(o.svg("g"));s.setAttribute("class","zoom");D=-0.5;if(C=="big"){J={};var E=G.zoomRange()[0];for(D=0;E<=G.zoomRange()[1];E++,D++)(J[E]=s.appendChild(l(E))).setAttribute("transform", +"translate(0,"+-(D+0.75)*g*0.4+")")}E=A=="none"?0.4:2;s.setAttribute("transform","translate(0,"+g*(/^top-/.test(k)?E+(D+0.5)*0.4:-E)+")");s.appendChild(m(+1)).setAttribute("transform","translate(0,"+-(D+0.5)*g*0.4+")");s.appendChild(m(-1)).setAttribute("transform","scale(-1)")}u()}var t={},z=o.svg("g"),J={},g=30,w=16,x=0,r=250,y=50,k="top-left",C="small",A="small",F,B,G;z.setAttribute("class","compass");t.radius=function(s){if(!arguments.length)return g;g=s;G&&v();return t};t.speed=function(s){if(!arguments.length)return g; +w=s;return t};t.position=function(s){if(!arguments.length)return k;k=s;G&&v();return t};t.pan=function(s){if(!arguments.length)return A;A=s;G&&v();return t};t.zoom=function(s){if(!arguments.length)return C;C=s;G&&v();return t};t.map=function(s){if(!arguments.length)return G;if(G){z.parentNode.removeChild(z);G.off("move",u).off("resize",u);window.removeEventListener("mouseup",a,false)}if(G=s){window.addEventListener("mouseup",a,false);G.on("move",u).on("resize",u);G.container().appendChild(z);v()}return t}; +return t};o.grid=function(){function e(){var i=h.firstChild,c=a.size(),d=a.pointLocation(U);a.pointLocation(c);var j=Math.pow(2,4-Math.round(a.zoom()));d.lat=Math.floor(d.lat/j)*j;d.lon=Math.ceil(d.lon/j)*j;for(var n;(n=a.locationPoint(d).x)<=c.x;d.lon+=j){i||(i=h.appendChild(o.svg("line")));i.setAttribute("x1",n);i.setAttribute("x2",n);i.setAttribute("y1",0);i.setAttribute("y2",c.y);i=i.nextSibling}for(;(n=a.locationPoint(d).y)<=c.y;d.lat-=j){i||(i=h.appendChild(o.svg("line")));i.setAttribute("y1", +n);i.setAttribute("y2",n);i.setAttribute("x1",0);i.setAttribute("x2",c.x);i=i.nextSibling}for(;i;){c=i.nextSibling;h.removeChild(i);i=c}}var f={},a,h=o.svg("g");h.setAttribute("class","grid");f.map=function(i){if(!arguments.length)return a;if(a){h.parentNode.removeChild(h);a.off("move",e).off("resize",e)}if(a=i){a.on("move",e).on("resize",e);a.container().appendChild(h);a.dispatch({type:"move"})}return f};return f}})(org.polymaps); diff --git a/src/GeoJson.js b/src/GeoJson.js index 744b8cb..694e152 100644 --- a/src/GeoJson.js +++ b/src/GeoJson.js @@ -1,12 +1,17 @@ po.geoJson = function(fetch) { var geoJson = po.layer(load, unload), + container = geoJson.container(), url = "about:blank", clip = true, clipId, + clipPath, + clipRect, zoom = null, tiles = {}, features; + container.setAttribute("fill-rule", "evenodd"); + if (!arguments.length) fetch = po.queue.json; function geometry(o, proj) { @@ -165,16 +170,24 @@ po.geoJson = function(fetch) { return geoJson; }; - geoJson.init = function(g) { - if (clip && geoJson.tile()) { - var size = geoJson.map().tileSize(), - clipPath = g.insertBefore(po.svg("clipPath"), g.firstChild), - rect = clipPath.appendChild(po.svg("rect")); - clipPath.setAttribute("id", clipId = "org.polymaps." + po.id()); - rect.setAttribute("width", size.x); - rect.setAttribute("height", size.y); + var __map__ = geoJson.map; + geoJson.map = function(x) { + if (x) { + if (clip && geoJson.tile()) { + if (!clipPath) { + clipPath = container.insertBefore(po.svg("clipPath"), container.firstChild); + clipRect = clipPath.appendChild(po.svg("rect")); + clipPath.setAttribute("id", clipId = "org.polymaps." + po.id()); + } + var size = x.tileSize(); + clipRect.setAttribute("width", size.x); + clipRect.setAttribute("height", size.y); + } else if (clipPath) { + container.removeChild(clipPath); + clipPath = clipRect = clipId = null; + } } - g.setAttribute("fill-rule", "evenodd"); + return __map__.apply(this, arguments); }; geoJson.show = function(tile) { diff --git a/src/Layer.js b/src/Layer.js index 6f4a39f..4cce03f 100644 --- a/src/Layer.js +++ b/src/Layer.js @@ -6,9 +6,47 @@ po.layer = function(load, unload) { zoom, id, map, - container, + container = po.svg("g"), transform, - levels; + levelZoom, + levels = {}; + + container.setAttribute("class", "layer"); + for (var i = -4; i <= -1; i++) levels[i] = container.appendChild(po.svg("g")); + for (var i = 2; i >= 1; i--) levels[i] = container.appendChild(po.svg("g")); + levels[0] = container.appendChild(po.svg("g")); + + function zoomIn(z) { + var end = levels[0].nextSibling; + for (; levelZoom < z; levelZoom++) { + // -4, -3, -2, -1, +2, +1, =0 // current order + // -3, -2, -1, +2, +1, =0, -4 // insertBefore(-4, end) + // -3, -2, -1, +1, =0, -4, +2 // insertBefore(+2, end) + // -3, -2, -1, =0, -4, +2, +1 // insertBefore(+1, end) + // -4, -3, -2, -1, +2, +1, =0 // relabel + container.insertBefore(levels[-4], end); + container.insertBefore(levels[2], end); + container.insertBefore(levels[1], end); + var t = levels[-4]; + for (var dz = -4; dz < 2;) levels[dz] = levels[++dz]; + levels[dz] = t; + } + } + + function zoomOut(z) { + var end = levels[0].nextSibling; + for (; levelZoom > z; levelZoom--) { + // -4, -3, -2, -1, +2, +1, =0 // current order + // -4, -3, -2, +2, +1, =0, -1 // insertBefore(-1, end) + // +2, -4, -3, -2, +1, =0, -1 // insertBefore(+2, -4) + // -4, -3, -2, -1, +2, +1, =0 // relabel + container.insertBefore(levels[-1], end); + container.insertBefore(levels[2], levels[-4]); + var t = levels[2]; + for (var dz = 2; dz > -4;) levels[dz] = levels[--dz]; + levels[dz] = t; + } + } function move() { var map = layer.map(), // in case the layer is removed @@ -25,8 +63,15 @@ po.layer = function(load, unload) { : container.setAttribute("visibility", "hidden"); // set the layer zoom levels - for (var z = -4; z <= 2; z++) { - levels[z].setAttribute("class", "zoom" + (z < 0 ? "" : "+") + z + " zoom" + (mapZoom + z)); + if (levelZoom != mapZoom) { + if (levelZoom < mapZoom) zoomIn(mapZoom); + else if (levelZoom > mapZoom) zoomOut(mapZoom); + else levelZoom = mapZoom; + for (var z = -4; z <= 2; z++) { + var l = levels[z]; + l.setAttribute("class", "zoom" + (z < 0 ? "" : "+") + z + " zoom" + (mapZoom + z)); + l.setAttribute("transform", "scale(" + Math.pow(2, -z) + ")"); + } } // set the layer transform @@ -216,23 +261,10 @@ po.layer = function(load, unload) { } map.off("move", move).off("resize", move); container.parentNode.removeChild(container); - container = levels = null; } map = x; if (map) { - container = map.container().appendChild(po.svg("g")); - if (id) container.setAttribute("id", id); - container.setAttribute("class", "layer"); - levels = {}; - for (var i = -4; i <= -1; i++) { - (levels[i] = container.appendChild(po.svg("g"))) - .setAttribute("transform", "scale(" + Math.pow(2, -i) + ")"); - } - for (var i = 2; i >= 1; i--) { - (levels[i] = container.appendChild(po.svg("g"))) - .setAttribute("transform", "scale(" + Math.pow(2, -i) + ")"); - } - levels[0] = container.appendChild(po.svg("g")); + map.container().appendChild(container); if (layer.init) layer.init(container); map.on("move", move).on("resize", move); move(); From 75973cc3c87fbbc458f2f587241aca4e52230fc0 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Thu, 2 Sep 2010 00:07:51 -0700 Subject: [PATCH 5/9] Shift-drag to set map extent. This functionality is added to the `compass` control, which at first glance might seem weird, but it provides a convenient place for the dragging rect (on top of the other layers), and can also inherit the compass styling. This functionality is built on top of the map's new `extent` method, which takes a two-element location array, similar to `centerRange`. In a future change, it would be nice to add key listeners to the compass control, so that the escape key can cancel the shift-drag operation, and the space key can move the bounds rather than resize them. You might also want to floor the zoom level after setting the extent. And maybe a way to turn off shift-dragging if the functionality is not desired. --- examples/example.css | 8 +++ polymaps.js | 131 ++++++++++++++++++++++++++++++++++--------- polymaps.min.js | 107 ++++++++++++++++++----------------- src/Compass.js | 101 ++++++++++++++++++++++++++------- src/Drag.js | 6 +- src/GeoJson.js | 2 +- src/Map.js | 20 +++++++ src/start.js | 2 +- 8 files changed, 273 insertions(+), 104 deletions(-) diff --git a/examples/example.css b/examples/example.css index b3169d6..ce65085 100644 --- a/examples/example.css +++ b/examples/example.css @@ -32,6 +32,14 @@ svg { stroke-width: 1.5px; } +.compass rect.back.fore { + fill: #999; + fill-opacity: .3; + stroke: #eee; + stroke-width: 1px; + shape-rendering: crispEdges; +} + .compass .direction { fill: none; } diff --git a/polymaps.js b/polymaps.js index 19a9686..f4b1e5b 100644 --- a/polymaps.js +++ b/polymaps.js @@ -2,7 +2,7 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+1.3+2"; // This fork not semver! + po.version = "2.0+2.3+3"; // This fork not semver! var zero = {x: 0, y: 0}; po.id = (function() { @@ -581,6 +581,26 @@ po.map = function() { return map.zoom(zoom + zoomFraction); }; + map.extent = function(x) { + if (!arguments.length) return [ + map.pointLocation({x: 0, y: sizeActual.y}), + map.pointLocation({x: sizeActual.x, y: 0}) + ]; + + // compute the extent in points, scale factor, and center + var bl = map.locationPoint(x[0]), + tr = map.locationPoint(x[1]), + k = Math.max((tr.x - bl.x) / sizeActual.x, (bl.y - tr.y) / sizeActual.y), + l = map.pointLocation({x: (bl.x + tr.x) / 2, y: (bl.y + tr.y) / 2}); + + // update the zoom level + zoom = zoom + zoomFraction - Math.log(k) / Math.log(2); + rezoom(); + + // set the new center + return map.center(l); + }; + map.angle = function(x) { if (!arguments.length) return angle; angle = x; @@ -1259,7 +1279,7 @@ po.geoJson = function(fetch) { clipPath = clipRect = clipId = null; } } - return __map__.apply(this, arguments); + return __map__.apply(geoJson, arguments); }; geoJson.show = function(tile) { @@ -1315,14 +1335,14 @@ po.drag = function() { dragging; function mousedown(e) { + if (e.shiftKey) return; dragging = { x: e.clientX, y: e.clientY }; map.focusableParent().focus(); e.preventDefault(); - cursor = document.body.style.cursor; - document.body.style.cursor = "move"; + document.body.style.setProperty("cursor", "move", null); } function mousemove(e) { @@ -1336,7 +1356,7 @@ po.drag = function() { if (!dragging) return; mousemove(e); dragging = null; - document.body.style.cursor = cursor; + document.body.style.removeProperty("cursor"); } drag.map = function(x) { @@ -1622,12 +1642,21 @@ po.compass = function() { repeatInterval = 50, position = "top-left", // top-left, top-right, bottom-left, bottom-right zoomStyle = "small", // none, small, big + zoomContainer, panStyle = "small", // none, small panTimer, panDirection, - map; + panContainer, + drag, + dragRect = po.svg("rect"), + map, + container, + window; g.setAttribute("class", "compass"); + dragRect.setAttribute("class", "back fore"); + dragRect.setAttribute("pointer-events", "none"); + dragRect.setAttribute("display", "none"); function panStart(e) { g.setAttribute("class", "compass active"); @@ -1643,8 +1672,42 @@ po.compass = function() { } } - function panStop() { + function mousedown(e) { + if (e.shiftKey) { + drag = {x0: map.mouse(e)}; + map.focusableParent().focus(); + return cancel(e); + } + } + + function mousemove(e) { + if (!drag) return; + drag.x1 = map.mouse(e); + dragRect.setAttribute("x", Math.min(drag.x0.x, drag.x1.x)); + dragRect.setAttribute("y", Math.min(drag.x0.y, drag.x1.y)); + dragRect.setAttribute("width", Math.abs(drag.x0.x - drag.x1.x)); + dragRect.setAttribute("height", Math.abs(drag.x0.y - drag.x1.y)); + dragRect.removeAttribute("display"); + } + + function mouseup(e) { g.setAttribute("class", "compass"); + if (drag) { + if (drag.x1) { + map.extent([ + map.pointLocation({ + x: Math.min(drag.x0.x, drag.x1.x), + y: Math.max(drag.x0.y, drag.x1.y) + }), + map.pointLocation({ + x: Math.max(drag.x0.x, drag.x1.x), + y: Math.min(drag.x0.y, drag.x1.y) + }) + ]); + dragRect.setAttribute("display", "none"); + } + drag = null; + } if (panTimer) { clearInterval(panTimer); panTimer = 0; @@ -1759,7 +1822,9 @@ po.compass = function() { case "bottom-left": y = size.y - y; break; case "bottom-right": x = size.x - x; y = size.y - y; break; } - g.setAttribute("transform", "translate(" + x + "," + y + ")"); + var tx = "translate(" + x + "," + y + ")"; + if (panContainer) panContainer.setAttribute("transform", tx); + if (zoomContainer) zoomContainer.setAttribute("transform", tx); for (var i in ticks) { i == map.zoom() ? ticks[i].setAttribute("class", "active") @@ -1770,49 +1835,55 @@ po.compass = function() { function draw() { while (g.lastChild) g.removeChild(g.lastChild); + g.appendChild(dragRect); + if (panStyle != "none") { - var d = g.appendChild(po.svg("g")); - d.setAttribute("class", "pan"); + panContainer = g.appendChild(po.svg("g")); + panContainer.setAttribute("class", "pan"); - var back = d.appendChild(po.svg("circle")); + var back = panContainer.appendChild(po.svg("circle")); back.setAttribute("class", "back"); back.setAttribute("r", r); - var s = d.appendChild(pan({x: 0, y: -speed})); + var s = panContainer.appendChild(pan({x: 0, y: -speed})); s.setAttribute("transform", "rotate(0)"); - var w = d.appendChild(pan({x: speed, y: 0})); + var w = panContainer.appendChild(pan({x: speed, y: 0})); w.setAttribute("transform", "rotate(90)"); - var n = d.appendChild(pan({x: 0, y: speed})); + var n = panContainer.appendChild(pan({x: 0, y: speed})); n.setAttribute("transform", "rotate(180)"); - var e = d.appendChild(pan({x: -speed, y: 0})); + var e = panContainer.appendChild(pan({x: -speed, y: 0})); e.setAttribute("transform", "rotate(270)"); - var fore = d.appendChild(po.svg("circle")); + var fore = panContainer.appendChild(po.svg("circle")); fore.setAttribute("fill", "none"); fore.setAttribute("class", "fore"); fore.setAttribute("r", r); + } else { + panContainer = null; } if (zoomStyle != "none") { - var z = g.appendChild(po.svg("g")); - z.setAttribute("class", "zoom"); + zoomContainer = g.appendChild(po.svg("g")); + zoomContainer.setAttribute("class", "zoom"); var j = -.5; if (zoomStyle == "big") { ticks = {}; for (var i = map.zoomRange()[0], j = 0; i <= map.zoomRange()[1]; i++, j++) { - (ticks[i] = z.appendChild(tick(i))) + (ticks[i] = zoomContainer.appendChild(tick(i))) .setAttribute("transform", "translate(0," + (-(j + .75) * r * .4) + ")"); } } var p = panStyle == "none" ? .4 : 2; - z.setAttribute("transform", "translate(0," + r * (/^top-/.test(position) ? (p + (j + .5) * .4) : -p) + ")"); - z.appendChild(zoom(+1)).setAttribute("transform", "translate(0," + (-(j + .5) * r * .4) + ")"); - z.appendChild(zoom(-1)).setAttribute("transform", "scale(-1)"); + zoomContainer.setAttribute("transform", "translate(0," + r * (/^top-/.test(position) ? (p + (j + .5) * .4) : -p) + ")"); + zoomContainer.appendChild(zoom(+1)).setAttribute("transform", "translate(0," + (-(j + .5) * r * .4) + ")"); + zoomContainer.appendChild(zoom(-1)).setAttribute("transform", "scale(-1)"); + } else { + zoomContainer = null; } move(); @@ -1855,14 +1926,22 @@ po.compass = function() { compass.map = function(x) { if (!arguments.length) return map; if (map) { - g.parentNode.removeChild(g); + container.removeEventListener("mousedown", mousedown, false); + container.removeChild(g); + container = null; + window.removeEventListener("mousemove", mousemove, false); + window.removeEventListener("mouseup", mouseup, false); + window = null; map.off("move", move).off("resize", move); - window.removeEventListener("mouseup", panStop, false); } if (map = x) { - window.addEventListener("mouseup", panStop, false); + container = map.container(); + container.appendChild(g); + container.addEventListener("mousedown", mousedown, false); + window = container.ownerDocument.defaultView; + window.addEventListener("mousemove", mousemove, false); + window.addEventListener("mouseup", mouseup, false); map.on("move", move).on("resize", move); - map.container().appendChild(g); draw(); } return compass; diff --git a/polymaps.min.js b/polymaps.min.js index 01bf97a..45c53e8 100644 --- a/polymaps.min.js +++ b/polymaps.min.js @@ -1,53 +1,56 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={}; -(function(o){function L(){for(var e=0;ef.row){var a=e;e=f;f=a}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,a,h,i){a=Math.max(a,Math.floor(f.y0));h=Math.min(h,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,h,i,c);f.dy&&ca(e,f,h,i,c)}o.version="2.0+1.3+2";var U={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, -e)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(e,f,a,h,i,c){var d={},j,n,q;if(!arguments.length){e=1;f=i=a=0;h=1;c=0}d.zoomFraction=function(m){if(!arguments.length)return n;n=m;j=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+h*h))/Math.log(2));q=Math.pow(2,-j);return d};d.apply=function(m){var l=Math.pow(2,-m.zoom),u=Math.pow(2,m.zoom-j);return{column:(e*m.column*l+a*m.row*l+i)*u,row:(f*m.column*l+h*m.row*l+c)*u,zoom:m.zoom-j}};d.unapply=function(m){var l= -Math.pow(2,-m.zoom),u=Math.pow(2,m.zoom+j);return{column:(m.column*l*h-m.row*l*a-i*h+c*a)/(e*h-f*a)*u,row:(m.column*l*f-m.row*l*e-i*f+c*e)/(a*f-h*e)*u,zoom:m.zoom+j}};d.toString=function(){return"matrix("+[e*q,f*q,a*q,h*q].join(" ")+" 0 0)"};return d.zoomFraction(0)};o.cache=function(e,f){function a(l){m--;f&&f(l);delete d[l.key];if(l.next)l.next.prev=l.prev;else if(n=l.prev)n.next=null;if(l.prev)l.prev.next=l.next;else if(j=l.next)j.prev=null}function h(){for(var l=n;m>q;l=l.prev){if(!l)break;l.lock|| -a(l)}}var i={},c={},d={},j=null,n=null,q=64,m=0;i.peek=function(l){return d[[l.zoom,l.column,l.row].join("/")]};i.load=function(l,u){var v=[l.zoom,l.column,l.row].join("/"),t=d[v];if(t){if(t.prev){if(t.prev.next=t.next)t.next.prev=t.prev;else n=t.prev;t.prev=null;t.next=j;j=j.prev=t}t.lock=1;return c[v]=t}t={key:v,column:l.column,row:l.row,zoom:l.zoom,next:j,prev:null,lock:1};e.call(null,t,u);c[v]=d[v]=t;if(j)j.prev=t;else n=t;j=t;m++;h();return t};i.unload=function(l){if(!(l in c))return false;var u= -c[l];u.lock=0;delete c[l];u.request&&u.request.abort(false)?a(u):h();return u};i.locks=function(){return c};i.size=function(l){if(!arguments.length)return q;q=l;h();return i};return i};o.url=function(e){function f(h){var i=h.zoom<0?1:1<=c||!h.length)){i++;h.pop()()}}function f(d){for(var j=0;ju[1])q=u[1];m=q-(q=Math.round(q));l=Math.pow(2,m)}function f(){if(r){var k=45/Math.pow(2,q+m-3),C=Math.max(Math.abs(z*d.x+ -t*d.y),Math.abs(g*d.x+J*d.y)),A=R(w-C*k/j.y);C=R(x+C*k/j.y);n.lat=Math.max(A,Math.min(C,n.lat));A=Math.max(Math.abs(z*d.y+t*d.x),Math.abs(g*d.y+J*d.x));n.lon=Math.max(r[0].lon-A*k/j.x,Math.min(r[1].lon+A*k/j.x,n.lon))}}var a={},h,i,c=U,d=U,j={x:256,y:256},n={lat:37.76487,lon:-122.41948},q=12,m=0,l=1,u=[1,18],v=0,t=1,z=0,J=1,g=0,w=-180,x=180,r=[{lat:R(w),lon:-Infinity},{lat:R(x),lon:Infinity}];a.locationCoordinate=function(k){k=o.map.locationCoordinate(k);var C=Math.pow(2,q);k.column*=C;k.row*=C;k.zoom+= -q;return k};a.coordinateLocation=o.map.coordinateLocation;a.coordinatePoint=function(k,C){var A=Math.pow(2,q-C.zoom),F=Math.pow(2,q-k.zoom),B=(C.column*A-k.column*F)*j.x*l;A=(C.row*A-k.row*F)*j.y*l;return{x:d.x+t*B-z*A,y:d.y+z*B+t*A}};a.pointCoordinate=function(k,C){var A=Math.pow(2,q-k.zoom),F=(C.x-d.x)/l,B=(C.y-d.y)/l;return{column:k.column*A+(J*F-g*B)/j.x,row:k.row*A+(g*F+J*B)/j.y,zoom:q}};a.locationPoint=function(k){var C=Math.pow(2,q+m-3)/45,A=(k.lon-n.lon)*C*j.x;k=(S(n.lat)-S(k.lat))*C*j.y; -return{x:d.x+t*A-z*k,y:d.y+z*A+t*k}};a.pointLocation=function(k){var C=45/Math.pow(2,q+m-3),A=(k.x-d.x)*C;k=(k.y-d.y)*C;return{lon:n.lon+(J*A-g*k)/j.x,lat:R(S(n.lat)-(g*A+J*k)/j.y)}};var y=o.svg("rect");y.setAttribute("visibility","hidden");y.setAttribute("pointer-events","all");a.container=function(k){if(!arguments.length)return h;h=k;h.setAttribute("class","map");h.appendChild(y);return a.resize()};a.focusableParent=function(){for(var k=h;k;k=k.parentNode)if(k.tabIndex>=0)return k;return window}; -a.mouse=function(k){var C=(h.ownerSVGElement||h).createSVGPoint();if(Y<0&&(window.scrollX||window.scrollY)){var A=document.body.appendChild(o.svg("svg"));A.style.position="absolute";A.style.top=A.style.left="0px";var F=A.getScreenCTM();Y=!(F.f||F.e);document.body.removeChild(A)}if(Y){C.x=k.pageX;C.y=k.pageY}else{C.x=k.clientX;C.y=k.clientY}return C.matrixTransform(h.getScreenCTM().inverse())};a.size=function(k){if(!arguments.length)return c;i=k;return a.resize()};a.resize=function(){if(i){c=i;L.remove(a)}else{var k= -h.ownerSVGElement||h;if(k.offsetWidth==null){y.setAttribute("width","100%");y.setAttribute("height","100%");k=y}b=k.getBoundingClientRect();c={x:b.width,y:b.height};L.add(a)}y.setAttribute("width",c.x);y.setAttribute("height",c.y);d={x:c.x/2,y:c.y/2};f();a.dispatch({type:"resize"});return a};a.tileSize=function(k){if(!arguments.length)return j;j=k;a.dispatch({type:"move"});return a};a.center=function(k){if(!arguments.length)return n;n=k;f();a.dispatch({type:"move"});return a};a.panBy=function(k){var C= -45/Math.pow(2,q+m-3),A=k.x*C;k=k.y*C;return a.center({lon:n.lon+(g*k-J*A)/j.x,lat:R(S(n.lat)+(g*A+J*k)/j.y)})};a.centerRange=function(k){if(!arguments.length)return r;if(r=k){w=r[0].lat>-90?S(r[0].lat):-Infinity;x=r[0].lat<90?S(r[1].lat):Infinity}else{w=-Infinity;x=Infinity}f();a.dispatch({type:"move"});return a};a.zoom=function(k){if(!arguments.length)return q+m;q=k;e();return a.center(n)};a.zoomBy=function(k,C,A){if(arguments.length<2)return a.zoom(q+m+k);if(arguments.length<3)A=a.pointLocation(C); -q=q+m+k;e();var F=a.locationPoint(A);return a.panBy({x:C.x-F.x,y:C.y-F.y})};a.zoomRange=function(k){if(!arguments.length)return u;u=k;return a.zoom(q+m)};a.angle=function(k){if(!arguments.length)return v;v=k;t=Math.cos(v);z=Math.sin(v);J=Math.cos(-v);g=Math.sin(-v);f();a.dispatch({type:"move"});return a};a.add=function(k){k.map(a);return a};a.remove=function(k){k.map(null);return a};a.dispatch=o.dispatch(a);return a};L.maps=[];L.add=function(e){for(var f=0;fg;t--){u.insertBefore(z[-1],w);u.insertBefore(z[2],z[-4]);for(var x=z[2],r=2;r>-4;)z[r]=z[--r];z[r]=x}}function i(){function g(I){var K=I.zoom,M=K<0?1:1<>O,row:M>>O,zoom:P-O}))&&N.ready){E[N.key]=d.load(V);N.proxyCount++;Q.proxyRefs[N.key]=N;break}}E[Q.key]=Q}} -var x=c.map(),r=x.zoom(),y=r-(r=Math.round(r)),k=x.size(),C=x.angle(),A=x.tileSize(),F=x.locationCoordinate(x.center());n?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden");if(t!=r){if(tr)h(r);else t=r;for(var B=-4;B<=2;B++){var G=z[B];G.setAttribute("class","zoom"+(B<0?"":"+")+B+" zoom"+(r+B));G.setAttribute("transform","scale("+Math.pow(2,-B)+")")}}u.setAttribute("transform","translate("+k.x/2+","+k.y/2+")"+(C?"rotate("+C/Math.PI*180+")":"")+(y?"scale("+Math.pow(2, -y)+")":"")+(v?v.zoomFraction(y):""));var s=x.pointCoordinate(F,U);B=x.pointCoordinate(F,{x:k.x,y:0});G=x.pointCoordinate(F,k);x=x.pointCoordinate(F,{x:0,y:k.y});if(!y&&!C&&!v){F.column=(Math.round(A.x*F.column)+(k.x&1)/2)/A.x;F.row=(Math.round(A.y*F.row)+(k.y&1)/2)/A.y}var D=q?q(r)-r:0;if(D){y=Math.pow(2,D);s.column*=y;s.row*=y;B.column*=y;B.row*=y;G.column*=y;G.row*=y;x.column*=y;x.row*=y;s.zoom=B.zoom=G.zoom=x.zoom+=D}if(v){s=v.unapply(s);B=v.unapply(B);G=v.unapply(G);x=v.unapply(x);F=v.unapply(F)}r= -d.locks();var E={};for(var H in r)r[H].proxyCount=0;if(n&&D>-5&&D<3){y=s.zoom<0?1:1<>B<>B<=1;J--)z[J]=u.appendChild(o.svg("g"));z[0]=u.appendChild(o.svg("g"));c.map=function(g){if(!arguments.length)return l;if(l){if(l==g){u.parentNode.appendChild(u);return c}l.off("move",i).off("resize", -i);u.parentNode.removeChild(u)}if(l=g){l.container().appendChild(u);c.init&&c.init(u);l.on("move",i).on("resize",i);i()}return c};c.container=function(){return u};c.id=function(g){if(!arguments.length)return m;m=g;return c};c.visible=function(g){if(!arguments.length)return n;n=g;l&&i();return c};c.transform=function(g){if(!arguments.length)return v;v=g;l&&i();return c};c.zoom=function(g){if(!arguments.length)return q;q=typeof g=="function"||g==null?g:function(){return g};return c};c.tile=function(g){if(!arguments.length)return j; -j=g;return c};c.dispatch=o.dispatch(c);c.on("load",function(g){if(g.tile.proxyRefs){for(var w in g.tile.proxyRefs){var x=g.tile.proxyRefs[w];--x.proxyCount<=0&&d.unload(w)&&x.element.parentNode.removeChild(x.element)}delete g.tile.proxyRefs}});return c};o.image=function(){var e=o.layer(function(a){var h=a.element=o.svg("image"),i=e.map().tileSize();h.setAttribute("preserveAspectRatio","none");h.setAttribute("width",i.x);h.setAttribute("height",i.y);h.setAttribute("opacity",0);if(typeof f=="function")a.request= -o.queue.image(h,f(a),function(c){delete a.request;a.ready=true;a.img=c;h.removeAttribute("opacity");e.dispatch({type:"load",tile:a})});else{a.ready=true;h.setAttributeNS(o.ns.xlink,"href",f);e.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),f="about:blank";e.url=function(a){if(!arguments.length)return f;f=typeof a=="string"&&/{.}/.test(a)?o.url(a):a;return e};return e};o.geoJson=function(e){function f(g,w){return g&&g.type in z&&z[g.type](g,w)}function a(g,w){var x= -w({lat:g[1],lon:g[0]}),r=o.svg("circle");r.setAttribute("r",4.5);r.setAttribute("cx",x.x);r.setAttribute("cy",x.y);return r}function h(g,w,x,r){r.push("M");for(var y=0;y9&&Math.abs(m.wheelDelta)/t>=50)ba=1;i=v}if(ba==1)l*=0.03;j||(j=n.pointLocation(u));n.off("move",e);if(c)d==="mouse"?n.zoomBy(l,u,j):n.zoomBy(l);else if(l){v= -Date.now();if(v-h>200){l=l>0?+1:-1;d==="mouse"?n.zoomBy(l,u,j):n.zoomBy(l);h=v}}n.on("move",e);m.preventDefault();return false}var a={},h=0,i=0,c=true,d="mouse",j,n,q;a.smooth=function(m){if(!arguments.length)return c;c=m;return a};a.zoom=function(m){if(!arguments.length)return d;d=m;return a};a.map=function(m){if(!arguments.length)return n;if(n){q.removeEventListener("mousemove",e,false);q.removeEventListener("mousewheel",f,false);q.removeEventListener("DOMMouseScroll",f,false);q=null;n.off("move", -e)}if(n=m){n.on("move",e);q=n.container();q.addEventListener("mousemove",e,false);q.addEventListener("mousewheel",f,false);q.addEventListener("DOMMouseScroll",f,false)}return a};return a};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;o.arrow=function(){function e(v){if(!(v.ctrlKey||v.altKey||v.metaKey)){var t=Date.now(),z=0,J=0;switch(v.keyCode){case 37:if(!c.left){d=t;c.left=1;c.right||(z=m)}break;case 39:if(!c.right){d=t;c.right=1;c.left||(z=-m)}break;case 38:if(!c.up){d=t;c.up=1;c.down|| -(J=m)}break;case 40:if(!c.down){d=t;c.down=1;c.up||(J=-m)}break;default:return}if(z||J)l.panBy({x:z,y:J});if(!j&&c.left|c.right|c.up|c.down)j=setInterval(h,q);v.preventDefault()}}function f(v){d=Date.now();switch(v.keyCode){case 37:c.left=0;break;case 39:c.right=0;break;case 38:c.up=0;break;case 40:c.down=0;break;default:return}if(j&&!(c.left|c.right|c.up|c.down))j=clearInterval(j);v.preventDefault()}function a(v){switch(v.charCode){case 45:case 95:l.zoom(Math.ceil(l.zoom())-1);break;case 43:case 61:l.zoom(Math.floor(l.zoom())+ -1);break;default:return}v.preventDefault()}function h(){if(l)if(!(Date.now()x+r&&G.panBy(B)}function a(){z.setAttribute("class","compass");if(F){clearInterval(F);F=0}}function h(s){return function(){s?this.setAttribute("class","active"):this.removeAttribute("class");B=s}}function i(s){return function(D){z.setAttribute("class","compass active");var E=G.zoom();G.zoom(s<0?Math.ceil(E)-1:Math.floor(E)+1);return n(D)}}function c(s){return function(D){G.zoom(s);return n(D)}} -function d(){this.setAttribute("class","active")}function j(){this.removeAttribute("class")}function n(s){s.stopPropagation();s.preventDefault();return false}function q(s){var D=Math.SQRT1_2*g,E=g*0.7,H=g*0.2,I=o.svg("g"),K=I.appendChild(o.svg("path")),M=I.appendChild(o.svg("path"));K.setAttribute("class","direction");K.setAttribute("pointer-events","all");K.setAttribute("d","M0,0L"+D+","+D+"A"+g+","+g+" 0 0,1 "+-D+","+D+"Z");M.setAttribute("class","chevron");M.setAttribute("d","M"+H+","+(E-H)+"L0,"+ -E+" "+-H+","+(E-H));M.setAttribute("pointer-events","none");I.addEventListener("mousedown",e,false);I.addEventListener("mouseover",h(s),false);I.addEventListener("mouseout",h(null),false);I.addEventListener("dblclick",n,false);return I}function m(s){var D=g*0.4,E=D/2,H=o.svg("g"),I=H.appendChild(o.svg("path")),K=H.appendChild(o.svg("path")),M=H.appendChild(o.svg("path")),P=H.appendChild(o.svg("path"));I.setAttribute("class","back");I.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+ -"V0Z");K.setAttribute("class","direction");K.setAttribute("d",I.getAttribute("d"));M.setAttribute("class","chevron");M.setAttribute("d","M"+-E+","+-D+"H"+E+(s>0?"M0,"+(-D-E)+"V"+-E:""));P.setAttribute("class","fore");P.setAttribute("fill","none");P.setAttribute("d",I.getAttribute("d"));H.addEventListener("mousedown",i(s),false);H.addEventListener("mouseover",d,false);H.addEventListener("mouseout",j,false);H.addEventListener("dblclick",n,false);return H}function l(s){var D=g*0.2,E=g*0.4,H=o.svg("g"), -I=H.appendChild(o.svg("rect")),K=H.appendChild(o.svg("path"));I.setAttribute("pointer-events","all");I.setAttribute("fill","none");I.setAttribute("x",-E);I.setAttribute("y",-0.75*E);I.setAttribute("width",2*E);I.setAttribute("height",1.5*E);K.setAttribute("class","chevron");K.setAttribute("d","M"+-D+",0H"+D);H.addEventListener("mousedown",c(s),false);H.addEventListener("dblclick",n,false);return H}function u(){var s=g+6,D=s,E=G.size();switch(k){case "top-left":break;case "top-right":s=E.x-s;break; -case "bottom-left":D=E.y-D;break;case "bottom-right":s=E.x-s;D=E.y-D;break}z.setAttribute("transform","translate("+s+","+D+")");for(var H in J)H==G.zoom()?J[H].setAttribute("class","active"):J[H].removeAttribute("class")}function v(){for(;z.lastChild;)z.removeChild(z.lastChild);if(A!="none"){var s=z.appendChild(o.svg("g"));s.setAttribute("class","pan");var D=s.appendChild(o.svg("circle"));D.setAttribute("class","back");D.setAttribute("r",g);s.appendChild(q({x:0,y:-w})).setAttribute("transform","rotate(0)"); -s.appendChild(q({x:w,y:0})).setAttribute("transform","rotate(90)");s.appendChild(q({x:0,y:w})).setAttribute("transform","rotate(180)");s.appendChild(q({x:-w,y:0})).setAttribute("transform","rotate(270)");s=s.appendChild(o.svg("circle"));s.setAttribute("fill","none");s.setAttribute("class","fore");s.setAttribute("r",g)}if(C!="none"){s=z.appendChild(o.svg("g"));s.setAttribute("class","zoom");D=-0.5;if(C=="big"){J={};var E=G.zoomRange()[0];for(D=0;E<=G.zoomRange()[1];E++,D++)(J[E]=s.appendChild(l(E))).setAttribute("transform", -"translate(0,"+-(D+0.75)*g*0.4+")")}E=A=="none"?0.4:2;s.setAttribute("transform","translate(0,"+g*(/^top-/.test(k)?E+(D+0.5)*0.4:-E)+")");s.appendChild(m(+1)).setAttribute("transform","translate(0,"+-(D+0.5)*g*0.4+")");s.appendChild(m(-1)).setAttribute("transform","scale(-1)")}u()}var t={},z=o.svg("g"),J={},g=30,w=16,x=0,r=250,y=50,k="top-left",C="small",A="small",F,B,G;z.setAttribute("class","compass");t.radius=function(s){if(!arguments.length)return g;g=s;G&&v();return t};t.speed=function(s){if(!arguments.length)return g; -w=s;return t};t.position=function(s){if(!arguments.length)return k;k=s;G&&v();return t};t.pan=function(s){if(!arguments.length)return A;A=s;G&&v();return t};t.zoom=function(s){if(!arguments.length)return C;C=s;G&&v();return t};t.map=function(s){if(!arguments.length)return G;if(G){z.parentNode.removeChild(z);G.off("move",u).off("resize",u);window.removeEventListener("mouseup",a,false)}if(G=s){window.addEventListener("mouseup",a,false);G.on("move",u).on("resize",u);G.container().appendChild(z);v()}return t}; -return t};o.grid=function(){function e(){var i=h.firstChild,c=a.size(),d=a.pointLocation(U);a.pointLocation(c);var j=Math.pow(2,4-Math.round(a.zoom()));d.lat=Math.floor(d.lat/j)*j;d.lon=Math.ceil(d.lon/j)*j;for(var n;(n=a.locationPoint(d).x)<=c.x;d.lon+=j){i||(i=h.appendChild(o.svg("line")));i.setAttribute("x1",n);i.setAttribute("x2",n);i.setAttribute("y1",0);i.setAttribute("y2",c.y);i=i.nextSibling}for(;(n=a.locationPoint(d).y)<=c.y;d.lat-=j){i||(i=h.appendChild(o.svg("line")));i.setAttribute("y1", -n);i.setAttribute("y2",n);i.setAttribute("x1",0);i.setAttribute("x2",c.x);i=i.nextSibling}for(;i;){c=i.nextSibling;h.removeChild(i);i=c}}var f={},a,h=o.svg("g");h.setAttribute("class","grid");f.map=function(i){if(!arguments.length)return a;if(a){h.parentNode.removeChild(h);a.off("move",e).off("resize",e)}if(a=i){a.on("move",e).on("resize",e);a.container().appendChild(h);a.dispatch({type:"move"})}return f};return f}})(org.polymaps); +(function(o){function R(){for(var e=0;ef.row){var a=e;e=f;f=a}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,a,g,i){a=Math.max(a,Math.floor(f.y0));g=Math.min(g,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,g,i,c);f.dy&&ca(e,f,g,i,c)}o.version="2.0+2.3+3";var Y={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, +e)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(e,f,a,g,i,c){var d={},m,n,s;if(!arguments.length){e=1;f=i=a=0;g=1;c=0}d.zoomFraction=function(l){if(!arguments.length)return n;n=l;m=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+g*g))/Math.log(2));s=Math.pow(2,-m);return d};d.apply=function(l){var k=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom-m);return{column:(e*l.column*k+a*l.row*k+i)*u,row:(f*l.column*k+g*l.row*k+c)*u,zoom:l.zoom-m}};d.unapply=function(l){var k= +Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+m);return{column:(l.column*k*g-l.row*k*a-i*g+c*a)/(e*g-f*a)*u,row:(l.column*k*f-l.row*k*e-i*f+c*e)/(a*f-g*e)*u,zoom:l.zoom+m}};d.toString=function(){return"matrix("+[e*s,f*s,a*s,g*s].join(" ")+" 0 0)"};return d.zoomFraction(0)};o.cache=function(e,f){function a(k){l--;f&&f(k);delete d[k.key];if(k.next)k.next.prev=k.prev;else if(n=k.prev)n.next=null;if(k.prev)k.prev.next=k.next;else if(m=k.next)m.prev=null}function g(){for(var k=n;l>s;k=k.prev){if(!k)break;k.lock|| +a(k)}}var i={},c={},d={},m=null,n=null,s=64,l=0;i.peek=function(k){return d[[k.zoom,k.column,k.row].join("/")]};i.load=function(k,u){var y=[k.zoom,k.column,k.row].join("/"),w=d[y];if(w){if(w.prev){if(w.prev.next=w.next)w.next.prev=w.prev;else n=w.prev;w.prev=null;w.next=m;m=m.prev=w}w.lock=1;return c[y]=w}w={key:y,column:k.column,row:k.row,zoom:k.zoom,next:m,prev:null,lock:1};e.call(null,w,u);c[y]=d[y]=w;if(m)m.prev=w;else n=w;m=w;l++;g();return w};i.unload=function(k){if(!(k in c))return false;var u= +c[k];u.lock=0;delete c[k];u.request&&u.request.abort(false)?a(u):g();return u};i.locks=function(){return c};i.size=function(k){if(!arguments.length)return s;s=k;g();return i};return i};o.url=function(e){function f(g){var i=g.zoom<0?1:1<=c||!g.length)){i++;g.pop()()}}function f(d){for(var m=0;mu[1])s=u[1];l=s-(s=Math.round(s));k=Math.pow(2,l)}function f(){if(r){var j=45/Math.pow(2,s+l-3),B=Math.max(Math.abs(C*d.x+ +w*d.y),Math.abs(h*d.x+F*d.y)),z=V(v-B*j/m.y);B=V(q+B*j/m.y);n.lat=Math.max(z,Math.min(B,n.lat));z=Math.max(Math.abs(C*d.y+w*d.x),Math.abs(h*d.y+F*d.x));n.lon=Math.max(r[0].lon-z*j/m.x,Math.min(r[1].lon+z*j/m.x,n.lon))}}var a={},g,i,c=Y,d=Y,m={x:256,y:256},n={lat:37.76487,lon:-122.41948},s=12,l=0,k=1,u=[1,18],y=0,w=1,C=0,F=1,h=0,v=-180,q=180,r=[{lat:V(v),lon:-Infinity},{lat:V(q),lon:Infinity}];a.locationCoordinate=function(j){j=o.map.locationCoordinate(j);var B=Math.pow(2,s);j.column*=B;j.row*=B;j.zoom+= +s;return j};a.coordinateLocation=o.map.coordinateLocation;a.coordinatePoint=function(j,B){var z=Math.pow(2,s-B.zoom),E=Math.pow(2,s-j.zoom),A=(B.column*z-j.column*E)*m.x*k;z=(B.row*z-j.row*E)*m.y*k;return{x:d.x+w*A-C*z,y:d.y+C*A+w*z}};a.pointCoordinate=function(j,B){var z=Math.pow(2,s-j.zoom),E=(B.x-d.x)/k,A=(B.y-d.y)/k;return{column:j.column*z+(F*E-h*A)/m.x,row:j.row*z+(h*E+F*A)/m.y,zoom:s}};a.locationPoint=function(j){var B=Math.pow(2,s+l-3)/45,z=(j.lon-n.lon)*B*m.x;j=(W(n.lat)-W(j.lat))*B*m.y; +return{x:d.x+w*z-C*j,y:d.y+C*z+w*j}};a.pointLocation=function(j){var B=45/Math.pow(2,s+l-3),z=(j.x-d.x)*B;j=(j.y-d.y)*B;return{lon:n.lon+(F*z-h*j)/m.x,lat:V(W(n.lat)-(h*z+F*j)/m.y)}};var x=o.svg("rect");x.setAttribute("visibility","hidden");x.setAttribute("pointer-events","all");a.container=function(j){if(!arguments.length)return g;g=j;g.setAttribute("class","map");g.appendChild(x);return a.resize()};a.focusableParent=function(){for(var j=g;j;j=j.parentNode)if(j.tabIndex>=0)return j;return window}; +a.mouse=function(j){var B=(g.ownerSVGElement||g).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var z=document.body.appendChild(o.svg("svg"));z.style.position="absolute";z.style.top=z.style.left="0px";var E=z.getScreenCTM();$=!(E.f||E.e);document.body.removeChild(z)}if($){B.x=j.pageX;B.y=j.pageY}else{B.x=j.clientX;B.y=j.clientY}return B.matrixTransform(g.getScreenCTM().inverse())};a.size=function(j){if(!arguments.length)return c;i=j;return a.resize()};a.resize=function(){if(i){c=i;R.remove(a)}else{var j= +g.ownerSVGElement||g;if(j.offsetWidth==null){x.setAttribute("width","100%");x.setAttribute("height","100%");j=x}b=j.getBoundingClientRect();c={x:b.width,y:b.height};R.add(a)}x.setAttribute("width",c.x);x.setAttribute("height",c.y);d={x:c.x/2,y:c.y/2};f();a.dispatch({type:"resize"});return a};a.tileSize=function(j){if(!arguments.length)return m;m=j;a.dispatch({type:"move"});return a};a.center=function(j){if(!arguments.length)return n;n=j;f();a.dispatch({type:"move"});return a};a.panBy=function(j){var B= +45/Math.pow(2,s+l-3),z=j.x*B;j=j.y*B;return a.center({lon:n.lon+(h*j-F*z)/m.x,lat:V(W(n.lat)+(h*z+F*j)/m.y)})};a.centerRange=function(j){if(!arguments.length)return r;if(r=j){v=r[0].lat>-90?W(r[0].lat):-Infinity;q=r[0].lat<90?W(r[1].lat):Infinity}else{v=-Infinity;q=Infinity}f();a.dispatch({type:"move"});return a};a.zoom=function(j){if(!arguments.length)return s+l;s=j;e();return a.center(n)};a.zoomBy=function(j,B,z){if(arguments.length<2)return a.zoom(s+l+j);if(arguments.length<3)z=a.pointLocation(B); +s=s+l+j;e();var E=a.locationPoint(z);return a.panBy({x:B.x-E.x,y:B.y-E.y})};a.zoomRange=function(j){if(!arguments.length)return u;u=j;return a.zoom(s+l)};a.extent=function(j){if(!arguments.length)return[a.pointLocation({x:0,y:c.y}),a.pointLocation({x:c.x,y:0})];var B=a.locationPoint(j[0]),z=a.locationPoint(j[1]),E=Math.max((z.x-B.x)/c.x,(B.y-z.y)/c.y);B=a.pointLocation({x:(B.x+z.x)/2,y:(B.y+z.y)/2});s=s+l-Math.log(E)/Math.log(2);e();return a.center(B)};a.angle=function(j){if(!arguments.length)return y; +y=j;w=Math.cos(y);C=Math.sin(y);F=Math.cos(-y);h=Math.sin(-y);f();a.dispatch({type:"move"});return a};a.add=function(j){j.map(a);return a};a.remove=function(j){j.map(null);return a};a.dispatch=o.dispatch(a);return a};R.maps=[];R.add=function(e){for(var f=0;fh;w--){u.insertBefore(C[-1],v);u.insertBefore(C[2], +C[-4]);for(var q=C[2],r=2;r>-4;)C[r]=C[--r];C[r]=q}}function i(){function h(M){var H=M.zoom,S=H<0?1:1<>P,row:S>>P,zoom:T-P}))&&N.ready){O[N.key]=d.load(J);N.proxyCount++;G.proxyRefs[N.key]=N;break}}O[G.key]=G}}var q=c.map(),r=q.zoom(),x=r-(r=Math.round(r)),j=q.size(),B=q.angle(),z=q.tileSize(),E=q.locationCoordinate(q.center());n?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden"); +if(w!=r){if(wr)g(r);else w=r;for(var A=-4;A<=2;A++){var L=C[A];L.setAttribute("class","zoom"+(A<0?"":"+")+A+" zoom"+(r+A));L.setAttribute("transform","scale("+Math.pow(2,-A)+")")}}u.setAttribute("transform","translate("+j.x/2+","+j.y/2+")"+(B?"rotate("+B/Math.PI*180+")":"")+(x?"scale("+Math.pow(2,x)+")":"")+(y?y.zoomFraction(x):""));var Q=q.pointCoordinate(E,Y);A=q.pointCoordinate(E,{x:j.x,y:0});L=q.pointCoordinate(E,j);q=q.pointCoordinate(E,{x:0,y:j.y});if(!x&&!B&&!y){E.column= +(Math.round(z.x*E.column)+(j.x&1)/2)/z.x;E.row=(Math.round(z.y*E.row)+(j.y&1)/2)/z.y}var U=s?s(r)-r:0;if(U){x=Math.pow(2,U);Q.column*=x;Q.row*=x;A.column*=x;A.row*=x;L.column*=x;L.row*=x;q.column*=x;q.row*=x;Q.zoom=A.zoom=L.zoom=q.zoom+=U}if(y){Q=y.unapply(Q);A=y.unapply(A);L=y.unapply(L);q=y.unapply(q);E=y.unapply(E)}r=d.locks();var O={};for(var I in r)r[I].proxyCount=0;if(n&&U>-5&&U<3){x=Q.zoom<0?1:1<>A<>A<=1;F--)C[F]=u.appendChild(o.svg("g"));C[0]=u.appendChild(o.svg("g"));c.map=function(h){if(!arguments.length)return k;if(k){if(k==h){u.parentNode.appendChild(u);return c}k.off("move",i).off("resize",i);u.parentNode.removeChild(u)}if(k=h){k.container().appendChild(u);c.init&&c.init(u);k.on("move",i).on("resize",i);i()}return c};c.container=function(){return u}; +c.id=function(h){if(!arguments.length)return l;l=h;return c};c.visible=function(h){if(!arguments.length)return n;n=h;k&&i();return c};c.transform=function(h){if(!arguments.length)return y;y=h;k&&i();return c};c.zoom=function(h){if(!arguments.length)return s;s=typeof h=="function"||h==null?h:function(){return h};return c};c.tile=function(h){if(!arguments.length)return m;m=h;return c};c.dispatch=o.dispatch(c);c.on("load",function(h){if(h.tile.proxyRefs){for(var v in h.tile.proxyRefs){var q=h.tile.proxyRefs[v]; +--q.proxyCount<=0&&d.unload(v)&&q.element.parentNode.removeChild(q.element)}delete h.tile.proxyRefs}});return c};o.image=function(){var e=o.layer(function(a){var g=a.element=o.svg("image"),i=e.map().tileSize();g.setAttribute("preserveAspectRatio","none");g.setAttribute("width",i.x);g.setAttribute("height",i.y);g.setAttribute("opacity",0);if(typeof f=="function")a.request=o.queue.image(g,f(a),function(c){delete a.request;a.ready=true;a.img=c;g.removeAttribute("opacity");e.dispatch({type:"load",tile:a})}); +else{a.ready=true;g.setAttributeNS(o.ns.xlink,"href",f);e.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),f="about:blank";e.url=function(a){if(!arguments.length)return f;f=typeof a=="string"&&/{.}/.test(a)?o.url(a):a;return e};return e};o.geoJson=function(e){function f(h,v){return h&&h.type in C&&C[h.type](h,v)}function a(h,v){var q=v({lat:h[1],lon:h[0]}),r=o.svg("circle");r.setAttribute("r",4.5);r.setAttribute("cx",q.x);r.setAttribute("cy",q.y);return r}function g(h, +v,q,r){r.push("M");for(var x=0;x9&&Math.abs(l.wheelDelta)/w>=50)ba=1;i=y}if(ba==1)k*=0.03;m||(m=n.pointLocation(u));n.off("move",e);if(c)d==="mouse"?n.zoomBy(k,u,m):n.zoomBy(k);else if(k){y=Date.now();if(y-g>200){k=k>0?+1:-1;d==="mouse"?n.zoomBy(k,u,m):n.zoomBy(k);g=y}}n.on("move",e);l.preventDefault();return false}var a= +{},g=0,i=0,c=true,d="mouse",m,n,s;a.smooth=function(l){if(!arguments.length)return c;c=l;return a};a.zoom=function(l){if(!arguments.length)return d;d=l;return a};a.map=function(l){if(!arguments.length)return n;if(n){s.removeEventListener("mousemove",e,false);s.removeEventListener("mousewheel",f,false);s.removeEventListener("DOMMouseScroll",f,false);s=null;n.off("move",e)}if(n=l){n.on("move",e);s=n.container();s.addEventListener("mousemove",e,false);s.addEventListener("mousewheel",f,false);s.addEventListener("DOMMouseScroll", +f,false)}return a};return a};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;o.arrow=function(){function e(y){if(!(y.ctrlKey||y.altKey||y.metaKey)){var w=Date.now(),C=0,F=0;switch(y.keyCode){case 37:if(!c.left){d=w;c.left=1;c.right||(C=l)}break;case 39:if(!c.right){d=w;c.right=1;c.left||(C=-l)}break;case 38:if(!c.up){d=w;c.up=1;c.down||(F=l)}break;case 40:if(!c.down){d=w;c.down=1;c.up||(F=-l)}break;default:return}if(C||F)k.panBy({x:C,y:F});if(!m&&c.left|c.right|c.up|c.down)m=setInterval(g,s); +y.preventDefault()}}function f(y){d=Date.now();switch(y.keyCode){case 37:c.left=0;break;case 39:c.right=0;break;case 38:c.up=0;break;case 40:c.down=0;break;default:return}if(m&&!(c.left|c.right|c.up|c.down))m=clearInterval(m);y.preventDefault()}function a(y){switch(y.charCode){case 45:case 95:k.zoom(Math.ceil(k.zoom())-1);break;case 43:case 61:k.zoom(Math.floor(k.zoom())+1);break;default:return}y.preventDefault()}function g(){if(k)if(!(Date.now() +x+j&&H.panBy(U)}function a(t){if(t.shiftKey){I={x0:H.mouse(t)};H.focusableParent().focus();return l(t)}}function g(t){if(I){I.x1=H.mouse(t);M.setAttribute("x",Math.min(I.x0.x,I.x1.x));M.setAttribute("y",Math.min(I.x0.y,I.x1.y));M.setAttribute("width",Math.abs(I.x0.x-I.x1.x));M.setAttribute("height",Math.abs(I.x0.y-I.x1.y));M.removeAttribute("display")}}function i(){h.setAttribute("class","compass");if(I){if(I.x1){H.extent([H.pointLocation({x:Math.min(I.x0.x,I.x1.x),y:Math.max(I.x0.y,I.x1.y)}),H.pointLocation({x:Math.max(I.x0.x, +I.x1.x),y:Math.min(I.x0.y,I.x1.y)})]);M.setAttribute("display","none")}I=null}if(Q){clearInterval(Q);Q=0}}function c(t){return function(){t?this.setAttribute("class","active"):this.removeAttribute("class");U=t}}function d(t){return function(D){h.setAttribute("class","compass active");var G=H.zoom();H.zoom(t<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function m(t){return function(D){H.zoom(t);return l(D)}}function n(){this.setAttribute("class","active")}function s(){this.removeAttribute("class")} +function l(t){t.stopPropagation();t.preventDefault();return false}function k(t){var D=Math.SQRT1_2*q,G=q*0.7,J=q*0.2,K=o.svg("g"),N=K.appendChild(o.svg("path")),P=K.appendChild(o.svg("path"));N.setAttribute("class","direction");N.setAttribute("pointer-events","all");N.setAttribute("d","M0,0L"+D+","+D+"A"+q+","+q+" 0 0,1 "+-D+","+D+"Z");P.setAttribute("class","chevron");P.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));P.setAttribute("pointer-events","none");K.addEventListener("mousedown", +e,false);K.addEventListener("mouseover",c(t),false);K.addEventListener("mouseout",c(null),false);K.addEventListener("dblclick",l,false);return K}function u(t){var D=q*0.4,G=D/2,J=o.svg("g"),K=J.appendChild(o.svg("path")),N=J.appendChild(o.svg("path")),P=J.appendChild(o.svg("path")),X=J.appendChild(o.svg("path"));K.setAttribute("class","back");K.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");N.setAttribute("class","direction");N.setAttribute("d",K.getAttribute("d"));P.setAttribute("class", +"chevron");P.setAttribute("d","M"+-G+","+-D+"H"+G+(t>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",K.getAttribute("d"));J.addEventListener("mousedown",d(t),false);J.addEventListener("mouseover",n,false);J.addEventListener("mouseout",s,false);J.addEventListener("dblclick",l,false);return J}function y(t){var D=q*0.2,G=q*0.4,J=o.svg("g"),K=J.appendChild(o.svg("rect")),N=J.appendChild(o.svg("path"));K.setAttribute("pointer-events","all");K.setAttribute("fill", +"none");K.setAttribute("x",-G);K.setAttribute("y",-0.75*G);K.setAttribute("width",2*G);K.setAttribute("height",1.5*G);N.setAttribute("class","chevron");N.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",m(t),false);J.addEventListener("dblclick",l,false);return J}function w(){var t=q+6,D=t,G=H.size();switch(z){case "top-left":break;case "top-right":t=G.x-t;break;case "bottom-left":D=G.y-D;break;case "bottom-right":t=G.x-t;D=G.y-D;break}t="translate("+t+","+D+")";O&&O.setAttribute("transform", +t);A&&A.setAttribute("transform",t);for(var J in v)J==H.zoom()?v[J].setAttribute("class","active"):v[J].removeAttribute("class")}function C(){for(;h.lastChild;)h.removeChild(h.lastChild);h.appendChild(M);if(L!="none"){O=h.appendChild(o.svg("g"));O.setAttribute("class","pan");var t=O.appendChild(o.svg("circle"));t.setAttribute("class","back");t.setAttribute("r",q);O.appendChild(k({x:0,y:-r})).setAttribute("transform","rotate(0)");O.appendChild(k({x:r,y:0})).setAttribute("transform","rotate(90)");O.appendChild(k({x:0, +y:r})).setAttribute("transform","rotate(180)");O.appendChild(k({x:-r,y:0})).setAttribute("transform","rotate(270)");t=O.appendChild(o.svg("circle"));t.setAttribute("fill","none");t.setAttribute("class","fore");t.setAttribute("r",q)}else O=null;if(E!="none"){A=h.appendChild(o.svg("g"));A.setAttribute("class","zoom");t=-0.5;if(E=="big"){v={};var D=H.zoomRange()[0];for(t=0;D<=H.zoomRange()[1];D++,t++)(v[D]=A.appendChild(y(D))).setAttribute("transform","translate(0,"+-(t+0.75)*q*0.4+")")}D=L=="none"? +0.4:2;A.setAttribute("transform","translate(0,"+q*(/^top-/.test(z)?D+(t+0.5)*0.4:-D)+")");A.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(t+0.5)*q*0.4+")");A.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else A=null;w()}var F={},h=o.svg("g"),v={},q=30,r=16,x=0,j=250,B=50,z="top-left",E="small",A,L="small",Q,U,O,I,M=o.svg("rect"),H,S,T;h.setAttribute("class","compass");M.setAttribute("class","back fore");M.setAttribute("pointer-events","none");M.setAttribute("display","none"); +F.radius=function(t){if(!arguments.length)return q;q=t;H&&C();return F};F.speed=function(t){if(!arguments.length)return q;r=t;return F};F.position=function(t){if(!arguments.length)return z;z=t;H&&C();return F};F.pan=function(t){if(!arguments.length)return L;L=t;H&&C();return F};F.zoom=function(t){if(!arguments.length)return E;E=t;H&&C();return F};F.map=function(t){if(!arguments.length)return H;if(H){S.removeEventListener("mousedown",a,false);S.removeChild(h);S=null;T.removeEventListener("mousemove", +g,false);T.removeEventListener("mouseup",i,false);T=null;H.off("move",w).off("resize",w)}if(H=t){S=H.container();S.appendChild(h);S.addEventListener("mousedown",a,false);T=S.ownerDocument.defaultView;T.addEventListener("mousemove",g,false);T.addEventListener("mouseup",i,false);H.on("move",w).on("resize",w);C()}return F};return F};o.grid=function(){function e(){var i=g.firstChild,c=a.size(),d=a.pointLocation(Y);a.pointLocation(c);var m=Math.pow(2,4-Math.round(a.zoom()));d.lat=Math.floor(d.lat/m)*m; +d.lon=Math.ceil(d.lon/m)*m;for(var n;(n=a.locationPoint(d).x)<=c.x;d.lon+=m){i||(i=g.appendChild(o.svg("line")));i.setAttribute("x1",n);i.setAttribute("x2",n);i.setAttribute("y1",0);i.setAttribute("y2",c.y);i=i.nextSibling}for(;(n=a.locationPoint(d).y)<=c.y;d.lat-=m){i||(i=g.appendChild(o.svg("line")));i.setAttribute("y1",n);i.setAttribute("y2",n);i.setAttribute("x1",0);i.setAttribute("x2",c.x);i=i.nextSibling}for(;i;){c=i.nextSibling;g.removeChild(i);i=c}}var f={},a,g=o.svg("g");g.setAttribute("class", +"grid");f.map=function(i){if(!arguments.length)return a;if(a){g.parentNode.removeChild(g);a.off("move",e).off("resize",e)}if(a=i){a.on("move",e).on("resize",e);a.container().appendChild(g);a.dispatch({type:"move"})}return f};return f}})(org.polymaps); diff --git a/src/Compass.js b/src/Compass.js index 6e0b2bd..bcb588d 100644 --- a/src/Compass.js +++ b/src/Compass.js @@ -9,12 +9,21 @@ po.compass = function() { repeatInterval = 50, position = "top-left", // top-left, top-right, bottom-left, bottom-right zoomStyle = "small", // none, small, big + zoomContainer, panStyle = "small", // none, small panTimer, panDirection, - map; + panContainer, + drag, + dragRect = po.svg("rect"), + map, + container, + window; g.setAttribute("class", "compass"); + dragRect.setAttribute("class", "back fore"); + dragRect.setAttribute("pointer-events", "none"); + dragRect.setAttribute("display", "none"); function panStart(e) { g.setAttribute("class", "compass active"); @@ -30,8 +39,42 @@ po.compass = function() { } } - function panStop() { + function mousedown(e) { + if (e.shiftKey) { + drag = {x0: map.mouse(e)}; + map.focusableParent().focus(); + return cancel(e); + } + } + + function mousemove(e) { + if (!drag) return; + drag.x1 = map.mouse(e); + dragRect.setAttribute("x", Math.min(drag.x0.x, drag.x1.x)); + dragRect.setAttribute("y", Math.min(drag.x0.y, drag.x1.y)); + dragRect.setAttribute("width", Math.abs(drag.x0.x - drag.x1.x)); + dragRect.setAttribute("height", Math.abs(drag.x0.y - drag.x1.y)); + dragRect.removeAttribute("display"); + } + + function mouseup(e) { g.setAttribute("class", "compass"); + if (drag) { + if (drag.x1) { + map.extent([ + map.pointLocation({ + x: Math.min(drag.x0.x, drag.x1.x), + y: Math.max(drag.x0.y, drag.x1.y) + }), + map.pointLocation({ + x: Math.max(drag.x0.x, drag.x1.x), + y: Math.min(drag.x0.y, drag.x1.y) + }) + ]); + dragRect.setAttribute("display", "none"); + } + drag = null; + } if (panTimer) { clearInterval(panTimer); panTimer = 0; @@ -146,7 +189,9 @@ po.compass = function() { case "bottom-left": y = size.y - y; break; case "bottom-right": x = size.x - x; y = size.y - y; break; } - g.setAttribute("transform", "translate(" + x + "," + y + ")"); + var tx = "translate(" + x + "," + y + ")"; + if (panContainer) panContainer.setAttribute("transform", tx); + if (zoomContainer) zoomContainer.setAttribute("transform", tx); for (var i in ticks) { i == map.zoom() ? ticks[i].setAttribute("class", "active") @@ -157,49 +202,55 @@ po.compass = function() { function draw() { while (g.lastChild) g.removeChild(g.lastChild); + g.appendChild(dragRect); + if (panStyle != "none") { - var d = g.appendChild(po.svg("g")); - d.setAttribute("class", "pan"); + panContainer = g.appendChild(po.svg("g")); + panContainer.setAttribute("class", "pan"); - var back = d.appendChild(po.svg("circle")); + var back = panContainer.appendChild(po.svg("circle")); back.setAttribute("class", "back"); back.setAttribute("r", r); - var s = d.appendChild(pan({x: 0, y: -speed})); + var s = panContainer.appendChild(pan({x: 0, y: -speed})); s.setAttribute("transform", "rotate(0)"); - var w = d.appendChild(pan({x: speed, y: 0})); + var w = panContainer.appendChild(pan({x: speed, y: 0})); w.setAttribute("transform", "rotate(90)"); - var n = d.appendChild(pan({x: 0, y: speed})); + var n = panContainer.appendChild(pan({x: 0, y: speed})); n.setAttribute("transform", "rotate(180)"); - var e = d.appendChild(pan({x: -speed, y: 0})); + var e = panContainer.appendChild(pan({x: -speed, y: 0})); e.setAttribute("transform", "rotate(270)"); - var fore = d.appendChild(po.svg("circle")); + var fore = panContainer.appendChild(po.svg("circle")); fore.setAttribute("fill", "none"); fore.setAttribute("class", "fore"); fore.setAttribute("r", r); + } else { + panContainer = null; } if (zoomStyle != "none") { - var z = g.appendChild(po.svg("g")); - z.setAttribute("class", "zoom"); + zoomContainer = g.appendChild(po.svg("g")); + zoomContainer.setAttribute("class", "zoom"); var j = -.5; if (zoomStyle == "big") { ticks = {}; for (var i = map.zoomRange()[0], j = 0; i <= map.zoomRange()[1]; i++, j++) { - (ticks[i] = z.appendChild(tick(i))) + (ticks[i] = zoomContainer.appendChild(tick(i))) .setAttribute("transform", "translate(0," + (-(j + .75) * r * .4) + ")"); } } var p = panStyle == "none" ? .4 : 2; - z.setAttribute("transform", "translate(0," + r * (/^top-/.test(position) ? (p + (j + .5) * .4) : -p) + ")"); - z.appendChild(zoom(+1)).setAttribute("transform", "translate(0," + (-(j + .5) * r * .4) + ")"); - z.appendChild(zoom(-1)).setAttribute("transform", "scale(-1)"); + zoomContainer.setAttribute("transform", "translate(0," + r * (/^top-/.test(position) ? (p + (j + .5) * .4) : -p) + ")"); + zoomContainer.appendChild(zoom(+1)).setAttribute("transform", "translate(0," + (-(j + .5) * r * .4) + ")"); + zoomContainer.appendChild(zoom(-1)).setAttribute("transform", "scale(-1)"); + } else { + zoomContainer = null; } move(); @@ -242,14 +293,22 @@ po.compass = function() { compass.map = function(x) { if (!arguments.length) return map; if (map) { - g.parentNode.removeChild(g); + container.removeEventListener("mousedown", mousedown, false); + container.removeChild(g); + container = null; + window.removeEventListener("mousemove", mousemove, false); + window.removeEventListener("mouseup", mouseup, false); + window = null; map.off("move", move).off("resize", move); - window.removeEventListener("mouseup", panStop, false); } if (map = x) { - window.addEventListener("mouseup", panStop, false); + container = map.container(); + container.appendChild(g); + container.addEventListener("mousedown", mousedown, false); + window = container.ownerDocument.defaultView; + window.addEventListener("mousemove", mousemove, false); + window.addEventListener("mouseup", mouseup, false); map.on("move", move).on("resize", move); - map.container().appendChild(g); draw(); } return compass; diff --git a/src/Drag.js b/src/Drag.js index bc8ace9..1b49942 100644 --- a/src/Drag.js +++ b/src/Drag.js @@ -6,14 +6,14 @@ po.drag = function() { dragging; function mousedown(e) { + if (e.shiftKey) return; dragging = { x: e.clientX, y: e.clientY }; map.focusableParent().focus(); e.preventDefault(); - cursor = document.body.style.cursor; - document.body.style.cursor = "move"; + document.body.style.setProperty("cursor", "move", null); } function mousemove(e) { @@ -27,7 +27,7 @@ po.drag = function() { if (!dragging) return; mousemove(e); dragging = null; - document.body.style.cursor = cursor; + document.body.style.removeProperty("cursor"); } drag.map = function(x) { diff --git a/src/GeoJson.js b/src/GeoJson.js index 694e152..251fd4b 100644 --- a/src/GeoJson.js +++ b/src/GeoJson.js @@ -187,7 +187,7 @@ po.geoJson = function(fetch) { clipPath = clipRect = clipId = null; } } - return __map__.apply(this, arguments); + return __map__.apply(geoJson, arguments); }; geoJson.show = function(tile) { diff --git a/src/Map.js b/src/Map.js index e97202b..f4de064 100644 --- a/src/Map.js +++ b/src/Map.js @@ -246,6 +246,26 @@ po.map = function() { return map.zoom(zoom + zoomFraction); }; + map.extent = function(x) { + if (!arguments.length) return [ + map.pointLocation({x: 0, y: sizeActual.y}), + map.pointLocation({x: sizeActual.x, y: 0}) + ]; + + // compute the extent in points, scale factor, and center + var bl = map.locationPoint(x[0]), + tr = map.locationPoint(x[1]), + k = Math.max((tr.x - bl.x) / sizeActual.x, (bl.y - tr.y) / sizeActual.y), + l = map.pointLocation({x: (bl.x + tr.x) / 2, y: (bl.y + tr.y) / 2}); + + // update the zoom level + zoom = zoom + zoomFraction - Math.log(k) / Math.log(2); + rezoom(); + + // set the new center + return map.center(l); + }; + map.angle = function(x) { if (!arguments.length) return angle; angle = x; diff --git a/src/start.js b/src/start.js index f5c7ff6..5e247db 100644 --- a/src/start.js +++ b/src/start.js @@ -2,6 +2,6 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+1.3+2"; // This fork not semver! + po.version = "2.0+2.3+3"; // This fork not semver! var zero = {x: 0, y: 0}; From 245e58c0dc602f9b040c40a69a561492a4ddcf33 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Thu, 2 Sep 2010 00:15:12 -0700 Subject: [PATCH 6/9] Remove cruft. --- polymaps.js | 3 +-- polymaps.min.js | 2 +- src/Drag.js | 1 - src/start.js | 2 +- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/polymaps.js b/polymaps.js index f4b1e5b..2e6819b 100644 --- a/polymaps.js +++ b/polymaps.js @@ -2,7 +2,7 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+2.3+3"; // This fork not semver! + po.version = "2.0+2.3+4"; // This fork not semver! var zero = {x: 0, y: 0}; po.id = (function() { @@ -1331,7 +1331,6 @@ po.drag = function() { var drag = {}, map, container, - cursor, dragging; function mousedown(e) { diff --git a/polymaps.min.js b/polymaps.min.js index 45c53e8..64049f6 100644 --- a/polymaps.min.js +++ b/polymaps.min.js @@ -1,6 +1,6 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={}; (function(o){function R(){for(var e=0;ef.row){var a=e;e=f;f=a}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,a,g,i){a=Math.max(a,Math.floor(f.y0));g=Math.min(g,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,g,i,c);f.dy&&ca(e,f,g,i,c)}o.version="2.0+2.3+3";var Y={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, +e.dy*e.dx0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,g,i,c);f.dy&&ca(e,f,g,i,c)}o.version="2.0+2.3+4";var Y={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, e)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(e,f,a,g,i,c){var d={},m,n,s;if(!arguments.length){e=1;f=i=a=0;g=1;c=0}d.zoomFraction=function(l){if(!arguments.length)return n;n=l;m=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+g*g))/Math.log(2));s=Math.pow(2,-m);return d};d.apply=function(l){var k=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom-m);return{column:(e*l.column*k+a*l.row*k+i)*u,row:(f*l.column*k+g*l.row*k+c)*u,zoom:l.zoom-m}};d.unapply=function(l){var k= Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+m);return{column:(l.column*k*g-l.row*k*a-i*g+c*a)/(e*g-f*a)*u,row:(l.column*k*f-l.row*k*e-i*f+c*e)/(a*f-g*e)*u,zoom:l.zoom+m}};d.toString=function(){return"matrix("+[e*s,f*s,a*s,g*s].join(" ")+" 0 0)"};return d.zoomFraction(0)};o.cache=function(e,f){function a(k){l--;f&&f(k);delete d[k.key];if(k.next)k.next.prev=k.prev;else if(n=k.prev)n.next=null;if(k.prev)k.prev.next=k.next;else if(m=k.next)m.prev=null}function g(){for(var k=n;l>s;k=k.prev){if(!k)break;k.lock|| a(k)}}var i={},c={},d={},m=null,n=null,s=64,l=0;i.peek=function(k){return d[[k.zoom,k.column,k.row].join("/")]};i.load=function(k,u){var y=[k.zoom,k.column,k.row].join("/"),w=d[y];if(w){if(w.prev){if(w.prev.next=w.next)w.next.prev=w.prev;else n=w.prev;w.prev=null;w.next=m;m=m.prev=w}w.lock=1;return c[y]=w}w={key:y,column:k.column,row:k.row,zoom:k.zoom,next:m,prev:null,lock:1};e.call(null,w,u);c[y]=d[y]=w;if(m)m.prev=w;else n=w;m=w;l++;g();return w};i.unload=function(k){if(!(k in c))return false;var u= diff --git a/src/Drag.js b/src/Drag.js index 1b49942..71f11dc 100644 --- a/src/Drag.js +++ b/src/Drag.js @@ -2,7 +2,6 @@ po.drag = function() { var drag = {}, map, container, - cursor, dragging; function mousedown(e) { diff --git a/src/start.js b/src/start.js index 5e247db..ea47f3b 100644 --- a/src/start.js +++ b/src/start.js @@ -2,6 +2,6 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+2.3+3"; // This fork not semver! + po.version = "2.0+2.3+4"; // This fork not semver! var zero = {x: 0, y: 0}; From 3de76d6667516dfc581006e0e2e8073edf15d8e8 Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Fri, 3 Sep 2010 14:25:15 -0700 Subject: [PATCH 7/9] Apply the zoom transform after the affine transform. This way, the zoom transform is computed based on the actual zoom level, after the affine transform is applied. --- src/Layer.js | 20 ++++++++++---------- src/start.js | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Layer.js b/src/Layer.js index 4cce03f..20bc260 100644 --- a/src/Layer.js +++ b/src/Layer.js @@ -93,8 +93,17 @@ po.layer = function(load, unload) { tileCenter.row = (Math.round(tileSize.y * tileCenter.row) + (mapSize.y & 1) / 2) / tileSize.y; } + // layer-specific coordinate transform + if (transform) { + c0 = transform.unapply(c0); + c1 = transform.unapply(c1); + c2 = transform.unapply(c2); + c3 = transform.unapply(c3); + tileCenter = transform.unapply(tileCenter); + } + // layer-specific zoom transform - var tileLevel = zoom ? zoom(mapZoom) - mapZoom : 0; + var tileLevel = zoom ? zoom(c0.zoom) - c0.zoom : 0; if (tileLevel) { var k = Math.pow(2, tileLevel); c0.column *= k; c0.row *= k; @@ -104,15 +113,6 @@ po.layer = function(load, unload) { c0.zoom = c1.zoom = c2.zoom = c3.zoom += tileLevel; } - // layer-specific coordinate transform - if (transform) { - c0 = transform.unapply(c0); - c1 = transform.unapply(c1); - c2 = transform.unapply(c2); - c3 = transform.unapply(c3); - tileCenter = transform.unapply(tileCenter); - } - // tile-specific projection function projection(c) { var zoom = c.zoom, diff --git a/src/start.js b/src/start.js index ea47f3b..80e8a16 100644 --- a/src/start.js +++ b/src/start.js @@ -2,6 +2,6 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+2.3+4"; // This fork not semver! + po.version = "2.0+2.3+5"; // This fork not semver! var zero = {x: 0, y: 0}; From 1db5ba59c88118adfbbaebe749e736935cc0626d Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Fri, 3 Sep 2010 14:26:45 -0700 Subject: [PATCH 8/9] Oops forgot to included generated files. --- polymaps.js | 22 ++++++------ polymaps.min.js | 94 ++++++++++++++++++++++++------------------------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/polymaps.js b/polymaps.js index 2e6819b..c9b9d71 100644 --- a/polymaps.js +++ b/polymaps.js @@ -2,7 +2,7 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+2.3+4"; // This fork not semver! + po.version = "2.0+2.3+5"; // This fork not semver! var zero = {x: 0, y: 0}; po.id = (function() { @@ -779,8 +779,17 @@ po.layer = function(load, unload) { tileCenter.row = (Math.round(tileSize.y * tileCenter.row) + (mapSize.y & 1) / 2) / tileSize.y; } + // layer-specific coordinate transform + if (transform) { + c0 = transform.unapply(c0); + c1 = transform.unapply(c1); + c2 = transform.unapply(c2); + c3 = transform.unapply(c3); + tileCenter = transform.unapply(tileCenter); + } + // layer-specific zoom transform - var tileLevel = zoom ? zoom(mapZoom) - mapZoom : 0; + var tileLevel = zoom ? zoom(c0.zoom) - c0.zoom : 0; if (tileLevel) { var k = Math.pow(2, tileLevel); c0.column *= k; c0.row *= k; @@ -790,15 +799,6 @@ po.layer = function(load, unload) { c0.zoom = c1.zoom = c2.zoom = c3.zoom += tileLevel; } - // layer-specific coordinate transform - if (transform) { - c0 = transform.unapply(c0); - c1 = transform.unapply(c1); - c2 = transform.unapply(c2); - c3 = transform.unapply(c3); - tileCenter = transform.unapply(tileCenter); - } - // tile-specific projection function projection(c) { var zoom = c.zoom, diff --git a/polymaps.min.js b/polymaps.min.js index 64049f6..56c8d56 100644 --- a/polymaps.min.js +++ b/polymaps.min.js @@ -1,56 +1,56 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={}; -(function(o){function R(){for(var e=0;ef.row){var a=e;e=f;f=a}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,a,g,i){a=Math.max(a,Math.floor(f.y0));g=Math.min(g,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,g,i,c);f.dy&&ca(e,f,g,i,c)}o.version="2.0+2.3+4";var Y={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, -e)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(e,f,a,g,i,c){var d={},m,n,s;if(!arguments.length){e=1;f=i=a=0;g=1;c=0}d.zoomFraction=function(l){if(!arguments.length)return n;n=l;m=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+g*g))/Math.log(2));s=Math.pow(2,-m);return d};d.apply=function(l){var k=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom-m);return{column:(e*l.column*k+a*l.row*k+i)*u,row:(f*l.column*k+g*l.row*k+c)*u,zoom:l.zoom-m}};d.unapply=function(l){var k= -Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+m);return{column:(l.column*k*g-l.row*k*a-i*g+c*a)/(e*g-f*a)*u,row:(l.column*k*f-l.row*k*e-i*f+c*e)/(a*f-g*e)*u,zoom:l.zoom+m}};d.toString=function(){return"matrix("+[e*s,f*s,a*s,g*s].join(" ")+" 0 0)"};return d.zoomFraction(0)};o.cache=function(e,f){function a(k){l--;f&&f(k);delete d[k.key];if(k.next)k.next.prev=k.prev;else if(n=k.prev)n.next=null;if(k.prev)k.prev.next=k.next;else if(m=k.next)m.prev=null}function g(){for(var k=n;l>s;k=k.prev){if(!k)break;k.lock|| -a(k)}}var i={},c={},d={},m=null,n=null,s=64,l=0;i.peek=function(k){return d[[k.zoom,k.column,k.row].join("/")]};i.load=function(k,u){var y=[k.zoom,k.column,k.row].join("/"),w=d[y];if(w){if(w.prev){if(w.prev.next=w.next)w.next.prev=w.prev;else n=w.prev;w.prev=null;w.next=m;m=m.prev=w}w.lock=1;return c[y]=w}w={key:y,column:k.column,row:k.row,zoom:k.zoom,next:m,prev:null,lock:1};e.call(null,w,u);c[y]=d[y]=w;if(m)m.prev=w;else n=w;m=w;l++;g();return w};i.unload=function(k){if(!(k in c))return false;var u= -c[k];u.lock=0;delete c[k];u.request&&u.request.abort(false)?a(u):g();return u};i.locks=function(){return c};i.size=function(k){if(!arguments.length)return s;s=k;g();return i};return i};o.url=function(e){function f(g){var i=g.zoom<0?1:1<f.row){var a=e;e=f;f=a}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,a,g,i){a=Math.max(a,Math.floor(f.y0));g=Math.min(g,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,g,i,c);f.dy&&ca(e,f,g,i,c)}o.version="2.0+2.3+5";var Y={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, +e)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(e,f,a,g,i,c){var d={},m,n,s;if(!arguments.length){e=1;f=i=a=0;g=1;c=0}d.zoomFraction=function(l){if(!arguments.length)return n;n=l;m=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+g*g))/Math.log(2));s=Math.pow(2,-m);return d};d.apply=function(l){var k=Math.pow(2,-l.zoom),v=Math.pow(2,l.zoom-m);return{column:(e*l.column*k+a*l.row*k+i)*v,row:(f*l.column*k+g*l.row*k+c)*v,zoom:l.zoom-m}};d.unapply=function(l){var k= +Math.pow(2,-l.zoom),v=Math.pow(2,l.zoom+m);return{column:(l.column*k*g-l.row*k*a-i*g+c*a)/(e*g-f*a)*v,row:(l.column*k*f-l.row*k*e-i*f+c*e)/(a*f-g*e)*v,zoom:l.zoom+m}};d.toString=function(){return"matrix("+[e*s,f*s,a*s,g*s].join(" ")+" 0 0)"};return d.zoomFraction(0)};o.cache=function(e,f){function a(k){l--;f&&f(k);delete d[k.key];if(k.next)k.next.prev=k.prev;else if(n=k.prev)n.next=null;if(k.prev)k.prev.next=k.next;else if(m=k.next)m.prev=null}function g(){for(var k=n;l>s;k=k.prev){if(!k)break;k.lock|| +a(k)}}var i={},c={},d={},m=null,n=null,s=64,l=0;i.peek=function(k){return d[[k.zoom,k.column,k.row].join("/")]};i.load=function(k,v){var y=[k.zoom,k.column,k.row].join("/"),x=d[y];if(x){if(x.prev){if(x.prev.next=x.next)x.next.prev=x.prev;else n=x.prev;x.prev=null;x.next=m;m=m.prev=x}x.lock=1;return c[y]=x}x={key:y,column:k.column,row:k.row,zoom:k.zoom,next:m,prev:null,lock:1};e.call(null,x,v);c[y]=d[y]=x;if(m)m.prev=x;else n=x;m=x;l++;g();return x};i.unload=function(k){if(!(k in c))return false;var v= +c[k];v.lock=0;delete c[k];v.request&&v.request.abort(false)?a(v):g();return v};i.locks=function(){return c};i.size=function(k){if(!arguments.length)return s;s=k;g();return i};return i};o.url=function(e){function f(g){var i=g.zoom<0?1:1<=c||!g.length)){i++;g.pop()()}}function f(d){for(var m=0;mu[1])s=u[1];l=s-(s=Math.round(s));k=Math.pow(2,l)}function f(){if(r){var j=45/Math.pow(2,s+l-3),B=Math.max(Math.abs(C*d.x+ -w*d.y),Math.abs(h*d.x+F*d.y)),z=V(v-B*j/m.y);B=V(q+B*j/m.y);n.lat=Math.max(z,Math.min(B,n.lat));z=Math.max(Math.abs(C*d.y+w*d.x),Math.abs(h*d.y+F*d.x));n.lon=Math.max(r[0].lon-z*j/m.x,Math.min(r[1].lon+z*j/m.x,n.lon))}}var a={},g,i,c=Y,d=Y,m={x:256,y:256},n={lat:37.76487,lon:-122.41948},s=12,l=0,k=1,u=[1,18],y=0,w=1,C=0,F=1,h=0,v=-180,q=180,r=[{lat:V(v),lon:-Infinity},{lat:V(q),lon:Infinity}];a.locationCoordinate=function(j){j=o.map.locationCoordinate(j);var B=Math.pow(2,s);j.column*=B;j.row*=B;j.zoom+= -s;return j};a.coordinateLocation=o.map.coordinateLocation;a.coordinatePoint=function(j,B){var z=Math.pow(2,s-B.zoom),E=Math.pow(2,s-j.zoom),A=(B.column*z-j.column*E)*m.x*k;z=(B.row*z-j.row*E)*m.y*k;return{x:d.x+w*A-C*z,y:d.y+C*A+w*z}};a.pointCoordinate=function(j,B){var z=Math.pow(2,s-j.zoom),E=(B.x-d.x)/k,A=(B.y-d.y)/k;return{column:j.column*z+(F*E-h*A)/m.x,row:j.row*z+(h*E+F*A)/m.y,zoom:s}};a.locationPoint=function(j){var B=Math.pow(2,s+l-3)/45,z=(j.lon-n.lon)*B*m.x;j=(W(n.lat)-W(j.lat))*B*m.y; -return{x:d.x+w*z-C*j,y:d.y+C*z+w*j}};a.pointLocation=function(j){var B=45/Math.pow(2,s+l-3),z=(j.x-d.x)*B;j=(j.y-d.y)*B;return{lon:n.lon+(F*z-h*j)/m.x,lat:V(W(n.lat)-(h*z+F*j)/m.y)}};var x=o.svg("rect");x.setAttribute("visibility","hidden");x.setAttribute("pointer-events","all");a.container=function(j){if(!arguments.length)return g;g=j;g.setAttribute("class","map");g.appendChild(x);return a.resize()};a.focusableParent=function(){for(var j=g;j;j=j.parentNode)if(j.tabIndex>=0)return j;return window}; -a.mouse=function(j){var B=(g.ownerSVGElement||g).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var z=document.body.appendChild(o.svg("svg"));z.style.position="absolute";z.style.top=z.style.left="0px";var E=z.getScreenCTM();$=!(E.f||E.e);document.body.removeChild(z)}if($){B.x=j.pageX;B.y=j.pageY}else{B.x=j.clientX;B.y=j.clientY}return B.matrixTransform(g.getScreenCTM().inverse())};a.size=function(j){if(!arguments.length)return c;i=j;return a.resize()};a.resize=function(){if(i){c=i;R.remove(a)}else{var j= -g.ownerSVGElement||g;if(j.offsetWidth==null){x.setAttribute("width","100%");x.setAttribute("height","100%");j=x}b=j.getBoundingClientRect();c={x:b.width,y:b.height};R.add(a)}x.setAttribute("width",c.x);x.setAttribute("height",c.y);d={x:c.x/2,y:c.y/2};f();a.dispatch({type:"resize"});return a};a.tileSize=function(j){if(!arguments.length)return m;m=j;a.dispatch({type:"move"});return a};a.center=function(j){if(!arguments.length)return n;n=j;f();a.dispatch({type:"move"});return a};a.panBy=function(j){var B= -45/Math.pow(2,s+l-3),z=j.x*B;j=j.y*B;return a.center({lon:n.lon+(h*j-F*z)/m.x,lat:V(W(n.lat)+(h*z+F*j)/m.y)})};a.centerRange=function(j){if(!arguments.length)return r;if(r=j){v=r[0].lat>-90?W(r[0].lat):-Infinity;q=r[0].lat<90?W(r[1].lat):Infinity}else{v=-Infinity;q=Infinity}f();a.dispatch({type:"move"});return a};a.zoom=function(j){if(!arguments.length)return s+l;s=j;e();return a.center(n)};a.zoomBy=function(j,B,z){if(arguments.length<2)return a.zoom(s+l+j);if(arguments.length<3)z=a.pointLocation(B); -s=s+l+j;e();var E=a.locationPoint(z);return a.panBy({x:B.x-E.x,y:B.y-E.y})};a.zoomRange=function(j){if(!arguments.length)return u;u=j;return a.zoom(s+l)};a.extent=function(j){if(!arguments.length)return[a.pointLocation({x:0,y:c.y}),a.pointLocation({x:c.x,y:0})];var B=a.locationPoint(j[0]),z=a.locationPoint(j[1]),E=Math.max((z.x-B.x)/c.x,(B.y-z.y)/c.y);B=a.pointLocation({x:(B.x+z.x)/2,y:(B.y+z.y)/2});s=s+l-Math.log(E)/Math.log(2);e();return a.center(B)};a.angle=function(j){if(!arguments.length)return y; -y=j;w=Math.cos(y);C=Math.sin(y);F=Math.cos(-y);h=Math.sin(-y);f();a.dispatch({type:"move"});return a};a.add=function(j){j.map(a);return a};a.remove=function(j){j.map(null);return a};a.dispatch=o.dispatch(a);return a};R.maps=[];R.add=function(e){for(var f=0;fh;w--){u.insertBefore(C[-1],v);u.insertBefore(C[2], -C[-4]);for(var q=C[2],r=2;r>-4;)C[r]=C[--r];C[r]=q}}function i(){function h(M){var H=M.zoom,S=H<0?1:1<>P,row:S>>P,zoom:T-P}))&&N.ready){O[N.key]=d.load(J);N.proxyCount++;G.proxyRefs[N.key]=N;break}}O[G.key]=G}}var q=c.map(),r=q.zoom(),x=r-(r=Math.round(r)),j=q.size(),B=q.angle(),z=q.tileSize(),E=q.locationCoordinate(q.center());n?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden"); -if(w!=r){if(wr)g(r);else w=r;for(var A=-4;A<=2;A++){var L=C[A];L.setAttribute("class","zoom"+(A<0?"":"+")+A+" zoom"+(r+A));L.setAttribute("transform","scale("+Math.pow(2,-A)+")")}}u.setAttribute("transform","translate("+j.x/2+","+j.y/2+")"+(B?"rotate("+B/Math.PI*180+")":"")+(x?"scale("+Math.pow(2,x)+")":"")+(y?y.zoomFraction(x):""));var Q=q.pointCoordinate(E,Y);A=q.pointCoordinate(E,{x:j.x,y:0});L=q.pointCoordinate(E,j);q=q.pointCoordinate(E,{x:0,y:j.y});if(!x&&!B&&!y){E.column= -(Math.round(z.x*E.column)+(j.x&1)/2)/z.x;E.row=(Math.round(z.y*E.row)+(j.y&1)/2)/z.y}var U=s?s(r)-r:0;if(U){x=Math.pow(2,U);Q.column*=x;Q.row*=x;A.column*=x;A.row*=x;L.column*=x;L.row*=x;q.column*=x;q.row*=x;Q.zoom=A.zoom=L.zoom=q.zoom+=U}if(y){Q=y.unapply(Q);A=y.unapply(A);L=y.unapply(L);q=y.unapply(q);E=y.unapply(E)}r=d.locks();var O={};for(var I in r)r[I].proxyCount=0;if(n&&U>-5&&U<3){x=Q.zoom<0?1:1<>A<>A<=1;F--)C[F]=u.appendChild(o.svg("g"));C[0]=u.appendChild(o.svg("g"));c.map=function(h){if(!arguments.length)return k;if(k){if(k==h){u.parentNode.appendChild(u);return c}k.off("move",i).off("resize",i);u.parentNode.removeChild(u)}if(k=h){k.container().appendChild(u);c.init&&c.init(u);k.on("move",i).on("resize",i);i()}return c};c.container=function(){return u}; -c.id=function(h){if(!arguments.length)return l;l=h;return c};c.visible=function(h){if(!arguments.length)return n;n=h;k&&i();return c};c.transform=function(h){if(!arguments.length)return y;y=h;k&&i();return c};c.zoom=function(h){if(!arguments.length)return s;s=typeof h=="function"||h==null?h:function(){return h};return c};c.tile=function(h){if(!arguments.length)return m;m=h;return c};c.dispatch=o.dispatch(c);c.on("load",function(h){if(h.tile.proxyRefs){for(var v in h.tile.proxyRefs){var q=h.tile.proxyRefs[v]; ---q.proxyCount<=0&&d.unload(v)&&q.element.parentNode.removeChild(q.element)}delete h.tile.proxyRefs}});return c};o.image=function(){var e=o.layer(function(a){var g=a.element=o.svg("image"),i=e.map().tileSize();g.setAttribute("preserveAspectRatio","none");g.setAttribute("width",i.x);g.setAttribute("height",i.y);g.setAttribute("opacity",0);if(typeof f=="function")a.request=o.queue.image(g,f(a),function(c){delete a.request;a.ready=true;a.img=c;g.removeAttribute("opacity");e.dispatch({type:"load",tile:a})}); -else{a.ready=true;g.setAttributeNS(o.ns.xlink,"href",f);e.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),f="about:blank";e.url=function(a){if(!arguments.length)return f;f=typeof a=="string"&&/{.}/.test(a)?o.url(a):a;return e};return e};o.geoJson=function(e){function f(h,v){return h&&h.type in C&&C[h.type](h,v)}function a(h,v){var q=v({lat:h[1],lon:h[0]}),r=o.svg("circle");r.setAttribute("r",4.5);r.setAttribute("cx",q.x);r.setAttribute("cy",q.y);return r}function g(h, -v,q,r){r.push("M");for(var x=0;xv[1])s=v[1];l=s-(s=Math.round(s));k=Math.pow(2,l)}function f(){if(q){var j=45/Math.pow(2,s+l-3),r=Math.max(Math.abs(C*d.x+ +x*d.y),Math.abs(h*d.x+F*d.y)),z=U(w-r*j/m.y);r=U(t+r*j/m.y);n.lat=Math.max(z,Math.min(r,n.lat));z=Math.max(Math.abs(C*d.y+x*d.x),Math.abs(h*d.y+F*d.x));n.lon=Math.max(q[0].lon-z*j/m.x,Math.min(q[1].lon+z*j/m.x,n.lon))}}var a={},g,i,c=Y,d=Y,m={x:256,y:256},n={lat:37.76487,lon:-122.41948},s=12,l=0,k=1,v=[1,18],y=0,x=1,C=0,F=1,h=0,w=-180,t=180,q=[{lat:U(w),lon:-Infinity},{lat:U(t),lon:Infinity}];a.locationCoordinate=function(j){j=o.map.locationCoordinate(j);var r=Math.pow(2,s);j.column*=r;j.row*=r;j.zoom+= +s;return j};a.coordinateLocation=o.map.coordinateLocation;a.coordinatePoint=function(j,r){var z=Math.pow(2,s-r.zoom),E=Math.pow(2,s-j.zoom),A=(r.column*z-j.column*E)*m.x*k;z=(r.row*z-j.row*E)*m.y*k;return{x:d.x+x*A-C*z,y:d.y+C*A+x*z}};a.pointCoordinate=function(j,r){var z=Math.pow(2,s-j.zoom),E=(r.x-d.x)/k,A=(r.y-d.y)/k;return{column:j.column*z+(F*E-h*A)/m.x,row:j.row*z+(h*E+F*A)/m.y,zoom:s}};a.locationPoint=function(j){var r=Math.pow(2,s+l-3)/45,z=(j.lon-n.lon)*r*m.x;j=(V(n.lat)-V(j.lat))*r*m.y; +return{x:d.x+x*z-C*j,y:d.y+C*z+x*j}};a.pointLocation=function(j){var r=45/Math.pow(2,s+l-3),z=(j.x-d.x)*r;j=(j.y-d.y)*r;return{lon:n.lon+(F*z-h*j)/m.x,lat:U(V(n.lat)-(h*z+F*j)/m.y)}};var B=o.svg("rect");B.setAttribute("visibility","hidden");B.setAttribute("pointer-events","all");a.container=function(j){if(!arguments.length)return g;g=j;g.setAttribute("class","map");g.appendChild(B);return a.resize()};a.focusableParent=function(){for(var j=g;j;j=j.parentNode)if(j.tabIndex>=0)return j;return window}; +a.mouse=function(j){var r=(g.ownerSVGElement||g).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var z=document.body.appendChild(o.svg("svg"));z.style.position="absolute";z.style.top=z.style.left="0px";var E=z.getScreenCTM();$=!(E.f||E.e);document.body.removeChild(z)}if($){r.x=j.pageX;r.y=j.pageY}else{r.x=j.clientX;r.y=j.clientY}return r.matrixTransform(g.getScreenCTM().inverse())};a.size=function(j){if(!arguments.length)return c;i=j;return a.resize()};a.resize=function(){if(i){c=i;Q.remove(a)}else{var j= +g.ownerSVGElement||g;if(j.offsetWidth==null){B.setAttribute("width","100%");B.setAttribute("height","100%");j=B}b=j.getBoundingClientRect();c={x:b.width,y:b.height};Q.add(a)}B.setAttribute("width",c.x);B.setAttribute("height",c.y);d={x:c.x/2,y:c.y/2};f();a.dispatch({type:"resize"});return a};a.tileSize=function(j){if(!arguments.length)return m;m=j;a.dispatch({type:"move"});return a};a.center=function(j){if(!arguments.length)return n;n=j;f();a.dispatch({type:"move"});return a};a.panBy=function(j){var r= +45/Math.pow(2,s+l-3),z=j.x*r;j=j.y*r;return a.center({lon:n.lon+(h*j-F*z)/m.x,lat:U(V(n.lat)+(h*z+F*j)/m.y)})};a.centerRange=function(j){if(!arguments.length)return q;if(q=j){w=q[0].lat>-90?V(q[0].lat):-Infinity;t=q[0].lat<90?V(q[1].lat):Infinity}else{w=-Infinity;t=Infinity}f();a.dispatch({type:"move"});return a};a.zoom=function(j){if(!arguments.length)return s+l;s=j;e();return a.center(n)};a.zoomBy=function(j,r,z){if(arguments.length<2)return a.zoom(s+l+j);if(arguments.length<3)z=a.pointLocation(r); +s=s+l+j;e();var E=a.locationPoint(z);return a.panBy({x:r.x-E.x,y:r.y-E.y})};a.zoomRange=function(j){if(!arguments.length)return v;v=j;return a.zoom(s+l)};a.extent=function(j){if(!arguments.length)return[a.pointLocation({x:0,y:c.y}),a.pointLocation({x:c.x,y:0})];var r=a.locationPoint(j[0]),z=a.locationPoint(j[1]),E=Math.max((z.x-r.x)/c.x,(r.y-z.y)/c.y);r=a.pointLocation({x:(r.x+z.x)/2,y:(r.y+z.y)/2});s=s+l-Math.log(E)/Math.log(2);e();return a.center(r)};a.angle=function(j){if(!arguments.length)return y; +y=j;x=Math.cos(y);C=Math.sin(y);F=Math.cos(-y);h=Math.sin(-y);f();a.dispatch({type:"move"});return a};a.add=function(j){j.map(a);return a};a.remove=function(j){j.map(null);return a};a.dispatch=o.dispatch(a);return a};Q.maps=[];Q.add=function(e){for(var f=0;fh;x--){v.insertBefore(C[-1],w);v.insertBefore(C[2], +C[-4]);for(var t=C[2],q=2;q>-4;)C[q]=C[--q];C[q]=t}}function i(){function h(L){var H=L.zoom,R=H<0?1:1<>P,row:R>>P,zoom:S-P}))&&M.ready){N[M.key]=d.load(J);M.proxyCount++;G.proxyRefs[M.key]=M;break}}N[G.key]=G}}var t=c.map(),q=t.zoom(),B=q-(q=Math.round(q)),j=t.size(),r=t.angle(),z=t.tileSize(),E=t.locationCoordinate(t.center());n?v.removeAttribute("visibility"):v.setAttribute("visibility","hidden"); +if(x!=q){if(xq)g(q);else x=q;for(var A=-4;A<=2;A++){var X=C[A];X.setAttribute("class","zoom"+(A<0?"":"+")+A+" zoom"+(q+A));X.setAttribute("transform","scale("+Math.pow(2,-A)+")")}}v.setAttribute("transform","translate("+j.x/2+","+j.y/2+")"+(r?"rotate("+r/Math.PI*180+")":"")+(B?"scale("+Math.pow(2,B)+")":"")+(y?y.zoomFraction(B):""));var O=t.pointCoordinate(E,Y);A=t.pointCoordinate(E,{x:j.x,y:0});q=t.pointCoordinate(E,j);t=t.pointCoordinate(E,{x:0,y:j.y});if(!B&&!r&&!y){E.column= +(Math.round(z.x*E.column)+(j.x&1)/2)/z.x;E.row=(Math.round(z.y*E.row)+(j.y&1)/2)/z.y}if(y){O=y.unapply(O);A=y.unapply(A);q=y.unapply(q);t=y.unapply(t);E=y.unapply(E)}var T=s?s(O.zoom)-O.zoom:0;if(T){r=Math.pow(2,T);O.column*=r;O.row*=r;A.column*=r;A.row*=r;q.column*=r;q.row*=r;t.column*=r;t.row*=r;O.zoom=A.zoom=q.zoom=t.zoom+=T}B=d.locks();var N={};for(var I in B)B[I].proxyCount=0;if(n&&T>-5&&T<3){r=O.zoom<0?1:1<>A<>A<=1;F--)C[F]=v.appendChild(o.svg("g"));C[0]=v.appendChild(o.svg("g"));c.map=function(h){if(!arguments.length)return k;if(k){if(k==h){v.parentNode.appendChild(v);return c}k.off("move",i).off("resize",i);v.parentNode.removeChild(v)}if(k=h){k.container().appendChild(v);c.init&&c.init(v);k.on("move",i).on("resize",i);i()}return c};c.container= +function(){return v};c.id=function(h){if(!arguments.length)return l;l=h;return c};c.visible=function(h){if(!arguments.length)return n;n=h;k&&i();return c};c.transform=function(h){if(!arguments.length)return y;y=h;k&&i();return c};c.zoom=function(h){if(!arguments.length)return s;s=typeof h=="function"||h==null?h:function(){return h};return c};c.tile=function(h){if(!arguments.length)return m;m=h;return c};c.dispatch=o.dispatch(c);c.on("load",function(h){if(h.tile.proxyRefs){for(var w in h.tile.proxyRefs){var t= +h.tile.proxyRefs[w];--t.proxyCount<=0&&d.unload(w)&&t.element.parentNode.removeChild(t.element)}delete h.tile.proxyRefs}});return c};o.image=function(){var e=o.layer(function(a){var g=a.element=o.svg("image"),i=e.map().tileSize();g.setAttribute("preserveAspectRatio","none");g.setAttribute("width",i.x);g.setAttribute("height",i.y);g.setAttribute("opacity",0);if(typeof f=="function")a.request=o.queue.image(g,f(a),function(c){delete a.request;a.ready=true;a.img=c;g.removeAttribute("opacity");e.dispatch({type:"load", +tile:a})});else{a.ready=true;g.setAttributeNS(o.ns.xlink,"href",f);e.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),f="about:blank";e.url=function(a){if(!arguments.length)return f;f=typeof a=="string"&&/{.}/.test(a)?o.url(a):a;return e};return e};o.geoJson=function(e){function f(h,w){return h&&h.type in C&&C[h.type](h,w)}function a(h,w){var t=w({lat:h[1],lon:h[0]}),q=o.svg("circle");q.setAttribute("r",4.5);q.setAttribute("cx",t.x);q.setAttribute("cy",t.y);return q} +function g(h,w,t,q){q.push("M");for(var B=0;B9&&Math.abs(l.wheelDelta)/w>=50)ba=1;i=y}if(ba==1)k*=0.03;m||(m=n.pointLocation(u));n.off("move",e);if(c)d==="mouse"?n.zoomBy(k,u,m):n.zoomBy(k);else if(k){y=Date.now();if(y-g>200){k=k>0?+1:-1;d==="mouse"?n.zoomBy(k,u,m):n.zoomBy(k);g=y}}n.on("move",e);l.preventDefault();return false}var a= +c=null;document.body.style.removeProperty("cursor")}},false);return a};o.wheel=function(){function e(){m=null}function f(l){var k=(l.wheelDelta/120||-l.detail)*0.1,v=n.mouse(l);if(ba<0){var y=Date.now(),x=y-i;if(x>9&&Math.abs(l.wheelDelta)/x>=50)ba=1;i=y}if(ba==1)k*=0.03;m||(m=n.pointLocation(v));n.off("move",e);if(c)d==="mouse"?n.zoomBy(k,v,m):n.zoomBy(k);else if(k){y=Date.now();if(y-g>200){k=k>0?+1:-1;d==="mouse"?n.zoomBy(k,v,m):n.zoomBy(k);g=y}}n.on("move",e);l.preventDefault();return false}var a= {},g=0,i=0,c=true,d="mouse",m,n,s;a.smooth=function(l){if(!arguments.length)return c;c=l;return a};a.zoom=function(l){if(!arguments.length)return d;d=l;return a};a.map=function(l){if(!arguments.length)return n;if(n){s.removeEventListener("mousemove",e,false);s.removeEventListener("mousewheel",f,false);s.removeEventListener("DOMMouseScroll",f,false);s=null;n.off("move",e)}if(n=l){n.on("move",e);s=n.container();s.addEventListener("mousemove",e,false);s.addEventListener("mousewheel",f,false);s.addEventListener("DOMMouseScroll", -f,false)}return a};return a};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;o.arrow=function(){function e(y){if(!(y.ctrlKey||y.altKey||y.metaKey)){var w=Date.now(),C=0,F=0;switch(y.keyCode){case 37:if(!c.left){d=w;c.left=1;c.right||(C=l)}break;case 39:if(!c.right){d=w;c.right=1;c.left||(C=-l)}break;case 38:if(!c.up){d=w;c.up=1;c.down||(F=l)}break;case 40:if(!c.down){d=w;c.down=1;c.up||(F=-l)}break;default:return}if(C||F)k.panBy({x:C,y:F});if(!m&&c.left|c.right|c.up|c.down)m=setInterval(g,s); -y.preventDefault()}}function f(y){d=Date.now();switch(y.keyCode){case 37:c.left=0;break;case 39:c.right=0;break;case 38:c.up=0;break;case 40:c.down=0;break;default:return}if(m&&!(c.left|c.right|c.up|c.down))m=clearInterval(m);y.preventDefault()}function a(y){switch(y.charCode){case 45:case 95:k.zoom(Math.ceil(k.zoom())-1);break;case 43:case 61:k.zoom(Math.floor(k.zoom())+1);break;default:return}y.preventDefault()}function g(){if(k)if(!(Date.now() -x+j&&H.panBy(U)}function a(t){if(t.shiftKey){I={x0:H.mouse(t)};H.focusableParent().focus();return l(t)}}function g(t){if(I){I.x1=H.mouse(t);M.setAttribute("x",Math.min(I.x0.x,I.x1.x));M.setAttribute("y",Math.min(I.x0.y,I.x1.y));M.setAttribute("width",Math.abs(I.x0.x-I.x1.x));M.setAttribute("height",Math.abs(I.x0.y-I.x1.y));M.removeAttribute("display")}}function i(){h.setAttribute("class","compass");if(I){if(I.x1){H.extent([H.pointLocation({x:Math.min(I.x0.x,I.x1.x),y:Math.max(I.x0.y,I.x1.y)}),H.pointLocation({x:Math.max(I.x0.x, -I.x1.x),y:Math.min(I.x0.y,I.x1.y)})]);M.setAttribute("display","none")}I=null}if(Q){clearInterval(Q);Q=0}}function c(t){return function(){t?this.setAttribute("class","active"):this.removeAttribute("class");U=t}}function d(t){return function(D){h.setAttribute("class","compass active");var G=H.zoom();H.zoom(t<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function m(t){return function(D){H.zoom(t);return l(D)}}function n(){this.setAttribute("class","active")}function s(){this.removeAttribute("class")} -function l(t){t.stopPropagation();t.preventDefault();return false}function k(t){var D=Math.SQRT1_2*q,G=q*0.7,J=q*0.2,K=o.svg("g"),N=K.appendChild(o.svg("path")),P=K.appendChild(o.svg("path"));N.setAttribute("class","direction");N.setAttribute("pointer-events","all");N.setAttribute("d","M0,0L"+D+","+D+"A"+q+","+q+" 0 0,1 "+-D+","+D+"Z");P.setAttribute("class","chevron");P.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));P.setAttribute("pointer-events","none");K.addEventListener("mousedown", -e,false);K.addEventListener("mouseover",c(t),false);K.addEventListener("mouseout",c(null),false);K.addEventListener("dblclick",l,false);return K}function u(t){var D=q*0.4,G=D/2,J=o.svg("g"),K=J.appendChild(o.svg("path")),N=J.appendChild(o.svg("path")),P=J.appendChild(o.svg("path")),X=J.appendChild(o.svg("path"));K.setAttribute("class","back");K.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");N.setAttribute("class","direction");N.setAttribute("d",K.getAttribute("d"));P.setAttribute("class", -"chevron");P.setAttribute("d","M"+-G+","+-D+"H"+G+(t>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",K.getAttribute("d"));J.addEventListener("mousedown",d(t),false);J.addEventListener("mouseover",n,false);J.addEventListener("mouseout",s,false);J.addEventListener("dblclick",l,false);return J}function y(t){var D=q*0.2,G=q*0.4,J=o.svg("g"),K=J.appendChild(o.svg("rect")),N=J.appendChild(o.svg("path"));K.setAttribute("pointer-events","all");K.setAttribute("fill", -"none");K.setAttribute("x",-G);K.setAttribute("y",-0.75*G);K.setAttribute("width",2*G);K.setAttribute("height",1.5*G);N.setAttribute("class","chevron");N.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",m(t),false);J.addEventListener("dblclick",l,false);return J}function w(){var t=q+6,D=t,G=H.size();switch(z){case "top-left":break;case "top-right":t=G.x-t;break;case "bottom-left":D=G.y-D;break;case "bottom-right":t=G.x-t;D=G.y-D;break}t="translate("+t+","+D+")";O&&O.setAttribute("transform", -t);A&&A.setAttribute("transform",t);for(var J in v)J==H.zoom()?v[J].setAttribute("class","active"):v[J].removeAttribute("class")}function C(){for(;h.lastChild;)h.removeChild(h.lastChild);h.appendChild(M);if(L!="none"){O=h.appendChild(o.svg("g"));O.setAttribute("class","pan");var t=O.appendChild(o.svg("circle"));t.setAttribute("class","back");t.setAttribute("r",q);O.appendChild(k({x:0,y:-r})).setAttribute("transform","rotate(0)");O.appendChild(k({x:r,y:0})).setAttribute("transform","rotate(90)");O.appendChild(k({x:0, -y:r})).setAttribute("transform","rotate(180)");O.appendChild(k({x:-r,y:0})).setAttribute("transform","rotate(270)");t=O.appendChild(o.svg("circle"));t.setAttribute("fill","none");t.setAttribute("class","fore");t.setAttribute("r",q)}else O=null;if(E!="none"){A=h.appendChild(o.svg("g"));A.setAttribute("class","zoom");t=-0.5;if(E=="big"){v={};var D=H.zoomRange()[0];for(t=0;D<=H.zoomRange()[1];D++,t++)(v[D]=A.appendChild(y(D))).setAttribute("transform","translate(0,"+-(t+0.75)*q*0.4+")")}D=L=="none"? -0.4:2;A.setAttribute("transform","translate(0,"+q*(/^top-/.test(z)?D+(t+0.5)*0.4:-D)+")");A.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(t+0.5)*q*0.4+")");A.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else A=null;w()}var F={},h=o.svg("g"),v={},q=30,r=16,x=0,j=250,B=50,z="top-left",E="small",A,L="small",Q,U,O,I,M=o.svg("rect"),H,S,T;h.setAttribute("class","compass");M.setAttribute("class","back fore");M.setAttribute("pointer-events","none");M.setAttribute("display","none"); -F.radius=function(t){if(!arguments.length)return q;q=t;H&&C();return F};F.speed=function(t){if(!arguments.length)return q;r=t;return F};F.position=function(t){if(!arguments.length)return z;z=t;H&&C();return F};F.pan=function(t){if(!arguments.length)return L;L=t;H&&C();return F};F.zoom=function(t){if(!arguments.length)return E;E=t;H&&C();return F};F.map=function(t){if(!arguments.length)return H;if(H){S.removeEventListener("mousedown",a,false);S.removeChild(h);S=null;T.removeEventListener("mousemove", -g,false);T.removeEventListener("mouseup",i,false);T=null;H.off("move",w).off("resize",w)}if(H=t){S=H.container();S.appendChild(h);S.addEventListener("mousedown",a,false);T=S.ownerDocument.defaultView;T.addEventListener("mousemove",g,false);T.addEventListener("mouseup",i,false);H.on("move",w).on("resize",w);C()}return F};return F};o.grid=function(){function e(){var i=g.firstChild,c=a.size(),d=a.pointLocation(Y);a.pointLocation(c);var m=Math.pow(2,4-Math.round(a.zoom()));d.lat=Math.floor(d.lat/m)*m; +if(c){c.off("move",e);window.removeEventListener("hashchange",f,false)}if(c=d){c.on("move",e);window.addEventListener("hashchange",f,false);location.hash?f():e()}return a};return a};o.interact=function(){var e={},f=o.drag(),a=o.wheel(),g=o.dblclick(),i=o.arrow();e.map=function(c){f.map(c);a.map(c);g.map(c);i.map(c);return e};return e};o.compass=function(){function e(u){h.setAttribute("class","compass active");O||(O=setInterval(f,r));T&&H.panBy(T);B=Date.now();return l(u)}function f(){T&&Date.now()> +B+j&&H.panBy(T)}function a(u){if(u.shiftKey){I={x0:H.mouse(u)};H.focusableParent().focus();return l(u)}}function g(u){if(I){I.x1=H.mouse(u);L.setAttribute("x",Math.min(I.x0.x,I.x1.x));L.setAttribute("y",Math.min(I.x0.y,I.x1.y));L.setAttribute("width",Math.abs(I.x0.x-I.x1.x));L.setAttribute("height",Math.abs(I.x0.y-I.x1.y));L.removeAttribute("display")}}function i(){h.setAttribute("class","compass");if(I){if(I.x1){H.extent([H.pointLocation({x:Math.min(I.x0.x,I.x1.x),y:Math.max(I.x0.y,I.x1.y)}),H.pointLocation({x:Math.max(I.x0.x, +I.x1.x),y:Math.min(I.x0.y,I.x1.y)})]);L.setAttribute("display","none")}I=null}if(O){clearInterval(O);O=0}}function c(u){return function(){u?this.setAttribute("class","active"):this.removeAttribute("class");T=u}}function d(u){return function(D){h.setAttribute("class","compass active");var G=H.zoom();H.zoom(u<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function m(u){return function(D){H.zoom(u);return l(D)}}function n(){this.setAttribute("class","active")}function s(){this.removeAttribute("class")} +function l(u){u.stopPropagation();u.preventDefault();return false}function k(u){var D=Math.SQRT1_2*t,G=t*0.7,J=t*0.2,K=o.svg("g"),M=K.appendChild(o.svg("path")),P=K.appendChild(o.svg("path"));M.setAttribute("class","direction");M.setAttribute("pointer-events","all");M.setAttribute("d","M0,0L"+D+","+D+"A"+t+","+t+" 0 0,1 "+-D+","+D+"Z");P.setAttribute("class","chevron");P.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));P.setAttribute("pointer-events","none");K.addEventListener("mousedown", +e,false);K.addEventListener("mouseover",c(u),false);K.addEventListener("mouseout",c(null),false);K.addEventListener("dblclick",l,false);return K}function v(u){var D=t*0.4,G=D/2,J=o.svg("g"),K=J.appendChild(o.svg("path")),M=J.appendChild(o.svg("path")),P=J.appendChild(o.svg("path")),W=J.appendChild(o.svg("path"));K.setAttribute("class","back");K.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");M.setAttribute("class","direction");M.setAttribute("d",K.getAttribute("d"));P.setAttribute("class", +"chevron");P.setAttribute("d","M"+-G+","+-D+"H"+G+(u>0?"M0,"+(-D-G)+"V"+-G:""));W.setAttribute("class","fore");W.setAttribute("fill","none");W.setAttribute("d",K.getAttribute("d"));J.addEventListener("mousedown",d(u),false);J.addEventListener("mouseover",n,false);J.addEventListener("mouseout",s,false);J.addEventListener("dblclick",l,false);return J}function y(u){var D=t*0.2,G=t*0.4,J=o.svg("g"),K=J.appendChild(o.svg("rect")),M=J.appendChild(o.svg("path"));K.setAttribute("pointer-events","all");K.setAttribute("fill", +"none");K.setAttribute("x",-G);K.setAttribute("y",-0.75*G);K.setAttribute("width",2*G);K.setAttribute("height",1.5*G);M.setAttribute("class","chevron");M.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",m(u),false);J.addEventListener("dblclick",l,false);return J}function x(){var u=t+6,D=u,G=H.size();switch(z){case "top-left":break;case "top-right":u=G.x-u;break;case "bottom-left":D=G.y-D;break;case "bottom-right":u=G.x-u;D=G.y-D;break}u="translate("+u+","+D+")";N&&N.setAttribute("transform", +u);A&&A.setAttribute("transform",u);for(var J in w)J==H.zoom()?w[J].setAttribute("class","active"):w[J].removeAttribute("class")}function C(){for(;h.lastChild;)h.removeChild(h.lastChild);h.appendChild(L);if(X!="none"){N=h.appendChild(o.svg("g"));N.setAttribute("class","pan");var u=N.appendChild(o.svg("circle"));u.setAttribute("class","back");u.setAttribute("r",t);N.appendChild(k({x:0,y:-q})).setAttribute("transform","rotate(0)");N.appendChild(k({x:q,y:0})).setAttribute("transform","rotate(90)");N.appendChild(k({x:0, +y:q})).setAttribute("transform","rotate(180)");N.appendChild(k({x:-q,y:0})).setAttribute("transform","rotate(270)");u=N.appendChild(o.svg("circle"));u.setAttribute("fill","none");u.setAttribute("class","fore");u.setAttribute("r",t)}else N=null;if(E!="none"){A=h.appendChild(o.svg("g"));A.setAttribute("class","zoom");u=-0.5;if(E=="big"){w={};var D=H.zoomRange()[0];for(u=0;D<=H.zoomRange()[1];D++,u++)(w[D]=A.appendChild(y(D))).setAttribute("transform","translate(0,"+-(u+0.75)*t*0.4+")")}D=X=="none"? +0.4:2;A.setAttribute("transform","translate(0,"+t*(/^top-/.test(z)?D+(u+0.5)*0.4:-D)+")");A.appendChild(v(+1)).setAttribute("transform","translate(0,"+-(u+0.5)*t*0.4+")");A.appendChild(v(-1)).setAttribute("transform","scale(-1)")}else A=null;x()}var F={},h=o.svg("g"),w={},t=30,q=16,B=0,j=250,r=50,z="top-left",E="small",A,X="small",O,T,N,I,L=o.svg("rect"),H,R,S;h.setAttribute("class","compass");L.setAttribute("class","back fore");L.setAttribute("pointer-events","none");L.setAttribute("display","none"); +F.radius=function(u){if(!arguments.length)return t;t=u;H&&C();return F};F.speed=function(u){if(!arguments.length)return t;q=u;return F};F.position=function(u){if(!arguments.length)return z;z=u;H&&C();return F};F.pan=function(u){if(!arguments.length)return X;X=u;H&&C();return F};F.zoom=function(u){if(!arguments.length)return E;E=u;H&&C();return F};F.map=function(u){if(!arguments.length)return H;if(H){R.removeEventListener("mousedown",a,false);R.removeChild(h);R=null;S.removeEventListener("mousemove", +g,false);S.removeEventListener("mouseup",i,false);S=null;H.off("move",x).off("resize",x)}if(H=u){R=H.container();R.appendChild(h);R.addEventListener("mousedown",a,false);S=R.ownerDocument.defaultView;S.addEventListener("mousemove",g,false);S.addEventListener("mouseup",i,false);H.on("move",x).on("resize",x);C()}return F};return F};o.grid=function(){function e(){var i=g.firstChild,c=a.size(),d=a.pointLocation(Y);a.pointLocation(c);var m=Math.pow(2,4-Math.round(a.zoom()));d.lat=Math.floor(d.lat/m)*m; d.lon=Math.ceil(d.lon/m)*m;for(var n;(n=a.locationPoint(d).x)<=c.x;d.lon+=m){i||(i=g.appendChild(o.svg("line")));i.setAttribute("x1",n);i.setAttribute("x2",n);i.setAttribute("y1",0);i.setAttribute("y2",c.y);i=i.nextSibling}for(;(n=a.locationPoint(d).y)<=c.y;d.lat-=m){i||(i=g.appendChild(o.svg("line")));i.setAttribute("y1",n);i.setAttribute("y2",n);i.setAttribute("x1",0);i.setAttribute("x2",c.x);i=i.nextSibling}for(;i;){c=i.nextSibling;g.removeChild(i);i=c}}var f={},a,g=o.svg("g");g.setAttribute("class", "grid");f.map=function(i){if(!arguments.length)return a;if(a){g.parentNode.removeChild(g);a.off("move",e).off("resize",e)}if(a=i){a.on("move",e).on("resize",e);a.container().appendChild(g);a.dispatch({type:"move"})}return f};return f}})(org.polymaps); From ac2f94a694adcf442151ac5c31c245b0ae4af4bc Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Tue, 7 Sep 2010 11:16:39 -0700 Subject: [PATCH 9/9] Fix a bug in previous commit re. layer ID. --- polymaps.js | 12 ++++------ polymaps.min.js | 64 ++++++++++++++++++++++++------------------------- src/Layer.js | 10 ++++---- src/start.js | 2 +- 4 files changed, 42 insertions(+), 46 deletions(-) diff --git a/polymaps.js b/polymaps.js index c9b9d71..4850947 100644 --- a/polymaps.js +++ b/polymaps.js @@ -2,7 +2,7 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+2.3+5"; // This fork not semver! + po.version = "2.0+2.3+6"; // This fork not semver! var zero = {x: 0, y: 0}; po.id = (function() { @@ -743,11 +743,6 @@ po.layer = function(load, unload) { tileSize = map.tileSize(), tileCenter = map.locationCoordinate(map.center()); - // set the layer visibility - visible - ? container.removeAttribute("visibility") - : container.setAttribute("visibility", "hidden"); - // set the layer zoom levels if (levelZoom != mapZoom) { if (levelZoom < mapZoom) zoomIn(mapZoom); @@ -965,12 +960,15 @@ po.layer = function(load, unload) { layer.id = function(x) { if (!arguments.length) return id; id = x; + container.setAttribute("id", x); return layer; }; layer.visible = function(x) { if (!arguments.length) return visible; - visible = x; + visible = x + ? container.removeAttribute("visibility") + : container.setAttribute("visibility", "hidden"); if (map) move(); return layer; }; diff --git a/polymaps.min.js b/polymaps.min.js index 56c8d56..e6ec0fa 100644 --- a/polymaps.min.js +++ b/polymaps.min.js @@ -1,56 +1,56 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={}; (function(o){function Q(){for(var e=0;ef.row){var a=e;e=f;f=a}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,a,g,i){a=Math.max(a,Math.floor(f.y0));g=Math.min(g,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,g,i,c);f.dy&&ca(e,f,g,i,c)}o.version="2.0+2.3+5";var Y={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, -e)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(e,f,a,g,i,c){var d={},m,n,s;if(!arguments.length){e=1;f=i=a=0;g=1;c=0}d.zoomFraction=function(l){if(!arguments.length)return n;n=l;m=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+g*g))/Math.log(2));s=Math.pow(2,-m);return d};d.apply=function(l){var k=Math.pow(2,-l.zoom),v=Math.pow(2,l.zoom-m);return{column:(e*l.column*k+a*l.row*k+i)*v,row:(f*l.column*k+g*l.row*k+c)*v,zoom:l.zoom-m}};d.unapply=function(l){var k= -Math.pow(2,-l.zoom),v=Math.pow(2,l.zoom+m);return{column:(l.column*k*g-l.row*k*a-i*g+c*a)/(e*g-f*a)*v,row:(l.column*k*f-l.row*k*e-i*f+c*e)/(a*f-g*e)*v,zoom:l.zoom+m}};d.toString=function(){return"matrix("+[e*s,f*s,a*s,g*s].join(" ")+" 0 0)"};return d.zoomFraction(0)};o.cache=function(e,f){function a(k){l--;f&&f(k);delete d[k.key];if(k.next)k.next.prev=k.prev;else if(n=k.prev)n.next=null;if(k.prev)k.prev.next=k.next;else if(m=k.next)m.prev=null}function g(){for(var k=n;l>s;k=k.prev){if(!k)break;k.lock|| -a(k)}}var i={},c={},d={},m=null,n=null,s=64,l=0;i.peek=function(k){return d[[k.zoom,k.column,k.row].join("/")]};i.load=function(k,v){var y=[k.zoom,k.column,k.row].join("/"),x=d[y];if(x){if(x.prev){if(x.prev.next=x.next)x.next.prev=x.prev;else n=x.prev;x.prev=null;x.next=m;m=m.prev=x}x.lock=1;return c[y]=x}x={key:y,column:k.column,row:k.row,zoom:k.zoom,next:m,prev:null,lock:1};e.call(null,x,v);c[y]=d[y]=x;if(m)m.prev=x;else n=x;m=x;l++;g();return x};i.unload=function(k){if(!(k in c))return false;var v= -c[k];v.lock=0;delete c[k];v.request&&v.request.abort(false)?a(v):g();return v};i.locks=function(){return c};i.size=function(k){if(!arguments.length)return s;s=k;g();return i};return i};o.url=function(e){function f(g){var i=g.zoom<0?1:1<0,n=f.dx<0;for(a=a;af.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,g,i,c);f.dy&&ca(e,f,g,i,c)}o.version="2.0+2.3+6";var Y={x:0,y:0};o.id=function(){var e=0;return function(){return++e}}();o.svg=function(e){return document.createElementNS(o.ns.svg, +e)};o.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};o.transform=function(e,f,a,g,i,c){var d={},m,n,s;if(!arguments.length){e=1;f=i=a=0;g=1;c=0}d.zoomFraction=function(l){if(!arguments.length)return n;n=l;m=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+g*g))/Math.log(2));s=Math.pow(2,-m);return d};d.apply=function(l){var k=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom-m);return{column:(e*l.column*k+a*l.row*k+i)*u,row:(f*l.column*k+g*l.row*k+c)*u,zoom:l.zoom-m}};d.unapply=function(l){var k= +Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+m);return{column:(l.column*k*g-l.row*k*a-i*g+c*a)/(e*g-f*a)*u,row:(l.column*k*f-l.row*k*e-i*f+c*e)/(a*f-g*e)*u,zoom:l.zoom+m}};d.toString=function(){return"matrix("+[e*s,f*s,a*s,g*s].join(" ")+" 0 0)"};return d.zoomFraction(0)};o.cache=function(e,f){function a(k){l--;f&&f(k);delete d[k.key];if(k.next)k.next.prev=k.prev;else if(n=k.prev)n.next=null;if(k.prev)k.prev.next=k.next;else if(m=k.next)m.prev=null}function g(){for(var k=n;l>s;k=k.prev){if(!k)break;k.lock|| +a(k)}}var i={},c={},d={},m=null,n=null,s=64,l=0;i.peek=function(k){return d[[k.zoom,k.column,k.row].join("/")]};i.load=function(k,u){var y=[k.zoom,k.column,k.row].join("/"),x=d[y];if(x){if(x.prev){if(x.prev.next=x.next)x.next.prev=x.prev;else n=x.prev;x.prev=null;x.next=m;m=m.prev=x}x.lock=1;return c[y]=x}x={key:y,column:k.column,row:k.row,zoom:k.zoom,next:m,prev:null,lock:1};e.call(null,x,u);c[y]=d[y]=x;if(m)m.prev=x;else n=x;m=x;l++;g();return x};i.unload=function(k){if(!(k in c))return false;var u= +c[k];u.lock=0;delete c[k];u.request&&u.request.abort(false)?a(u):g();return u};i.locks=function(){return c};i.size=function(k){if(!arguments.length)return s;s=k;g();return i};return i};o.url=function(e){function f(g){var i=g.zoom<0?1:1<=c||!g.length)){i++;g.pop()()}}function f(d){for(var m=0;mv[1])s=v[1];l=s-(s=Math.round(s));k=Math.pow(2,l)}function f(){if(q){var j=45/Math.pow(2,s+l-3),r=Math.max(Math.abs(C*d.x+ -x*d.y),Math.abs(h*d.x+F*d.y)),z=U(w-r*j/m.y);r=U(t+r*j/m.y);n.lat=Math.max(z,Math.min(r,n.lat));z=Math.max(Math.abs(C*d.y+x*d.x),Math.abs(h*d.y+F*d.x));n.lon=Math.max(q[0].lon-z*j/m.x,Math.min(q[1].lon+z*j/m.x,n.lon))}}var a={},g,i,c=Y,d=Y,m={x:256,y:256},n={lat:37.76487,lon:-122.41948},s=12,l=0,k=1,v=[1,18],y=0,x=1,C=0,F=1,h=0,w=-180,t=180,q=[{lat:U(w),lon:-Infinity},{lat:U(t),lon:Infinity}];a.locationCoordinate=function(j){j=o.map.locationCoordinate(j);var r=Math.pow(2,s);j.column*=r;j.row*=r;j.zoom+= +"application/json")},image:function(d,m,n){function s(){l=document.createElement("img");l.onerror=function(){i--;e()};l.onload=function(){i--;n(l);e()};l.src=m;d.setAttributeNS(o.ns.xlink,"href",m)}var l;g.push(s);e();return{abort:function(k){if(f(s))return true;if(k&&l){l.src="about:";return true}return false}}}}}();o.map=function(){function e(){if(u)if(su[1])s=u[1];l=s-(s=Math.round(s));k=Math.pow(2,l)}function f(){if(q){var j=45/Math.pow(2,s+l-3),r=Math.max(Math.abs(C*d.x+ +x*d.y),Math.abs(h*d.x+F*d.y)),z=U(w-r*j/m.y);r=U(t+r*j/m.y);n.lat=Math.max(z,Math.min(r,n.lat));z=Math.max(Math.abs(C*d.y+x*d.x),Math.abs(h*d.y+F*d.x));n.lon=Math.max(q[0].lon-z*j/m.x,Math.min(q[1].lon+z*j/m.x,n.lon))}}var a={},g,i,c=Y,d=Y,m={x:256,y:256},n={lat:37.76487,lon:-122.41948},s=12,l=0,k=1,u=[1,18],y=0,x=1,C=0,F=1,h=0,w=-180,t=180,q=[{lat:U(w),lon:-Infinity},{lat:U(t),lon:Infinity}];a.locationCoordinate=function(j){j=o.map.locationCoordinate(j);var r=Math.pow(2,s);j.column*=r;j.row*=r;j.zoom+= s;return j};a.coordinateLocation=o.map.coordinateLocation;a.coordinatePoint=function(j,r){var z=Math.pow(2,s-r.zoom),E=Math.pow(2,s-j.zoom),A=(r.column*z-j.column*E)*m.x*k;z=(r.row*z-j.row*E)*m.y*k;return{x:d.x+x*A-C*z,y:d.y+C*A+x*z}};a.pointCoordinate=function(j,r){var z=Math.pow(2,s-j.zoom),E=(r.x-d.x)/k,A=(r.y-d.y)/k;return{column:j.column*z+(F*E-h*A)/m.x,row:j.row*z+(h*E+F*A)/m.y,zoom:s}};a.locationPoint=function(j){var r=Math.pow(2,s+l-3)/45,z=(j.lon-n.lon)*r*m.x;j=(V(n.lat)-V(j.lat))*r*m.y; return{x:d.x+x*z-C*j,y:d.y+C*z+x*j}};a.pointLocation=function(j){var r=45/Math.pow(2,s+l-3),z=(j.x-d.x)*r;j=(j.y-d.y)*r;return{lon:n.lon+(F*z-h*j)/m.x,lat:U(V(n.lat)-(h*z+F*j)/m.y)}};var B=o.svg("rect");B.setAttribute("visibility","hidden");B.setAttribute("pointer-events","all");a.container=function(j){if(!arguments.length)return g;g=j;g.setAttribute("class","map");g.appendChild(B);return a.resize()};a.focusableParent=function(){for(var j=g;j;j=j.parentNode)if(j.tabIndex>=0)return j;return window}; a.mouse=function(j){var r=(g.ownerSVGElement||g).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var z=document.body.appendChild(o.svg("svg"));z.style.position="absolute";z.style.top=z.style.left="0px";var E=z.getScreenCTM();$=!(E.f||E.e);document.body.removeChild(z)}if($){r.x=j.pageX;r.y=j.pageY}else{r.x=j.clientX;r.y=j.clientY}return r.matrixTransform(g.getScreenCTM().inverse())};a.size=function(j){if(!arguments.length)return c;i=j;return a.resize()};a.resize=function(){if(i){c=i;Q.remove(a)}else{var j= g.ownerSVGElement||g;if(j.offsetWidth==null){B.setAttribute("width","100%");B.setAttribute("height","100%");j=B}b=j.getBoundingClientRect();c={x:b.width,y:b.height};Q.add(a)}B.setAttribute("width",c.x);B.setAttribute("height",c.y);d={x:c.x/2,y:c.y/2};f();a.dispatch({type:"resize"});return a};a.tileSize=function(j){if(!arguments.length)return m;m=j;a.dispatch({type:"move"});return a};a.center=function(j){if(!arguments.length)return n;n=j;f();a.dispatch({type:"move"});return a};a.panBy=function(j){var r= 45/Math.pow(2,s+l-3),z=j.x*r;j=j.y*r;return a.center({lon:n.lon+(h*j-F*z)/m.x,lat:U(V(n.lat)+(h*z+F*j)/m.y)})};a.centerRange=function(j){if(!arguments.length)return q;if(q=j){w=q[0].lat>-90?V(q[0].lat):-Infinity;t=q[0].lat<90?V(q[1].lat):Infinity}else{w=-Infinity;t=Infinity}f();a.dispatch({type:"move"});return a};a.zoom=function(j){if(!arguments.length)return s+l;s=j;e();return a.center(n)};a.zoomBy=function(j,r,z){if(arguments.length<2)return a.zoom(s+l+j);if(arguments.length<3)z=a.pointLocation(r); -s=s+l+j;e();var E=a.locationPoint(z);return a.panBy({x:r.x-E.x,y:r.y-E.y})};a.zoomRange=function(j){if(!arguments.length)return v;v=j;return a.zoom(s+l)};a.extent=function(j){if(!arguments.length)return[a.pointLocation({x:0,y:c.y}),a.pointLocation({x:c.x,y:0})];var r=a.locationPoint(j[0]),z=a.locationPoint(j[1]),E=Math.max((z.x-r.x)/c.x,(r.y-z.y)/c.y);r=a.pointLocation({x:(r.x+z.x)/2,y:(r.y+z.y)/2});s=s+l-Math.log(E)/Math.log(2);e();return a.center(r)};a.angle=function(j){if(!arguments.length)return y; +s=s+l+j;e();var E=a.locationPoint(z);return a.panBy({x:r.x-E.x,y:r.y-E.y})};a.zoomRange=function(j){if(!arguments.length)return u;u=j;return a.zoom(s+l)};a.extent=function(j){if(!arguments.length)return[a.pointLocation({x:0,y:c.y}),a.pointLocation({x:c.x,y:0})];var r=a.locationPoint(j[0]),z=a.locationPoint(j[1]),E=Math.max((z.x-r.x)/c.x,(r.y-z.y)/c.y);r=a.pointLocation({x:(r.x+z.x)/2,y:(r.y+z.y)/2});s=s+l-Math.log(E)/Math.log(2);e();return a.center(r)};a.angle=function(j){if(!arguments.length)return y; y=j;x=Math.cos(y);C=Math.sin(y);F=Math.cos(-y);h=Math.sin(-y);f();a.dispatch({type:"move"});return a};a.add=function(j){j.map(a);return a};a.remove=function(j){j.map(null);return a};a.dispatch=o.dispatch(a);return a};Q.maps=[];Q.add=function(e){for(var f=0;fh;x--){v.insertBefore(C[-1],w);v.insertBefore(C[2], -C[-4]);for(var t=C[2],q=2;q>-4;)C[q]=C[--q];C[q]=t}}function i(){function h(L){var H=L.zoom,R=H<0?1:1<>P,row:R>>P,zoom:S-P}))&&M.ready){N[M.key]=d.load(J);M.proxyCount++;G.proxyRefs[M.key]=M;break}}N[G.key]=G}}var t=c.map(),q=t.zoom(),B=q-(q=Math.round(q)),j=t.size(),r=t.angle(),z=t.tileSize(),E=t.locationCoordinate(t.center());n?v.removeAttribute("visibility"):v.setAttribute("visibility","hidden"); -if(x!=q){if(xq)g(q);else x=q;for(var A=-4;A<=2;A++){var X=C[A];X.setAttribute("class","zoom"+(A<0?"":"+")+A+" zoom"+(q+A));X.setAttribute("transform","scale("+Math.pow(2,-A)+")")}}v.setAttribute("transform","translate("+j.x/2+","+j.y/2+")"+(r?"rotate("+r/Math.PI*180+")":"")+(B?"scale("+Math.pow(2,B)+")":"")+(y?y.zoomFraction(B):""));var O=t.pointCoordinate(E,Y);A=t.pointCoordinate(E,{x:j.x,y:0});q=t.pointCoordinate(E,j);t=t.pointCoordinate(E,{x:0,y:j.y});if(!B&&!r&&!y){E.column= -(Math.round(z.x*E.column)+(j.x&1)/2)/z.x;E.row=(Math.round(z.y*E.row)+(j.y&1)/2)/z.y}if(y){O=y.unapply(O);A=y.unapply(A);q=y.unapply(q);t=y.unapply(t);E=y.unapply(E)}var T=s?s(O.zoom)-O.zoom:0;if(T){r=Math.pow(2,T);O.column*=r;O.row*=r;A.column*=r;A.row*=r;q.column*=r;q.row*=r;t.column*=r;t.row*=r;O.zoom=A.zoom=q.zoom=t.zoom+=T}B=d.locks();var N={};for(var I in B)B[I].proxyCount=0;if(n&&T>-5&&T<3){r=O.zoom<0?1:1<>A<>A<=1;F--)C[F]=v.appendChild(o.svg("g"));C[0]=v.appendChild(o.svg("g"));c.map=function(h){if(!arguments.length)return k;if(k){if(k==h){v.parentNode.appendChild(v);return c}k.off("move",i).off("resize",i);v.parentNode.removeChild(v)}if(k=h){k.container().appendChild(v);c.init&&c.init(v);k.on("move",i).on("resize",i);i()}return c};c.container= -function(){return v};c.id=function(h){if(!arguments.length)return l;l=h;return c};c.visible=function(h){if(!arguments.length)return n;n=h;k&&i();return c};c.transform=function(h){if(!arguments.length)return y;y=h;k&&i();return c};c.zoom=function(h){if(!arguments.length)return s;s=typeof h=="function"||h==null?h:function(){return h};return c};c.tile=function(h){if(!arguments.length)return m;m=h;return c};c.dispatch=o.dispatch(c);c.on("load",function(h){if(h.tile.proxyRefs){for(var w in h.tile.proxyRefs){var t= +360;return{column:(e.lon+180)*f,row:(180-V(e.lat))*f,zoom:0}};o.map.coordinateLocation=function(e){var f=45/Math.pow(2,e.zoom-3);return{lon:f*e.column-180,lat:U(180-f*e.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;o.layer=function(e,f){function a(h){for(var w=C[0].nextSibling;xh;x--){u.insertBefore(C[-1],w);u.insertBefore(C[2], +C[-4]);for(var t=C[2],q=2;q>-4;)C[q]=C[--q];C[q]=t}}function i(){function h(L){var H=L.zoom,R=H<0?1:1<>P,row:R>>P,zoom:S-P}))&&M.ready){N[M.key]=d.load(J);M.proxyCount++;G.proxyRefs[M.key]=M;break}}N[G.key]=G}}var t=c.map(),q=t.zoom(),B=q-(q=Math.round(q)),j=t.size(),r=t.angle(),z=t.tileSize(),E=t.locationCoordinate(t.center());if(x!=q){if(xq)g(q);else x=q;for(var A=-4;A<=2;A++){var X= +C[A];X.setAttribute("class","zoom"+(A<0?"":"+")+A+" zoom"+(q+A));X.setAttribute("transform","scale("+Math.pow(2,-A)+")")}}u.setAttribute("transform","translate("+j.x/2+","+j.y/2+")"+(r?"rotate("+r/Math.PI*180+")":"")+(B?"scale("+Math.pow(2,B)+")":"")+(y?y.zoomFraction(B):""));var O=t.pointCoordinate(E,Y);A=t.pointCoordinate(E,{x:j.x,y:0});q=t.pointCoordinate(E,j);t=t.pointCoordinate(E,{x:0,y:j.y});if(!B&&!r&&!y){E.column=(Math.round(z.x*E.column)+(j.x&1)/2)/z.x;E.row=(Math.round(z.y*E.row)+(j.y&1)/ +2)/z.y}if(y){O=y.unapply(O);A=y.unapply(A);q=y.unapply(q);t=y.unapply(t);E=y.unapply(E)}var T=s?s(O.zoom)-O.zoom:0;if(T){r=Math.pow(2,T);O.column*=r;O.row*=r;A.column*=r;A.row*=r;q.column*=r;q.row*=r;t.column*=r;t.row*=r;O.zoom=A.zoom=q.zoom=t.zoom+=T}B=d.locks();var N={};for(var I in B)B[I].proxyCount=0;if(n&&T>-5&&T<3){r=O.zoom<0?1:1<>A<>A<=1;F--)C[F]=u.appendChild(o.svg("g"));C[0]=u.appendChild(o.svg("g"));c.map=function(h){if(!arguments.length)return k;if(k){if(k==h){u.parentNode.appendChild(u);return c}k.off("move",i).off("resize",i);u.parentNode.removeChild(u)}if(k=h){k.container().appendChild(u);c.init&&c.init(u);k.on("move",i).on("resize",i);i()}return c};c.container=function(){return u};c.id=function(h){if(!arguments.length)return l;l=h;u.setAttribute("id", +h);return c};c.visible=function(h){if(!arguments.length)return n;n=h?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden");k&&i();return c};c.transform=function(h){if(!arguments.length)return y;y=h;k&&i();return c};c.zoom=function(h){if(!arguments.length)return s;s=typeof h=="function"||h==null?h:function(){return h};return c};c.tile=function(h){if(!arguments.length)return m;m=h;return c};c.dispatch=o.dispatch(c);c.on("load",function(h){if(h.tile.proxyRefs){for(var w in h.tile.proxyRefs){var t= h.tile.proxyRefs[w];--t.proxyCount<=0&&d.unload(w)&&t.element.parentNode.removeChild(t.element)}delete h.tile.proxyRefs}});return c};o.image=function(){var e=o.layer(function(a){var g=a.element=o.svg("image"),i=e.map().tileSize();g.setAttribute("preserveAspectRatio","none");g.setAttribute("width",i.x);g.setAttribute("height",i.y);g.setAttribute("opacity",0);if(typeof f=="function")a.request=o.queue.image(g,f(a),function(c){delete a.request;a.ready=true;a.img=c;g.removeAttribute("opacity");e.dispatch({type:"load", tile:a})});else{a.ready=true;g.setAttributeNS(o.ns.xlink,"href",f);e.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),f="about:blank";e.url=function(a){if(!arguments.length)return f;f=typeof a=="string"&&/{.}/.test(a)?o.url(a):a;return e};return e};o.geoJson=function(e){function f(h,w){return h&&h.type in C&&C[h.type](h,w)}function a(h,w){var t=w({lat:h[1],lon:h[0]}),q=o.svg("circle");q.setAttribute("r",4.5);q.setAttribute("cx",t.x);q.setAttribute("cy",t.y);return q} function g(h,w,t,q){q.push("M");for(var B=0;B9&&Math.abs(l.wheelDelta)/x>=50)ba=1;i=y}if(ba==1)k*=0.03;m||(m=n.pointLocation(v));n.off("move",e);if(c)d==="mouse"?n.zoomBy(k,v,m):n.zoomBy(k);else if(k){y=Date.now();if(y-g>200){k=k>0?+1:-1;d==="mouse"?n.zoomBy(k,v,m):n.zoomBy(k);g=y}}n.on("move",e);l.preventDefault();return false}var a= +c=null;document.body.style.removeProperty("cursor")}},false);return a};o.wheel=function(){function e(){m=null}function f(l){var k=(l.wheelDelta/120||-l.detail)*0.1,u=n.mouse(l);if(ba<0){var y=Date.now(),x=y-i;if(x>9&&Math.abs(l.wheelDelta)/x>=50)ba=1;i=y}if(ba==1)k*=0.03;m||(m=n.pointLocation(u));n.off("move",e);if(c)d==="mouse"?n.zoomBy(k,u,m):n.zoomBy(k);else if(k){y=Date.now();if(y-g>200){k=k>0?+1:-1;d==="mouse"?n.zoomBy(k,u,m):n.zoomBy(k);g=y}}n.on("move",e);l.preventDefault();return false}var a= {},g=0,i=0,c=true,d="mouse",m,n,s;a.smooth=function(l){if(!arguments.length)return c;c=l;return a};a.zoom=function(l){if(!arguments.length)return d;d=l;return a};a.map=function(l){if(!arguments.length)return n;if(n){s.removeEventListener("mousemove",e,false);s.removeEventListener("mousewheel",f,false);s.removeEventListener("DOMMouseScroll",f,false);s=null;n.off("move",e)}if(n=l){n.on("move",e);s=n.container();s.addEventListener("mousemove",e,false);s.addEventListener("mousewheel",f,false);s.addEventListener("DOMMouseScroll", f,false)}return a};return a};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;o.arrow=function(){function e(y){if(!(y.ctrlKey||y.altKey||y.metaKey)){var x=Date.now(),C=0,F=0;switch(y.keyCode){case 37:if(!c.left){d=x;c.left=1;c.right||(C=l)}break;case 39:if(!c.right){d=x;c.right=1;c.left||(C=-l)}break;case 38:if(!c.up){d=x;c.up=1;c.down||(F=l)}break;case 40:if(!c.down){d=x;c.down=1;c.up||(F=-l)}break;default:return}if(C||F)k.panBy({x:C,y:F});if(!m&&c.left|c.right|c.up|c.down)m=setInterval(g,s); y.preventDefault()}}function f(y){d=Date.now();switch(y.keyCode){case 37:c.left=0;break;case 39:c.right=0;break;case 38:c.up=0;break;case 40:c.down=0;break;default:return}if(m&&!(c.left|c.right|c.up|c.down))m=clearInterval(m);y.preventDefault()}function a(y){switch(y.charCode){case 45:case 95:k.zoom(Math.ceil(k.zoom())-1);break;case 43:case 61:k.zoom(Math.floor(k.zoom())+1);break;default:return}y.preventDefault()}function g(){if(k)if(!(Date.now() -B+j&&H.panBy(T)}function a(u){if(u.shiftKey){I={x0:H.mouse(u)};H.focusableParent().focus();return l(u)}}function g(u){if(I){I.x1=H.mouse(u);L.setAttribute("x",Math.min(I.x0.x,I.x1.x));L.setAttribute("y",Math.min(I.x0.y,I.x1.y));L.setAttribute("width",Math.abs(I.x0.x-I.x1.x));L.setAttribute("height",Math.abs(I.x0.y-I.x1.y));L.removeAttribute("display")}}function i(){h.setAttribute("class","compass");if(I){if(I.x1){H.extent([H.pointLocation({x:Math.min(I.x0.x,I.x1.x),y:Math.max(I.x0.y,I.x1.y)}),H.pointLocation({x:Math.max(I.x0.x, -I.x1.x),y:Math.min(I.x0.y,I.x1.y)})]);L.setAttribute("display","none")}I=null}if(O){clearInterval(O);O=0}}function c(u){return function(){u?this.setAttribute("class","active"):this.removeAttribute("class");T=u}}function d(u){return function(D){h.setAttribute("class","compass active");var G=H.zoom();H.zoom(u<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function m(u){return function(D){H.zoom(u);return l(D)}}function n(){this.setAttribute("class","active")}function s(){this.removeAttribute("class")} -function l(u){u.stopPropagation();u.preventDefault();return false}function k(u){var D=Math.SQRT1_2*t,G=t*0.7,J=t*0.2,K=o.svg("g"),M=K.appendChild(o.svg("path")),P=K.appendChild(o.svg("path"));M.setAttribute("class","direction");M.setAttribute("pointer-events","all");M.setAttribute("d","M0,0L"+D+","+D+"A"+t+","+t+" 0 0,1 "+-D+","+D+"Z");P.setAttribute("class","chevron");P.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));P.setAttribute("pointer-events","none");K.addEventListener("mousedown", -e,false);K.addEventListener("mouseover",c(u),false);K.addEventListener("mouseout",c(null),false);K.addEventListener("dblclick",l,false);return K}function v(u){var D=t*0.4,G=D/2,J=o.svg("g"),K=J.appendChild(o.svg("path")),M=J.appendChild(o.svg("path")),P=J.appendChild(o.svg("path")),W=J.appendChild(o.svg("path"));K.setAttribute("class","back");K.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");M.setAttribute("class","direction");M.setAttribute("d",K.getAttribute("d"));P.setAttribute("class", -"chevron");P.setAttribute("d","M"+-G+","+-D+"H"+G+(u>0?"M0,"+(-D-G)+"V"+-G:""));W.setAttribute("class","fore");W.setAttribute("fill","none");W.setAttribute("d",K.getAttribute("d"));J.addEventListener("mousedown",d(u),false);J.addEventListener("mouseover",n,false);J.addEventListener("mouseout",s,false);J.addEventListener("dblclick",l,false);return J}function y(u){var D=t*0.2,G=t*0.4,J=o.svg("g"),K=J.appendChild(o.svg("rect")),M=J.appendChild(o.svg("path"));K.setAttribute("pointer-events","all");K.setAttribute("fill", -"none");K.setAttribute("x",-G);K.setAttribute("y",-0.75*G);K.setAttribute("width",2*G);K.setAttribute("height",1.5*G);M.setAttribute("class","chevron");M.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",m(u),false);J.addEventListener("dblclick",l,false);return J}function x(){var u=t+6,D=u,G=H.size();switch(z){case "top-left":break;case "top-right":u=G.x-u;break;case "bottom-left":D=G.y-D;break;case "bottom-right":u=G.x-u;D=G.y-D;break}u="translate("+u+","+D+")";N&&N.setAttribute("transform", -u);A&&A.setAttribute("transform",u);for(var J in w)J==H.zoom()?w[J].setAttribute("class","active"):w[J].removeAttribute("class")}function C(){for(;h.lastChild;)h.removeChild(h.lastChild);h.appendChild(L);if(X!="none"){N=h.appendChild(o.svg("g"));N.setAttribute("class","pan");var u=N.appendChild(o.svg("circle"));u.setAttribute("class","back");u.setAttribute("r",t);N.appendChild(k({x:0,y:-q})).setAttribute("transform","rotate(0)");N.appendChild(k({x:q,y:0})).setAttribute("transform","rotate(90)");N.appendChild(k({x:0, -y:q})).setAttribute("transform","rotate(180)");N.appendChild(k({x:-q,y:0})).setAttribute("transform","rotate(270)");u=N.appendChild(o.svg("circle"));u.setAttribute("fill","none");u.setAttribute("class","fore");u.setAttribute("r",t)}else N=null;if(E!="none"){A=h.appendChild(o.svg("g"));A.setAttribute("class","zoom");u=-0.5;if(E=="big"){w={};var D=H.zoomRange()[0];for(u=0;D<=H.zoomRange()[1];D++,u++)(w[D]=A.appendChild(y(D))).setAttribute("transform","translate(0,"+-(u+0.75)*t*0.4+")")}D=X=="none"? -0.4:2;A.setAttribute("transform","translate(0,"+t*(/^top-/.test(z)?D+(u+0.5)*0.4:-D)+")");A.appendChild(v(+1)).setAttribute("transform","translate(0,"+-(u+0.5)*t*0.4+")");A.appendChild(v(-1)).setAttribute("transform","scale(-1)")}else A=null;x()}var F={},h=o.svg("g"),w={},t=30,q=16,B=0,j=250,r=50,z="top-left",E="small",A,X="small",O,T,N,I,L=o.svg("rect"),H,R,S;h.setAttribute("class","compass");L.setAttribute("class","back fore");L.setAttribute("pointer-events","none");L.setAttribute("display","none"); -F.radius=function(u){if(!arguments.length)return t;t=u;H&&C();return F};F.speed=function(u){if(!arguments.length)return t;q=u;return F};F.position=function(u){if(!arguments.length)return z;z=u;H&&C();return F};F.pan=function(u){if(!arguments.length)return X;X=u;H&&C();return F};F.zoom=function(u){if(!arguments.length)return E;E=u;H&&C();return F};F.map=function(u){if(!arguments.length)return H;if(H){R.removeEventListener("mousedown",a,false);R.removeChild(h);R=null;S.removeEventListener("mousemove", -g,false);S.removeEventListener("mouseup",i,false);S=null;H.off("move",x).off("resize",x)}if(H=u){R=H.container();R.appendChild(h);R.addEventListener("mousedown",a,false);S=R.ownerDocument.defaultView;S.addEventListener("mousemove",g,false);S.addEventListener("mouseup",i,false);H.on("move",x).on("resize",x);C()}return F};return F};o.grid=function(){function e(){var i=g.firstChild,c=a.size(),d=a.pointLocation(Y);a.pointLocation(c);var m=Math.pow(2,4-Math.round(a.zoom()));d.lat=Math.floor(d.lat/m)*m; +if(c){c.off("move",e);window.removeEventListener("hashchange",f,false)}if(c=d){c.on("move",e);window.addEventListener("hashchange",f,false);location.hash?f():e()}return a};return a};o.interact=function(){var e={},f=o.drag(),a=o.wheel(),g=o.dblclick(),i=o.arrow();e.map=function(c){f.map(c);a.map(c);g.map(c);i.map(c);return e};return e};o.compass=function(){function e(v){h.setAttribute("class","compass active");O||(O=setInterval(f,r));T&&H.panBy(T);B=Date.now();return l(v)}function f(){T&&Date.now()> +B+j&&H.panBy(T)}function a(v){if(v.shiftKey){I={x0:H.mouse(v)};H.focusableParent().focus();return l(v)}}function g(v){if(I){I.x1=H.mouse(v);L.setAttribute("x",Math.min(I.x0.x,I.x1.x));L.setAttribute("y",Math.min(I.x0.y,I.x1.y));L.setAttribute("width",Math.abs(I.x0.x-I.x1.x));L.setAttribute("height",Math.abs(I.x0.y-I.x1.y));L.removeAttribute("display")}}function i(){h.setAttribute("class","compass");if(I){if(I.x1){H.extent([H.pointLocation({x:Math.min(I.x0.x,I.x1.x),y:Math.max(I.x0.y,I.x1.y)}),H.pointLocation({x:Math.max(I.x0.x, +I.x1.x),y:Math.min(I.x0.y,I.x1.y)})]);L.setAttribute("display","none")}I=null}if(O){clearInterval(O);O=0}}function c(v){return function(){v?this.setAttribute("class","active"):this.removeAttribute("class");T=v}}function d(v){return function(D){h.setAttribute("class","compass active");var G=H.zoom();H.zoom(v<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function m(v){return function(D){H.zoom(v);return l(D)}}function n(){this.setAttribute("class","active")}function s(){this.removeAttribute("class")} +function l(v){v.stopPropagation();v.preventDefault();return false}function k(v){var D=Math.SQRT1_2*t,G=t*0.7,J=t*0.2,K=o.svg("g"),M=K.appendChild(o.svg("path")),P=K.appendChild(o.svg("path"));M.setAttribute("class","direction");M.setAttribute("pointer-events","all");M.setAttribute("d","M0,0L"+D+","+D+"A"+t+","+t+" 0 0,1 "+-D+","+D+"Z");P.setAttribute("class","chevron");P.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));P.setAttribute("pointer-events","none");K.addEventListener("mousedown", +e,false);K.addEventListener("mouseover",c(v),false);K.addEventListener("mouseout",c(null),false);K.addEventListener("dblclick",l,false);return K}function u(v){var D=t*0.4,G=D/2,J=o.svg("g"),K=J.appendChild(o.svg("path")),M=J.appendChild(o.svg("path")),P=J.appendChild(o.svg("path")),W=J.appendChild(o.svg("path"));K.setAttribute("class","back");K.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");M.setAttribute("class","direction");M.setAttribute("d",K.getAttribute("d"));P.setAttribute("class", +"chevron");P.setAttribute("d","M"+-G+","+-D+"H"+G+(v>0?"M0,"+(-D-G)+"V"+-G:""));W.setAttribute("class","fore");W.setAttribute("fill","none");W.setAttribute("d",K.getAttribute("d"));J.addEventListener("mousedown",d(v),false);J.addEventListener("mouseover",n,false);J.addEventListener("mouseout",s,false);J.addEventListener("dblclick",l,false);return J}function y(v){var D=t*0.2,G=t*0.4,J=o.svg("g"),K=J.appendChild(o.svg("rect")),M=J.appendChild(o.svg("path"));K.setAttribute("pointer-events","all");K.setAttribute("fill", +"none");K.setAttribute("x",-G);K.setAttribute("y",-0.75*G);K.setAttribute("width",2*G);K.setAttribute("height",1.5*G);M.setAttribute("class","chevron");M.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",m(v),false);J.addEventListener("dblclick",l,false);return J}function x(){var v=t+6,D=v,G=H.size();switch(z){case "top-left":break;case "top-right":v=G.x-v;break;case "bottom-left":D=G.y-D;break;case "bottom-right":v=G.x-v;D=G.y-D;break}v="translate("+v+","+D+")";N&&N.setAttribute("transform", +v);A&&A.setAttribute("transform",v);for(var J in w)J==H.zoom()?w[J].setAttribute("class","active"):w[J].removeAttribute("class")}function C(){for(;h.lastChild;)h.removeChild(h.lastChild);h.appendChild(L);if(X!="none"){N=h.appendChild(o.svg("g"));N.setAttribute("class","pan");var v=N.appendChild(o.svg("circle"));v.setAttribute("class","back");v.setAttribute("r",t);N.appendChild(k({x:0,y:-q})).setAttribute("transform","rotate(0)");N.appendChild(k({x:q,y:0})).setAttribute("transform","rotate(90)");N.appendChild(k({x:0, +y:q})).setAttribute("transform","rotate(180)");N.appendChild(k({x:-q,y:0})).setAttribute("transform","rotate(270)");v=N.appendChild(o.svg("circle"));v.setAttribute("fill","none");v.setAttribute("class","fore");v.setAttribute("r",t)}else N=null;if(E!="none"){A=h.appendChild(o.svg("g"));A.setAttribute("class","zoom");v=-0.5;if(E=="big"){w={};var D=H.zoomRange()[0];for(v=0;D<=H.zoomRange()[1];D++,v++)(w[D]=A.appendChild(y(D))).setAttribute("transform","translate(0,"+-(v+0.75)*t*0.4+")")}D=X=="none"? +0.4:2;A.setAttribute("transform","translate(0,"+t*(/^top-/.test(z)?D+(v+0.5)*0.4:-D)+")");A.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(v+0.5)*t*0.4+")");A.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else A=null;x()}var F={},h=o.svg("g"),w={},t=30,q=16,B=0,j=250,r=50,z="top-left",E="small",A,X="small",O,T,N,I,L=o.svg("rect"),H,R,S;h.setAttribute("class","compass");L.setAttribute("class","back fore");L.setAttribute("pointer-events","none");L.setAttribute("display","none"); +F.radius=function(v){if(!arguments.length)return t;t=v;H&&C();return F};F.speed=function(v){if(!arguments.length)return t;q=v;return F};F.position=function(v){if(!arguments.length)return z;z=v;H&&C();return F};F.pan=function(v){if(!arguments.length)return X;X=v;H&&C();return F};F.zoom=function(v){if(!arguments.length)return E;E=v;H&&C();return F};F.map=function(v){if(!arguments.length)return H;if(H){R.removeEventListener("mousedown",a,false);R.removeChild(h);R=null;S.removeEventListener("mousemove", +g,false);S.removeEventListener("mouseup",i,false);S=null;H.off("move",x).off("resize",x)}if(H=v){R=H.container();R.appendChild(h);R.addEventListener("mousedown",a,false);S=R.ownerDocument.defaultView;S.addEventListener("mousemove",g,false);S.addEventListener("mouseup",i,false);H.on("move",x).on("resize",x);C()}return F};return F};o.grid=function(){function e(){var i=g.firstChild,c=a.size(),d=a.pointLocation(Y);a.pointLocation(c);var m=Math.pow(2,4-Math.round(a.zoom()));d.lat=Math.floor(d.lat/m)*m; d.lon=Math.ceil(d.lon/m)*m;for(var n;(n=a.locationPoint(d).x)<=c.x;d.lon+=m){i||(i=g.appendChild(o.svg("line")));i.setAttribute("x1",n);i.setAttribute("x2",n);i.setAttribute("y1",0);i.setAttribute("y2",c.y);i=i.nextSibling}for(;(n=a.locationPoint(d).y)<=c.y;d.lat-=m){i||(i=g.appendChild(o.svg("line")));i.setAttribute("y1",n);i.setAttribute("y2",n);i.setAttribute("x1",0);i.setAttribute("x2",c.x);i=i.nextSibling}for(;i;){c=i.nextSibling;g.removeChild(i);i=c}}var f={},a,g=o.svg("g");g.setAttribute("class", "grid");f.map=function(i){if(!arguments.length)return a;if(a){g.parentNode.removeChild(g);a.off("move",e).off("resize",e)}if(a=i){a.on("move",e).on("resize",e);a.container().appendChild(g);a.dispatch({type:"move"})}return f};return f}})(org.polymaps); diff --git a/src/Layer.js b/src/Layer.js index 20bc260..bb61cf8 100644 --- a/src/Layer.js +++ b/src/Layer.js @@ -57,11 +57,6 @@ po.layer = function(load, unload) { tileSize = map.tileSize(), tileCenter = map.locationCoordinate(map.center()); - // set the layer visibility - visible - ? container.removeAttribute("visibility") - : container.setAttribute("visibility", "hidden"); - // set the layer zoom levels if (levelZoom != mapZoom) { if (levelZoom < mapZoom) zoomIn(mapZoom); @@ -279,12 +274,15 @@ po.layer = function(load, unload) { layer.id = function(x) { if (!arguments.length) return id; id = x; + container.setAttribute("id", x); return layer; }; layer.visible = function(x) { if (!arguments.length) return visible; - visible = x; + visible = x + ? container.removeAttribute("visibility") + : container.setAttribute("visibility", "hidden"); if (map) move(); return layer; }; diff --git a/src/start.js b/src/start.js index 80e8a16..2653e3d 100644 --- a/src/start.js +++ b/src/start.js @@ -2,6 +2,6 @@ if (!org) var org = {}; if (!org.polymaps) org.polymaps = {}; (function(po){ - po.version = "2.0+2.3+5"; // This fork not semver! + po.version = "2.0+2.3+6"; // This fork not semver! var zero = {x: 0, y: 0};