Permalink
Browse files

Add `repeat` property to po.url.

True by default. Can be set to false to disable column wrap-around.
  • Loading branch information...
1 parent 1e3ea23 commit 1754c96066ef45ca37d41de9d53d3c70cbb0a651 @mbostock mbostock committed Nov 26, 2010
Showing with 94 additions and 69 deletions.
  1. +1 −0 examples/cloudmade/pale-dawn.js
  2. +16 −4 polymaps.js
  3. +61 −61 polymaps.min.js
  4. +15 −3 src/Url.js
  5. +1 −1 src/start.js
@@ -9,6 +9,7 @@ map.add(po.image()
.url(po.url("http://{S}tile.cloudmade.com"
+ "/1a1b06b230af4efdbb989ea99e9841af" // http://cloudmade.com/register
+ "/998/256/{Z}/{X}/{Y}.png")
+ .repeat(false)
.hosts(["a.", "b.", "c.", ""])));
map.add(po.compass()
View
@@ -2,7 +2,7 @@ if (!org) var org = {};
if (!org.polymaps) org.polymaps = {};
(function(po){
- po.version = "2.3.0"; // semver.org
+ po.version = "2.3+1.0"; // not semver!
var zero = {x: 0, y: 0};
po.ns = {
@@ -182,12 +182,18 @@ po.cache = function(load, unload) {
return cache;
};
po.url = function(template) {
- var hosts = [];
+ var hosts = [],
+ repeat = true;
function format(c) {
var max = c.zoom < 0 ? 1 : 1 << c.zoom,
- column = c.column % max;
- if (column < 0) column += max;
+ column = c.column;
+ if (repeat) {
+ column = c.column % max;
+ if (column < 0) column += max;
+ } else if ((column < 0) || (column >= max)) {
+ return "about:blank";
+ }
return template.replace(/{(.)}/g, function(s, v) {
switch (v) {
case "S": return hosts[(Math.abs(c.zoom) + c.row + column) % hosts.length];
@@ -220,6 +226,12 @@ po.url = function(template) {
return format;
};
+ format.repeat = function(x) {
+ if (!arguments.length) return repeat;
+ repeat = x;
+ return format;
+ };
+
return format;
};
po.dispatch = function(that) {
Oops, something went wrong.

0 comments on commit 1754c96

Please sign in to comment.