From a9d879a02afb4ccb54dcbe4534c870ff4dc44efb Mon Sep 17 00:00:00 2001 From: Jason Davies Date: Tue, 12 Apr 2011 08:58:17 +0100 Subject: [PATCH] Fix for "thin lines" bug in all current browsers. The fix works by applying the translation transform to the whole layer at once, rounding the zoom level to the nearest 1/256th, and of course rounding any translation transforms to the nearest pixel. --- polymaps.js | 39 +++++++++------ polymaps.min.js | 129 ++++++++++++++++++++++++------------------------ src/Layer.js | 39 +++++++++------ 3 files changed, 113 insertions(+), 94 deletions(-) diff --git a/polymaps.js b/polymaps.js index 9dc2c70..064451a 100644 --- a/polymaps.js +++ b/polymaps.js @@ -787,24 +787,29 @@ po.layer = function(load, unload) { } } - // set the layer transform - container.setAttribute("transform", - "translate(" + (mapSize.x / 2) + "," + (mapSize.y / 2) + ")" - + (mapAngle ? "rotate(" + mapAngle / Math.PI * 180 + ")" : "") - + (mapZoomFraction ? "scale(" + Math.pow(2, mapZoomFraction) + ")" : "") - + (transform ? transform.zoomFraction(mapZoomFraction) : "")); - // get the coordinates of the four corners var c0 = map.pointCoordinate(tileCenter, zero), c1 = map.pointCoordinate(tileCenter, {x: mapSize.x, y: 0}), c2 = map.pointCoordinate(tileCenter, mapSize), c3 = map.pointCoordinate(tileCenter, {x: 0, y: mapSize.y}); - // round to pixel boundary to avoid anti-aliasing artifacts - if (!mapZoomFraction && !mapAngle && !transform) { - tileCenter.column = (Math.round(tileSize.x * tileCenter.column) + (mapSize.x & 1) / 2) / tileSize.x; - tileCenter.row = (Math.round(tileSize.y * tileCenter.row) + (mapSize.y & 1) / 2) / tileSize.y; - } + var col = tileCenter.column, row = tileCenter.row; + tileCenter.column = Math.round((Math.round(tileSize.x * tileCenter.column) + (mapSize.x & 1) / 2) / tileSize.x); + tileCenter.row = Math.round((Math.round(tileSize.y * tileCenter.row) + (mapSize.y & 1) / 2) / tileSize.y); + col -= tileCenter.column; + row -= tileCenter.row; + + // set the layer transform + var roundedZoomFraction = roundZoom(Math.pow(2, mapZoomFraction)); + container.setAttribute("transform", + "translate(" + + Math.round(mapSize.x / 2 - col * tileSize.x * roundedZoomFraction) + + "," + + Math.round(mapSize.y / 2 - row * tileSize.y * roundedZoomFraction) + + ")" + + (mapAngle ? "rotate(" + mapAngle / Math.PI * 180 + ")" : "") + + (mapZoomFraction ? "scale(" + roundedZoomFraction + ")" : "") + + (transform ? transform.zoomFraction(mapZoomFraction) : "")); // layer-specific coordinate transform if (transform) { @@ -924,13 +929,17 @@ po.layer = function(load, unload) { } } + function roundZoom(z) { + return Math.round(z * 256) / 256; + } + // position tiles for (var key in newLocks) { var t = newLocks[key], - k = Math.pow(2, t.level = t.zoom - tileCenter.zoom); + k = roundZoom(Math.pow(2, t.level = t.zoom - tileCenter.zoom)); t.element.setAttribute("transform", "translate(" - + (t.x = tileSize.x * (t.column - tileCenter.column * k)) + "," - + (t.y = tileSize.y * (t.row - tileCenter.row * k)) + ")"); + + Math.round(t.x = tileSize.x * (t.column - tileCenter.column * k)) + "," + + Math.round(t.y = tileSize.y * (t.row - tileCenter.row * k)) + ")"); } // remove tiles that are no longer visible diff --git a/polymaps.min.js b/polymaps.min.js index 491a031..8996080 100644 --- a/polymaps.min.js +++ b/polymaps.min.js @@ -1,65 +1,66 @@ if(!org)var org={};if(!org.polymaps)org.polymaps={}; -(function(r){function ea(d){var h=d.indexOf(":");return h<0?d:{space:r.ns[d.substring(0,h)],local:d.substring(h+1)}}function R(){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 ba(d,h,a,m,e){a=Math.max(a,Math.floor(h.y0)); -m=Math.min(m,Math.ceil(h.y1));if(d.x0==h.x0&&d.y0==h.y0?d.x0+h.dy/d.dy*d.dx0,t=h.dx<0;for(a=a;ah.dy){a=g;g=h;h=a}if(g.dy>d.dy){a=g;g=d;d=a}if(h.dy>d.dy){a=h;h=d;d=a}g.dy&&ba(d,g,m,e,c);h.dy&&ba(d,h,m,e,c)}r.version="2.5.0"; -var Y={x:0,y:0};r.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};r.id=function(){var d=0;return function(){return++d}}();r.svg=function(d){return document.createElementNS(r.ns.svg,d)};r.transform=function(d,h,a,m,e,c){var g={},k,t,n;if(!arguments.length){d=1;h=e=a=0;m=1;c=0}g.zoomFraction=function(l){if(!arguments.length)return t;t=l;k=Math.floor(t+Math.log(Math.sqrt(d*d+h*h+a*a+m*m))/Math.LN2);n=Math.pow(2,-k);return g};g.apply=function(l){var i=Math.pow(2,-l.zoom),q= -Math.pow(2,l.zoom-k);return{column:(d*l.column*i+a*l.row*i+e)*q,row:(h*l.column*i+m*l.row*i+c)*q,zoom:l.zoom-k}};g.unapply=function(l){var i=Math.pow(2,-l.zoom),q=Math.pow(2,l.zoom+k);return{column:(l.column*i*m-l.row*i*a-e*m+c*a)/(d*m-h*a)*q,row:(l.column*i*h-l.row*i*d-e*h+c*d)/(a*h-m*d)*q,zoom:l.zoom+k}};g.toString=function(){return"matrix("+[d*n,h*n,a*n,m*n].join(" ")+" 0 0)"};return g.zoomFraction(0)};r.cache=function(d,h){function a(i){l--;h&&h(i);delete g[i.key];if(i.next)i.next.prev=i.prev; -else if(t=i.prev)t.next=null;if(i.prev)i.prev.next=i.next;else if(k=i.next)k.prev=null}function m(){for(var i=t;l>n;i=i.prev){if(!i)break;i.lock||a(i)}}var e={},c={},g={},k=null,t=null,n=64,l=0;e.peek=function(i){return g[[i.zoom,i.column,i.row].join("/")]};e.load=function(i,q){var w=[i.zoom,i.column,i.row].join("/"),A=g[w];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else t=A.prev;A.prev=null;A.next=k;k=k.prev=A}A.lock=1;return c[w]=A}A={key:w,column:i.column,row:i.row,zoom:i.zoom,next:k, -prev:null,lock:1};d.call(null,A,q);c[w]=g[w]=A;if(k)k.prev=A;else t=A;k=A;l++;return A};e.unload=function(i){if(!(i in c))return false;var q=c[i];q.lock=0;delete c[i];q.request&&q.request.abort(false)&&a(q);return q};e.locks=function(){return c};e.size=function(i){if(!arguments.length)return n;n=i;m();return e};e.flush=function(){m();return e};e.clear=function(){for(var i in g){var q=g[i];q.request&&q.request.abort(false);h&&h(g[i]);if(q.lock){q.lock=0;q.element.parentNode.removeChild(q.element)}}c= -{};g={};k=t=null;l=0;return e};return e};r.url=function(d){function h(e){var c=e.zoom<0?1:1<=c)return null;return d.replace(/{(.)}/g,function(k,t){switch(t){case "S":return a[(Math.abs(e.zoom)+e.row+g)%a.length];case "Z":return e.zoom;case "X":return g;case "Y":return e.row;case "B":var n=r.map.coordinateLocation({row:e.row,column:g,zoom:e.zoom}),l=r.map.coordinateLocation({row:e.row+1,column:g+1,zoom:e.zoom}),i=Math.ceil(Math.log(e.zoom)/ -Math.LN2);return l.lat.toFixed(i)+","+n.lon.toFixed(i)+","+n.lat.toFixed(i)+","+l.lon.toFixed(i)}return t})}var a=[],m=true;h.template=function(e){if(!arguments.length)return d;d=e;return h};h.hosts=function(e){if(!arguments.length)return a;a=e;return h};h.repeat=function(e){if(!arguments.length)return m;m=e;return h};return h};r.dispatch=function(d){var h={};d.on=function(a,m){for(var e=h[a]||(h[a]=[]),c=0;c=c||!m.length)){e++;m.pop()()}}function h(g){for(var k=0;kq[1])n=q[1];l=n-(n=Math.round(n));i=Math.pow(2,l)}function h(){if(o){var f=45/Math.pow(2,n+l-3),u=Math.max(Math.abs(C*g.x+A*g.y),Math.abs(B*g.x+E*g.y)),s=V(K- -u*f/k.y);u=V(j+u*f/k.y);t.lat=Math.max(s,Math.min(u,t.lat));s=Math.max(Math.abs(C*g.y+A*g.x),Math.abs(B*g.y+E*g.x));t.lon=Math.max(o[0].lon-s*f/k.x,Math.min(o[1].lon+s*f/k.x,t.lon))}}var a={},m,e,c=Y,g=Y,k={x:256,y:256},t={lat:37.76487,lon:-122.41948},n=12,l=0,i=1,q=[1,18],w=0,A=1,C=0,E=1,B=0,K=-180,j=180,o=[{lat:V(K),lon:-Infinity},{lat:V(j),lon:Infinity}];a.locationCoordinate=function(f){f=r.map.locationCoordinate(f);var u=Math.pow(2,n);f.column*=u;f.row*=u;f.zoom+=n;return f};a.coordinateLocation= -r.map.coordinateLocation;a.coordinatePoint=function(f,u){var s=Math.pow(2,n-u.zoom),z=Math.pow(2,n-f.zoom),v=(u.column*s-f.column*z)*k.x*i;s=(u.row*s-f.row*z)*k.y*i;return{x:g.x+A*v-C*s,y:g.y+C*v+A*s}};a.pointCoordinate=function(f,u){var s=Math.pow(2,n-f.zoom),z=(u.x-g.x)/i,v=(u.y-g.y)/i;return{column:f.column*s+(E*z-B*v)/k.x,row:f.row*s+(B*z+E*v)/k.y,zoom:n}};a.locationPoint=function(f){var u=Math.pow(2,n+l-3)/45,s=(f.lon-t.lon)*u*k.x;f=(W(t.lat)-W(f.lat))*u*k.y;return{x:g.x+A*s-C*f,y:g.y+C*s+A* -f}};a.pointLocation=function(f){var u=45/Math.pow(2,n+l-3),s=(f.x-g.x)*u;f=(f.y-g.y)*u;return{lon:t.lon+(E*s-B*f)/k.x,lat:V(W(t.lat)-(B*s+E*f)/k.y)}};var x=r.svg("rect");x.setAttribute("visibility","hidden");x.setAttribute("pointer-events","all");a.container=function(f){if(!arguments.length)return m;m=f;m.setAttribute("class","map");m.appendChild(x);return a.resize()};a.focusableParent=function(){for(var f=m;f;f=f.parentNode)if(f.tabIndex>=0)return f;return window};a.mouse=function(f){var u=(m.ownerSVGElement|| -m).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var s=document.body.appendChild(r.svg("svg"));s.style.position="absolute";s.style.top=s.style.left="0px";var z=s.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(s)}if($){u.x=f.pageX;u.y=f.pageY}else{u.x=f.clientX;u.y=f.clientY}return u.matrixTransform(m.getScreenCTM().inverse())};a.size=function(f){if(!arguments.length)return c;e=f;return a.resize()};a.resize=function(){if(e){c=e;R.remove(a)}else{x.setAttribute("width","100%");x.setAttribute("height", -"100%");b=x.getBBox();c={x:b.width,y:b.height};R.add(a)}x.setAttribute("width",c.x);x.setAttribute("height",c.y);g={x:c.x/2,y:c.y/2};h();a.dispatch({type:"resize"});return a};a.tileSize=function(f){if(!arguments.length)return k;k=f;a.dispatch({type:"move"});return a};a.center=function(f){if(!arguments.length)return t;t=f;h();a.dispatch({type:"move"});return a};a.panBy=function(f){var u=45/Math.pow(2,n+l-3),s=f.x*u;f=f.y*u;return a.center({lon:t.lon+(B*f-E*s)/k.x,lat:V(W(t.lat)+(B*s+E*f)/k.y)})};a.centerRange= -function(f){if(!arguments.length)return o;if(o=f){K=o[0].lat>-90?W(o[0].lat):-Infinity;j=o[0].lat<90?W(o[1].lat):Infinity}else{K=-Infinity;j=Infinity}h();a.dispatch({type:"move"});return a};a.zoom=function(f){if(!arguments.length)return n+l;n=f;d();return a.center(t)};a.zoomBy=function(f,u,s){if(arguments.length<2)return a.zoom(n+l+f);if(arguments.length<3)s=a.pointLocation(u);n=n+l+f;d();var z=a.locationPoint(s);return a.panBy({x:u.x-z.x,y:u.y-z.y})};a.zoomRange=function(f){if(!arguments.length)return q; -q=f;return a.zoom(n+l)};a.extent=function(f){if(!arguments.length)return[a.pointLocation({x:0,y:c.y}),a.pointLocation({x:c.x,y:0})];var u=a.locationPoint(f[0]),s=a.locationPoint(f[1]),z=Math.max((s.x-u.x)/c.x,(u.y-s.y)/c.y);u=a.pointLocation({x:(u.x+s.x)/2,y:(u.y+s.y)/2});n=n+l-Math.log(z)/Math.LN2;d();return a.center(u)};a.angle=function(f){if(!arguments.length)return w;w=f;A=Math.cos(w);C=Math.sin(w);E=Math.cos(-w);B=Math.sin(-w);h();a.dispatch({type:"move"});return a};a.add=function(f){f.map(a); -return a};a.remove=function(f){f.map(null);return a};a.dispatch=r.dispatch(a);return a};R.maps=[];R.add=function(d){for(var h=0;hB;A--){q.insertBefore(C[-1],K);q.insertBefore(C[2],C[-4]);for(var j=C[2],o=2;o>-4;)C[o]=C[--o];C[o]=j}}function e(){function B(N){var H=N.zoom,T=H<0?1:1<< -H,U=N.column%T,y=N.row;if(U<0)U+=T;return{locationPoint:function(D){D=r.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:s.x*(G*D.column-U),y:s.y*(G*D.row-y)}}}}function K(N,H,T){var U=I.zoom,y=2-S,D=4+S;for(N=N;N>Q,row:T>>Q,zoom:U-Q}))&&P.ready){O[P.key]=g.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}O[G.key]=G}}var j=c.map(),o=j.zoom(),x=o-(o=Math.round(o)),f=j.size(),u=j.angle(),s=j.tileSize(),z=j.locationCoordinate(j.center());if(A!=o){if(Ao)m(o);else A=o;for(var v=-4;v<=2;v++){var L=C[v];L.setAttribute("class","zoom"+(v<0?"":"+")+v+" zoom"+(o+v));L.setAttribute("transform","scale("+Math.pow(2, --v)+")")}}q.setAttribute("transform","translate("+f.x/2+","+f.y/2+")"+(u?"rotate("+u/Math.PI*180+")":"")+(x?"scale("+Math.pow(2,x)+")":"")+(w?w.zoomFraction(x):""));var I=j.pointCoordinate(z,Y);v=j.pointCoordinate(z,{x:f.x,y:0});o=j.pointCoordinate(z,f);j=j.pointCoordinate(z,{x:0,y:f.y});if(!x&&!u&&!w){z.column=(Math.round(s.x*z.column)+(f.x&1)/2)/s.x;z.row=(Math.round(s.y*z.row)+(f.y&1)/2)/s.y}if(w){I=w.unapply(I);v=w.unapply(v);o=w.unapply(o);j=w.unapply(j);z=w.unapply(z)}var S=n?n(I.zoom)-I.zoom: -0;if(S){f=Math.pow(2,S);I.column*=f;I.row*=f;v.column*=f;v.row*=f;o.column*=f;o.row*=f;j.column*=f;j.row*=f;I.zoom=v.zoom=o.zoom=j.zoom+=S}x=g.locks();var O={};for(var F in x)x[F].proxyCount=0;if(t&&S>-5&&S<3){u=I.zoom<0?1:1<>v<>v<=1;E--)C[E]=q.appendChild(r.svg("g"));C[0]=q.appendChild(r.svg("g"));c.map=function(B){if(!arguments.length)return i;if(i){if(i==B){q.parentNode.appendChild(q);return c}i.off("move",e).off("resize",e);q.parentNode.removeChild(q)}if(i=B){i.container().appendChild(q);c.init&&c.init(q);i.on("move",e).on("resize",e);e()}return c};c.container=function(){return q};c.levels=function(){return C};c.id=function(B){if(!arguments.length)return l;l=B;q.setAttribute("id",B);return c};c.visible=function(B){if(!arguments.length)return t; -(t=B)?q.removeAttribute("visibility"):q.setAttribute("visibility","hidden");i&&e();return c};c.transform=function(B){if(!arguments.length)return w;w=B;i&&e();return c};c.zoom=function(B){if(!arguments.length)return n;n=typeof B=="function"||B==null?B:function(){return B};i&&e();return c};c.tile=function(B){if(!arguments.length)return k;k=B;i&&e();return c};c.reload=function(){g.clear();i&&e();return c};c.dispatch=r.dispatch(c);c.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var j= -B.tile.proxyRefs[K];--j.proxyCount<=0&&g.unload(K)&&j.element.parentNode.removeChild(j.element)}delete B.tile.proxyRefs}});return c};r.image=function(){var d=r.layer(function(a){var m=a.element=r.svg("image"),e=d.map().tileSize();m.setAttribute("preserveAspectRatio","none");m.setAttribute("width",e.x);m.setAttribute("height",e.y);if(typeof h=="function"){m.setAttribute("opacity",0);e=h(a);if(e!=null)a.request=r.queue.image(m,e,function(c){delete a.request;a.ready=true;a.img=c;m.removeAttribute("opacity"); -d.dispatch({type:"load",tile:a})});else{a.ready=true;d.dispatch({type:"load",tile:a})}}else{a.ready=true;h!=null&&m.setAttributeNS(r.ns.xlink,"href",h);d.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),h;d.url=function(a){if(!arguments.length)return h;h=typeof a=="string"&&/{.}/.test(a)?r.url(a):a;return d.reload()};return d};r.geoJson=function(d){function h(j){var o={lat:0,lon:0};return function(x){o.lat=x[1];o.lon=x[0];var f=j(o);x.x=f.x;x.y=f.y;return f}}function a(j, -o){return j&&j.type in C&&C[j.type](j,o)}function m(j,o,x){return j.type in E&&E[j.type](j,o,x)}function e(){var j=c.map().zoom(),o=c.cache.locks(),x,f,u,s,z,v,L;if(w=="fixed")for(x in o){if((f=o[x]).scale!=j){L="scale("+Math.pow(2,f.zoom-j)+")";s=-1;for(z=(u=f.features).length;++s -200){q=q>0?+1:-1;m=w}else q=0}if(q)switch(c){case "mouse":w=k.mouse(i);g||(g=k.pointLocation(w));k.off("move",d).zoomBy(q,w,g).on("move",d);break;case "location":k.zoomBy(q,k.locationPoint(g),g);break;default:k.zoomBy(q);break}i.preventDefault();return false}var a={},m=0,e=true,c="mouse",g,k,t,n=document.createElement("div"),l=document.createElement("div");l.style.visibility="hidden";l.style.top="0px";l.style.height="0px";l.style.width="0px";l.style.overflowY="scroll";n.style.height="2000px";l.appendChild(n); -document.body.appendChild(l);a.smooth=function(i){if(!arguments.length)return e;e=i;return a};a.zoom=function(i,q){if(!arguments.length)return c;c=i;g=q;if(k)c=="mouse"?k.on("move",d):k.off("move",d);return a};a.map=function(i){if(!arguments.length)return k;if(k){t.removeEventListener("mousemove",d,false);t.removeEventListener("mousewheel",h,false);t.removeEventListener("MozMousePixelScroll",h,false);t=null;k.off("move",d)}if(k=i){c=="mouse"&&k.on("move",d);t=k.container();t.addEventListener("mousemove", -d,false);t.addEventListener("mousewheel",h,false);t.addEventListener("MozMousePixelScroll",h,false)}return a};return a};r.arrow=function(){function d(w){if(!(w.ctrlKey||w.altKey||w.metaKey)){var A=Date.now(),C=0,E=0;switch(w.keyCode){case 37:if(!c.left){g=A;c.left=1;c.right||(C=l)}break;case 39:if(!c.right){g=A;c.right=1;c.left||(C=-l)}break;case 38:if(!c.up){g=A;c.up=1;c.down||(E=l)}break;case 40:if(!c.down){g=A;c.down=1;c.up||(E=-l)}break;default:return}if(C||E)i.panBy({x:C,y:E});if(!k&&c.left| -c.right|c.up|c.down)k=setInterval(m,n);w.preventDefault()}}function h(w){g=Date.now();switch(w.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(k&&!(c.left|c.right|c.up|c.down))k=clearInterval(k);w.preventDefault()}function a(w){switch(w.charCode){case 45:case 95:i.zoom(Math.ceil(i.zoom())-1);break;case 43:case 61:i.zoom(Math.floor(i.zoom())+1);break;default:return}w.preventDefault()}function m(){if(i)if(!(Date.now()x+f&&H.panBy(S)}function a(y){if(y.shiftKey){F={x0:H.mouse(y)};H.focusableParent().focus();return l(y)}}function m(y){if(F){F.x1=H.mouse(y);N.setAttribute("x", -Math.min(F.x0.x,F.x1.x));N.setAttribute("y",Math.min(F.x0.y,F.x1.y));N.setAttribute("width",Math.abs(F.x0.x-F.x1.x));N.setAttribute("height",Math.abs(F.x0.y-F.x1.y));N.removeAttribute("display")}}function e(){B.setAttribute("class","compass");if(F){if(F.x1){H.extent([H.pointLocation({x:Math.min(F.x0.x,F.x1.x),y:Math.max(F.x0.y,F.x1.y)}),H.pointLocation({x:Math.max(F.x0.x,F.x1.x),y:Math.min(F.x0.y,F.x1.y)})]);N.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function c(y){return function(){y? -this.setAttribute("class","active"):this.removeAttribute("class");S=y}}function g(y){return function(D){B.setAttribute("class","compass active");var G=H.zoom();H.zoom(y<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function k(y){return function(D){H.zoom(y);return l(D)}}function t(){this.setAttribute("class","active")}function n(){this.removeAttribute("class")}function l(y){y.stopPropagation();y.preventDefault();return false}function i(y){var D=Math.SQRT1_2*j,G=j*0.7,J=j*0.2,M=r.svg("g"),P=M.appendChild(r.svg("path")), -Q=M.appendChild(r.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d","M0,0L"+D+","+D+"A"+j+","+j+" 0 0,1 "+-D+","+D+"Z");Q.setAttribute("class","chevron");Q.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));Q.setAttribute("pointer-events","none");M.addEventListener("mousedown",d,false);M.addEventListener("mouseover",c(y),false);M.addEventListener("mouseout",c(null),false);M.addEventListener("dblclick",l,false);return M}function q(y){var D= -j*0.4,G=D/2,J=r.svg("g"),M=J.appendChild(r.svg("path")),P=J.appendChild(r.svg("path")),Q=J.appendChild(r.svg("path")),X=J.appendChild(r.svg("path"));M.setAttribute("class","back");M.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",M.getAttribute("d"));Q.setAttribute("class","chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(y>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d", -M.getAttribute("d"));J.addEventListener("mousedown",g(y),false);J.addEventListener("mouseover",t,false);J.addEventListener("mouseout",n,false);J.addEventListener("dblclick",l,false);return J}function w(y){var D=j*0.2,G=j*0.4,J=r.svg("g"),M=J.appendChild(r.svg("rect")),P=J.appendChild(r.svg("path"));M.setAttribute("pointer-events","all");M.setAttribute("fill","none");M.setAttribute("x",-G);M.setAttribute("y",-0.75*G);M.setAttribute("width",2*G);M.setAttribute("height",1.5*G);P.setAttribute("class", -"chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",k(y),false);J.addEventListener("dblclick",l,false);return J}function A(){var y=j+6,D=y,G=H.size();switch(s){case "top-left":break;case "top-right":y=G.x-y;break;case "bottom-left":D=G.y-D;break;case "bottom-right":y=G.x-y;D=G.y-D;break}B.setAttribute("transform","translate("+y+","+D+")");N.setAttribute("transform","translate("+-y+","+-D+")");for(var J in K)J==H.zoom()?K[J].setAttribute("class","active"):K[J].removeAttribute("class")} -function C(){for(;B.lastChild;)B.removeChild(B.lastChild);B.appendChild(N);if(L!="none"){O=B.appendChild(r.svg("g"));O.setAttribute("class","pan");var y=O.appendChild(r.svg("circle"));y.setAttribute("class","back");y.setAttribute("r",j);O.appendChild(i({x:0,y:-o})).setAttribute("transform","rotate(0)");O.appendChild(i({x:o,y:0})).setAttribute("transform","rotate(90)");O.appendChild(i({x:0,y:o})).setAttribute("transform","rotate(180)");O.appendChild(i({x:-o,y:0})).setAttribute("transform","rotate(270)"); -y=O.appendChild(r.svg("circle"));y.setAttribute("fill","none");y.setAttribute("class","fore");y.setAttribute("r",j)}else O=null;if(z!="none"){v=B.appendChild(r.svg("g"));v.setAttribute("class","zoom");y=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(y=0;D<=H.zoomRange()[1];D++,y++)(K[D]=v.appendChild(w(D))).setAttribute("transform","translate(0,"+-(y+0.75)*j*0.4+")")}D=L=="none"?0.4:2;v.setAttribute("transform","translate(0,"+j*(/^top-/.test(s)?D+(y+0.5)*0.4:-D)+")");v.appendChild(q(+1)).setAttribute("transform", -"translate(0,"+-(y+0.5)*j*0.4+")");v.appendChild(q(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E={},B=r.svg("g"),K={},j=30,o=16,x=0,f=250,u=50,s="top-left",z="small",v,L="small",I,S,O,F,N=r.svg("rect"),H,T,U;B.setAttribute("class","compass");N.setAttribute("class","back fore");N.setAttribute("pointer-events","none");N.setAttribute("display","none");E.radius=function(y){if(!arguments.length)return j;j=y;H&&C();return E};E.speed=function(y){if(!arguments.length)return j;o=y;return E}; -E.position=function(y){if(!arguments.length)return s;s=y;H&&C();return E};E.pan=function(y){if(!arguments.length)return L;L=y;H&&C();return E};E.zoom=function(y){if(!arguments.length)return z;z=y;H&&C();return E};E.map=function(y){if(!arguments.length)return H;if(H){T.removeEventListener("mousedown",a,false);T.removeChild(B);T=null;U.removeEventListener("mousemove",m,false);U.removeEventListener("mouseup",e,false);U=null;H.off("move",A).off("resize",A)}if(H=y){T=H.container();T.appendChild(B);T.addEventListener("mousedown", -a,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",m,false);U.addEventListener("mouseup",e,false);H.on("move",A).on("resize",A);C()}return E};return E};r.grid=function(){function d(){var e=m.firstChild,c=a.size(),g=a.pointLocation(Y);a.pointLocation(c);var k=Math.pow(2,4-Math.round(a.zoom()));g.lat=Math.floor(g.lat/k)*k;g.lon=Math.ceil(g.lon/k)*k;for(var t;(t=a.locationPoint(g).x)<=c.x;g.lon+=k){e||(e=m.appendChild(r.svg("line")));e.setAttribute("x1",t);e.setAttribute("x2",t);e.setAttribute("y1", -0);e.setAttribute("y2",c.y);e=e.nextSibling}for(;(t=a.locationPoint(g).y)<=c.y;g.lat-=k){e||(e=m.appendChild(r.svg("line")));e.setAttribute("y1",t);e.setAttribute("y2",t);e.setAttribute("x1",0);e.setAttribute("x2",c.x);e=e.nextSibling}for(;e;){c=e.nextSibling;m.removeChild(e);e=c}}var h={},a,m=r.svg("g");m.setAttribute("class","grid");h.map=function(e){if(!arguments.length)return a;if(a){m.parentNode.removeChild(m);a.off("move",d).off("resize",d)}if(a=e){a.on("move",d).on("resize",d);a.container().appendChild(m); -a.dispatch({type:"move"})}return h};return h};r.stylist=function(){function d(e){var c=e.features.length,g=h.length,k=a.length,t,n,l,i,q,w;for(q=0;qg.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 ea(d,g,a,l,e){a=Math.max(a,Math.floor(g.y0)); +l=Math.min(l,Math.ceil(g.y1));if(d.x0==g.x0&&d.y0==g.y0?d.x0+g.dy/d.dy*d.dx0,u=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&&ea(d,f,l,e,c);g.dy&&ea(d,g,l,e,c)}t.version="2.5.0"; +var $={x:0,y:0};t.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};t.id=function(){var d=0;return function(){return++d}}();t.svg=function(d){return document.createElementNS(t.ns.svg,d)};t.transform=function(d,g,a,l,e,c){var f={},j,u,n;if(!arguments.length){d=1;g=e=a=0;l=1;c=0}f.zoomFraction=function(k){if(!arguments.length)return u;u=k;j=Math.floor(u+Math.log(Math.sqrt(d*d+g*g+a*a+l*l))/Math.LN2);n=Math.pow(2,-j);return f};f.apply=function(k){var h=Math.pow(2,-k.zoom),q= +Math.pow(2,k.zoom-j);return{column:(d*k.column*h+a*k.row*h+e)*q,row:(g*k.column*h+l*k.row*h+c)*q,zoom:k.zoom-j}};f.unapply=function(k){var h=Math.pow(2,-k.zoom),q=Math.pow(2,k.zoom+j);return{column:(k.column*h*l-k.row*h*a-e*l+c*a)/(d*l-g*a)*q,row:(k.column*h*g-k.row*h*d-e*g+c*d)/(a*g-l*d)*q,zoom:k.zoom+j}};f.toString=function(){return"matrix("+[d*n,g*n,a*n,l*n].join(" ")+" 0 0)"};return f.zoomFraction(0)};t.cache=function(d,g){function a(h){k--;g&&g(h);delete f[h.key];if(h.next)h.next.prev=h.prev; +else if(u=h.prev)u.next=null;if(h.prev)h.prev.next=h.next;else if(j=h.next)j.prev=null}function l(){for(var h=u;k>n;h=h.prev){if(!h)break;h.lock||a(h)}}var e={},c={},f={},j=null,u=null,n=64,k=0;e.peek=function(h){return f[[h.zoom,h.column,h.row].join("/")]};e.load=function(h,q){var w=[h.zoom,h.column,h.row].join("/"),A=f[w];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else u=A.prev;A.prev=null;A.next=j;j=j.prev=A}A.lock=1;return c[w]=A}A={key:w,column:h.column,row:h.row,zoom:h.zoom,next:j, +prev:null,lock:1};d.call(null,A,q);c[w]=f[w]=A;if(j)j.prev=A;else u=A;j=A;k++;return A};e.unload=function(h){if(!(h in c))return false;var q=c[h];q.lock=0;delete c[h];q.request&&q.request.abort(false)&&a(q);return q};e.locks=function(){return c};e.size=function(h){if(!arguments.length)return n;n=h;l();return e};e.flush=function(){l();return e};e.clear=function(){for(var h in f){var q=f[h];q.request&&q.request.abort(false);g&&g(f[h]);if(q.lock){q.lock=0;q.element.parentNode.removeChild(q.element)}}c= +{};f={};j=u=null;k=0;return e};return e};t.url=function(d){function g(e){var c=e.zoom<0?1:1<=c)return null;return d.replace(/{(.)}/g,function(j,u){switch(u){case "S":return a[(Math.abs(e.zoom)+e.row+f)%a.length];case "Z":return e.zoom;case "X":return f;case "Y":return e.row;case "B":var n=t.map.coordinateLocation({row:e.row,column:f,zoom:e.zoom}),k=t.map.coordinateLocation({row:e.row+1,column:f+1,zoom:e.zoom}),h=Math.ceil(Math.log(e.zoom)/ +Math.LN2);return k.lat.toFixed(h)+","+n.lon.toFixed(h)+","+n.lat.toFixed(h)+","+k.lon.toFixed(h)}return u})}var a=[],l=true;g.template=function(e){if(!arguments.length)return d;d=e;return g};g.hosts=function(e){if(!arguments.length)return a;a=e;return g};g.repeat=function(e){if(!arguments.length)return l;l=e;return g};return g};t.dispatch=function(d){var g={};d.on=function(a,l){for(var e=g[a]||(g[a]=[]),c=0;c=c||!l.length)){e++;l.pop()()}}function g(f){for(var j=0;jq[1])n=q[1];k=n-(n=Math.round(n));h=Math.pow(2,k)}function g(){if(r){var i=45/Math.pow(2,n+k-3),o=Math.max(Math.abs(D*f.x+A*f.y),Math.abs(C*f.x+F*f.y)),s=Y(L- +o*i/j.y);o=Y(m+o*i/j.y);u.lat=Math.max(s,Math.min(o,u.lat));s=Math.max(Math.abs(D*f.y+A*f.x),Math.abs(C*f.y+F*f.x));u.lon=Math.max(r[0].lon-s*i/j.x,Math.min(r[1].lon+s*i/j.x,u.lon))}}var a={},l,e,c=$,f=$,j={x:256,y:256},u={lat:37.76487,lon:-122.41948},n=12,k=0,h=1,q=[1,18],w=0,A=1,D=0,F=1,C=0,L=-180,m=180,r=[{lat:Y(L),lon:-Infinity},{lat:Y(m),lon:Infinity}];a.locationCoordinate=function(i){i=t.map.locationCoordinate(i);var o=Math.pow(2,n);i.column*=o;i.row*=o;i.zoom+=n;return i};a.coordinateLocation= +t.map.coordinateLocation;a.coordinatePoint=function(i,o){var s=Math.pow(2,n-o.zoom),z=Math.pow(2,n-i.zoom),B=(o.column*s-i.column*z)*j.x*h;s=(o.row*s-i.row*z)*j.y*h;return{x:f.x+A*B-D*s,y:f.y+D*B+A*s}};a.pointCoordinate=function(i,o){var s=Math.pow(2,n-i.zoom),z=(o.x-f.x)/h,B=(o.y-f.y)/h;return{column:i.column*s+(F*z-C*B)/j.x,row:i.row*s+(C*z+F*B)/j.y,zoom:n}};a.locationPoint=function(i){var o=Math.pow(2,n+k-3)/45,s=(i.lon-u.lon)*o*j.x;i=(Z(u.lat)-Z(i.lat))*o*j.y;return{x:f.x+A*s-D*i,y:f.y+D*s+A* +i}};a.pointLocation=function(i){var o=45/Math.pow(2,n+k-3),s=(i.x-f.x)*o;i=(i.y-f.y)*o;return{lon:u.lon+(F*s-C*i)/j.x,lat:Y(Z(u.lat)-(C*s+F*i)/j.y)}};var v=t.svg("rect");v.setAttribute("visibility","hidden");v.setAttribute("pointer-events","all");a.container=function(i){if(!arguments.length)return l;l=i;l.setAttribute("class","map");l.appendChild(v);return a.resize()};a.focusableParent=function(){for(var i=l;i;i=i.parentNode)if(i.tabIndex>=0)return i;return window};a.mouse=function(i){var o=(l.ownerSVGElement|| +l).createSVGPoint();if(ba<0&&(window.scrollX||window.scrollY)){var s=document.body.appendChild(t.svg("svg"));s.style.position="absolute";s.style.top=s.style.left="0px";var z=s.getScreenCTM();ba=!(z.f||z.e);document.body.removeChild(s)}if(ba){o.x=i.pageX;o.y=i.pageY}else{o.x=i.clientX;o.y=i.clientY}return o.matrixTransform(l.getScreenCTM().inverse())};a.size=function(i){if(!arguments.length)return c;e=i;return a.resize()};a.resize=function(){if(e){c=e;S.remove(a)}else{v.setAttribute("width","100%"); +v.setAttribute("height","100%");b=v.getBBox();c={x:b.width,y:b.height};S.add(a)}v.setAttribute("width",c.x);v.setAttribute("height",c.y);f={x:c.x/2,y:c.y/2};g();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 u;u=i;g();a.dispatch({type:"move"});return a};a.panBy=function(i){var o=45/Math.pow(2,n+k-3),s=i.x*o;i=i.y*o;return a.center({lon:u.lon+(C*i-F*s)/j.x,lat:Y(Z(u.lat)+ +(C*s+F*i)/j.y)})};a.centerRange=function(i){if(!arguments.length)return r;if(r=i){L=r[0].lat>-90?Z(r[0].lat):-Infinity;m=r[0].lat<90?Z(r[1].lat):Infinity}else{L=-Infinity;m=Infinity}g();a.dispatch({type:"move"});return a};a.zoom=function(i){if(!arguments.length)return n+k;n=i;d();return a.center(u)};a.zoomBy=function(i,o,s){if(arguments.length<2)return a.zoom(n+k+i);if(arguments.length<3)s=a.pointLocation(o);n=n+k+i;d();var z=a.locationPoint(s);return a.panBy({x:o.x-z.x,y:o.y-z.y})};a.zoomRange=function(i){if(!arguments.length)return q; +q=i;return a.zoom(n+k)};a.extent=function(i){if(!arguments.length)return[a.pointLocation({x:0,y:c.y}),a.pointLocation({x:c.x,y:0})];var o=a.locationPoint(i[0]),s=a.locationPoint(i[1]),z=Math.max((s.x-o.x)/c.x,(o.y-s.y)/c.y);o=a.pointLocation({x:(o.x+s.x)/2,y:(o.y+s.y)/2});n=n+k-Math.log(z)/Math.LN2;d();return a.center(o)};a.angle=function(i){if(!arguments.length)return w;w=i;A=Math.cos(w);D=Math.sin(w);F=Math.cos(-w);C=Math.sin(-w);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=t.dispatch(a);return a};S.maps=[];S.add=function(d){for(var g=0;gC;A--){q.insertBefore(D[-1],L);q.insertBefore(D[2],D[-4]);for(var m=D[2],r=2;r>-4;)D[r]=D[--r];D[r]=m}}function e(){function C(O){var x=O.zoom,E=x<0?1:1<< +x,H=O.column%E,J=O.row;if(H<0)H+=E;return{locationPoint:function(K){K=t.map.locationCoordinate(K);var P=Math.pow(2,x-K.zoom);return{x:z.x*(P*K.column-H),y:z.y*(P*K.row-J)}}}}function L(O,x,E){var H=M.zoom,J=2-Q,K=4+Q;for(O=O;O>V,row:E>>V,zoom:H-V}))&&U.ready){G[U.key]=f.load(W);U.proxyCount++;P.proxyRefs[U.key]=U;break}}G[P.key]=P}}function m(O){return Math.round(O*256)/256}var r=c.map(),v=r.zoom(),i=v-(v=Math.round(v)),o=r.size(),s=r.angle(),z=r.tileSize(),B=r.locationCoordinate(r.center());if(A!=v){if(Av)l(v);else A=v;for(var y=-4;y<=2;y++){var N=D[y];N.setAttribute("class","zoom"+(y<0?"":"+")+y+" zoom"+(v+ +y));N.setAttribute("transform","scale("+Math.pow(2,-y)+")")}}var M=r.pointCoordinate(B,$);y=r.pointCoordinate(B,{x:o.x,y:0});v=r.pointCoordinate(B,o);r=r.pointCoordinate(B,{x:0,y:o.y});N=B.column;var T=B.row;B.column=Math.round((Math.round(z.x*B.column)+(o.x&1)/2)/z.x);B.row=Math.round((Math.round(z.y*B.row)+(o.y&1)/2)/z.y);N-=B.column;T-=B.row;var I=m(Math.pow(2,i));q.setAttribute("transform","translate("+Math.round(o.x/2-N*z.x*I)+","+Math.round(o.y/2-T*z.y*I)+")"+(s?"rotate("+s/Math.PI*180+")": +"")+(i?"scale("+I+")":"")+(w?w.zoomFraction(i):""));if(w){M=w.unapply(M);y=w.unapply(y);v=w.unapply(v);r=w.unapply(r);B=w.unapply(B)}var Q=n?n(M.zoom)-M.zoom:0;if(Q){o=Math.pow(2,Q);M.column*=o;M.row*=o;y.column*=o;y.row*=o;v.column*=o;v.row*=o;r.column*=o;r.row*=o;M.zoom=y.zoom=v.zoom=r.zoom+=Q}i=f.locks();var G={};for(var R in i)i[R].proxyCount=0;if(u&&Q>-5&&Q<3){s=M.zoom<0?1:1<>y<>y<=1;F--)D[F]=q.appendChild(t.svg("g"));D[0]=q.appendChild(t.svg("g"));c.map=function(C){if(!arguments.length)return h;if(h){if(h==C){q.parentNode.appendChild(q);return c}h.off("move",e).off("resize",e);q.parentNode.removeChild(q)}if(h=C){h.container().appendChild(q);c.init&&c.init(q);h.on("move",e).on("resize",e);e()}return c}; +c.container=function(){return q};c.levels=function(){return D};c.id=function(C){if(!arguments.length)return k;k=C;q.setAttribute("id",C);return c};c.visible=function(C){if(!arguments.length)return u;(u=C)?q.removeAttribute("visibility"):q.setAttribute("visibility","hidden");h&&e();return c};c.transform=function(C){if(!arguments.length)return w;w=C;h&&e();return c};c.zoom=function(C){if(!arguments.length)return n;n=typeof C=="function"||C==null?C:function(){return C};h&&e();return c};c.tile=function(C){if(!arguments.length)return j; +j=C;h&&e();return c};c.reload=function(){f.clear();h&&e();return c};c.dispatch=t.dispatch(c);c.on("load",function(C){if(C.tile.proxyRefs){for(var L in C.tile.proxyRefs){var m=C.tile.proxyRefs[L];--m.proxyCount<=0&&f.unload(L)&&m.element.parentNode.removeChild(m.element)}delete C.tile.proxyRefs}});return c};t.image=function(){var d=t.layer(function(a){var l=a.element=t.svg("image"),e=d.map().tileSize();l.setAttribute("preserveAspectRatio","none");l.setAttribute("width",e.x);l.setAttribute("height", +e.y);if(typeof g=="function"){l.setAttribute("opacity",0);e=g(a);if(e!=null)a.request=t.queue.image(l,e,function(c){delete a.request;a.ready=true;a.img=c;l.removeAttribute("opacity");d.dispatch({type:"load",tile:a})});else{a.ready=true;d.dispatch({type:"load",tile:a})}}else{a.ready=true;g!=null&&l.setAttributeNS(t.ns.xlink,"href",g);d.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),g;d.url=function(a){if(!arguments.length)return g;g=typeof a=="string"&&/{.}/.test(a)? +t.url(a):a;return d.reload()};return d};t.geoJson=function(d){function g(m){var r={lat:0,lon:0};return function(v){r.lat=v[1];r.lon=v[0];var i=m(r);v.x=i.x;v.y=i.y;return i}}function a(m,r){return m&&m.type in D&&D[m.type](m,r)}function l(m,r,v){return m.type in F&&F[m.type](m,r,v)}function e(){var m=c.map().zoom(),r=c.cache.locks(),v,i,o,s,z,B,y;if(w=="fixed")for(v in r){if((i=r[v]).scale!=m){y="scale("+Math.pow(2,i.zoom-m)+")";s=-1;for(z=(o=i.features).length;++s200){q=q>0?+1:-1;l=w}else q=0}if(q)switch(c){case "mouse":w=j.mouse(h);f||(f=j.pointLocation(w));j.off("move",d).zoomBy(q,w,f).on("move",d);break;case "location":j.zoomBy(q,j.locationPoint(f),f);break;default:j.zoomBy(q);break}h.preventDefault();return false}var a={},l=0,e=true,c="mouse",f,j,u,n=document.createElement("div"),k=document.createElement("div"); +k.style.visibility="hidden";k.style.top="0px";k.style.height="0px";k.style.width="0px";k.style.overflowY="scroll";n.style.height="2000px";k.appendChild(n);document.body.appendChild(k);a.smooth=function(h){if(!arguments.length)return e;e=h;return a};a.zoom=function(h,q){if(!arguments.length)return c;c=h;f=q;if(j)c=="mouse"?j.on("move",d):j.off("move",d);return a};a.map=function(h){if(!arguments.length)return j;if(j){u.removeEventListener("mousemove",d,false);u.removeEventListener("mousewheel",g,false); +u.removeEventListener("MozMousePixelScroll",g,false);u=null;j.off("move",d)}if(j=h){c=="mouse"&&j.on("move",d);u=j.container();u.addEventListener("mousemove",d,false);u.addEventListener("mousewheel",g,false);u.addEventListener("MozMousePixelScroll",g,false)}return a};return a};t.arrow=function(){function d(w){if(!(w.ctrlKey||w.altKey||w.metaKey)){var A=Date.now(),D=0,F=0;switch(w.keyCode){case 37:if(!c.left){f=A;c.left=1;c.right||(D=k)}break;case 39:if(!c.right){f=A;c.right=1;c.left||(D=-k)}break; +case 38:if(!c.up){f=A;c.up=1;c.down||(F=k)}break;case 40:if(!c.down){f=A;c.down=1;c.up||(F=-k)}break;default:return}if(D||F)h.panBy({x:D,y:F});if(!j&&c.left|c.right|c.up|c.down)j=setInterval(l,n);w.preventDefault()}}function g(w){f=Date.now();switch(w.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);w.preventDefault()}function a(w){switch(w.charCode){case 45:case 95:h.zoom(Math.ceil(h.zoom())- +1);break;case 43:case 61:h.zoom(Math.floor(h.zoom())+1);break;default:return}w.preventDefault()}function l(){if(h)if(!(Date.now()v+i&&G.panBy(M)}function a(x){if(x.shiftKey){I={x0:G.mouse(x)}; +G.focusableParent().focus();return k(x)}}function l(x){if(I){I.x1=G.mouse(x);Q.setAttribute("x",Math.min(I.x0.x,I.x1.x));Q.setAttribute("y",Math.min(I.x0.y,I.x1.y));Q.setAttribute("width",Math.abs(I.x0.x-I.x1.x));Q.setAttribute("height",Math.abs(I.x0.y-I.x1.y));Q.removeAttribute("display")}}function e(){C.setAttribute("class","compass");if(I){if(I.x1){G.extent([G.pointLocation({x:Math.min(I.x0.x,I.x1.x),y:Math.max(I.x0.y,I.x1.y)}),G.pointLocation({x:Math.max(I.x0.x,I.x1.x),y:Math.min(I.x0.y,I.x1.y)})]); +Q.setAttribute("display","none")}I=null}if(N){clearInterval(N);N=0}}function c(x){return function(){x?this.setAttribute("class","active"):this.removeAttribute("class");M=x}}function f(x){return function(E){C.setAttribute("class","compass active");var H=G.zoom();G.zoom(x<0?Math.ceil(H)-1:Math.floor(H)+1);return k(E)}}function j(x){return function(E){G.zoom(x);return k(E)}}function u(){this.setAttribute("class","active")}function n(){this.removeAttribute("class")}function k(x){x.stopPropagation();x.preventDefault(); +return false}function h(x){var E=Math.SQRT1_2*m,H=m*0.7,J=m*0.2,K=t.svg("g"),P=K.appendChild(t.svg("path")),W=K.appendChild(t.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d","M0,0L"+E+","+E+"A"+m+","+m+" 0 0,1 "+-E+","+E+"Z");W.setAttribute("class","chevron");W.setAttribute("d","M"+J+","+(H-J)+"L0,"+H+" "+-J+","+(H-J));W.setAttribute("pointer-events","none");K.addEventListener("mousedown",d,false);K.addEventListener("mouseover",c(x),false); +K.addEventListener("mouseout",c(null),false);K.addEventListener("dblclick",k,false);return K}function q(x){var E=m*0.4,H=E/2,J=t.svg("g"),K=J.appendChild(t.svg("path")),P=J.appendChild(t.svg("path")),W=J.appendChild(t.svg("path")),X=J.appendChild(t.svg("path"));K.setAttribute("class","back");K.setAttribute("d","M"+-E+",0V"+-E+"A"+E+","+E+" 0 1,1 "+E+","+-E+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",K.getAttribute("d"));W.setAttribute("class","chevron");W.setAttribute("d","M"+-H+ +","+-E+"H"+H+(x>0?"M0,"+(-E-H)+"V"+-H:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",K.getAttribute("d"));J.addEventListener("mousedown",f(x),false);J.addEventListener("mouseover",u,false);J.addEventListener("mouseout",n,false);J.addEventListener("dblclick",k,false);return J}function w(x){var E=m*0.2,H=m*0.4,J=t.svg("g"),K=J.appendChild(t.svg("rect")),P=J.appendChild(t.svg("path"));K.setAttribute("pointer-events","all");K.setAttribute("fill","none");K.setAttribute("x", +-H);K.setAttribute("y",-0.75*H);K.setAttribute("width",2*H);K.setAttribute("height",1.5*H);P.setAttribute("class","chevron");P.setAttribute("d","M"+-E+",0H"+E);J.addEventListener("mousedown",j(x),false);J.addEventListener("dblclick",k,false);return J}function A(){var x=m+6,E=x,H=G.size();switch(s){case "top-left":break;case "top-right":x=H.x-x;break;case "bottom-left":E=H.y-E;break;case "bottom-right":x=H.x-x;E=H.y-E;break}C.setAttribute("transform","translate("+x+","+E+")");Q.setAttribute("transform", +"translate("+-x+","+-E+")");for(var J in L)J==G.zoom()?L[J].setAttribute("class","active"):L[J].removeAttribute("class")}function D(){for(;C.lastChild;)C.removeChild(C.lastChild);C.appendChild(Q);if(y!="none"){T=C.appendChild(t.svg("g"));T.setAttribute("class","pan");var x=T.appendChild(t.svg("circle"));x.setAttribute("class","back");x.setAttribute("r",m);T.appendChild(h({x:0,y:-r})).setAttribute("transform","rotate(0)");T.appendChild(h({x:r,y:0})).setAttribute("transform","rotate(90)");T.appendChild(h({x:0, +y:r})).setAttribute("transform","rotate(180)");T.appendChild(h({x:-r,y:0})).setAttribute("transform","rotate(270)");x=T.appendChild(t.svg("circle"));x.setAttribute("fill","none");x.setAttribute("class","fore");x.setAttribute("r",m)}else T=null;if(z!="none"){B=C.appendChild(t.svg("g"));B.setAttribute("class","zoom");x=-0.5;if(z=="big"){L={};var E=G.zoomRange()[0];for(x=0;E<=G.zoomRange()[1];E++,x++)(L[E]=B.appendChild(w(E))).setAttribute("transform","translate(0,"+-(x+0.75)*m*0.4+")")}E=y=="none"? +0.4:2;B.setAttribute("transform","translate(0,"+m*(/^top-/.test(s)?E+(x+0.5)*0.4:-E)+")");B.appendChild(q(+1)).setAttribute("transform","translate(0,"+-(x+0.5)*m*0.4+")");B.appendChild(q(-1)).setAttribute("transform","scale(-1)")}else B=null;A()}var F={},C=t.svg("g"),L={},m=30,r=16,v=0,i=250,o=50,s="top-left",z="small",B,y="small",N,M,T,I,Q=t.svg("rect"),G,R,O;C.setAttribute("class","compass");Q.setAttribute("class","back fore");Q.setAttribute("pointer-events","none");Q.setAttribute("display","none"); +F.radius=function(x){if(!arguments.length)return m;m=x;G&&D();return F};F.speed=function(x){if(!arguments.length)return m;r=x;return F};F.position=function(x){if(!arguments.length)return s;s=x;G&&D();return F};F.pan=function(x){if(!arguments.length)return y;y=x;G&&D();return F};F.zoom=function(x){if(!arguments.length)return z;z=x;G&&D();return F};F.map=function(x){if(!arguments.length)return G;if(G){R.removeEventListener("mousedown",a,false);R.removeChild(C);R=null;O.removeEventListener("mousemove", +l,false);O.removeEventListener("mouseup",e,false);O=null;G.off("move",A).off("resize",A)}if(G=x){R=G.container();R.appendChild(C);R.addEventListener("mousedown",a,false);O=R.ownerDocument.defaultView;O.addEventListener("mousemove",l,false);O.addEventListener("mouseup",e,false);G.on("move",A).on("resize",A);D()}return F};return F};t.grid=function(){function d(){var e=l.firstChild,c=a.size(),f=a.pointLocation($);a.pointLocation(c);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 u;(u=a.locationPoint(f).x)<=c.x;f.lon+=j){e||(e=l.appendChild(t.svg("line")));e.setAttribute("x1",u);e.setAttribute("x2",u);e.setAttribute("y1",0);e.setAttribute("y2",c.y);e=e.nextSibling}for(;(u=a.locationPoint(f).y)<=c.y;f.lat-=j){e||(e=l.appendChild(t.svg("line")));e.setAttribute("y1",u);e.setAttribute("y2",u);e.setAttribute("x1",0);e.setAttribute("x2",c.x);e=e.nextSibling}for(;e;){c=e.nextSibling;l.removeChild(e);e=c}}var g={},a,l=t.svg("g");l.setAttribute("class", +"grid");g.map=function(e){if(!arguments.length)return a;if(a){l.parentNode.removeChild(l);a.off("move",d).off("resize",d)}if(a=e){a.on("move",d).on("resize",d);a.container().appendChild(l);a.dispatch({type:"move"})}return g};return g};t.stylist=function(){function d(e){var c=e.features.length,f=g.length,j=a.length,u,n,k,h,q,w;for(q=0;q