Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mbostock/polymaps
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Sep 25, 2010
2 parents b31f277 + 7033e1c commit fcfe702
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 31 deletions.
2 changes: 1 addition & 1 deletion examples/kml/kml.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}
if (f.geometry) features.push(f);
}
return {features: features};
return {type: "FeatureCollection", features: features};
}

return kml;
Expand Down
23 changes: 13 additions & 10 deletions polymaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ if (!org) var org = {};
if (!org.polymaps) org.polymaps = {};
(function(po){

po.version = "2.2+1.0+1"; // This fork not semver!
po.version = "2.2+1.0+2"; // This fork not semver!

var zero = {x: 0, y: 0};
po.ns = {
Expand Down Expand Up @@ -1089,16 +1089,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;
Expand All @@ -1108,7 +1108,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});
}
}
Expand All @@ -1128,7 +1128,7 @@ 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 + ")",
Expand Down Expand Up @@ -1352,10 +1352,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 || []});
}
}

Expand Down Expand Up @@ -1396,14 +1396,17 @@ po.geoJson = function(fetch) {
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();
};

Expand Down
20 changes: 10 additions & 10 deletions polymaps.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/GeoJson.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 + ")",
Expand Down Expand Up @@ -225,10 +225,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 || []});
}
}

Expand Down Expand Up @@ -269,14 +269,17 @@ po.geoJson = function(fetch) {
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();
};

Expand Down
6 changes: 3 additions & 3 deletions src/Image.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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;
Expand All @@ -19,7 +19,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});
}
}
Expand Down
Loading

0 comments on commit fcfe702

Please sign in to comment.