Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add `parse` and `format` properties to `po.hash()`.

These can be used to override the default location hash formatting e.g.
to add other parameters.  As `parse` is called every time the location
hash changes, it can be used to detect other parameters at the same
time.
  • Loading branch information...
commit 012d0e4b9d55ebe436638f6d6ff409015b0f85f1 1 parent 1e3ea23
@jasondavies jasondavies authored
Showing with 109 additions and 69 deletions.
  1. +24 −4 polymaps.js
  2. +61 −61 polymaps.min.js
  3. +24 −4 src/Hash.js
View
28 polymaps.js
@@ -1763,19 +1763,27 @@ po.hash = function() {
lat = 90 - 1e-8, // allowable latitude range
map;
- function move() {
+ var parse = function(s) {
+ return s.split("/").map(Number);
+ };
+
+ var format = function(map) {
var center = map.center(),
zoom = map.zoom(),
- precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
- s1 = "#" + zoom.toFixed(2)
+ precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
+ return "#" + zoom.toFixed(2)
+ "/" + center.lat.toFixed(precision)
+ "/" + center.lon.toFixed(precision);
+ };
+
+ function move() {
+ var s1 = format(map);
if (s0 !== s1) location.replace(s0 = s1); // don't recenter the map!
}
function hashchange() {
if (location.hash === s0) return; // ignore spurious hashchange events
- var args = (s0 = location.hash).substring(1).split("/").map(Number);
+ var args = parse((s0 = location.hash).substring(1));
if (args.length < 3 || args.some(isNaN)) move(); // replace bogus hash
else {
var size = map.size();
@@ -1799,6 +1807,18 @@ po.hash = function() {
return hash;
};
+ hash.parse = function(x) {
+ if (!arguments.length) return parse;
+ parse = x;
+ return hash;
+ }
+
+ hash.format = function(x) {
+ if (!arguments.length) return format;
+ format = x;
+ return hash;
+ }
+
return hash;
};
// Default map controls.
View
122 polymaps.min.js
@@ -1,62 +1,62 @@
if(!org)var org={};if(!org.polymaps)org.polymaps={};
-(function(s){function fa(e){var g=e.indexOf(":");return g<0?e:{space:s.ns[e.substring(0,g)],local:e.substring(g+1)}}function S(){for(var e=0;e<S.maps.length;e++)S.maps[e].resize()}function V(e){return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function W(e){return 180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360))}function Z(e,g){if(e.row>g.row){var c=e;e=g;g=c}return{x0:e.column,y0:e.row,x1:g.column,y1:g.row,dx:g.column-e.column,dy:g.row-e.row}}function ca(e,g,c,k,i){c=Math.max(c,Math.floor(g.y0));
-k=Math.min(k,Math.ceil(g.y1));if(e.x0==g.x0&&e.y0==g.y0?e.x0+g.dy/e.dy*e.dx<g.x1:e.x1-g.dy/e.dy*e.dx<g.x0){var a=e;e=g;g=a}a=e.dx/e.dy;var f=g.dx/g.dy,m=e.dx>0,q=g.dx<0;for(c=c;c<k;c++){var t=a*Math.max(0,Math.min(e.dy,c+m-e.y0))+e.x0;i(Math.floor(f*Math.max(0,Math.min(g.dy,c+q-g.y0))+g.x0),Math.ceil(t),c)}}function da(e,g,c,k,i,a){var f=Z(e,g);g=Z(g,c);e=Z(c,e);if(f.dy>g.dy){c=f;f=g;g=c}if(f.dy>e.dy){c=f;f=e;e=c}if(g.dy>e.dy){c=g;g=e;e=c}f.dy&&ca(e,f,k,i,a);g.dy&&ca(e,g,k,i,a)}s.version="2.3.0";
-var Y={x:0,y:0};s.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};s.id=function(){var e=0;return function(){return++e}}();s.svg=function(e){return document.createElementNS(s.ns.svg,e)};s.transform=function(e,g,c,k,i,a){var f={},m,q,t;if(!arguments.length){e=1;g=i=c=0;k=1;a=0}f.zoomFraction=function(l){if(!arguments.length)return q;q=l;m=Math.floor(q+Math.log(Math.sqrt(e*e+g*g+c*c+k*k))/Math.log(2));t=Math.pow(2,-m);return f};f.apply=function(l){var j=Math.pow(2,-l.zoom),
-u=Math.pow(2,l.zoom-m);return{column:(e*l.column*j+c*l.row*j+i)*u,row:(g*l.column*j+k*l.row*j+a)*u,zoom:l.zoom-m}};f.unapply=function(l){var j=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+m);return{column:(l.column*j*k-l.row*j*c-i*k+a*c)/(e*k-g*c)*u,row:(l.column*j*g-l.row*j*e-i*g+a*e)/(c*g-k*e)*u,zoom:l.zoom+m}};f.toString=function(){return"matrix("+[e*t,g*t,c*t,k*t].join(" ")+" 0 0)"};return f.zoomFraction(0)};s.cache=function(e,g){function c(j){l--;g&&g(j);delete f[j.key];if(j.next)j.next.prev=j.prev;
-else if(q=j.prev)q.next=null;if(j.prev)j.prev.next=j.next;else if(m=j.next)m.prev=null}function k(){for(var j=q;l>t;j=j.prev){if(!j)break;j.lock||c(j)}}var i={},a={},f={},m=null,q=null,t=64,l=0;i.peek=function(j){return f[[j.zoom,j.column,j.row].join("/")]};i.load=function(j,u){var y=[j.zoom,j.column,j.row].join("/"),A=f[y];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else q=A.prev;A.prev=null;A.next=m;m=m.prev=A}A.lock=1;return a[y]=A}A={key:y,column:j.column,row:j.row,zoom:j.zoom,next:m,
-prev:null,lock:1};e.call(null,A,u);a[y]=f[y]=A;if(m)m.prev=A;else q=A;m=A;l++;return A};i.unload=function(j){if(!(j in a))return false;var u=a[j];u.lock=0;delete a[j];u.request&&u.request.abort(false)&&c(u);return u};i.locks=function(){return a};i.size=function(j){if(!arguments.length)return t;t=j;k();return i};i.flush=function(){k();return i};i.clear=function(){for(var j in f){var u=f[j];u.request&&u.request.abort(false);g&&g(f[j]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
-{};f={};m=q=null;l=0;return i};return i};s.url=function(e){function g(k){var i=k.zoom<0?1:1<<k.zoom,a=k.column%i;if(a<0)a+=i;return e.replace(/{(.)}/g,function(f,m){switch(m){case "S":return c[(Math.abs(k.zoom)+k.row+a)%c.length];case "Z":return k.zoom;case "X":return a;case "Y":return k.row;case "B":var q=s.map.coordinateLocation({row:k.row,column:a,zoom:k.zoom}),t=s.map.coordinateLocation({row:k.row+1,column:a+1,zoom:k.zoom}),l=Math.ceil(Math.log(k.zoom)/Math.LN2);return t.lat.toFixed(l)+","+q.lon.toFixed(l)+
-","+q.lat.toFixed(l)+","+t.lon.toFixed(l)}return m})}var c=[];g.template=function(k){if(!arguments.length)return e;e=k;return g};g.hosts=function(k){if(!arguments.length)return c;c=k;return g};return g};s.dispatch=function(e){var g={};e.on=function(c,k){for(var i=g[c]||(g[c]=[]),a=0;a<i.length;a++)if(i[a].handler==k)return e;i.push({handler:k,on:true});return e};e.off=function(c,k){var i=g[c];if(i)for(var a=0;a<i.length;a++){var f=i[a];if(f.handler==k){f.on=false;i.splice(a,1);break}}return e};return function(c){var k=
-g[c.type];if(k){k=k.slice();for(var i=0;i<k.length;i++){var a=k[i];a.on&&a.handler.call(e,c)}}}};s.queue=function(){function e(){if(!(i>=a||!k.length)){i++;k.pop()()}}function g(f){for(var m=0;m<k.length;m++)if(k[m]==f){k.splice(m,1);return true}return false}function c(f,m,q){function t(){l=new XMLHttpRequest;q&&l.overrideMimeType(q);l.open("GET",f,true);l.onreadystatechange=function(){if(l.readyState==4){i--;l.status<300&&m(l);e()}};l.send(null)}var l;k.push(t);e();return{abort:function(j){if(g(t))return true;
-if(j&&l){l.abort();return true}return false}}}var k=[],i=0,a=6;return{text:function(f,m,q){return c(f,function(t){t.responseText&&m(t.responseText)},q)},xml:function(f,m){return c(f,function(q){q.responseXML&&m(q.responseXML)},"application/xml")},json:function(f,m){return c(f,function(q){q.responseText&&m(JSON.parse(q.responseText))},"application/json")},image:function(f,m,q){function t(){l=document.createElement("img");l.onerror=function(){i--;e()};l.onload=function(){i--;q(l);e()};l.src=m;f.setAttributeNS(s.ns.xlink,
-"href",m)}var l;k.push(t);e();return{abort:function(j){if(g(t))return true;if(j&&l){l.src="about:";return true}return false}}}}}();s.map=function(){function e(){if(u)if(t<u[0])t=u[0];else if(t>u[1])t=u[1];l=t-(t=Math.round(t));j=Math.pow(2,l)}function g(){if(n){var d=45/Math.pow(2,t+l-3),r=Math.max(Math.abs(C*f.x+A*f.y),Math.abs(B*f.x+E*f.y)),o=V(K-r*d/m.y);r=V(h+r*d/m.y);q.lat=Math.max(o,Math.min(r,q.lat));o=Math.max(Math.abs(C*f.y+A*f.x),Math.abs(B*f.y+E*f.x));q.lon=Math.max(n[0].lon-o*d/m.x,Math.min(n[1].lon+
-o*d/m.x,q.lon))}}var c={},k,i,a=Y,f=Y,m={x:256,y:256},q={lat:37.76487,lon:-122.41948},t=12,l=0,j=1,u=[1,18],y=0,A=1,C=0,E=1,B=0,K=-180,h=180,n=[{lat:V(K),lon:-Infinity},{lat:V(h),lon:Infinity}];c.locationCoordinate=function(d){d=s.map.locationCoordinate(d);var r=Math.pow(2,t);d.column*=r;d.row*=r;d.zoom+=t;return d};c.coordinateLocation=s.map.coordinateLocation;c.coordinatePoint=function(d,r){var o=Math.pow(2,t-r.zoom),z=Math.pow(2,t-d.zoom),v=(r.column*o-d.column*z)*m.x*j;o=(r.row*o-d.row*z)*m.y*
-j;return{x:f.x+A*v-C*o,y:f.y+C*v+A*o}};c.pointCoordinate=function(d,r){var o=Math.pow(2,t-d.zoom),z=(r.x-f.x)/j,v=(r.y-f.y)/j;return{column:d.column*o+(E*z-B*v)/m.x,row:d.row*o+(B*z+E*v)/m.y,zoom:t}};c.locationPoint=function(d){var r=Math.pow(2,t+l-3)/45,o=(d.lon-q.lon)*r*m.x;d=(W(q.lat)-W(d.lat))*r*m.y;return{x:f.x+A*o-C*d,y:f.y+C*o+A*d}};c.pointLocation=function(d){var r=45/Math.pow(2,t+l-3),o=(d.x-f.x)*r;d=(d.y-f.y)*r;return{lon:q.lon+(E*o-B*d)/m.x,lat:V(W(q.lat)-(B*o+E*d)/m.y)}};var w=s.svg("rect");
-w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(d){if(!arguments.length)return k;k=d;k.setAttribute("class","map");k.appendChild(w);return c.resize()};c.focusableParent=function(){for(var d=k;d;d=d.parentNode)if(d.tabIndex>=0)return d;return window};c.mouse=function(d){var r=(k.ownerSVGElement||k).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var o=document.body.appendChild(s.svg("svg"));o.style.position="absolute";o.style.top=o.style.left=
-"0px";var z=o.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(o)}if($){r.x=d.pageX;r.y=d.pageY}else{r.x=d.clientX;r.y=d.clientY}return r.matrixTransform(k.getScreenCTM().inverse())};c.size=function(d){if(!arguments.length)return a;i=d;return c.resize()};c.resize=function(){if(i){a=i;S.remove(c)}else{w.setAttribute("width","100%");w.setAttribute("height","100%");b=w.getBBox();a={x:b.width,y:b.height};S.add(c)}w.setAttribute("width",a.x);w.setAttribute("height",a.y);f={x:a.x/2,y:a.y/2};g();c.dispatch({type:"resize"});
-return c};c.tileSize=function(d){if(!arguments.length)return m;m=d;c.dispatch({type:"move"});return c};c.center=function(d){if(!arguments.length)return q;q=d;g();c.dispatch({type:"move"});return c};c.panBy=function(d){var r=45/Math.pow(2,t+l-3),o=d.x*r;d=d.y*r;return c.center({lon:q.lon+(B*d-E*o)/m.x,lat:V(W(q.lat)+(B*o+E*d)/m.y)})};c.centerRange=function(d){if(!arguments.length)return n;if(n=d){K=n[0].lat>-90?W(n[0].lat):-Infinity;h=n[0].lat<90?W(n[1].lat):Infinity}else{K=-Infinity;h=Infinity}g();
-c.dispatch({type:"move"});return c};c.zoom=function(d){if(!arguments.length)return t+l;t=d;e();return c.center(q)};c.zoomBy=function(d,r,o){if(arguments.length<2)return c.zoom(t+l+d);if(arguments.length<3)o=c.pointLocation(r);t=t+l+d;e();var z=c.locationPoint(o);return c.panBy({x:r.x-z.x,y:r.y-z.y})};c.zoomRange=function(d){if(!arguments.length)return u;u=d;return c.zoom(t+l)};c.extent=function(d){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var r=c.locationPoint(d[0]),
-o=c.locationPoint(d[1]),z=Math.max((o.x-r.x)/a.x,(r.y-o.y)/a.y);r=c.pointLocation({x:(r.x+o.x)/2,y:(r.y+o.y)/2});t=t+l-Math.log(z)/Math.log(2);e();return c.center(r)};c.angle=function(d){if(!arguments.length)return y;y=d;A=Math.cos(y);C=Math.sin(y);E=Math.cos(-y);B=Math.sin(-y);g();c.dispatch({type:"move"});return c};c.add=function(d){d.map(c);return c};c.remove=function(d){d.map(null);return c};c.dispatch=s.dispatch(c);return c};S.maps=[];S.add=function(e){for(var g=0;g<S.maps.length;g++)if(S.maps[g]==
-e)return;S.maps.push(e)};S.remove=function(e){for(var g=0;g<S.maps.length;g++)if(S.maps[g]==e){S.maps.splice(g,1);return}};window.addEventListener("resize",S,false);s.map.locationCoordinate=function(e){var g=1/360;return{column:(e.lon+180)*g,row:(180-W(e.lat))*g,zoom:0}};s.map.coordinateLocation=function(e){var g=45/Math.pow(2,e.zoom-3);return{lon:g*e.column-180,lat:V(180-g*e.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;s.layer=function(e,g){function c(B){for(var K=C[0].nextSibling;A<B;A++){u.insertBefore(C[-4],
-K);u.insertBefore(C[2],K);u.insertBefore(C[1],K);for(var h=C[-4],n=-4;n<2;)C[n]=C[++n];C[n]=h}}function k(B){for(var K=C[0].nextSibling;A>B;A--){u.insertBefore(C[-1],K);u.insertBefore(C[2],C[-4]);for(var h=C[2],n=2;n>-4;)C[n]=C[--n];C[n]=h}}function i(){function B(O){var H=O.zoom,T=H<0?1:1<<H,U=O.column%T,x=O.row;if(U<0)U+=T;return{locationPoint:function(D){D=s.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:o.x*(G*D.column-U),y:o.y*(G*D.row-x)}}}}function K(O,H,T){var U=I.zoom,x=2-
-R,D=4+R;for(O=O;O<H;O++){var G=f.load({column:O,row:T,zoom:U},B);if(!G.ready&&!(G.key in M)){G.proxyRefs={};for(var J,N,P,Q=1;Q<=x;Q++){N=true;for(var X=0,ea=1<<Q;X<=ea;X++)for(var aa=0;aa<=ea;aa++)if((P=f.peek(J={column:(O<<Q)+aa,row:(T<<Q)+X,zoom:U+Q}))&&P.ready){M[P.key]=f.load(J);P.proxyCount++;G.proxyRefs[P.key]=P}else N=false;if(N)break}if(!N)for(Q=1;Q<=D;Q++)if((P=f.peek(J={column:O>>Q,row:T>>Q,zoom:U-Q}))&&P.ready){M[P.key]=f.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}M[G.key]=G}}
-var h=a.map(),n=h.zoom(),w=n-(n=Math.round(n)),d=h.size(),r=h.angle(),o=h.tileSize(),z=h.locationCoordinate(h.center());if(A!=n){if(A<n)c(n);else if(A>n)k(n);else A=n;for(var v=-4;v<=2;v++){var L=C[v];L.setAttribute("class","zoom"+(v<0?"":"+")+v+" zoom"+(n+v));L.setAttribute("transform","scale("+Math.pow(2,-v)+")")}}u.setAttribute("transform","translate("+d.x/2+","+d.y/2+")"+(r?"rotate("+r/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(y?y.zoomFraction(w):""));var I=h.pointCoordinate(z,Y);
-v=h.pointCoordinate(z,{x:d.x,y:0});n=h.pointCoordinate(z,d);h=h.pointCoordinate(z,{x:0,y:d.y});if(!w&&!r&&!y){z.column=(Math.round(o.x*z.column)+(d.x&1)/2)/o.x;z.row=(Math.round(o.y*z.row)+(d.y&1)/2)/o.y}if(y){I=y.unapply(I);v=y.unapply(v);n=y.unapply(n);h=y.unapply(h);z=y.unapply(z)}var R=t?t(I.zoom)-I.zoom:0;if(R){d=Math.pow(2,R);I.column*=d;I.row*=d;v.column*=d;v.row*=d;n.column*=d;n.row*=d;h.column*=d;h.row*=d;I.zoom=v.zoom=n.zoom=h.zoom+=R}w=f.locks();var M={};for(var F in w)w[F].proxyCount=
-0;if(q&&R>-5&&R<3){r=I.zoom<0?1:1<<I.zoom;if(m){da(I,v,n,0,r,K);da(n,h,I,0,r,K)}else{d=Math.floor((I.column+n.column)/2);r=Math.max(0,Math.min(r-1,Math.floor((v.row+h.row)/2)));v=Math.min(4,I.zoom);d=d>>v<<v;r=r>>v<<v;K(d,d+1,r)}}for(F in M){v=M[F];d=Math.pow(2,v.level=v.zoom-z.zoom);v.element.setAttribute("transform","translate("+(v.x=o.x*(v.column-z.column*d))+","+(v.y=o.y*(v.row-z.row*d))+")")}for(F in w)if(!(F in M)){v=f.unload(F);v.element.parentNode.removeChild(v.element);delete v.proxyRefs}for(F in M){v=
-M[F];if(v.element.parentNode!=C[v.level]){C[v.level].appendChild(v.element);a.show&&a.show(v)}}f.flush();a.dispatch({type:"move"})}var a={},f=a.cache=s.cache(e,g).size(512),m=true,q=true,t,l,j,u=s.svg("g"),y,A,C={};u.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=u.appendChild(s.svg("g"));for(E=2;E>=1;E--)C[E]=u.appendChild(s.svg("g"));C[0]=u.appendChild(s.svg("g"));a.map=function(B){if(!arguments.length)return j;if(j){if(j==B){u.parentNode.appendChild(u);return a}j.off("move",i).off("resize",
-i);u.parentNode.removeChild(u)}if(j=B){j.container().appendChild(u);a.init&&a.init(u);j.on("move",i).on("resize",i);i()}return a};a.container=function(){return u};a.levels=function(){return C};a.id=function(B){if(!arguments.length)return l;l=B;u.setAttribute("id",B);return a};a.visible=function(B){if(!arguments.length)return q;(q=B)?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden");j&&i();return a};a.transform=function(B){if(!arguments.length)return y;y=B;j&&i();return a};a.zoom=
-function(B){if(!arguments.length)return t;t=typeof B=="function"||B==null?B:function(){return B};j&&i();return a};a.tile=function(B){if(!arguments.length)return m;m=B;j&&i();return a};a.reload=function(){f.clear();j&&i();return a};a.dispatch=s.dispatch(a);a.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var h=B.tile.proxyRefs[K];--h.proxyCount<=0&&f.unload(K)&&h.element.parentNode.removeChild(h.element)}delete B.tile.proxyRefs}});return a};s.image=function(){var e=s.layer(function(c){var k=
-c.element=s.svg("image"),i=e.map().tileSize();k.setAttribute("preserveAspectRatio","none");k.setAttribute("width",i.x);k.setAttribute("height",i.y);if(typeof g=="function"){k.setAttribute("opacity",0);c.request=s.queue.image(k,g(c),function(a){delete c.request;c.ready=true;c.img=a;k.removeAttribute("opacity");e.dispatch({type:"load",tile:c})})}else{c.ready=true;g&&k.setAttributeNS(s.ns.xlink,"href",g);e.dispatch({type:"load",tile:c})}},function(c){c.request&&c.request.abort(true)}),g;e.url=function(c){if(!arguments.length)return g;
-g=typeof c=="string"&&/{.}/.test(c)?s.url(c):c;return e.reload()};return e};s.geoJson=function(e){function g(h){var n={lat:0,lon:0};return function(w){n.lat=w[1];n.lon=w[0];var d=h(n);w.x=d.x;w.y=d.y;return d}}function c(h,n){return h&&h.type in C&&C[h.type](h,n)}function k(h,n,w){return h.type in E&&E[h.type](h,n,w)}function i(){var h=a.map().zoom(),n=a.cache.locks(),w,d,r,o,z,v,L;if(y=="fixed")for(w in n){if((d=n[w]).scale!=h){L="scale("+Math.pow(2,d.zoom-h)+")";o=-1;for(z=(r=d.features).length;++o<
-z;)k((v=r[o]).data.geometry,v.element,L);d.scale=h}}else for(w in n){o=-1;for(z=(r=(d=n[w]).features).length;++o<z;)k((v=r[o]).data.geometry,v.element,"");delete d.scale}}var a=s.layer(function(h,n){function w(r){var o=[];if(r.next)h.request=e(r.next.href,w);switch(r.type){case "FeatureCollection":for(var z=0;z<r.features.length;z++){var v=r.features[z],L=c(v.geometry,n);L&&o.push({element:d.appendChild(L),data:v})}break;case "Feature":(L=c(r.geometry,n))&&o.push({element:d.appendChild(L),data:r});
-break;default:(L=c(r,n))&&o.push({element:d.appendChild(L),data:{type:"Feature",geometry:r}});break}h.ready=true;o.push.apply(h.features,o);a.dispatch({type:"load",tile:h,features:o})}var d=h.element=s.svg("g");h.features=[];n=g(n(h).locationPoint);if(m!=null)h.request=e(typeof m=="function"?m(h):m,w);else w({type:"FeatureCollection",features:A||[]})},function(h){h.request&&h.request.abort(true)}),f=a.container(),m,q=true,t="org.polymaps."+s.id(),l="url(#"+t+")",j=f.insertBefore(s.svg("clipPath"),
-f.firstChild),u=j.appendChild(s.svg("rect")),y="auto",A;f.setAttribute("fill-rule","evenodd");j.setAttribute("id",t);if(!arguments.length)e=s.queue.json;var C={Point:function(h,n){var w=n(h.coordinates),d=s.svg("circle");d.setAttribute("r",4.5);d.setAttribute("transform","translate("+w.x+","+w.y+")");return d},MultiPoint:function(h,n){for(var w=s.svg("g"),d=h.coordinates,r,o,z=-1,v=d.length;++z<v;){o=w.appendChild(s.svg("circle"));o.setAttribute("r",4.5);o.setAttribute("transform","translate("+(r=
-n(d[z])).x+","+r.y+")")}return w},LineString:function(h,n){for(var w=s.svg("path"),d=["M"],r=h.coordinates,o,z=-1,v=r.length;++z<v;)d.push((o=n(r[z])).x,",",o.y,"L");d.pop();if(d.length){w.setAttribute("d",d.join(""));return w}},MultiLineString:function(h,n){for(var w=s.svg("path"),d=[],r=h.coordinates,o,z=-1,v,L=r.length,I;++z<L;){o=r[z];v=-1;I=o.length;for(d.push("M");++v<I;)d.push((p=n(o[v])).x,",",p.y,"L");d.pop()}if(d.length){w.setAttribute("d",d.join(""));return w}},Polygon:function(h,n){for(var w=
-s.svg("path"),d=[],r=h.coordinates,o,z=-1,v,L=r.length,I;++z<L;){o=r[z];v=-1;I=o.length-1;for(d.push("M");++v<I;)d.push((p=n(o[v])).x,",",p.y,"L");d[d.length-1]="Z"}if(d.length){w.setAttribute("d",d.join(""));return w}},MultiPolygon:function(h,n){for(var w=s.svg("path"),d=[],r=h.coordinates,o,z,v=-1,L,I,R=r.length,M,F;++v<R;){o=r[v];L=-1;for(M=o.length;++L<M;){z=o[L];I=-1;F=z.length-1;for(d.push("M");++I<F;)d.push((p=n(z[I])).x,",",p.y,"L");d[d.length-1]="Z"}}if(d.length){w.setAttribute("d",d.join(""));
-return w}},GeometryCollection:function(h,n){for(var w=s.svg("g"),d=-1,r=h.geometries,o=r.length,z;++d<o;)(z=c(r[d],n))&&w.appendChild(z);return w}},E={Point:function(h,n,w){h=h.coordinates;n.setAttribute("transform","translate("+h.x+","+h.y+")"+w)},MultiPoint:function(h,n,w){h=h.coordinates;var d=-1,r=o.length;n=n.firstChild;for(var o;++d<r;){o=h[d];n.setAttribute("transform","translate("+o.x+","+o.y+")"+w);n=n.nextSibling}}};a.url=function(h){if(!arguments.length)return m;m=typeof h=="string"&&/{.}/.test(h)?
-s.url(h):h;if(m!=null)A=null;typeof m=="string"&&a.tile(false);return a.reload()};a.features=function(h){if(!arguments.length)return A;if(A=h){m=null;a.tile(false)}return a.reload()};a.clip=function(h){if(!arguments.length)return q;q&&f.removeChild(j);if(q=h)f.insertBefore(j,f.firstChild);var n=a.cache.locks();for(var w in n)q?n[w].element.setAttribute("clip-path",l):n[w].element.removeAttribute("clip-path");return a};var B=a.tile;a.tile=function(h){arguments.length&&!h&&a.clip(h);return B.apply(a,
-arguments)};var K=a.map;a.map=function(h){if(h&&u){var n=h.tileSize();u.setAttribute("width",n.x);u.setAttribute("height",n.y)}return K.apply(a,arguments)};a.scale=function(h){if(!arguments.length)return y;(y=h)?a.on("move",i):a.off("move",i);a.map()&&i();return a};a.show=function(h){q?h.element.setAttribute("clip-path",l):h.element.removeAttribute("clip-path");a.dispatch({type:"show",tile:h,features:h.features});return a};a.reshow=function(){var h=a.cache.locks();for(var n in h)a.show(h[n]);return a};
-return a};s.dblclick=function(){function e(a){var f=k.zoom();f=a.shiftKey?Math.ceil(f)-f-1:1-f+Math.floor(f);c==="mouse"?k.zoomBy(f,k.mouse(a)):k.zoomBy(f)}var g={},c="mouse",k,i;g.zoom=function(a){if(!arguments.length)return c;c=a;return g};g.map=function(a){if(!arguments.length)return k;if(k){i.removeEventListener("dblclick",e,false);i=null}if(k=a){i=k.container();i.addEventListener("dblclick",e,false)}return g};return g};s.drag=function(){function e(f){if(!f.shiftKey){a={x:f.clientX,y:f.clientY};
-k.focusableParent().focus();f.preventDefault();document.body.style.setProperty("cursor","move",null)}}function g(f){if(a){k.panBy({x:f.clientX-a.x,y:f.clientY-a.y});a.x=f.clientX;a.y=f.clientY}}var c={},k,i,a;c.map=function(f){if(!arguments.length)return k;if(k){i.removeEventListener("mousedown",e,false);i=null}if(k=f){i=k.container();i.addEventListener("mousedown",e,false)}return c};window.addEventListener("mousemove",g,false);window.addEventListener("mouseup",function(f){if(a){g(f);a=null;document.body.style.removeProperty("cursor")}},
-false);return c};s.wheel=function(){function e(){m=null}function g(l){var j=(l.wheelDelta/120||-l.detail)*0.1,u;if(ba<0){u=Date.now();var y=u-i;if(y>9&&Math.abs(l.wheelDelta)/y>=50)ba=1;i=u}if(ba==1)j*=0.03;if(!a&&j){u=Date.now();if(u-k>200){j=j>0?+1:-1;k=u}else j=0}if(j)switch(f){case "mouse":u=q.mouse(l);m||(m=q.pointLocation(u));q.off("move",e).zoomBy(j,u,m).on("move",e);break;case "location":q.zoomBy(j,q.locationPoint(m),m);break;default:q.zoomBy(j);break}l.preventDefault();return false}var c=
-{},k=0,i=0,a=true,f="mouse",m,q,t;c.smooth=function(l){if(!arguments.length)return a;a=l;return c};c.zoom=function(l,j){if(!arguments.length)return f;f=l;m=j;if(q)f=="mouse"?q.on("move",e):q.off("move",e);return c};c.map=function(l){if(!arguments.length)return q;if(q){t.removeEventListener("mousemove",e,false);t.removeEventListener("mousewheel",g,false);t.removeEventListener("DOMMouseScroll",g,false);t=null;q.off("move",e)}if(q=l){f=="mouse"&&q.on("move",e);t=q.container();t.addEventListener("mousemove",
-e,false);t.addEventListener("mousewheel",g,false);t.addEventListener("DOMMouseScroll",g,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;s.arrow=function(){function e(y){if(!(y.ctrlKey||y.altKey||y.metaKey)){var A=Date.now(),C=0,E=0;switch(y.keyCode){case 37:if(!a.left){f=A;a.left=1;a.right||(C=l)}break;case 39:if(!a.right){f=A;a.right=1;a.left||(C=-l)}break;case 38:if(!a.up){f=A;a.up=1;a.down||(E=l)}break;case 40:if(!a.down){f=A;a.down=1;a.up||(E=-l)}break;default:return}if(C||
-E)j.panBy({x:C,y:E});if(!m&&a.left|a.right|a.up|a.down)m=setInterval(k,t);y.preventDefault()}}function g(y){f=Date.now();switch(y.keyCode){case 37:a.left=0;break;case 39:a.right=0;break;case 38:a.up=0;break;case 40:a.down=0;break;default:return}if(m&&!(a.left|a.right|a.up|a.down))m=clearInterval(m);y.preventDefault()}function c(y){switch(y.charCode){case 45:case 95:j.zoom(Math.ceil(j.zoom())-1);break;case 43:case 61:j.zoom(Math.floor(j.zoom())+1);break;default:return}y.preventDefault()}function k(){if(j)if(!(Date.now()<
-f+q)){var y=(a.left-a.right)*l,A=(a.up-a.down)*l;if(y||A)j.panBy({x:y,y:A})}}var i={},a={left:0,right:0,up:0,down:0},f=0,m,q=250,t=50,l=16,j,u;i.map=function(y){if(!arguments.length)return j;if(j){u.removeEventListener("keypress",c,false);u.removeEventListener("keydown",e,false);u.removeEventListener("keyup",g,false);u=null}if(j=y){u=j.focusableParent();u.addEventListener("keypress",c,false);u.addEventListener("keydown",e,false);u.addEventListener("keyup",g,false)}return i};i.speed=function(y){if(!arguments.length)return l;
-l=y;return i};return i};s.hash=function(){function e(){var f=a.center(),m=a.zoom(),q=Math.max(0,Math.ceil(Math.log(m)/Math.LN2));f="#"+m.toFixed(2)+"/"+f.lat.toFixed(q)+"/"+f.lon.toFixed(q);if(k!==f)location.replace(k=f)}function g(){if(location.hash!==k){var f=(k=location.hash).substring(1).split("/").map(Number);if(f.length<3||f.some(isNaN))e();else{var m=a.size();a.zoomBy(f[0]-a.zoom(),{x:m.x/2,y:m.y/2},{lat:Math.min(i,Math.max(-i,f[1])),lon:f[2]})}}}var c={},k,i=89.99999999,a;c.map=function(f){if(!arguments.length)return a;
-if(a){a.off("move",e);window.removeEventListener("hashchange",g,false)}if(a=f){a.on("move",e);window.addEventListener("hashchange",g,false);location.hash?g():e()}return c};return c};s.interact=function(){var e={},g=s.drag(),c=s.wheel(),k=s.dblclick(),i=s.arrow();e.map=function(a){g.map(a);c.map(a);k.map(a);i.map(a);return e};return e};s.compass=function(){function e(x){B.setAttribute("class","compass active");I||(I=setInterval(g,r));R&&H.panBy(R);w=Date.now();return l(x)}function g(){R&&Date.now()>
-w+d&&H.panBy(R)}function c(x){if(x.shiftKey){F={x0:H.mouse(x)};H.focusableParent().focus();return l(x)}}function k(x){if(F){F.x1=H.mouse(x);O.setAttribute("x",Math.min(F.x0.x,F.x1.x));O.setAttribute("y",Math.min(F.x0.y,F.x1.y));O.setAttribute("width",Math.abs(F.x0.x-F.x1.x));O.setAttribute("height",Math.abs(F.x0.y-F.x1.y));O.removeAttribute("display")}}function i(){B.setAttribute("class","compass");if(F){if(F.x1){H.extent([H.pointLocation({x:Math.min(F.x0.x,F.x1.x),y:Math.max(F.x0.y,F.x1.y)}),H.pointLocation({x:Math.max(F.x0.x,
-F.x1.x),y:Math.min(F.x0.y,F.x1.y)})]);O.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function a(x){return function(){x?this.setAttribute("class","active"):this.removeAttribute("class");R=x}}function f(x){return function(D){B.setAttribute("class","compass active");var G=H.zoom();H.zoom(x<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function m(x){return function(D){H.zoom(x);return l(D)}}function q(){this.setAttribute("class","active")}function t(){this.removeAttribute("class")}
-function l(x){x.stopPropagation();x.preventDefault();return false}function j(x){var D=Math.SQRT1_2*h,G=h*0.7,J=h*0.2,N=s.svg("g"),P=N.appendChild(s.svg("path")),Q=N.appendChild(s.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d","M0,0L"+D+","+D+"A"+h+","+h+" 0 0,1 "+-D+","+D+"Z");Q.setAttribute("class","chevron");Q.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));Q.setAttribute("pointer-events","none");N.addEventListener("mousedown",
-e,false);N.addEventListener("mouseover",a(x),false);N.addEventListener("mouseout",a(null),false);N.addEventListener("dblclick",l,false);return N}function u(x){var D=h*0.4,G=D/2,J=s.svg("g"),N=J.appendChild(s.svg("path")),P=J.appendChild(s.svg("path")),Q=J.appendChild(s.svg("path")),X=J.appendChild(s.svg("path"));N.setAttribute("class","back");N.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",N.getAttribute("d"));Q.setAttribute("class",
-"chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(x>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",N.getAttribute("d"));J.addEventListener("mousedown",f(x),false);J.addEventListener("mouseover",q,false);J.addEventListener("mouseout",t,false);J.addEventListener("dblclick",l,false);return J}function y(x){var D=h*0.2,G=h*0.4,J=s.svg("g"),N=J.appendChild(s.svg("rect")),P=J.appendChild(s.svg("path"));N.setAttribute("pointer-events","all");N.setAttribute("fill",
-"none");N.setAttribute("x",-G);N.setAttribute("y",-0.75*G);N.setAttribute("width",2*G);N.setAttribute("height",1.5*G);P.setAttribute("class","chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",m(x),false);J.addEventListener("dblclick",l,false);return J}function A(){var x=h+6,D=x,G=H.size();switch(o){case "top-left":break;case "top-right":x=G.x-x;break;case "bottom-left":D=G.y-D;break;case "bottom-right":x=G.x-x;D=G.y-D;break}x="translate("+x+","+D+")";M&&M.setAttribute("transform",
-x);v&&v.setAttribute("transform",x);for(var J in K)J==H.zoom()?K[J].setAttribute("class","active"):K[J].removeAttribute("class")}function C(){for(;B.lastChild;)B.removeChild(B.lastChild);B.appendChild(O);if(L!="none"){M=B.appendChild(s.svg("g"));M.setAttribute("class","pan");var x=M.appendChild(s.svg("circle"));x.setAttribute("class","back");x.setAttribute("r",h);M.appendChild(j({x:0,y:-n})).setAttribute("transform","rotate(0)");M.appendChild(j({x:n,y:0})).setAttribute("transform","rotate(90)");M.appendChild(j({x:0,
-y:n})).setAttribute("transform","rotate(180)");M.appendChild(j({x:-n,y:0})).setAttribute("transform","rotate(270)");x=M.appendChild(s.svg("circle"));x.setAttribute("fill","none");x.setAttribute("class","fore");x.setAttribute("r",h)}else M=null;if(z!="none"){v=B.appendChild(s.svg("g"));v.setAttribute("class","zoom");x=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(x=0;D<=H.zoomRange()[1];D++,x++)(K[D]=v.appendChild(y(D))).setAttribute("transform","translate(0,"+-(x+0.75)*h*0.4+")")}D=L=="none"?
-0.4:2;v.setAttribute("transform","translate(0,"+h*(/^top-/.test(o)?D+(x+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(x+0.5)*h*0.4+")");v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E={},B=s.svg("g"),K={},h=30,n=16,w=0,d=250,r=50,o="top-left",z="small",v,L="small",I,R,M,F,O=s.svg("rect"),H,T,U;B.setAttribute("class","compass");O.setAttribute("class","back fore");O.setAttribute("pointer-events","none");O.setAttribute("display","none");
-E.radius=function(x){if(!arguments.length)return h;h=x;H&&C();return E};E.speed=function(x){if(!arguments.length)return h;n=x;return E};E.position=function(x){if(!arguments.length)return o;o=x;H&&C();return E};E.pan=function(x){if(!arguments.length)return L;L=x;H&&C();return E};E.zoom=function(x){if(!arguments.length)return z;z=x;H&&C();return E};E.map=function(x){if(!arguments.length)return H;if(H){T.removeEventListener("mousedown",c,false);T.removeChild(B);T=null;U.removeEventListener("mousemove",
-k,false);U.removeEventListener("mouseup",i,false);U=null;H.off("move",A).off("resize",A)}if(H=x){T=H.container();T.appendChild(B);T.addEventListener("mousedown",c,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",k,false);U.addEventListener("mouseup",i,false);H.on("move",A).on("resize",A);C()}return E};return E};s.grid=function(){function e(){var i=k.firstChild,a=c.size(),f=c.pointLocation(Y);c.pointLocation(a);var m=Math.pow(2,4-Math.round(c.zoom()));f.lat=Math.floor(f.lat/m)*m;
-f.lon=Math.ceil(f.lon/m)*m;for(var q;(q=c.locationPoint(f).x)<=a.x;f.lon+=m){i||(i=k.appendChild(s.svg("line")));i.setAttribute("x1",q);i.setAttribute("x2",q);i.setAttribute("y1",0);i.setAttribute("y2",a.y);i=i.nextSibling}for(;(q=c.locationPoint(f).y)<=a.y;f.lat-=m){i||(i=k.appendChild(s.svg("line")));i.setAttribute("y1",q);i.setAttribute("y2",q);i.setAttribute("x1",0);i.setAttribute("x2",a.x);i=i.nextSibling}for(;i;){a=i.nextSibling;k.removeChild(i);i=a}}var g={},c,k=s.svg("g");k.setAttribute("class",
-"grid");g.map=function(i){if(!arguments.length)return c;if(c){k.parentNode.removeChild(k);c.off("move",e).off("resize",e)}if(c=i){c.on("move",e).on("resize",e);c.container().appendChild(k);c.dispatch({type:"move"})}return g};return g};s.stylist=function(){function e(i){var a=i.features.length,f=g.length,m=c.length,q,t,l,j,u,y;for(u=0;u<a;++u)if(t=(q=i.features[u]).element){q=q.data;for(y=0;y<f;++y){j=(l=g[y]).value;if(typeof j==="function")j=j.call(null,q);j==null?l.name.local?t.removeAttributeNS(l.name.space,
-l.name.local):t.removeAttribute(l.name):l.name.local?t.setAttributeNS(l.name.space,l.name.local,j):t.setAttribute(l.name,j)}for(y=0;y<m;++y){j=(l=c[y]).value;if(typeof j==="function")j=j.call(null,q);j==null?t.style.removeProperty(l.name):t.style.setProperty(l.name,j,l.priority)}if(j=k){if(typeof j==="function")j=j.call(null,q);for(;t.lastChild;)t.removeChild(t.lastChild);j!=null&&t.appendChild(s.svg("title")).appendChild(document.createTextNode(j))}}}var g=[],c=[],k;e.attr=function(i,a){g.push({name:fa(i),
-value:a});return e};e.style=function(i,a,f){c.push({name:i,value:a,priority:arguments.length<3?null:f});return e};e.title=function(i){k=i;return e};return e}})(org.polymaps);
+(function(t){function fa(e){var f=e.indexOf(":");return f<0?e:{space:t.ns[e.substring(0,f)],local:e.substring(f+1)}}function S(){for(var e=0;e<S.maps.length;e++)S.maps[e].resize()}function V(e){return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function W(e){return 180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360))}function Z(e,f){if(e.row>f.row){var c=e;e=f;f=c}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,c,k,i){c=Math.max(c,Math.floor(f.y0));
+k=Math.min(k,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx<f.x1:e.x1-f.dy/e.dy*e.dx<f.x0){var a=e;e=f;f=a}a=e.dx/e.dy;var g=f.dx/f.dy,n=e.dx>0,m=f.dx<0;for(c=c;c<k;c++){var s=a*Math.max(0,Math.min(e.dy,c+n-e.y0))+e.x0;i(Math.floor(g*Math.max(0,Math.min(f.dy,c+m-f.y0))+f.x0),Math.ceil(s),c)}}function da(e,f,c,k,i,a){var g=Z(e,f);f=Z(f,c);e=Z(c,e);if(g.dy>f.dy){c=g;g=f;f=c}if(g.dy>e.dy){c=g;g=e;e=c}if(f.dy>e.dy){c=f;f=e;e=c}g.dy&&ca(e,g,k,i,a);f.dy&&ca(e,f,k,i,a)}t.version="2.3.0";
+var Y={x:0,y:0};t.ns={svg:"http://www.w3.org/2000/svg",xlink:"http://www.w3.org/1999/xlink"};t.id=function(){var e=0;return function(){return++e}}();t.svg=function(e){return document.createElementNS(t.ns.svg,e)};t.transform=function(e,f,c,k,i,a){var g={},n,m,s;if(!arguments.length){e=1;f=i=c=0;k=1;a=0}g.zoomFraction=function(l){if(!arguments.length)return m;m=l;n=Math.floor(m+Math.log(Math.sqrt(e*e+f*f+c*c+k*k))/Math.log(2));s=Math.pow(2,-n);return g};g.apply=function(l){var j=Math.pow(2,-l.zoom),
+u=Math.pow(2,l.zoom-n);return{column:(e*l.column*j+c*l.row*j+i)*u,row:(f*l.column*j+k*l.row*j+a)*u,zoom:l.zoom-n}};g.unapply=function(l){var j=Math.pow(2,-l.zoom),u=Math.pow(2,l.zoom+n);return{column:(l.column*j*k-l.row*j*c-i*k+a*c)/(e*k-f*c)*u,row:(l.column*j*f-l.row*j*e-i*f+a*e)/(c*f-k*e)*u,zoom:l.zoom+n}};g.toString=function(){return"matrix("+[e*s,f*s,c*s,k*s].join(" ")+" 0 0)"};return g.zoomFraction(0)};t.cache=function(e,f){function c(j){l--;f&&f(j);delete g[j.key];if(j.next)j.next.prev=j.prev;
+else if(m=j.prev)m.next=null;if(j.prev)j.prev.next=j.next;else if(n=j.next)n.prev=null}function k(){for(var j=m;l>s;j=j.prev){if(!j)break;j.lock||c(j)}}var i={},a={},g={},n=null,m=null,s=64,l=0;i.peek=function(j){return g[[j.zoom,j.column,j.row].join("/")]};i.load=function(j,u){var y=[j.zoom,j.column,j.row].join("/"),A=g[y];if(A){if(A.prev){if(A.prev.next=A.next)A.next.prev=A.prev;else m=A.prev;A.prev=null;A.next=n;n=n.prev=A}A.lock=1;return a[y]=A}A={key:y,column:j.column,row:j.row,zoom:j.zoom,next:n,
+prev:null,lock:1};e.call(null,A,u);a[y]=g[y]=A;if(n)n.prev=A;else m=A;n=A;l++;return A};i.unload=function(j){if(!(j in a))return false;var u=a[j];u.lock=0;delete a[j];u.request&&u.request.abort(false)&&c(u);return u};i.locks=function(){return a};i.size=function(j){if(!arguments.length)return s;s=j;k();return i};i.flush=function(){k();return i};i.clear=function(){for(var j in g){var u=g[j];u.request&&u.request.abort(false);f&&f(g[j]);if(u.lock){u.lock=0;u.element.parentNode.removeChild(u.element)}}a=
+{};g={};n=m=null;l=0;return i};return i};t.url=function(e){function f(k){var i=k.zoom<0?1:1<<k.zoom,a=k.column%i;if(a<0)a+=i;return e.replace(/{(.)}/g,function(g,n){switch(n){case "S":return c[(Math.abs(k.zoom)+k.row+a)%c.length];case "Z":return k.zoom;case "X":return a;case "Y":return k.row;case "B":var m=t.map.coordinateLocation({row:k.row,column:a,zoom:k.zoom}),s=t.map.coordinateLocation({row:k.row+1,column:a+1,zoom:k.zoom}),l=Math.ceil(Math.log(k.zoom)/Math.LN2);return s.lat.toFixed(l)+","+m.lon.toFixed(l)+
+","+m.lat.toFixed(l)+","+s.lon.toFixed(l)}return n})}var c=[];f.template=function(k){if(!arguments.length)return e;e=k;return f};f.hosts=function(k){if(!arguments.length)return c;c=k;return f};return f};t.dispatch=function(e){var f={};e.on=function(c,k){for(var i=f[c]||(f[c]=[]),a=0;a<i.length;a++)if(i[a].handler==k)return e;i.push({handler:k,on:true});return e};e.off=function(c,k){var i=f[c];if(i)for(var a=0;a<i.length;a++){var g=i[a];if(g.handler==k){g.on=false;i.splice(a,1);break}}return e};return function(c){var k=
+f[c.type];if(k){k=k.slice();for(var i=0;i<k.length;i++){var a=k[i];a.on&&a.handler.call(e,c)}}}};t.queue=function(){function e(){if(!(i>=a||!k.length)){i++;k.pop()()}}function f(g){for(var n=0;n<k.length;n++)if(k[n]==g){k.splice(n,1);return true}return false}function c(g,n,m){function s(){l=new XMLHttpRequest;m&&l.overrideMimeType(m);l.open("GET",g,true);l.onreadystatechange=function(){if(l.readyState==4){i--;l.status<300&&n(l);e()}};l.send(null)}var l;k.push(s);e();return{abort:function(j){if(f(s))return true;
+if(j&&l){l.abort();return true}return false}}}var k=[],i=0,a=6;return{text:function(g,n,m){return c(g,function(s){s.responseText&&n(s.responseText)},m)},xml:function(g,n){return c(g,function(m){m.responseXML&&n(m.responseXML)},"application/xml")},json:function(g,n){return c(g,function(m){m.responseText&&n(JSON.parse(m.responseText))},"application/json")},image:function(g,n,m){function s(){l=document.createElement("img");l.onerror=function(){i--;e()};l.onload=function(){i--;m(l);e()};l.src=n;g.setAttributeNS(t.ns.xlink,
+"href",n)}var l;k.push(s);e();return{abort:function(j){if(f(s))return true;if(j&&l){l.src="about:";return true}return false}}}}}();t.map=function(){function e(){if(u)if(s<u[0])s=u[0];else if(s>u[1])s=u[1];l=s-(s=Math.round(s));j=Math.pow(2,l)}function f(){if(o){var d=45/Math.pow(2,s+l-3),r=Math.max(Math.abs(C*g.x+A*g.y),Math.abs(B*g.x+E*g.y)),q=V(K-r*d/n.y);r=V(h+r*d/n.y);m.lat=Math.max(q,Math.min(r,m.lat));q=Math.max(Math.abs(C*g.y+A*g.x),Math.abs(B*g.y+E*g.x));m.lon=Math.max(o[0].lon-q*d/n.x,Math.min(o[1].lon+
+q*d/n.x,m.lon))}}var c={},k,i,a=Y,g=Y,n={x:256,y:256},m={lat:37.76487,lon:-122.41948},s=12,l=0,j=1,u=[1,18],y=0,A=1,C=0,E=1,B=0,K=-180,h=180,o=[{lat:V(K),lon:-Infinity},{lat:V(h),lon:Infinity}];c.locationCoordinate=function(d){d=t.map.locationCoordinate(d);var r=Math.pow(2,s);d.column*=r;d.row*=r;d.zoom+=s;return d};c.coordinateLocation=t.map.coordinateLocation;c.coordinatePoint=function(d,r){var q=Math.pow(2,s-r.zoom),z=Math.pow(2,s-d.zoom),v=(r.column*q-d.column*z)*n.x*j;q=(r.row*q-d.row*z)*n.y*
+j;return{x:g.x+A*v-C*q,y:g.y+C*v+A*q}};c.pointCoordinate=function(d,r){var q=Math.pow(2,s-d.zoom),z=(r.x-g.x)/j,v=(r.y-g.y)/j;return{column:d.column*q+(E*z-B*v)/n.x,row:d.row*q+(B*z+E*v)/n.y,zoom:s}};c.locationPoint=function(d){var r=Math.pow(2,s+l-3)/45,q=(d.lon-m.lon)*r*n.x;d=(W(m.lat)-W(d.lat))*r*n.y;return{x:g.x+A*q-C*d,y:g.y+C*q+A*d}};c.pointLocation=function(d){var r=45/Math.pow(2,s+l-3),q=(d.x-g.x)*r;d=(d.y-g.y)*r;return{lon:m.lon+(E*q-B*d)/n.x,lat:V(W(m.lat)-(B*q+E*d)/n.y)}};var w=t.svg("rect");
+w.setAttribute("visibility","hidden");w.setAttribute("pointer-events","all");c.container=function(d){if(!arguments.length)return k;k=d;k.setAttribute("class","map");k.appendChild(w);return c.resize()};c.focusableParent=function(){for(var d=k;d;d=d.parentNode)if(d.tabIndex>=0)return d;return window};c.mouse=function(d){var r=(k.ownerSVGElement||k).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var q=document.body.appendChild(t.svg("svg"));q.style.position="absolute";q.style.top=q.style.left=
+"0px";var z=q.getScreenCTM();$=!(z.f||z.e);document.body.removeChild(q)}if($){r.x=d.pageX;r.y=d.pageY}else{r.x=d.clientX;r.y=d.clientY}return r.matrixTransform(k.getScreenCTM().inverse())};c.size=function(d){if(!arguments.length)return a;i=d;return c.resize()};c.resize=function(){if(i){a=i;S.remove(c)}else{w.setAttribute("width","100%");w.setAttribute("height","100%");b=w.getBBox();a={x:b.width,y:b.height};S.add(c)}w.setAttribute("width",a.x);w.setAttribute("height",a.y);g={x:a.x/2,y:a.y/2};f();c.dispatch({type:"resize"});
+return c};c.tileSize=function(d){if(!arguments.length)return n;n=d;c.dispatch({type:"move"});return c};c.center=function(d){if(!arguments.length)return m;m=d;f();c.dispatch({type:"move"});return c};c.panBy=function(d){var r=45/Math.pow(2,s+l-3),q=d.x*r;d=d.y*r;return c.center({lon:m.lon+(B*d-E*q)/n.x,lat:V(W(m.lat)+(B*q+E*d)/n.y)})};c.centerRange=function(d){if(!arguments.length)return o;if(o=d){K=o[0].lat>-90?W(o[0].lat):-Infinity;h=o[0].lat<90?W(o[1].lat):Infinity}else{K=-Infinity;h=Infinity}f();
+c.dispatch({type:"move"});return c};c.zoom=function(d){if(!arguments.length)return s+l;s=d;e();return c.center(m)};c.zoomBy=function(d,r,q){if(arguments.length<2)return c.zoom(s+l+d);if(arguments.length<3)q=c.pointLocation(r);s=s+l+d;e();var z=c.locationPoint(q);return c.panBy({x:r.x-z.x,y:r.y-z.y})};c.zoomRange=function(d){if(!arguments.length)return u;u=d;return c.zoom(s+l)};c.extent=function(d){if(!arguments.length)return[c.pointLocation({x:0,y:a.y}),c.pointLocation({x:a.x,y:0})];var r=c.locationPoint(d[0]),
+q=c.locationPoint(d[1]),z=Math.max((q.x-r.x)/a.x,(r.y-q.y)/a.y);r=c.pointLocation({x:(r.x+q.x)/2,y:(r.y+q.y)/2});s=s+l-Math.log(z)/Math.log(2);e();return c.center(r)};c.angle=function(d){if(!arguments.length)return y;y=d;A=Math.cos(y);C=Math.sin(y);E=Math.cos(-y);B=Math.sin(-y);f();c.dispatch({type:"move"});return c};c.add=function(d){d.map(c);return c};c.remove=function(d){d.map(null);return c};c.dispatch=t.dispatch(c);return c};S.maps=[];S.add=function(e){for(var f=0;f<S.maps.length;f++)if(S.maps[f]==
+e)return;S.maps.push(e)};S.remove=function(e){for(var f=0;f<S.maps.length;f++)if(S.maps[f]==e){S.maps.splice(f,1);return}};window.addEventListener("resize",S,false);t.map.locationCoordinate=function(e){var f=1/360;return{column:(e.lon+180)*f,row:(180-W(e.lat))*f,zoom:0}};t.map.coordinateLocation=function(e){var f=45/Math.pow(2,e.zoom-3);return{lon:f*e.column-180,lat:V(180-f*e.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;t.layer=function(e,f){function c(B){for(var K=C[0].nextSibling;A<B;A++){u.insertBefore(C[-4],
+K);u.insertBefore(C[2],K);u.insertBefore(C[1],K);for(var h=C[-4],o=-4;o<2;)C[o]=C[++o];C[o]=h}}function k(B){for(var K=C[0].nextSibling;A>B;A--){u.insertBefore(C[-1],K);u.insertBefore(C[2],C[-4]);for(var h=C[2],o=2;o>-4;)C[o]=C[--o];C[o]=h}}function i(){function B(O){var H=O.zoom,T=H<0?1:1<<H,U=O.column%T,x=O.row;if(U<0)U+=T;return{locationPoint:function(D){D=t.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);return{x:q.x*(G*D.column-U),y:q.y*(G*D.row-x)}}}}function K(O,H,T){var U=I.zoom,x=2-
+R,D=4+R;for(O=O;O<H;O++){var G=g.load({column:O,row:T,zoom:U},B);if(!G.ready&&!(G.key in M)){G.proxyRefs={};for(var J,N,P,Q=1;Q<=x;Q++){N=true;for(var X=0,ea=1<<Q;X<=ea;X++)for(var aa=0;aa<=ea;aa++)if((P=g.peek(J={column:(O<<Q)+aa,row:(T<<Q)+X,zoom:U+Q}))&&P.ready){M[P.key]=g.load(J);P.proxyCount++;G.proxyRefs[P.key]=P}else N=false;if(N)break}if(!N)for(Q=1;Q<=D;Q++)if((P=g.peek(J={column:O>>Q,row:T>>Q,zoom:U-Q}))&&P.ready){M[P.key]=g.load(J);P.proxyCount++;G.proxyRefs[P.key]=P;break}}M[G.key]=G}}
+var h=a.map(),o=h.zoom(),w=o-(o=Math.round(o)),d=h.size(),r=h.angle(),q=h.tileSize(),z=h.locationCoordinate(h.center());if(A!=o){if(A<o)c(o);else if(A>o)k(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)+")")}}u.setAttribute("transform","translate("+d.x/2+","+d.y/2+")"+(r?"rotate("+r/Math.PI*180+")":"")+(w?"scale("+Math.pow(2,w)+")":"")+(y?y.zoomFraction(w):""));var I=h.pointCoordinate(z,Y);
+v=h.pointCoordinate(z,{x:d.x,y:0});o=h.pointCoordinate(z,d);h=h.pointCoordinate(z,{x:0,y:d.y});if(!w&&!r&&!y){z.column=(Math.round(q.x*z.column)+(d.x&1)/2)/q.x;z.row=(Math.round(q.y*z.row)+(d.y&1)/2)/q.y}if(y){I=y.unapply(I);v=y.unapply(v);o=y.unapply(o);h=y.unapply(h);z=y.unapply(z)}var R=s?s(I.zoom)-I.zoom:0;if(R){d=Math.pow(2,R);I.column*=d;I.row*=d;v.column*=d;v.row*=d;o.column*=d;o.row*=d;h.column*=d;h.row*=d;I.zoom=v.zoom=o.zoom=h.zoom+=R}w=g.locks();var M={};for(var F in w)w[F].proxyCount=
+0;if(m&&R>-5&&R<3){r=I.zoom<0?1:1<<I.zoom;if(n){da(I,v,o,0,r,K);da(o,h,I,0,r,K)}else{d=Math.floor((I.column+o.column)/2);r=Math.max(0,Math.min(r-1,Math.floor((v.row+h.row)/2)));v=Math.min(4,I.zoom);d=d>>v<<v;r=r>>v<<v;K(d,d+1,r)}}for(F in M){v=M[F];d=Math.pow(2,v.level=v.zoom-z.zoom);v.element.setAttribute("transform","translate("+(v.x=q.x*(v.column-z.column*d))+","+(v.y=q.y*(v.row-z.row*d))+")")}for(F in w)if(!(F in M)){v=g.unload(F);v.element.parentNode.removeChild(v.element);delete v.proxyRefs}for(F in M){v=
+M[F];if(v.element.parentNode!=C[v.level]){C[v.level].appendChild(v.element);a.show&&a.show(v)}}g.flush();a.dispatch({type:"move"})}var a={},g=a.cache=t.cache(e,f).size(512),n=true,m=true,s,l,j,u=t.svg("g"),y,A,C={};u.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=u.appendChild(t.svg("g"));for(E=2;E>=1;E--)C[E]=u.appendChild(t.svg("g"));C[0]=u.appendChild(t.svg("g"));a.map=function(B){if(!arguments.length)return j;if(j){if(j==B){u.parentNode.appendChild(u);return a}j.off("move",i).off("resize",
+i);u.parentNode.removeChild(u)}if(j=B){j.container().appendChild(u);a.init&&a.init(u);j.on("move",i).on("resize",i);i()}return a};a.container=function(){return u};a.levels=function(){return C};a.id=function(B){if(!arguments.length)return l;l=B;u.setAttribute("id",B);return a};a.visible=function(B){if(!arguments.length)return m;(m=B)?u.removeAttribute("visibility"):u.setAttribute("visibility","hidden");j&&i();return a};a.transform=function(B){if(!arguments.length)return y;y=B;j&&i();return a};a.zoom=
+function(B){if(!arguments.length)return s;s=typeof B=="function"||B==null?B:function(){return B};j&&i();return a};a.tile=function(B){if(!arguments.length)return n;n=B;j&&i();return a};a.reload=function(){g.clear();j&&i();return a};a.dispatch=t.dispatch(a);a.on("load",function(B){if(B.tile.proxyRefs){for(var K in B.tile.proxyRefs){var h=B.tile.proxyRefs[K];--h.proxyCount<=0&&g.unload(K)&&h.element.parentNode.removeChild(h.element)}delete B.tile.proxyRefs}});return a};t.image=function(){var e=t.layer(function(c){var k=
+c.element=t.svg("image"),i=e.map().tileSize();k.setAttribute("preserveAspectRatio","none");k.setAttribute("width",i.x);k.setAttribute("height",i.y);if(typeof f=="function"){k.setAttribute("opacity",0);c.request=t.queue.image(k,f(c),function(a){delete c.request;c.ready=true;c.img=a;k.removeAttribute("opacity");e.dispatch({type:"load",tile:c})})}else{c.ready=true;f&&k.setAttributeNS(t.ns.xlink,"href",f);e.dispatch({type:"load",tile:c})}},function(c){c.request&&c.request.abort(true)}),f;e.url=function(c){if(!arguments.length)return f;
+f=typeof c=="string"&&/{.}/.test(c)?t.url(c):c;return e.reload()};return e};t.geoJson=function(e){function f(h){var o={lat:0,lon:0};return function(w){o.lat=w[1];o.lon=w[0];var d=h(o);w.x=d.x;w.y=d.y;return d}}function c(h,o){return h&&h.type in C&&C[h.type](h,o)}function k(h,o,w){return h.type in E&&E[h.type](h,o,w)}function i(){var h=a.map().zoom(),o=a.cache.locks(),w,d,r,q,z,v,L;if(y=="fixed")for(w in o){if((d=o[w]).scale!=h){L="scale("+Math.pow(2,d.zoom-h)+")";q=-1;for(z=(r=d.features).length;++q<
+z;)k((v=r[q]).data.geometry,v.element,L);d.scale=h}}else for(w in o){q=-1;for(z=(r=(d=o[w]).features).length;++q<z;)k((v=r[q]).data.geometry,v.element,"");delete d.scale}}var a=t.layer(function(h,o){function w(r){var q=[];if(r.next)h.request=e(r.next.href,w);switch(r.type){case "FeatureCollection":for(var z=0;z<r.features.length;z++){var v=r.features[z],L=c(v.geometry,o);L&&q.push({element:d.appendChild(L),data:v})}break;case "Feature":(L=c(r.geometry,o))&&q.push({element:d.appendChild(L),data:r});
+break;default:(L=c(r,o))&&q.push({element:d.appendChild(L),data:{type:"Feature",geometry:r}});break}h.ready=true;q.push.apply(h.features,q);a.dispatch({type:"load",tile:h,features:q})}var d=h.element=t.svg("g");h.features=[];o=f(o(h).locationPoint);if(n!=null)h.request=e(typeof n=="function"?n(h):n,w);else w({type:"FeatureCollection",features:A||[]})},function(h){h.request&&h.request.abort(true)}),g=a.container(),n,m=true,s="org.polymaps."+t.id(),l="url(#"+s+")",j=g.insertBefore(t.svg("clipPath"),
+g.firstChild),u=j.appendChild(t.svg("rect")),y="auto",A;g.setAttribute("fill-rule","evenodd");j.setAttribute("id",s);if(!arguments.length)e=t.queue.json;var C={Point:function(h,o){var w=o(h.coordinates),d=t.svg("circle");d.setAttribute("r",4.5);d.setAttribute("transform","translate("+w.x+","+w.y+")");return d},MultiPoint:function(h,o){for(var w=t.svg("g"),d=h.coordinates,r,q,z=-1,v=d.length;++z<v;){q=w.appendChild(t.svg("circle"));q.setAttribute("r",4.5);q.setAttribute("transform","translate("+(r=
+o(d[z])).x+","+r.y+")")}return w},LineString:function(h,o){for(var w=t.svg("path"),d=["M"],r=h.coordinates,q,z=-1,v=r.length;++z<v;)d.push((q=o(r[z])).x,",",q.y,"L");d.pop();if(d.length){w.setAttribute("d",d.join(""));return w}},MultiLineString:function(h,o){for(var w=t.svg("path"),d=[],r=h.coordinates,q,z=-1,v,L=r.length,I;++z<L;){q=r[z];v=-1;I=q.length;for(d.push("M");++v<I;)d.push((p=o(q[v])).x,",",p.y,"L");d.pop()}if(d.length){w.setAttribute("d",d.join(""));return w}},Polygon:function(h,o){for(var w=
+t.svg("path"),d=[],r=h.coordinates,q,z=-1,v,L=r.length,I;++z<L;){q=r[z];v=-1;I=q.length-1;for(d.push("M");++v<I;)d.push((p=o(q[v])).x,",",p.y,"L");d[d.length-1]="Z"}if(d.length){w.setAttribute("d",d.join(""));return w}},MultiPolygon:function(h,o){for(var w=t.svg("path"),d=[],r=h.coordinates,q,z,v=-1,L,I,R=r.length,M,F;++v<R;){q=r[v];L=-1;for(M=q.length;++L<M;){z=q[L];I=-1;F=z.length-1;for(d.push("M");++I<F;)d.push((p=o(z[I])).x,",",p.y,"L");d[d.length-1]="Z"}}if(d.length){w.setAttribute("d",d.join(""));
+return w}},GeometryCollection:function(h,o){for(var w=t.svg("g"),d=-1,r=h.geometries,q=r.length,z;++d<q;)(z=c(r[d],o))&&w.appendChild(z);return w}},E={Point:function(h,o,w){h=h.coordinates;o.setAttribute("transform","translate("+h.x+","+h.y+")"+w)},MultiPoint:function(h,o,w){h=h.coordinates;var d=-1,r=q.length;o=o.firstChild;for(var q;++d<r;){q=h[d];o.setAttribute("transform","translate("+q.x+","+q.y+")"+w);o=o.nextSibling}}};a.url=function(h){if(!arguments.length)return n;n=typeof h=="string"&&/{.}/.test(h)?
+t.url(h):h;if(n!=null)A=null;typeof n=="string"&&a.tile(false);return a.reload()};a.features=function(h){if(!arguments.length)return A;if(A=h){n=null;a.tile(false)}return a.reload()};a.clip=function(h){if(!arguments.length)return m;m&&g.removeChild(j);if(m=h)g.insertBefore(j,g.firstChild);var o=a.cache.locks();for(var w in o)m?o[w].element.setAttribute("clip-path",l):o[w].element.removeAttribute("clip-path");return a};var B=a.tile;a.tile=function(h){arguments.length&&!h&&a.clip(h);return B.apply(a,
+arguments)};var K=a.map;a.map=function(h){if(h&&u){var o=h.tileSize();u.setAttribute("width",o.x);u.setAttribute("height",o.y)}return K.apply(a,arguments)};a.scale=function(h){if(!arguments.length)return y;(y=h)?a.on("move",i):a.off("move",i);a.map()&&i();return a};a.show=function(h){m?h.element.setAttribute("clip-path",l):h.element.removeAttribute("clip-path");a.dispatch({type:"show",tile:h,features:h.features});return a};a.reshow=function(){var h=a.cache.locks();for(var o in h)a.show(h[o]);return a};
+return a};t.dblclick=function(){function e(a){var g=k.zoom();g=a.shiftKey?Math.ceil(g)-g-1:1-g+Math.floor(g);c==="mouse"?k.zoomBy(g,k.mouse(a)):k.zoomBy(g)}var f={},c="mouse",k,i;f.zoom=function(a){if(!arguments.length)return c;c=a;return f};f.map=function(a){if(!arguments.length)return k;if(k){i.removeEventListener("dblclick",e,false);i=null}if(k=a){i=k.container();i.addEventListener("dblclick",e,false)}return f};return f};t.drag=function(){function e(g){if(!g.shiftKey){a={x:g.clientX,y:g.clientY};
+k.focusableParent().focus();g.preventDefault();document.body.style.setProperty("cursor","move",null)}}function f(g){if(a){k.panBy({x:g.clientX-a.x,y:g.clientY-a.y});a.x=g.clientX;a.y=g.clientY}}var c={},k,i,a;c.map=function(g){if(!arguments.length)return k;if(k){i.removeEventListener("mousedown",e,false);i=null}if(k=g){i=k.container();i.addEventListener("mousedown",e,false)}return c};window.addEventListener("mousemove",f,false);window.addEventListener("mouseup",function(g){if(a){f(g);a=null;document.body.style.removeProperty("cursor")}},
+false);return c};t.wheel=function(){function e(){n=null}function f(l){var j=(l.wheelDelta/120||-l.detail)*0.1,u;if(ba<0){u=Date.now();var y=u-i;if(y>9&&Math.abs(l.wheelDelta)/y>=50)ba=1;i=u}if(ba==1)j*=0.03;if(!a&&j){u=Date.now();if(u-k>200){j=j>0?+1:-1;k=u}else j=0}if(j)switch(g){case "mouse":u=m.mouse(l);n||(n=m.pointLocation(u));m.off("move",e).zoomBy(j,u,n).on("move",e);break;case "location":m.zoomBy(j,m.locationPoint(n),n);break;default:m.zoomBy(j);break}l.preventDefault();return false}var c=
+{},k=0,i=0,a=true,g="mouse",n,m,s;c.smooth=function(l){if(!arguments.length)return a;a=l;return c};c.zoom=function(l,j){if(!arguments.length)return g;g=l;n=j;if(m)g=="mouse"?m.on("move",e):m.off("move",e);return c};c.map=function(l){if(!arguments.length)return m;if(m){s.removeEventListener("mousemove",e,false);s.removeEventListener("mousewheel",f,false);s.removeEventListener("DOMMouseScroll",f,false);s=null;m.off("move",e)}if(m=l){g=="mouse"&&m.on("move",e);s=m.container();s.addEventListener("mousemove",
+e,false);s.addEventListener("mousewheel",f,false);s.addEventListener("DOMMouseScroll",f,false)}return c};return c};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;t.arrow=function(){function e(y){if(!(y.ctrlKey||y.altKey||y.metaKey)){var A=Date.now(),C=0,E=0;switch(y.keyCode){case 37:if(!a.left){g=A;a.left=1;a.right||(C=l)}break;case 39:if(!a.right){g=A;a.right=1;a.left||(C=-l)}break;case 38:if(!a.up){g=A;a.up=1;a.down||(E=l)}break;case 40:if(!a.down){g=A;a.down=1;a.up||(E=-l)}break;default:return}if(C||
+E)j.panBy({x:C,y:E});if(!n&&a.left|a.right|a.up|a.down)n=setInterval(k,s);y.preventDefault()}}function f(y){g=Date.now();switch(y.keyCode){case 37:a.left=0;break;case 39:a.right=0;break;case 38:a.up=0;break;case 40:a.down=0;break;default:return}if(n&&!(a.left|a.right|a.up|a.down))n=clearInterval(n);y.preventDefault()}function c(y){switch(y.charCode){case 45:case 95:j.zoom(Math.ceil(j.zoom())-1);break;case 43:case 61:j.zoom(Math.floor(j.zoom())+1);break;default:return}y.preventDefault()}function k(){if(j)if(!(Date.now()<
+g+m)){var y=(a.left-a.right)*l,A=(a.up-a.down)*l;if(y||A)j.panBy({x:y,y:A})}}var i={},a={left:0,right:0,up:0,down:0},g=0,n,m=250,s=50,l=16,j,u;i.map=function(y){if(!arguments.length)return j;if(j){u.removeEventListener("keypress",c,false);u.removeEventListener("keydown",e,false);u.removeEventListener("keyup",f,false);u=null}if(j=y){u=j.focusableParent();u.addEventListener("keypress",c,false);u.addEventListener("keydown",e,false);u.addEventListener("keyup",f,false)}return i};i.speed=function(y){if(!arguments.length)return l;
+l=y;return i};return i};t.hash=function(){function e(){var m=n(a);if(k!==m)location.replace(k=m)}function f(){if(location.hash!==k){var m=g((k=location.hash).substring(1));if(m.length<3||m.some(isNaN))e();else{var s=a.size();a.zoomBy(m[0]-a.zoom(),{x:s.x/2,y:s.y/2},{lat:Math.min(i,Math.max(-i,m[1])),lon:m[2]})}}}var c={},k,i=89.99999999,a,g=function(m){return m.split("/").map(Number)},n=function(m){var s=m.center();m=m.zoom();var l=Math.max(0,Math.ceil(Math.log(m)/Math.LN2));return"#"+m.toFixed(2)+
+"/"+s.lat.toFixed(l)+"/"+s.lon.toFixed(l)};c.map=function(m){if(!arguments.length)return a;if(a){a.off("move",e);window.removeEventListener("hashchange",f,false)}if(a=m){a.on("move",e);window.addEventListener("hashchange",f,false);location.hash?f():e()}return c};c.parse=function(m){if(!arguments.length)return g;g=m;return c};c.format=function(m){if(!arguments.length)return n;n=m;return c};return c};t.interact=function(){var e={},f=t.drag(),c=t.wheel(),k=t.dblclick(),i=t.arrow();e.map=function(a){f.map(a);
+c.map(a);k.map(a);i.map(a);return e};return e};t.compass=function(){function e(x){B.setAttribute("class","compass active");I||(I=setInterval(f,r));R&&H.panBy(R);w=Date.now();return l(x)}function f(){R&&Date.now()>w+d&&H.panBy(R)}function c(x){if(x.shiftKey){F={x0:H.mouse(x)};H.focusableParent().focus();return l(x)}}function k(x){if(F){F.x1=H.mouse(x);O.setAttribute("x",Math.min(F.x0.x,F.x1.x));O.setAttribute("y",Math.min(F.x0.y,F.x1.y));O.setAttribute("width",Math.abs(F.x0.x-F.x1.x));O.setAttribute("height",
+Math.abs(F.x0.y-F.x1.y));O.removeAttribute("display")}}function i(){B.setAttribute("class","compass");if(F){if(F.x1){H.extent([H.pointLocation({x:Math.min(F.x0.x,F.x1.x),y:Math.max(F.x0.y,F.x1.y)}),H.pointLocation({x:Math.max(F.x0.x,F.x1.x),y:Math.min(F.x0.y,F.x1.y)})]);O.setAttribute("display","none")}F=null}if(I){clearInterval(I);I=0}}function a(x){return function(){x?this.setAttribute("class","active"):this.removeAttribute("class");R=x}}function g(x){return function(D){B.setAttribute("class","compass active");
+var G=H.zoom();H.zoom(x<0?Math.ceil(G)-1:Math.floor(G)+1);return l(D)}}function n(x){return function(D){H.zoom(x);return l(D)}}function m(){this.setAttribute("class","active")}function s(){this.removeAttribute("class")}function l(x){x.stopPropagation();x.preventDefault();return false}function j(x){var D=Math.SQRT1_2*h,G=h*0.7,J=h*0.2,N=t.svg("g"),P=N.appendChild(t.svg("path")),Q=N.appendChild(t.svg("path"));P.setAttribute("class","direction");P.setAttribute("pointer-events","all");P.setAttribute("d",
+"M0,0L"+D+","+D+"A"+h+","+h+" 0 0,1 "+-D+","+D+"Z");Q.setAttribute("class","chevron");Q.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));Q.setAttribute("pointer-events","none");N.addEventListener("mousedown",e,false);N.addEventListener("mouseover",a(x),false);N.addEventListener("mouseout",a(null),false);N.addEventListener("dblclick",l,false);return N}function u(x){var D=h*0.4,G=D/2,J=t.svg("g"),N=J.appendChild(t.svg("path")),P=J.appendChild(t.svg("path")),Q=J.appendChild(t.svg("path")),
+X=J.appendChild(t.svg("path"));N.setAttribute("class","back");N.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");P.setAttribute("class","direction");P.setAttribute("d",N.getAttribute("d"));Q.setAttribute("class","chevron");Q.setAttribute("d","M"+-G+","+-D+"H"+G+(x>0?"M0,"+(-D-G)+"V"+-G:""));X.setAttribute("class","fore");X.setAttribute("fill","none");X.setAttribute("d",N.getAttribute("d"));J.addEventListener("mousedown",g(x),false);J.addEventListener("mouseover",m,false);J.addEventListener("mouseout",
+s,false);J.addEventListener("dblclick",l,false);return J}function y(x){var D=h*0.2,G=h*0.4,J=t.svg("g"),N=J.appendChild(t.svg("rect")),P=J.appendChild(t.svg("path"));N.setAttribute("pointer-events","all");N.setAttribute("fill","none");N.setAttribute("x",-G);N.setAttribute("y",-0.75*G);N.setAttribute("width",2*G);N.setAttribute("height",1.5*G);P.setAttribute("class","chevron");P.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",n(x),false);J.addEventListener("dblclick",l,false);return J}
+function A(){var x=h+6,D=x,G=H.size();switch(q){case "top-left":break;case "top-right":x=G.x-x;break;case "bottom-left":D=G.y-D;break;case "bottom-right":x=G.x-x;D=G.y-D;break}x="translate("+x+","+D+")";M&&M.setAttribute("transform",x);v&&v.setAttribute("transform",x);for(var J in K)J==H.zoom()?K[J].setAttribute("class","active"):K[J].removeAttribute("class")}function C(){for(;B.lastChild;)B.removeChild(B.lastChild);B.appendChild(O);if(L!="none"){M=B.appendChild(t.svg("g"));M.setAttribute("class",
+"pan");var x=M.appendChild(t.svg("circle"));x.setAttribute("class","back");x.setAttribute("r",h);M.appendChild(j({x:0,y:-o})).setAttribute("transform","rotate(0)");M.appendChild(j({x:o,y:0})).setAttribute("transform","rotate(90)");M.appendChild(j({x:0,y:o})).setAttribute("transform","rotate(180)");M.appendChild(j({x:-o,y:0})).setAttribute("transform","rotate(270)");x=M.appendChild(t.svg("circle"));x.setAttribute("fill","none");x.setAttribute("class","fore");x.setAttribute("r",h)}else M=null;if(z!=
+"none"){v=B.appendChild(t.svg("g"));v.setAttribute("class","zoom");x=-0.5;if(z=="big"){K={};var D=H.zoomRange()[0];for(x=0;D<=H.zoomRange()[1];D++,x++)(K[D]=v.appendChild(y(D))).setAttribute("transform","translate(0,"+-(x+0.75)*h*0.4+")")}D=L=="none"?0.4:2;v.setAttribute("transform","translate(0,"+h*(/^top-/.test(q)?D+(x+0.5)*0.4:-D)+")");v.appendChild(u(+1)).setAttribute("transform","translate(0,"+-(x+0.5)*h*0.4+")");v.appendChild(u(-1)).setAttribute("transform","scale(-1)")}else v=null;A()}var E=
+{},B=t.svg("g"),K={},h=30,o=16,w=0,d=250,r=50,q="top-left",z="small",v,L="small",I,R,M,F,O=t.svg("rect"),H,T,U;B.setAttribute("class","compass");O.setAttribute("class","back fore");O.setAttribute("pointer-events","none");O.setAttribute("display","none");E.radius=function(x){if(!arguments.length)return h;h=x;H&&C();return E};E.speed=function(x){if(!arguments.length)return h;o=x;return E};E.position=function(x){if(!arguments.length)return q;q=x;H&&C();return E};E.pan=function(x){if(!arguments.length)return L;
+L=x;H&&C();return E};E.zoom=function(x){if(!arguments.length)return z;z=x;H&&C();return E};E.map=function(x){if(!arguments.length)return H;if(H){T.removeEventListener("mousedown",c,false);T.removeChild(B);T=null;U.removeEventListener("mousemove",k,false);U.removeEventListener("mouseup",i,false);U=null;H.off("move",A).off("resize",A)}if(H=x){T=H.container();T.appendChild(B);T.addEventListener("mousedown",c,false);U=T.ownerDocument.defaultView;U.addEventListener("mousemove",k,false);U.addEventListener("mouseup",
+i,false);H.on("move",A).on("resize",A);C()}return E};return E};t.grid=function(){function e(){var i=k.firstChild,a=c.size(),g=c.pointLocation(Y);c.pointLocation(a);var n=Math.pow(2,4-Math.round(c.zoom()));g.lat=Math.floor(g.lat/n)*n;g.lon=Math.ceil(g.lon/n)*n;for(var m;(m=c.locationPoint(g).x)<=a.x;g.lon+=n){i||(i=k.appendChild(t.svg("line")));i.setAttribute("x1",m);i.setAttribute("x2",m);i.setAttribute("y1",0);i.setAttribute("y2",a.y);i=i.nextSibling}for(;(m=c.locationPoint(g).y)<=a.y;g.lat-=n){i||
+(i=k.appendChild(t.svg("line")));i.setAttribute("y1",m);i.setAttribute("y2",m);i.setAttribute("x1",0);i.setAttribute("x2",a.x);i=i.nextSibling}for(;i;){a=i.nextSibling;k.removeChild(i);i=a}}var f={},c,k=t.svg("g");k.setAttribute("class","grid");f.map=function(i){if(!arguments.length)return c;if(c){k.parentNode.removeChild(k);c.off("move",e).off("resize",e)}if(c=i){c.on("move",e).on("resize",e);c.container().appendChild(k);c.dispatch({type:"move"})}return f};return f};t.stylist=function(){function e(i){var a=
+i.features.length,g=f.length,n=c.length,m,s,l,j,u,y;for(u=0;u<a;++u)if(s=(m=i.features[u]).element){m=m.data;for(y=0;y<g;++y){j=(l=f[y]).value;if(typeof j==="function")j=j.call(null,m);j==null?l.name.local?s.removeAttributeNS(l.name.space,l.name.local):s.removeAttribute(l.name):l.name.local?s.setAttributeNS(l.name.space,l.name.local,j):s.setAttribute(l.name,j)}for(y=0;y<n;++y){j=(l=c[y]).value;if(typeof j==="function")j=j.call(null,m);j==null?s.style.removeProperty(l.name):s.style.setProperty(l.name,
+j,l.priority)}if(j=k){if(typeof j==="function")j=j.call(null,m);for(;s.lastChild;)s.removeChild(s.lastChild);j!=null&&s.appendChild(t.svg("title")).appendChild(document.createTextNode(j))}}}var f=[],c=[],k;e.attr=function(i,a){f.push({name:fa(i),value:a});return e};e.style=function(i,a,g){c.push({name:i,value:a,priority:arguments.length<3?null:g});return e};e.title=function(i){k=i;return e};return e}})(org.polymaps);
View
28 src/Hash.js
@@ -4,19 +4,27 @@ po.hash = function() {
lat = 90 - 1e-8, // allowable latitude range
map;
- function move() {
+ var parse = function(s) {
+ return s.split("/").map(Number);
+ };
+
+ var format = function(map) {
var center = map.center(),
zoom = map.zoom(),
- precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2)),
- s1 = "#" + zoom.toFixed(2)
+ precision = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
+ return "#" + zoom.toFixed(2)
+ "/" + center.lat.toFixed(precision)
+ "/" + center.lon.toFixed(precision);
+ };
+
+ function move() {
+ var s1 = format(map);
if (s0 !== s1) location.replace(s0 = s1); // don't recenter the map!
}
function hashchange() {
if (location.hash === s0) return; // ignore spurious hashchange events
- var args = (s0 = location.hash).substring(1).split("/").map(Number);
+ var args = parse((s0 = location.hash).substring(1));
if (args.length < 3 || args.some(isNaN)) move(); // replace bogus hash
else {
var size = map.size();
@@ -40,5 +48,17 @@ po.hash = function() {
return hash;
};
+ hash.parse = function(x) {
+ if (!arguments.length) return parse;
+ parse = x;
+ return hash;
+ }
+
+ hash.format = function(x) {
+ if (!arguments.length) return format;
+ format = x;
+ return hash;
+ }
+
return hash;
};
Please sign in to comment.
Something went wrong with that request. Please try again.