Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote branch 'mbostock/master'

  • Loading branch information...
commit 92d64b0c9f2478a705beb5aed40151b6787bc485 2 parents dfd5375 + 518014f
@mbostock mbostock authored
View
2  .gitignore
@@ -1,2 +0,0 @@
-html
-*.d
View
1  examples/cluster/cluster.html
@@ -1,6 +1,7 @@
<html>
<head>
<script type="text/javascript" src="../../polymaps.js"></script>
+ <script type="text/javascript" src="../../lib/crimespotting/crimespotting.js"></script>
<script type="text/javascript" src="kmeans.js"></script>
<style type="text/css">
View
27 examples/cluster/cluster.js
@@ -28,38 +28,13 @@ map.add(po.geoJson()
map.add(po.compass()
.pan("none"));
-function crimespotting(template) {
- return function(c) {
- var max = 1 << c.zoom, column = c.column % max;
- if (column < 0) column += max;
- return template.replace(/{(.)}/g, function(s, v) {
- switch (v) {
- case "B": {
- var nw = map.coordinateLocation({row: c.row, column: column, zoom: c.zoom}),
- se = map.coordinateLocation({row: c.row + 1, column: column + 1, zoom: c.zoom}),
- pn = Math.ceil(Math.log(c.zoom) / Math.LN2);
- return nw.lon.toFixed(pn)
- + "," + se.lat.toFixed(pn)
- + "," + se.lon.toFixed(pn)
- + "," + nw.lat.toFixed(pn);
- }
- }
- return v;
- });
- };
-}
-
function load(e) {
var cluster = e.tile.cluster || (e.tile.cluster = kmeans()
.iterations(16)
.size(64));
for (var i = 0; i < e.features.length; i++) {
- var feature = e.features[i];
- cluster.add({
- x: Number(feature.element.getAttribute("cx")),
- y: Number(feature.element.getAttribute("cy"))
- });
+ cluster.add(e.features[i].data.geometry.coordinates);
}
var tile = e.tile, g = tile.element;
View
6 examples/example.css
@@ -1,9 +1,15 @@
+html, body {
+ height: 100%;
+}
+
body {
margin: 0;
background: #E5E0D9;
}
svg {
+ display: block;
+ overflow: hidden;
width: 100%;
height: 100%;
}
View
17 examples/hilbert/hilbert.html
@@ -0,0 +1,17 @@
+<html>
+ <head>
+ <script type="text/javascript" src="../../polymaps.js"></script>
+ <style type="text/css">
+
+@import url("../example.css");
+
+rect {
+ shape-rendering: crispEdges;
+}
+
+ </style>
+ </head>
+ <body id="map">
+ <script type="text/javascript" src="hilbert.js"></script>
+ </body>
+</html>
View
76 examples/hilbert/hilbert.js
@@ -0,0 +1,76 @@
+hilbert = (function() {
+ // Adapted from Nick Johnson: http://bit.ly/biWkkq
+ var pairs = [
+ [[0, 3], [1, 0], [3, 1], [2, 0]],
+ [[2, 1], [1, 1], [3, 0], [0, 2]],
+ [[2, 2], [3, 3], [1, 2], [0, 1]],
+ [[0, 0], [3, 2], [1, 3], [2, 3]]
+ ];
+ return function(x, y, z) {
+ var quad = 0,
+ pair,
+ i = 0;
+ while (--z >= 0) {
+ pair = pairs[quad][(x & (1 << z) ? 2 : 0) | (y & (1 << z) ? 1 : 0)];
+ i = (i << 2) | pair[0];
+ quad = pair[1];
+ }
+ return i;
+ };
+})();
+
+var po = org.polymaps;
+
+var size = {x: 32, y: 32};
+
+var map = po.map()
+ .container(document.getElementById("map").appendChild(po.svg("svg")))
+ .zoomRange([0, 6])
+ .tileSize(size)
+ .add(po.interact())
+ .add(po.hash());
+
+map.add(po.layer(rainbow));
+
+map.add(po.compass()
+ .pan("none"));
+
+function rainbow(tile) {
+ var rect = tile.element = po.svg("rect"),
+ i = hilbert(tile.column, tile.row, tile.zoom),
+ j = i / (Math.pow(4, tile.zoom) - 1),
+ k = 1 << tile.zoom;
+ if (tile.column < 0 || tile.column >= k) return;
+ rect.setAttribute("width", size.x);
+ rect.setAttribute("height", size.y);
+ rect.setAttribute("fill", hsl(30, .2, j));
+}
+
+function hsl(h, s, l) {
+ var m1,
+ m2;
+
+ /* Some simple corrections for h, s and l. */
+ h = h % 360; if (h < 0) h += 360;
+ s = s < 0 ? 0 : s > 1 ? 1 : s;
+ l = l < 0 ? 0 : l > 1 ? 1 : l;
+
+ /* From FvD 13.37, CSS Color Module Level 3 */
+ m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
+ m1 = 2 * l - m2;
+
+ function v(h) {
+ if (h > 360) h -= 360;
+ else if (h < 0) h += 360;
+ if (h < 60) return m1 + (m2 - m1) * h / 60;
+ if (h < 180) return m2;
+ if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
+ return m1;
+ }
+
+ function vv(h) {
+ return Math.round(v(h) * 255);
+ }
+
+ return "rgb(" + vv(h + 120) + "," + vv(h) + "," + vv(h - 120) + ")";
+}
View
2  examples/kml/kml.js
@@ -55,7 +55,7 @@
}
if (f.geometry) features.push(f);
}
- return {features: features};
+ return {type: "FeatureCollection", features: features};
}
return kml;
View
22 examples/loupe/loupe-map.js
@@ -0,0 +1,22 @@
+var po = org.polymaps;
+
+var map = po.map()
+ .container(document.getElementById("map").appendChild(po.svg("svg")))
+ .add(po.interact())
+ .add(po.hash());
+
+map.add(po.image()
+ .url(po.url("http://{S}tile.cloudmade.com"
+ + "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register
+ + "/998/256/{Z}/{X}/{Y}.png")
+ .hosts(["a.", "b.", "c.", ""])));
+
+map.add(po.loupe()
+ .add(po.image()
+ .url(po.url("http://{S}tile.cloudmade.com"
+ + "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register
+ + "/999/256/{Z}/{X}/{Y}.png")
+ .hosts(["a.", "b.", "c.", ""]))));
+
+map.add(po.compass()
+ .pan("none"));
View
30 examples/loupe/loupe.html
@@ -0,0 +1,30 @@
+<html>
+ <head>
+ <script type="text/javascript" src="../../polymaps.js"></script>
+ <script type="text/javascript" src="loupe.js"></script>
+ <style type="text/css">
+
+@import url("../example.css");
+
+.loupe .back {
+ stroke: #000;
+ stroke-width: 8px;
+}
+
+.loupe .fore {
+ stroke: #ccc;
+ stroke-width: 6px;
+}
+
+ </style>
+ </head>
+ <body id="map">
+ <script type="text/javascript" src="loupe-map.js"></script>
+ <span id="copy">
+ &copy; 2010
+ <a href="http://www.cloudmade.com/">CloudMade</a>,
+ <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors,
+ <a href="http://creativecommons.org/licenses/by-sa/2.0/">CCBYSA</a>.
+ </span>
+ </body>
+</html>
View
244 examples/loupe/loupe.js
@@ -0,0 +1,244 @@
+(function(po) {
+ po.loupe = function() {
+ var loupe = po.map(),
+ container = po.svg("g"),
+ clipId = "org.polymaps." + po.id(),
+ clipHref = "url(#" + clipId + ")",
+ clipPath = container.appendChild(po.svg("clipPath")),
+ clipCircle = clipPath.appendChild(po.svg("circle")),
+ back = po.svg("circle"),
+ tab = po.svg("path"),
+ fore = po.svg("circle"),
+ centerPoint = null,
+ zoomDelta = 0,
+ tabPosition = "bottom-right",
+ tabAngles = {"top-left": 180, "top-right": 270, "bottom-left": 90},
+ visible = true,
+ r = 128,
+ rr = [64, 384],
+ k = 1,
+ map,
+ f0,
+ m0,
+ p0,
+ repeatInterval,
+ repeatRate = 30,
+ repeatPan = {x: 0, y: 0};
+
+ loupe
+ .size({x: r * 2, y: r * 2})
+ .container(container)
+ .centerRange(null)
+ .zoomRange(null)
+ .on("move", loupemove);
+
+ container.appendChild(back).setAttribute("class", "back");
+ container.appendChild(tab).setAttribute("class", "tab");
+ container.appendChild(fore).setAttribute("class", "fore");
+ clipPath.setAttribute("id", clipId);
+ container.setAttribute("class", "map loupe");
+
+ back.addEventListener("mousedown", mousedown, false);
+ tab.addEventListener("mousedown", mousedown, false);
+ fore.addEventListener("mousedown", foredown, false);
+ fore.setAttribute("fill", "none");
+ fore.setAttribute("cursor", "ew-resize");
+ window.addEventListener("mouseup", mouseup, false);
+ window.addEventListener("mousemove", mousemove, false);
+
+ // update the center point if the center is set explicitly
+ function loupemove() {
+ if (!map) return;
+ loupe.centerPoint(map.locationPoint(loupe.center()));
+ }
+
+ // update the center and zoom level if the underlying map moves
+ function mapmove() {
+ if (!map) return;
+ var z0 = map.zoom() + zoomDelta,
+ z1 = loupe.zoom();
+ loupe.off("move", loupemove)
+ .zoomBy(z0 - z1, {x: r, y: r}, map.pointLocation(centerPoint))
+ .on("move", loupemove);
+ clipCircle.setAttribute("r", r * (k = Math.pow(2, Math.round(z0) - z0)));
+ container.setAttribute("transform", "translate(" + (centerPoint.x - r) + "," + (centerPoint.y - r) + ")");
+ }
+
+ function foredown(e) {
+ f0 = true;
+ document.body.style.setProperty("cursor", "ew-resize", null);
+ map.focusableParent().focus();
+ return cancel(e);
+ }
+
+ function foremove(e) {
+ var p0 = map.mouse(e),
+ p1 = loupe.centerPoint(),
+ dx = p1.x - p0.x,
+ dy = p1.y - p0.y,
+ r = Math.sqrt(dx * dx + dy * dy);
+ loupe.radius(r ^ (r & 1));
+ return cancel(e);
+ }
+
+ function mousedown(e) {
+ m0 = map.mouse(e);
+ p0 = loupe.centerPoint();
+ map.focusableParent().focus();
+ return cancel(e);
+ }
+
+ function mousemove(e) {
+ if (f0) return foremove(e);
+ if (!m0) return;
+ var m1 = map.mouse(e),
+ size = map.size(),
+ x = p0.x - m0.x + m1.x,
+ y = p0.y - m0.y + m1.y;
+
+ // determine whether we're offscreen
+ repeatPan.x = x < 0 ? -x : x > size.x ? size.x - x : 0;
+ repeatPan.y = y < 0 ? -y : y > size.y ? size.y - y : 0;
+
+ // if the loupe is offscreen, start a new pan interval
+ if (repeatPan.x || repeatPan.y) {
+ repeatPan.x /= 10;
+ repeatPan.y /= 10;
+ if (!repeatInterval) repeatInterval = setInterval(mouserepeat, repeatRate);
+ } else if (repeatInterval) {
+ repeatInterval = clearInterval(repeatInterval);
+ }
+
+ centerPoint = {x: Math.round(x), y: Math.round(y)};
+ mapmove();
+ return cancel(e);
+ }
+
+ function mouserepeat() {
+ map.panBy(repeatPan);
+ }
+
+ function mouseup(e) {
+ if (f0) {
+ f0 = null;
+ document.body.style.removeProperty("cursor");
+ }
+ if (m0) {
+ if (repeatInterval) repeatInterval = clearInterval(repeatInterval);
+ m0 = p0 = null;
+ }
+ return cancel(e);
+ }
+
+ function cancel(e) {
+ e.stopPropagation();
+ e.preventDefault();
+ return false;
+ }
+
+ loupe.map = function(x) {
+ if (!arguments.length) return map;
+ if (map) {
+ map.container().removeChild(loupe.container());
+ map.off("move", move).off("resize", move);
+ }
+ if (map = x) {
+ if (!centerPoint) {
+ var size = map.size();
+ centerPoint = {x: size.x >> 1, y: size.y >> 1};
+ }
+ map.on("move", mapmove).on("resize", mapmove);
+ map.container().appendChild(loupe.container());
+ mapmove();
+ }
+ return loupe;
+ };
+
+ var __add__ = loupe.add;
+ loupe.add = function(x) {
+ __add__(x);
+ if (x.container) {
+ x = x.container();
+ x.setAttribute("clip-path", clipHref);
+ x.setAttribute("pointer-events", "none");
+ }
+ container.appendChild(fore); // move to end
+ return loupe;
+ };
+
+ loupe.centerPoint = function(x) {
+ if (!arguments.length) return centerPoint;
+ centerPoint = {x: Math.round(x.x), y: Math.round(x.y)};
+ if (map) mapmove();
+ return loupe;
+ };
+
+ loupe.radiusRange = function(x) {
+ if (!arguments.length) return rr;
+ rr = x;
+ return loupe.radius(r);
+ };
+
+ loupe.radius = function(x) {
+ if (!arguments.length) return r;
+ r = rr ? Math.max(rr[0], Math.min(rr[1], x)) : x;
+
+ // update back, fore and clip
+ back.setAttribute("cx", r);
+ back.setAttribute("cy", r);
+ back.setAttribute("r", r);
+ fore.setAttribute("cx", r);
+ fore.setAttribute("cy", r);
+ fore.setAttribute("r", r);
+ clipCircle.setAttribute("r", r * k);
+
+ // update the tab path
+ tab.setAttribute("d", "M" + r + "," + 2 * r
+ + "H" + 1.9 * r
+ + "A" + r * .1 + "," + r * .1 + " 0 0,0 " + 2 * r + "," + 1.9 * r
+ + "V" + r
+ + "A" + r + "," + r + " 0 0,1 " + r + "," + 2 * r
+ + "Z");
+
+ // update the tab position
+ if (tabPosition == "none") tab.setAttribute("display", "none");
+ else {
+ tab.removeAttribute("display");
+ var a = tabAngles[tabPosition];
+ if (a) tab.setAttribute("transform", "rotate(" + a + " " + r + "," + r + ")");
+ else tab.removeAttribute("transform");
+ }
+
+ // update map size
+ loupe.size({x: r * 2, y: r * 2})
+
+ if (map) mapmove();
+ return loupe;
+ };
+
+ loupe.tab = function(x) {
+ if (!arguments.length) return tabPosition;
+ tabPosition = x;
+ return loupe.radius(r);
+ };
+
+ loupe.zoomDelta = function(x) {
+ if (!arguments.length) return zoomDelta;
+ zoomDelta = x;
+ if (map) mapmove();
+ return loupe;
+ };
+
+ loupe.visible = function(x) {
+ if (!arguments.length) return visible;
+ visible = x;
+ if (x) g.removeAttribute("visibility");
+ else g.setAttribute("visibility", "hidden");
+ return loupe;
+ };
+
+ loupe.radius(r); // initialize circles
+
+ return loupe;
+ };
+})(org.polymaps);
View
39 examples/marker/marker.html
@@ -0,0 +1,39 @@
+<html>
+ <head>
+ <script type="text/javascript" src="../../polymaps.js"></script>
+ <script type="text/javascript" src="../../lib/raphaeljs/icons.js"></script>
+ <script type="text/javascript" src="../../lib/crimespotting/crimespotting.js"></script>
+ <style type="text/css">
+
+@import url("../example.css");
+
+#map {
+ background: #E6E6E6;
+}
+
+.layer use {
+ stroke: #ccc;
+ stroke-opacity: .5;
+}
+
+#copy {
+ color: #000;
+ opacity: .5;
+}
+
+#copy a {
+ color: #000;
+}
+
+ </style>
+ </head>
+ <body id="map">
+ <script type="text/javascript" src="marker.js"></script>
+ <span id="copy">
+ &copy; 2010
+ <a href="http://www.cloudmade.com/">CloudMade</a>,
+ <a href="http://www.openstreetmap.org/">OpenStreetMap</a> contributors,
+ <a href="http://creativecommons.org/licenses/by-sa/2.0/">CCBYSA</a>.
+ </span>
+ </body>
+</html>
View
76 examples/marker/marker.js
@@ -0,0 +1,76 @@
+var po = org.polymaps;
+
+var svg = document.getElementById("map").appendChild(po.svg("svg")),
+ defs = svg.appendChild(po.svg("defs"));
+
+/* Create three linear gradients for each category. */
+defs.appendChild(gradient("#D90000", "#A30000")).setAttribute("id", "gradient-violent");
+defs.appendChild(gradient("#23965E", "#1A7046")).setAttribute("id", "gradient-property");
+defs.appendChild(gradient("#3489BA", "#27678B")).setAttribute("id", "gradient-quality");
+
+/* Create a marker path. */
+defs.appendChild(icons.marker()).setAttribute("id", "marker");
+
+var map = po.map()
+ .container(svg)
+ .center({lat: 37.787, lon: -122.228})
+ .zoomRange([11,16])
+ .zoom(12)
+ .add(po.interact());
+
+map.add(po.image()
+ .url(po.url("http://{S}tile.cloudmade.com"
+ + "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register
+ + "/998/256/{Z}/{X}/{Y}.png")
+ .hosts(["a.", "b.", "c.", ""])));
+
+map.add(po.geoJson()
+ .url(crimespotting("http://oakland.crimespotting.org"
+ + "/crime-data"
+ + "?count=100"
+ + "&format=json"
+ + "&bbox={B}"
+ + "&dstart=2010-04-01"
+ + "&dend=2010-04-01"))
+ .on("load", load)
+ .clip(false)
+ .scale("fixed")
+ .zoom(12));
+
+map.add(po.compass()
+ .pan("none"));
+
+/* Post-process the GeoJSON points and replace them with markers! */
+function load(e) {
+ e.features.sort(function(a, b) {
+ return b.data.geometry.coordinates[1] - a.data.geometry.coordinates[1];
+ });
+ for (var i = 0; i < e.features.length; i++) {
+ var f = e.features[i],
+ d = f.data,
+ c = f.element,
+ p = c.parentNode,
+ u = f.element = po.svg("use");
+ u.setAttributeNS(po.ns.xlink, "href", "url(#marker)");
+ u.setAttribute("transform", c.getAttribute("transform"));
+ u.setAttribute("fill", "url(#gradient-" + crimespotting.categorize(d) + ")");
+ p.removeChild(c);
+ p.appendChild(u);
+ }
+}
+
+/* Helper method for constructing a linear gradient. */
+function gradient(a, b) {
+ var g = po.svg("linearGradient");
+ g.setAttribute("x1", 0);
+ g.setAttribute("y1", 1);
+ g.setAttribute("x2", 0);
+ g.setAttribute("y2", 0);
+ var s0 = g.appendChild(po.svg("stop"));
+ s0.setAttribute("offset", "0%");
+ s0.setAttribute("stop-color", a);
+ var s1 = g.appendChild(po.svg("stop"));
+ s1.setAttribute("offset", "100%");
+ s1.setAttribute("stop-color", b);
+ return g;
+}
View
5 examples/tipsy/tipsy.html
@@ -9,11 +9,6 @@
@import url("../../lib/tipsy/tipsy.css");
@import url("../example.css");
-body {
- font: 12px Helvetica Neue;
- overflow: hidden;
-}
-
.layer circle {
fill: lightcoral;
fill-opacity: .5;
View
42 lib/crimespotting/crimespotting.js
@@ -0,0 +1,42 @@
+/* URL template for loading Crimespotting data. */
+function crimespotting(template) {
+ return function(c) {
+ var max = 1 << c.zoom, column = c.column % max;
+ if (column < 0) column += max;
+ return template.replace(/{(.)}/g, function(s, v) {
+ switch (v) {
+ case "B": {
+ var nw = map.coordinateLocation({row: c.row, column: column, zoom: c.zoom}),
+ se = map.coordinateLocation({row: c.row + 1, column: column + 1, zoom: c.zoom}),
+ pn = Math.ceil(Math.log(c.zoom) / Math.LN2);
+ return nw.lon.toFixed(pn)
+ + "," + se.lat.toFixed(pn)
+ + "," + se.lon.toFixed(pn)
+ + "," + nw.lat.toFixed(pn);
+ }
+ }
+ return v;
+ });
+ };
+}
+
+crimespotting.categorize = (function() {
+ var categories = {
+ "aggravated assault": "violent",
+ "murder": "violent",
+ "robbery": "violent",
+ "simple assault": "violent",
+ "arson": "property",
+ "burglary": "property",
+ "theft": "property",
+ "vandalism": "property",
+ "vehicle theft": "property",
+ "alcohol": "quality",
+ "disturbing the peace": "quality",
+ "narcotics": "quality",
+ "prostitution": "quality"
+ };
+ return function(d) {
+ return categories[d.properties.crime_type.toLowerCase()];
+ };
+})();
View
18 lib/raphaeljs/LICENSE
@@ -0,0 +1,18 @@
+Copyright (c) 2008 Dmitry Baranovskiy
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
12 lib/raphaeljs/icons.js
@@ -0,0 +1,12 @@
+// http://raphaeljs.com/icons/
+
+var icons = (function(po) {
+ return {
+ marker: function() {
+ var path = po.svg("path");
+ path.setAttribute("transform", "translate(-16,-28)");
+ path.setAttribute("d", "M16,3.5c-4.142,0-7.5,3.358-7.5,7.5c0,4.143,7.5,18.121,7.5,18.121S23.5,15.143,23.5,11C23.5,6.858,20.143,3.5,16,3.5z M16,14.584c-1.979,0-3.584-1.604-3.584-3.584S14.021,7.416,16,7.416S19.584,9.021,19.584,11S17.979,14.584,16,14.584z");
+ return path;
+ }
+ };
+})(org.polymaps);
View
287 polymaps.js
@@ -2,7 +2,7 @@ if (!org) var org = {};
if (!org.polymaps) org.polymaps = {};
(function(po){
- po.version = "2.2.0"; // semver.org
+ po.version = "2.3.0"; // semver.org
var zero = {x: 0, y: 0};
po.ns = {
@@ -514,17 +514,9 @@ po.map = function() {
map.resize = function() {
if (!size) {
- /*
- * Firefox does not correctly report the dimensions of SVG elements.
- * However, it does correctly report the size of the child rect!
- */
- var e = container.ownerSVGElement || container;
- if (e.offsetWidth == null) {
- rect.setAttribute("width", "100%");
- rect.setAttribute("height", "100%");
- e = rect;
- }
- b = e.getClientRects()[0];
+ rect.setAttribute("width", "100%");
+ rect.setAttribute("height", "100%");
+ b = rect.getBBox();
sizeActual = {x: b.width, y: b.height};
resizer.add(map);
} else {
@@ -922,10 +914,10 @@ po.layer = function(load, unload) {
// position tiles
for (var key in newLocks) {
var t = newLocks[key],
- k = Math.pow(2, t.level = t.zoom - tileCenter.zoom),
- x = tileSize.x * (t.column - tileCenter.column * k),
- y = tileSize.y * (t.row - tileCenter.row * k);
- t.element.setAttribute("transform", "translate(" + x + "," + y + ")");
+ k = 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)) + ")");
}
// remove tiles that are no longer visible
@@ -948,6 +940,9 @@ po.layer = function(load, unload) {
// flush the cache, clearing no-longer-needed tiles
cache.flush();
+
+ // dispatch the move event
+ layer.dispatch({type: "move"});
}
// remove proxy tiles when tiles load
@@ -987,6 +982,10 @@ po.layer = function(load, unload) {
return container;
};
+ layer.levels = function() {
+ return levels;
+ };
+
layer.id = function(x) {
if (!arguments.length) return id;
id = x;
@@ -1089,16 +1088,16 @@ function scanTriangle(a, b, c, ymin, ymax, scanLine) {
}
po.image = function() {
var image = po.layer(load, unload),
- url = "about:blank";
+ url;
function load(tile) {
var element = tile.element = po.svg("image"), size = image.map().tileSize();
element.setAttribute("preserveAspectRatio", "none");
element.setAttribute("width", size.x);
element.setAttribute("height", size.y);
- element.setAttribute("opacity", 0);
if (typeof url == "function") {
+ element.setAttribute("opacity", 0);
tile.request = po.queue.image(element, url(tile), function(img) {
delete tile.request;
tile.ready = true;
@@ -1108,7 +1107,7 @@ po.image = function() {
});
} else {
tile.ready = true;
- element.setAttributeNS(po.ns.xlink, "href", url);
+ if (url) element.setAttributeNS(po.ns.xlink, "href", url);
image.dispatch({type: "load", tile: tile});
}
}
@@ -1128,12 +1127,13 @@ po.image = function() {
po.geoJson = function(fetch) {
var geoJson = po.layer(load, unload),
container = geoJson.container(),
- url = "about:blank",
+ url,
clip = true,
clipId = "org.polymaps." + po.id(),
clipHref = "url(#" + clipId + ")",
clipPath = container.insertBefore(po.svg("clipPath"), container.firstChild),
clipRect = clipPath.appendChild(po.svg("rect")),
+ scale = "auto",
zoom = null,
features;
@@ -1142,95 +1142,181 @@ po.geoJson = function(fetch) {
if (!arguments.length) fetch = po.queue.json;
- function geometry(o, proj) {
- return o && o.type in types && types[o.type](o, proj);
- }
-
- function point(coordinates, proj) {
- var p = proj({lat: coordinates[1], lon: coordinates[0]}),
- c = po.svg("circle");
- c.setAttribute("r", 4.5);
- c.setAttribute("cx", p.x);
- c.setAttribute("cy", p.y);
- return c;
- }
-
- function line(coordinates, closed, proj, d) {
- d.push("M");
- for (var i = 0; i < coordinates.length - closed; i++) {
- p = proj({lat: coordinates[i][1], lon: coordinates[i][0]});
- d.push(p.x);
- d.push(",");
- d.push(p.y);
- d.push("L");
- }
- d.pop();
- }
-
- function polygon(coordinates, closed, proj, d) {
- for (var i = 0; i < coordinates.length; i++) {
- line(coordinates[i], closed, proj, d);
- }
- if (closed) d.push("Z");
+ function projection(proj) {
+ var l = {lat: 0, lon: 0};
+ return function(coordinates) {
+ l.lat = coordinates[1];
+ l.lon = coordinates[0];
+ var p = proj(l);
+ coordinates.x = p.x;
+ coordinates.y = p.y;
+ return p;
+ };
}
- function multi(type, coordinates, closed, proj) {
- var d = [];
- for (var i = 0; i < coordinates.length; i++) {
- type(coordinates[i], closed, proj, d);
- }
- if (!d.length) return;
- var path = po.svg("path");
- path.setAttribute("d", d.join(""));
- return path;
+ function geometry(o, proj) {
+ return o && o.type in types && types[o.type](o, proj);
}
var types = {
Point: function(o, proj) {
- return point(o.coordinates, proj);
+ var p = proj(o.coordinates),
+ c = po.svg("circle");
+ c.setAttribute("r", 4.5);
+ c.setAttribute("transform", "translate(" + p.x + "," + p.y + ")");
+ return c;
},
MultiPoint: function(o, proj) {
- var g = po.svg("g");
- for (var i = 0; i < o.coordinates.length; i++) {
- g.appendChild(point(o.coordinates[i], proj));
+ var g = po.svg("g"),
+ c = o.coordinates,
+ p, // proj(c[i])
+ x, // svg:circle
+ i = -1,
+ n = c.length;
+ while (++i < n) {
+ x = g.appendChild(po.svg("circle"));
+ x.setAttribute("r", 4.5);
+ x.setAttribute("transform", "translate(" + (p = proj(c[i])).x + "," + p.y + ")");
}
return g;
},
LineString: function(o, proj) {
- return multi(line, [o.coordinates], 0, proj);
+ var x = po.svg("path"),
+ d = ["M"],
+ c = o.coordinates,
+ p, // proj(c[i])
+ i = -1,
+ n = c.length;
+ while (++i < n) d.push((p = proj(c[i])).x, ",", p.y, "L");
+ d.pop();
+ if (!d.length) return;
+ x.setAttribute("d", d.join(""));
+ return x;
},
MultiLineString: function(o, proj) {
- return multi(line, o.coordinates, 0, proj);
+ var x = po.svg("path"),
+ d = [],
+ ci = o.coordinates,
+ cj, // ci[i]
+ i = -1,
+ j,
+ n = ci.length,
+ m;
+ while (++i < n) {
+ cj = ci[i];
+ j = -1;
+ m = cj.length;
+ d.push("M");
+ while (++j < m) d.push((p = proj(cj[j])).x, ",", p.y, "L");
+ d.pop();
+ }
+ if (!d.length) return;
+ x.setAttribute("d", d.join(""));
+ return x;
},
Polygon: function(o, proj) {
- return multi(polygon, [o.coordinates], 1, proj);
+ var x = po.svg("path"),
+ d = [],
+ ci = o.coordinates,
+ cj, // ci[i]
+ i = -1,
+ j,
+ n = ci.length,
+ m;
+ while (++i < n) {
+ cj = ci[i];
+ j = -1;
+ m = cj.length - 1;
+ d.push("M");
+ while (++j < m) d.push((p = proj(cj[j])).x, ",", p.y, "L");
+ d[d.length - 1] = "Z";
+ }
+ if (!d.length) return;
+ x.setAttribute("d", d.join(""));
+ return x;
},
MultiPolygon: function(o, proj) {
- return multi(polygon, o.coordinates || o.coords, 1, proj); // TODO coords
+ var x = po.svg("path"),
+ d = [],
+ ci = o.coordinates,
+ cj, // ci[i]
+ ck, // cj[j]
+ i = -1,
+ j,
+ k,
+ n = ci.length,
+ m,
+ l;
+ while (++i < n) {
+ cj = ci[i];
+ j = -1;
+ m = cj.length;
+ while (++j < m) {
+ ck = cj[j];
+ k = -1;
+ l = ck.length - 1;
+ d.push("M");
+ while (++k < l) d.push((p = proj(ck[k])).x, ",", p.y, "L");
+ d[d.length - 1] = "Z";
+ }
+ }
+ if (!d.length) return;
+ x.setAttribute("d", d.join(""));
+ return x;
},
GeometryCollection: function(o, proj) {
- var g = po.svg("g");
- for (var i = 0; i < o.geometries.length; i++) {
- var element = geometry(o.geometries[i], proj);
- if (element) g.appendChild(element);
+ var g = po.svg("g"),
+ i = -1,
+ c = o.geometries,
+ n = c.length,
+ x;
+ while (++i < n) {
+ x = geometry(c[i], proj);
+ if (x) g.appendChild(x);
}
return g;
}
};
+ function rescale(o, e, k) {
+ return o.type in rescales && rescales[o.type](o, e, k);
+ }
+
+ var rescales = {
+
+ Point: function (o, e, k) {
+ var p = o.coordinates;
+ e.setAttribute("transform", "translate(" + p.x + "," + p.y + ")" + k);
+ },
+
+ MultiPoint: function (o, e, k) {
+ var c = o.coordinates,
+ i = -1,
+ n = p.length,
+ x = e.firstChild,
+ p;
+ while (++i < n) {
+ p = c[i];
+ x.setAttribute("transform", "translate(" + p.x + "," + p.y + ")" + k);
+ x = x.nextSibling;
+ }
+ }
+
+ };
+
function load(tile, proj) {
var g = tile.element = po.svg("g");
tile.features = [];
- proj = proj(tile);
+ proj = projection(proj(tile).locationPoint);
function update(data) {
var updated = [];
@@ -1243,18 +1329,18 @@ po.geoJson = function(fetch) {
case "FeatureCollection": {
for (var i = 0; i < data.features.length; i++) {
var feature = data.features[i],
- element = geometry(feature.geometry, proj.locationPoint);
+ element = geometry(feature.geometry, proj);
if (element) updated.push({element: g.appendChild(element), data: feature});
}
break;
}
case "Feature": {
- var element = geometry(data.geometry, proj.locationPoint);
+ var element = geometry(data.geometry, proj);
if (element) updated.push({element: g.appendChild(element), data: data});
break;
}
default: {
- var element = geometry(data, proj.locationPoint);
+ var element = geometry(data, proj);
if (element) updated.push({element: g.appendChild(element), data: {type: "Feature", geometry: data}});
break;
}
@@ -1265,10 +1351,10 @@ po.geoJson = function(fetch) {
geoJson.dispatch({type: "load", tile: tile, features: updated});
}
- if (features) {
- update({type: "FeatureCollection", features: features});
- } else {
+ if (url != null) {
tile.request = fetch(typeof url == "function" ? url(tile) : url, update);
+ } else {
+ update({type: "FeatureCollection", features: features || []});
}
}
@@ -1276,17 +1362,50 @@ po.geoJson = function(fetch) {
if (tile.request) tile.request.abort(true);
}
+ function move() {
+ var zoom = geoJson.map().zoom(),
+ tiles = geoJson.cache.locks(), // visible tiles
+ key, // key in locks
+ tile, // locks[key]
+ features, // tile.features
+ i, // current feature index
+ n, // current feature count, features.length
+ feature, // features[i]
+ k; // scale transform
+ if (scale == "fixed") {
+ for (key in tiles) {
+ if ((tile = tiles[key]).scale != zoom) {
+ k = "scale(" + Math.pow(2, tile.zoom - zoom) + ")";
+ i = -1;
+ n = (features = tile.features).length;
+ while (++i < n) rescale((feature = features[i]).data.geometry, feature.element, k);
+ tile.scale = zoom;
+ }
+ }
+ } else {
+ for (key in tiles) {
+ i = -1;
+ n = (features = (tile = tiles[key]).features).length;
+ while (++i < n) rescale((feature = features[i]).data.geometry, feature.element, "");
+ delete tile.scale;
+ }
+ }
+ }
+
geoJson.url = function(x) {
if (!arguments.length) return url;
url = typeof x == "string" && /{.}/.test(x) ? po.url(x) : x;
+ if (url != null) features = null;
if (typeof url == "string") geoJson.tile(false);
return geoJson.reload();
};
geoJson.features = function(x) {
if (!arguments.length) return features;
- if (x) geoJson.tile(false);
- features = x;
+ if (features = x) {
+ url = null;
+ geoJson.tile(false);
+ }
return geoJson.reload();
};
@@ -1318,6 +1437,14 @@ po.geoJson = function(fetch) {
return __map__.apply(geoJson, arguments);
};
+ geoJson.scale = function(x) {
+ if (!arguments.length) return scale;
+ if (scale = x) geoJson.on("move", move);
+ else geoJson.off("move", move);
+ if (geoJson.map()) move();
+ return geoJson;
+ };
+
geoJson.show = function(tile) {
if (clip) tile.element.setAttribute("clip-path", clipHref);
else tile.element.removeAttribute("clip-path");
View
119 polymaps.min.js
@@ -1,59 +1,62 @@
if(!org)var org={};if(!org.polymaps)org.polymaps={};
-(function(r){function fa(e){var f=e.indexOf(":");return f<0?e:{space:r.ns[e.substring(0,f)],local:e.substring(f+1)}}function Q(){for(var e=0;e<Q.maps.length;e++)Q.maps[e].resize()}function U(e){return 360/Math.PI*Math.atan(Math.exp(e*Math.PI/180))-90}function V(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 a=e;e=f;f=a}return{x0:e.column,y0:e.row,x1:f.column,y1:f.row,dx:f.column-e.column,dy:f.row-e.row}}function ca(e,f,a,g,h){a=Math.max(a,Math.floor(f.y0));
-g=Math.min(g,Math.ceil(f.y1));if(e.x0==f.x0&&e.y0==f.y0?e.x0+f.dy/e.dy*e.dx<f.x1:e.x1-f.dy/e.dy*e.dx<f.x0){var c=e;e=f;f=c}c=e.dx/e.dy;var d=f.dx/f.dy,l=e.dx>0,n=f.dx<0;for(a=a;a<g;a++){var q=c*Math.max(0,Math.min(e.dy,a+l-e.y0))+e.x0;h(Math.floor(d*Math.max(0,Math.min(f.dy,a+n-f.y0))+f.x0),Math.ceil(q),a)}}function da(e,f,a,g,h,c){var d=Z(e,f);f=Z(f,a);e=Z(a,e);if(d.dy>f.dy){a=d;d=f;f=a}if(d.dy>e.dy){a=d;d=e;e=a}if(f.dy>e.dy){a=f;f=e;e=a}d.dy&&ca(e,d,g,h,c);f.dy&&ca(e,f,g,h,c)}r.version="2.2.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 e=0;return function(){return++e}}();r.svg=function(e){return document.createElementNS(r.ns.svg,e)};r.transform=function(e,f,a,g,h,c){var d={},l,n,q;if(!arguments.length){e=1;f=h=a=0;g=1;c=0}d.zoomFraction=function(k){if(!arguments.length)return n;n=k;l=Math.floor(n+Math.log(Math.sqrt(e*e+f*f+a*a+g*g))/Math.log(2));q=Math.pow(2,-l);return d};d.apply=function(k){var i=Math.pow(2,-k.zoom),
-s=Math.pow(2,k.zoom-l);return{column:(e*k.column*i+a*k.row*i+h)*s,row:(f*k.column*i+g*k.row*i+c)*s,zoom:k.zoom-l}};d.unapply=function(k){var i=Math.pow(2,-k.zoom),s=Math.pow(2,k.zoom+l);return{column:(k.column*i*g-k.row*i*a-h*g+c*a)/(e*g-f*a)*s,row:(k.column*i*f-k.row*i*e-h*f+c*e)/(a*f-g*e)*s,zoom:k.zoom+l}};d.toString=function(){return"matrix("+[e*q,f*q,a*q,g*q].join(" ")+" 0 0)"};return d.zoomFraction(0)};r.cache=function(e,f){function a(i){k--;f&&f(i);delete d[i.key];if(i.next)i.next.prev=i.prev;
-else if(n=i.prev)n.next=null;if(i.prev)i.prev.next=i.next;else if(l=i.next)l.prev=null}function g(){for(var i=n;k>q;i=i.prev){if(!i)break;i.lock||a(i)}}var h={},c={},d={},l=null,n=null,q=64,k=0;h.peek=function(i){return d[[i.zoom,i.column,i.row].join("/")]};h.load=function(i,s){var w=[i.zoom,i.column,i.row].join("/"),y=d[w];if(y){if(y.prev){if(y.prev.next=y.next)y.next.prev=y.prev;else n=y.prev;y.prev=null;y.next=l;l=l.prev=y}y.lock=1;return c[w]=y}y={key:w,column:i.column,row:i.row,zoom:i.zoom,next:l,
-prev:null,lock:1};e.call(null,y,s);c[w]=d[w]=y;if(l)l.prev=y;else n=y;l=y;k++;return y};h.unload=function(i){if(!(i in c))return false;var s=c[i];s.lock=0;delete c[i];s.request&&s.request.abort(false)&&a(s);return s};h.locks=function(){return c};h.size=function(i){if(!arguments.length)return q;q=i;g();return h};h.flush=function(){g();return h};h.clear=function(){for(var i in d){var s=d[i];s.request&&s.request.abort(false);f&&f(d[i]);if(s.lock){s.lock=0;s.element.parentNode.removeChild(s.element)}}c=
-{};d={};l=n=null;k=0;return h};return h};r.url=function(e){function f(g){var h=g.zoom<0?1:1<<g.zoom,c=g.column%h;if(c<0)c+=h;return e.replace(/{(.)}/g,function(d,l){switch(l){case "S":return a[(Math.abs(g.zoom)+g.row+c)%a.length];case "Z":return g.zoom;case "X":return c;case "Y":return g.row;case "B":var n=r.map.coordinateLocation({row:g.row,column:c,zoom:g.zoom}),q=r.map.coordinateLocation({row:g.row+1,column:c+1,zoom:g.zoom}),k=Math.ceil(Math.log(g.zoom)/Math.LN2);return q.lat.toFixed(k)+","+n.lon.toFixed(k)+
-","+n.lat.toFixed(k)+","+q.lon.toFixed(k)}return l})}var a=[];f.template=function(g){if(!arguments.length)return e;e=g;return f};f.hosts=function(g){if(!arguments.length)return a;a=g;return f};return f};r.dispatch=function(e){var f={};e.on=function(a,g){for(var h=f[a]||(f[a]=[]),c=0;c<h.length;c++)if(h[c].handler==g)return e;h.push({handler:g,on:true});return e};e.off=function(a,g){var h=f[a];if(h)for(var c=0;c<h.length;c++){var d=h[c];if(d.handler==g){d.on=false;h.splice(c,1);break}}return e};return function(a){var g=
-f[a.type];if(g){g=g.slice();for(var h=0;h<g.length;h++){var c=g[h];c.on&&c.handler.call(e,a)}}}};r.queue=function(){function e(){if(!(h>=c||!g.length)){h++;g.pop()()}}function f(d){for(var l=0;l<g.length;l++)if(g[l]==d){g.splice(l,1);return true}return false}function a(d,l,n){function q(){k=new XMLHttpRequest;n&&k.overrideMimeType(n);k.open("GET",d,true);k.onreadystatechange=function(){if(k.readyState==4){h--;k.status<300&&l(k);e()}};k.send(null)}var k;g.push(q);e();return{abort:function(i){if(f(q))return true;
-if(i&&k){k.abort();return true}return false}}}var g=[],h=0,c=6;return{text:function(d,l,n){return a(d,function(q){q.responseText&&l(q.responseText)},n)},xml:function(d,l){return a(d,function(n){n.responseXML&&l(n.responseXML)},"application/xml")},json:function(d,l){return a(d,function(n){n.responseText&&l(JSON.parse(n.responseText))},"application/json")},image:function(d,l,n){function q(){k=document.createElement("img");k.onerror=function(){h--;e()};k.onload=function(){h--;n(k);e()};k.src=l;d.setAttributeNS(r.ns.xlink,
-"href",l)}var k;g.push(q);e();return{abort:function(i){if(f(q))return true;if(i&&k){k.src="about:";return true}return false}}}}}();r.map=function(){function e(){if(s)if(q<s[0])q=s[0];else if(q>s[1])q=s[1];k=q-(q=Math.round(q));i=Math.pow(2,k)}function f(){if(u){var j=45/Math.pow(2,q+k-3),t=Math.max(Math.abs(C*d.x+y*d.y),Math.abs(A*d.x+E*d.y)),z=U(m-t*j/l.y);t=U(o+t*j/l.y);n.lat=Math.max(z,Math.min(t,n.lat));z=Math.max(Math.abs(C*d.y+y*d.x),Math.abs(A*d.y+E*d.x));n.lon=Math.max(u[0].lon-z*j/l.x,Math.min(u[1].lon+
-z*j/l.x,n.lon))}}var a={},g,h,c=Y,d=Y,l={x:256,y:256},n={lat:37.76487,lon:-122.41948},q=12,k=0,i=1,s=[1,18],w=0,y=1,C=0,E=1,A=0,m=-180,o=180,u=[{lat:U(m),lon:-Infinity},{lat:U(o),lon:Infinity}];a.locationCoordinate=function(j){j=r.map.locationCoordinate(j);var t=Math.pow(2,q);j.column*=t;j.row*=t;j.zoom+=q;return j};a.coordinateLocation=r.map.coordinateLocation;a.coordinatePoint=function(j,t){var z=Math.pow(2,q-t.zoom),F=Math.pow(2,q-j.zoom),x=(t.column*z-j.column*F)*l.x*i;z=(t.row*z-j.row*F)*l.y*
-i;return{x:d.x+y*x-C*z,y:d.y+C*x+y*z}};a.pointCoordinate=function(j,t){var z=Math.pow(2,q-j.zoom),F=(t.x-d.x)/i,x=(t.y-d.y)/i;return{column:j.column*z+(E*F-A*x)/l.x,row:j.row*z+(A*F+E*x)/l.y,zoom:q}};a.locationPoint=function(j){var t=Math.pow(2,q+k-3)/45,z=(j.lon-n.lon)*t*l.x;j=(V(n.lat)-V(j.lat))*t*l.y;return{x:d.x+y*z-C*j,y:d.y+C*z+y*j}};a.pointLocation=function(j){var t=45/Math.pow(2,q+k-3),z=(j.x-d.x)*t;j=(j.y-d.y)*t;return{lon:n.lon+(E*z-A*j)/l.x,lat:U(V(n.lat)-(A*z+E*j)/l.y)}};var B=r.svg("rect");
-B.setAttribute("visibility","hidden");B.setAttribute("pointer-events","all");a.container=function(j){if(!arguments.length)return g;g=j;g.setAttribute("class","map");g.appendChild(B);return a.resize()};a.focusableParent=function(){for(var j=g;j;j=j.parentNode)if(j.tabIndex>=0)return j;return window};a.mouse=function(j){var t=(g.ownerSVGElement||g).createSVGPoint();if($<0&&(window.scrollX||window.scrollY)){var z=document.body.appendChild(r.svg("svg"));z.style.position="absolute";z.style.top=z.style.left=
-"0px";var F=z.getScreenCTM();$=!(F.f||F.e);document.body.removeChild(z)}if($){t.x=j.pageX;t.y=j.pageY}else{t.x=j.clientX;t.y=j.clientY}return t.matrixTransform(g.getScreenCTM().inverse())};a.size=function(j){if(!arguments.length)return c;h=j;return a.resize()};a.resize=function(){if(h){c=h;Q.remove(a)}else{var j=g.ownerSVGElement||g;if(j.offsetWidth==null){B.setAttribute("width","100%");B.setAttribute("height","100%");j=B}b=j.getClientRects()[0];c={x:b.width,y:b.height};Q.add(a)}B.setAttribute("width",
-c.x);B.setAttribute("height",c.y);d={x:c.x/2,y:c.y/2};f();a.dispatch({type:"resize"});return a};a.tileSize=function(j){if(!arguments.length)return l;l=j;a.dispatch({type:"move"});return a};a.center=function(j){if(!arguments.length)return n;n=j;f();a.dispatch({type:"move"});return a};a.panBy=function(j){var t=45/Math.pow(2,q+k-3),z=j.x*t;j=j.y*t;return a.center({lon:n.lon+(A*j-E*z)/l.x,lat:U(V(n.lat)+(A*z+E*j)/l.y)})};a.centerRange=function(j){if(!arguments.length)return u;if(u=j){m=u[0].lat>-90?V(u[0].lat):
--Infinity;o=u[0].lat<90?V(u[1].lat):Infinity}else{m=-Infinity;o=Infinity}f();a.dispatch({type:"move"});return a};a.zoom=function(j){if(!arguments.length)return q+k;q=j;e();return a.center(n)};a.zoomBy=function(j,t,z){if(arguments.length<2)return a.zoom(q+k+j);if(arguments.length<3)z=a.pointLocation(t);q=q+k+j;e();var F=a.locationPoint(z);return a.panBy({x:t.x-F.x,y:t.y-F.y})};a.zoomRange=function(j){if(!arguments.length)return s;s=j;return a.zoom(q+k)};a.extent=function(j){if(!arguments.length)return[a.pointLocation({x:0,
-y:c.y}),a.pointLocation({x:c.x,y:0})];var t=a.locationPoint(j[0]),z=a.locationPoint(j[1]),F=Math.max((z.x-t.x)/c.x,(t.y-z.y)/c.y);t=a.pointLocation({x:(t.x+z.x)/2,y:(t.y+z.y)/2});q=q+k-Math.log(F)/Math.log(2);e();return a.center(t)};a.angle=function(j){if(!arguments.length)return w;w=j;y=Math.cos(w);C=Math.sin(w);E=Math.cos(-w);A=Math.sin(-w);f();a.dispatch({type:"move"});return a};a.add=function(j){j.map(a);return a};a.remove=function(j){j.map(null);return a};a.dispatch=r.dispatch(a);return a};Q.maps=
-[];Q.add=function(e){for(var f=0;f<Q.maps.length;f++)if(Q.maps[f]==e)return;Q.maps.push(e)};Q.remove=function(e){for(var f=0;f<Q.maps.length;f++)if(Q.maps[f]==e){Q.maps.splice(f,1);return}};window.addEventListener("resize",Q,false);r.map.locationCoordinate=function(e){var f=1/360;return{column:(e.lon+180)*f,row:(180-V(e.lat))*f,zoom:0}};r.map.coordinateLocation=function(e){var f=45/Math.pow(2,e.zoom-3);return{lon:f*e.column-180,lat:U(180-f*e.row)}};var $=/WebKit/.test(navigator.userAgent)?-1:0;r.layer=
-function(e,f){function a(A){for(var m=C[0].nextSibling;y<A;y++){s.insertBefore(C[-4],m);s.insertBefore(C[2],m);s.insertBefore(C[1],m);for(var o=C[-4],u=-4;u<2;)C[u]=C[++u];C[u]=o}}function g(A){for(var m=C[0].nextSibling;y>A;y--){s.insertBefore(C[-1],m);s.insertBefore(C[2],C[-4]);for(var o=C[2],u=2;u>-4;)C[u]=C[--u];C[u]=o}}function h(){function A(L){var H=L.zoom,R=H<0?1:1<<H,S=L.column%R,v=L.row;if(S<0)S+=R;return{locationPoint:function(D){D=r.map.locationCoordinate(D);var G=Math.pow(2,H-D.zoom);
-return{x:z.x*(G*D.column-S),y:z.y*(G*D.row-v)}}}}function m(L,H,R){var S=O.zoom,v=2-T,D=4+T;for(L=L;L<H;L++){var G=d.load({column:L,row:R,zoom:S},A);if(!G.ready&&!(G.key in N)){G.proxyRefs={};for(var J,K,M,P=1;P<=v;P++){K=true;for(var W=0,ea=1<<P;W<=ea;W++)for(var aa=0;aa<=ea;aa++)if((M=d.peek(J={column:(L<<P)+aa,row:(R<<P)+W,zoom:S+P}))&&M.ready){N[M.key]=d.load(J);M.proxyCount++;G.proxyRefs[M.key]=M}else K=false;if(K)break}if(!K)for(P=1;P<=D;P++)if((M=d.peek(J={column:L>>P,row:R>>P,zoom:S-P}))&&
-M.ready){N[M.key]=d.load(J);M.proxyCount++;G.proxyRefs[M.key]=M;break}}N[G.key]=G}}var o=c.map(),u=o.zoom(),B=u-(u=Math.round(u)),j=o.size(),t=o.angle(),z=o.tileSize(),F=o.locationCoordinate(o.center());if(y!=u){if(y<u)a(u);else if(y>u)g(u);else y=u;for(var x=-4;x<=2;x++){var X=C[x];X.setAttribute("class","zoom"+(x<0?"":"+")+x+" zoom"+(u+x));X.setAttribute("transform","scale("+Math.pow(2,-x)+")")}}s.setAttribute("transform","translate("+j.x/2+","+j.y/2+")"+(t?"rotate("+t/Math.PI*180+")":"")+(B?"scale("+
-Math.pow(2,B)+")":"")+(w?w.zoomFraction(B):""));var O=o.pointCoordinate(F,Y);x=o.pointCoordinate(F,{x:j.x,y:0});u=o.pointCoordinate(F,j);o=o.pointCoordinate(F,{x:0,y:j.y});if(!B&&!t&&!w){F.column=(Math.round(z.x*F.column)+(j.x&1)/2)/z.x;F.row=(Math.round(z.y*F.row)+(j.y&1)/2)/z.y}if(w){O=w.unapply(O);x=w.unapply(x);u=w.unapply(u);o=w.unapply(o);F=w.unapply(F)}var T=q?q(O.zoom)-O.zoom:0;if(T){t=Math.pow(2,T);O.column*=t;O.row*=t;x.column*=t;x.row*=t;u.column*=t;u.row*=t;o.column*=t;o.row*=t;O.zoom=
-x.zoom=u.zoom=o.zoom+=T}B=d.locks();var N={};for(var I in B)B[I].proxyCount=0;if(n&&T>-5&&T<3){t=O.zoom<0?1:1<<O.zoom;if(l){da(O,x,u,0,t,m);da(u,o,O,0,t,m)}else{j=Math.floor((O.column+u.column)/2);t=Math.max(0,Math.min(t-1,Math.floor((x.row+o.row)/2)));x=Math.min(4,O.zoom);j=j>>x<<x;t=t>>x<<x;m(j,j+1,t)}}for(I in N){x=N[I];t=Math.pow(2,x.level=x.zoom-F.zoom);j=z.x*(x.column-F.column*t);t=z.y*(x.row-F.row*t);x.element.setAttribute("transform","translate("+j+","+t+")")}for(I in B)if(!(I in N)){x=d.unload(I);
-x.element.parentNode.removeChild(x.element);delete x.proxyRefs}for(I in N){x=N[I];if(x.element.parentNode!=C[x.level]){C[x.level].appendChild(x.element);c.show&&c.show(x)}}d.flush()}var c={},d=c.cache=r.cache(e,f).size(512),l=true,n=true,q,k,i,s=r.svg("g"),w,y,C={};s.setAttribute("class","layer");for(var E=-4;E<=-1;E++)C[E]=s.appendChild(r.svg("g"));for(E=2;E>=1;E--)C[E]=s.appendChild(r.svg("g"));C[0]=s.appendChild(r.svg("g"));c.map=function(A){if(!arguments.length)return i;if(i){if(i==A){s.parentNode.appendChild(s);
-return c}i.off("move",h).off("resize",h);s.parentNode.removeChild(s)}if(i=A){i.container().appendChild(s);c.init&&c.init(s);i.on("move",h).on("resize",h);h()}return c};c.container=function(){return s};c.id=function(A){if(!arguments.length)return k;k=A;s.setAttribute("id",A);return c};c.visible=function(A){if(!arguments.length)return n;(n=A)?s.removeAttribute("visibility"):s.setAttribute("visibility","hidden");i&&h();return c};c.transform=function(A){if(!arguments.length)return w;w=A;i&&h();return c};
-c.zoom=function(A){if(!arguments.length)return q;q=typeof A=="function"||A==null?A:function(){return A};i&&h();return c};c.tile=function(A){if(!arguments.length)return l;l=A;i&&h();return c};c.reload=function(){d.clear();i&&h();return c};c.dispatch=r.dispatch(c);c.on("load",function(A){if(A.tile.proxyRefs){for(var m in A.tile.proxyRefs){var o=A.tile.proxyRefs[m];--o.proxyCount<=0&&d.unload(m)&&o.element.parentNode.removeChild(o.element)}delete A.tile.proxyRefs}});return c};r.image=function(){var e=
-r.layer(function(a){var g=a.element=r.svg("image"),h=e.map().tileSize();g.setAttribute("preserveAspectRatio","none");g.setAttribute("width",h.x);g.setAttribute("height",h.y);g.setAttribute("opacity",0);if(typeof f=="function")a.request=r.queue.image(g,f(a),function(c){delete a.request;a.ready=true;a.img=c;g.removeAttribute("opacity");e.dispatch({type:"load",tile:a})});else{a.ready=true;g.setAttributeNS(r.ns.xlink,"href",f);e.dispatch({type:"load",tile:a})}},function(a){a.request&&a.request.abort(true)}),
-f="about:blank";e.url=function(a){if(!arguments.length)return f;f=typeof a=="string"&&/{.}/.test(a)?r.url(a):a;return e.reload()};return e};r.geoJson=function(e){function f(m,o){return m&&m.type in C&&C[m.type](m,o)}function a(m,o){var u=o({lat:m[1],lon:m[0]}),B=r.svg("circle");B.setAttribute("r",4.5);B.setAttribute("cx",u.x);B.setAttribute("cy",u.y);return B}function g(m,o,u,B){B.push("M");for(var j=0;j<m.length-o;j++){p=u({lat:m[j][1],lon:m[j][0]});B.push(p.x);B.push(",");B.push(p.y);B.push("L")}B.pop()}
-function h(m,o,u,B){for(var j=0;j<m.length;j++)g(m[j],o,u,B);o&&B.push("Z")}function c(m,o,u,B){for(var j=[],t=0;t<o.length;t++)m(o[t],u,B,j);if(j.length){m=r.svg("path");m.setAttribute("d",j.join(""));return m}}var d=r.layer(function(m,o){function u(j){var t=[];if(j.next)m.request=e(j.next.href,u);switch(j.type){case "FeatureCollection":for(var z=0;z<j.features.length;z++){var F=j.features[z],x=f(F.geometry,o.locationPoint);x&&t.push({element:B.appendChild(x),data:F})}break;case "Feature":(x=f(j.geometry,
-o.locationPoint))&&t.push({element:B.appendChild(x),data:j});break;default:(x=f(j,o.locationPoint))&&t.push({element:B.appendChild(x),data:{type:"Feature",geometry:j}});break}m.ready=true;t.push.apply(m.features,t);d.dispatch({type:"load",tile:m,features:t})}var B=m.element=r.svg("g");m.features=[];o=o(m);if(y)u({type:"FeatureCollection",features:y});else m.request=e(typeof n=="function"?n(m):n,u)},function(m){m.request&&m.request.abort(true)}),l=d.container(),n="about:blank",q=true,k="org.polymaps."+
-r.id(),i="url(#"+k+")",s=l.insertBefore(r.svg("clipPath"),l.firstChild),w=s.appendChild(r.svg("rect")),y;l.setAttribute("fill-rule","evenodd");s.setAttribute("id",k);if(!arguments.length)e=r.queue.json;var C={Point:function(m,o){return a(m.coordinates,o)},MultiPoint:function(m,o){for(var u=r.svg("g"),B=0;B<m.coordinates.length;B++)u.appendChild(a(m.coordinates[B],o));return u},LineString:function(m,o){return c(g,[m.coordinates],0,o)},MultiLineString:function(m,o){return c(g,m.coordinates,0,o)},Polygon:function(m,
-o){return c(h,[m.coordinates],1,o)},MultiPolygon:function(m,o){return c(h,m.coordinates||m.coords,1,o)},GeometryCollection:function(m,o){for(var u=r.svg("g"),B=0;B<m.geometries.length;B++){var j=f(m.geometries[B],o);j&&u.appendChild(j)}return u}};d.url=function(m){if(!arguments.length)return n;n=typeof m=="string"&&/{.}/.test(m)?r.url(m):m;typeof n=="string"&&d.tile(false);return d.reload()};d.features=function(m){if(!arguments.length)return y;m&&d.tile(false);y=m;return d.reload()};d.clip=function(m){if(!arguments.length)return q;
-q&&l.removeChild(s);if(q=m)l.insertBefore(s,l.firstChild);var o=d.cache.locks();for(var u in o)q?o[u].element.setAttribute("clip-path",i):o[u].element.removeAttribute("clip-path");return d};var E=d.tile;d.tile=function(m){arguments.length&&!m&&d.clip(m);return E.apply(d,arguments)};var A=d.map;d.map=function(m){if(m&&w){var o=m.tileSize();w.setAttribute("width",o.x);w.setAttribute("height",o.y)}return A.apply(d,arguments)};d.show=function(m){q?m.element.setAttribute("clip-path",i):m.element.removeAttribute("clip-path");
-d.dispatch({type:"show",tile:m,features:m.features});return d};d.reshow=function(){var m=d.cache.locks();for(var o in m)d.show(m[o]);return d};return d};r.dblclick=function(){function e(c){var d=g.zoom();d=c.shiftKey?Math.ceil(d)-d-1:1-d+Math.floor(d);a==="mouse"?g.zoomBy(d,g.mouse(c)):g.zoomBy(d)}var f={},a="mouse",g,h;f.zoom=function(c){if(!arguments.length)return a;a=c;return f};f.map=function(c){if(!arguments.length)return g;if(g){h.removeEventListener("dblclick",e,false);h=null}if(g=c){h=g.container();
-h.addEventListener("dblclick",e,false)}return f};return f};r.drag=function(){function e(d){if(!d.shiftKey){c={x:d.clientX,y:d.clientY};g.focusableParent().focus();d.preventDefault();document.body.style.setProperty("cursor","move",null)}}function f(d){if(c){g.panBy({x:d.clientX-c.x,y:d.clientY-c.y});c.x=d.clientX;c.y=d.clientY}}var a={},g,h,c;a.map=function(d){if(!arguments.length)return g;if(g){h.removeEventListener("mousedown",e,false);h=null}if(g=d){h=g.container();h.addEventListener("mousedown",
-e,false)}return a};window.addEventListener("mousemove",f,false);window.addEventListener("mouseup",function(d){if(c){f(d);c=null;document.body.style.removeProperty("cursor")}},false);return a};r.wheel=function(){function e(){l=null}function f(k){var i=(k.wheelDelta/120||-k.detail)*0.1,s;if(ba<0){s=Date.now();var w=s-h;if(w>9&&Math.abs(k.wheelDelta)/w>=50)ba=1;h=s}if(ba==1)i*=0.03;if(!c&&i){s=Date.now();if(s-g>200){i=i>0?+1:-1;g=s}else i=0}if(i)switch(d){case "mouse":s=n.mouse(k);l||(l=n.pointLocation(s));
-n.off("move",e).zoomBy(i,s,l).on("move",e);break;case "location":n.zoomBy(i,n.locationPoint(l),l);break;default:n.zoomBy(i);break}k.preventDefault();return false}var a={},g=0,h=0,c=true,d="mouse",l,n,q;a.smooth=function(k){if(!arguments.length)return c;c=k;return a};a.zoom=function(k,i){if(!arguments.length)return d;d=k;l=i;if(n)d=="mouse"?n.on("move",e):n.off("move",e);return a};a.map=function(k){if(!arguments.length)return n;if(n){q.removeEventListener("mousemove",e,false);q.removeEventListener("mousewheel",
-f,false);q.removeEventListener("DOMMouseScroll",f,false);q=null;n.off("move",e)}if(n=k){d=="mouse"&&n.on("move",e);q=n.container();q.addEventListener("mousemove",e,false);q.addEventListener("mousewheel",f,false);q.addEventListener("DOMMouseScroll",f,false)}return a};return a};var ba=/WebKit\/533/.test(navigator.userAgent)?-1:0;r.arrow=function(){function e(w){if(!(w.ctrlKey||w.altKey||w.metaKey)){var y=Date.now(),C=0,E=0;switch(w.keyCode){case 37:if(!c.left){d=y;c.left=1;c.right||(C=k)}break;case 39:if(!c.right){d=
-y;c.right=1;c.left||(C=-k)}break;case 38:if(!c.up){d=y;c.up=1;c.down||(E=k)}break;case 40:if(!c.down){d=y;c.down=1;c.up||(E=-k)}break;default:return}if(C||E)i.panBy({x:C,y:E});if(!l&&c.left|c.right|c.up|c.down)l=setInterval(g,q);w.preventDefault()}}function f(w){d=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(l&&!(c.left|c.right|c.up|c.down))l=clearInterval(l);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 g(){if(i)if(!(Date.now()<d+n)){var w=(c.left-c.right)*k,y=(c.up-c.down)*k;if(w||y)i.panBy({x:w,y:y})}}var h={},c={left:0,right:0,up:0,down:0},d=0,l,n=250,q=50,k=16,i,s;h.map=function(w){if(!arguments.length)return i;if(i){s.removeEventListener("keypress",a,false);s.removeEventListener("keydown",e,false);s.removeEventListener("keyup",f,false);s=null}if(i=w){s=i.focusableParent();s.addEventListener("keypress",
-a,false);s.addEventListener("keydown",e,false);s.addEventListener("keyup",f,false)}return h};h.speed=function(w){if(!arguments.length)return k;k=w;return h};return h};r.hash=function(){function e(){var d=c.center(),l=c.zoom(),n=Math.max(0,Math.ceil(Math.log(l)/Math.LN2));d="#"+l.toFixed(2)+"/"+d.lat.toFixed(n)+"/"+d.lon.toFixed(n);if(g!==d)location.replace(g=d)}function f(){if(location.hash!==g){var d=(g=location.hash).substring(1).split("/").map(Number);if(d.length<3||d.some(isNaN))e();else{var l=
-c.size();c.zoomBy(d[0]-c.zoom(),{x:l.x/2,y:l.y/2},{lat:Math.min(h,Math.max(-h,d[1])),lon:d[2]})}}}var a={},g,h=89.99999999,c;a.map=function(d){if(!arguments.length)return c;if(c){c.off("move",e);window.removeEventListener("hashchange",f,false)}if(c=d){c.on("move",e);window.addEventListener("hashchange",f,false);location.hash?f():e()}return a};return a};r.interact=function(){var e={},f=r.drag(),a=r.wheel(),g=r.dblclick(),h=r.arrow();e.map=function(c){f.map(c);a.map(c);g.map(c);h.map(c);return e};return e};
-r.compass=function(){function e(v){A.setAttribute("class","compass active");O||(O=setInterval(f,t));T&&H.panBy(T);B=Date.now();return k(v)}function f(){T&&Date.now()>B+j&&H.panBy(T)}function a(v){if(v.shiftKey){I={x0:H.mouse(v)};H.focusableParent().focus();return k(v)}}function g(v){if(I){I.x1=H.mouse(v);L.setAttribute("x",Math.min(I.x0.x,I.x1.x));L.setAttribute("y",Math.min(I.x0.y,I.x1.y));L.setAttribute("width",Math.abs(I.x0.x-I.x1.x));L.setAttribute("height",Math.abs(I.x0.y-I.x1.y));L.removeAttribute("display")}}
-function h(){A.setAttribute("class","compass");if(I){if(I.x1){H.extent([H.pointLocation({x:Math.min(I.x0.x,I.x1.x),y:Math.max(I.x0.y,I.x1.y)}),H.pointLocation({x:Math.max(I.x0.x,I.x1.x),y:Math.min(I.x0.y,I.x1.y)})]);L.setAttribute("display","none")}I=null}if(O){clearInterval(O);O=0}}function c(v){return function(){v?this.setAttribute("class","active"):this.removeAttribute("class");T=v}}function d(v){return function(D){A.setAttribute("class","compass active");var G=H.zoom();H.zoom(v<0?Math.ceil(G)-
-1:Math.floor(G)+1);return k(D)}}function l(v){return function(D){H.zoom(v);return k(D)}}function n(){this.setAttribute("class","active")}function q(){this.removeAttribute("class")}function k(v){v.stopPropagation();v.preventDefault();return false}function i(v){var D=Math.SQRT1_2*o,G=o*0.7,J=o*0.2,K=r.svg("g"),M=K.appendChild(r.svg("path")),P=K.appendChild(r.svg("path"));M.setAttribute("class","direction");M.setAttribute("pointer-events","all");M.setAttribute("d","M0,0L"+D+","+D+"A"+o+","+o+" 0 0,1 "+
--D+","+D+"Z");P.setAttribute("class","chevron");P.setAttribute("d","M"+J+","+(G-J)+"L0,"+G+" "+-J+","+(G-J));P.setAttribute("pointer-events","none");K.addEventListener("mousedown",e,false);K.addEventListener("mouseover",c(v),false);K.addEventListener("mouseout",c(null),false);K.addEventListener("dblclick",k,false);return K}function s(v){var D=o*0.4,G=D/2,J=r.svg("g"),K=J.appendChild(r.svg("path")),M=J.appendChild(r.svg("path")),P=J.appendChild(r.svg("path")),W=J.appendChild(r.svg("path"));K.setAttribute("class",
-"back");K.setAttribute("d","M"+-D+",0V"+-D+"A"+D+","+D+" 0 1,1 "+D+","+-D+"V0Z");M.setAttribute("class","direction");M.setAttribute("d",K.getAttribute("d"));P.setAttribute("class","chevron");P.setAttribute("d","M"+-G+","+-D+"H"+G+(v>0?"M0,"+(-D-G)+"V"+-G:""));W.setAttribute("class","fore");W.setAttribute("fill","none");W.setAttribute("d",K.getAttribute("d"));J.addEventListener("mousedown",d(v),false);J.addEventListener("mouseover",n,false);J.addEventListener("mouseout",q,false);J.addEventListener("dblclick",
-k,false);return J}function w(v){var D=o*0.2,G=o*0.4,J=r.svg("g"),K=J.appendChild(r.svg("rect")),M=J.appendChild(r.svg("path"));K.setAttribute("pointer-events","all");K.setAttribute("fill","none");K.setAttribute("x",-G);K.setAttribute("y",-0.75*G);K.setAttribute("width",2*G);K.setAttribute("height",1.5*G);M.setAttribute("class","chevron");M.setAttribute("d","M"+-D+",0H"+D);J.addEventListener("mousedown",l(v),false);J.addEventListener("dblclick",k,false);return J}function y(){var v=o+6,D=v,G=H.size();
-switch(z){case "top-left":break;case "top-right":v=G.x-v;break;case "bottom-left":D=G.y-D;break;case "bottom-right":v=G.x-v;D=G.y-D;break}v="translate("+v+","+D+")";N&&N.setAttribute("transform",v);x&&x.setAttribute("transform",v);for(var J in m)J==H.zoom()?m[J].setAttribute("class","active"):m[J].removeAttribute("class")}function C(){for(;A.lastChild;)A.removeChild(A.lastChild);A.appendChild(L);if(X!="none"){N=A.appendChild(r.svg("g"));N.setAttribute("class","pan");var v=N.appendChild(r.svg("circle"));
-v.setAttribute("class","back");v.setAttribute("r",o);N.appendChild(i({x:0,y:-u})).setAttribute("transform","rotate(0)");N.appendChild(i({x:u,y:0})).setAttribute("transform","rotate(90)");N.appendChild(i({x:0,y:u})).setAttribute("transform","rotate(180)");N.appendChild(i({x:-u,y:0})).setAttribute("transform","rotate(270)");v=N.appendChild(r.svg("circle"));v.setAttribute("fill","none");v.setAttribute("class","fore");v.setAttribute("r",o)}else N=null;if(F!="none"){x=A.appendChild(r.svg("g"));x.setAttribute("class",
-"zoom");v=-0.5;if(F=="big"){m={};var D=H.zoomRange()[0];for(v=0;D<=H.zoomRange()[1];D++,v++)(m[D]=x.appendChild(w(D))).setAttribute("transform","translate(0,"+-(v+0.75)*o*0.4+")")}D=X=="none"?0.4:2;x.setAttribute("transform","translate(0,"+o*(/^top-/.test(z)?D+(v+0.5)*0.4:-D)+")");x.appendChild(s(+1)).setAttribute("transform","translate(0,"+-(v+0.5)*o*0.4+")");x.appendChild(s(-1)).setAttribute("transform","scale(-1)")}else x=null;y()}var E={},A=r.svg("g"),m={},o=30,u=16,B=0,j=250,t=50,z="top-left",
-F="small",x,X="small",O,T,N,I,L=r.svg("rect"),H,R,S;A.setAttribute("class","compass");L.setAttribute("class","back fore");L.setAttribute("pointer-events","none");L.setAttribute("display","none");E.radius=function(v){if(!arguments.length)return o;o=v;H&&C();return E};E.speed=function(v){if(!arguments.length)return o;u=v;return E};E.position=function(v){if(!arguments.length)return z;z=v;H&&C();return E};E.pan=function(v){if(!arguments.length)return X;X=v;H&&C();return E};E.zoom=function(v){if(!arguments.length)return F;
-F=v;H&&C();return E};E.map=function(v){if(!arguments.length)return H;if(H){R.removeEventListener("mousedown",a,false);R.removeChild(A);R=null;S.removeEventListener("mousemove",g,false);S.removeEventListener("mouseup",h,false);S=null;H.off("move",y).off("resize",y)}if(H=v){R=H.container();R.appendChild(A);R.addEventListener("mousedown",a,false);S=R.ownerDocument.defaultView;S.addEventListener("mousemove",g,false);S.addEventListener("mouseup",h,false);H.on("move",y).on("resize",y);C()}return E};return E};
-r.grid=function(){function e(){var h=g.firstChild,c=a.size(),d=a.pointLocation(Y);a.pointLocation(c);var l=Math.pow(2,4-Math.round(a.zoom()));d.lat=Math.floor(d.lat/l)*l;d.lon=Math.ceil(d.lon/l)*l;for(var n;(n=a.locationPoint(d).x)<=c.x;d.lon+=l){h||(h=g.appendChild(r.svg("line")));h.setAttribute("x1",n);h.setAttribute("x2",n);h.setAttribute("y1",0);h.setAttribute("y2",c.y);h=h.nextSibling}for(;(n=a.locationPoint(d).y)<=c.y;d.lat-=l){h||(h=g.appendChild(r.svg("line")));h.setAttribute("y1",n);h.setAttribute("y2",
-n);h.setAttribute("x1",0);h.setAttribute("x2",c.x);h=h.nextSibling}for(;h;){c=h.nextSibling;g.removeChild(h);h=c}}var f={},a,g=r.svg("g");g.setAttribute("class","grid");f.map=function(h){if(!arguments.length)return a;if(a){g.parentNode.removeChild(g);a.off("move",e).off("resize",e)}if(a=h){a.on("move",e).on("resize",e);a.container().appendChild(g);a.dispatch({type:"move"})}return f};return f};r.stylist=function(){function e(h){var c=h.features.length,d=f.length,l=a.length,n,q,k,i,s,w;for(s=0;s<c;++s)if(q=
-(n=h.features[s]).element){n=n.data;for(w=0;w<d;++w){i=(k=f[w]).value;if(typeof i==="function")i=i.call(null,n);i==null?k.name.local?q.removeAttributeNS(k.name.space,k.name.local):q.removeAttribute(k.name):k.name.local?q.setAttributeNS(k.name.space,k.name.local,i):q.setAttribute(k.name,i)}for(w=0;w<l;++w){i=(k=a[w]).value;if(typeof i==="function")i=i.call(null,n);i==null?q.style.removeProperty(k.name):q.style.setProperty(k.name,i,k.priority)}if(i=g){if(typeof i==="function")i=i.call(null,n);for(;q.lastChild;)q.removeChild(q.lastChild);
-i!=null&&q.appendChild(r.svg("title")).appendChild(document.createTextNode(i))}}}var f=[],a=[],g;e.attr=function(h,c){f.push({name:fa(h),value:c});return e};e.style=function(h,c,d){a.push({name:h,value:c,priority:arguments.length<3?null:d});return e};e.title=function(h){g=h;return e};return e}})(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);
View
250 src/GeoJson.js
@@ -1,12 +1,13 @@
po.geoJson = function(fetch) {
var geoJson = po.layer(load, unload),
container = geoJson.container(),
- url = "about:blank",
+ url,
clip = true,
clipId = "org.polymaps." + po.id(),
clipHref = "url(#" + clipId + ")",
clipPath = container.insertBefore(po.svg("clipPath"), container.firstChild),
clipRect = clipPath.appendChild(po.svg("rect")),
+ scale = "auto",
zoom = null,
features;
@@ -15,95 +16,181 @@ po.geoJson = function(fetch) {
if (!arguments.length) fetch = po.queue.json;
- function geometry(o, proj) {