限制多边形贴图仅显示某些状态?
我希望使用 Polymaps 仅显示某些状态。我以失业图为例:
http://polymaps.org/ex/unemployment.html< /a>
我意识到返回的图块来自polymaps.appspot.com,并且我尝试创建这样的回调函数:
map.add(po.geoJson().url("http://polymaps.appspot.com/state/{Z}/{X}/{Y}.json").on("load", load2).id("state"));
function load2(c) {
for (var b = 0; b < c.features.length; b++) {
if (c.features.length > 1) {
if (c.features[b].data.properties.name == "California") {
var a = c.features[b];
a.element.setAttribute("class", "hidden");
}
}
}
}
但这里的问题是a)它不起作用(即使使用正确的CSS)如果它这样做,它只会隐藏州的轮廓,而不是县的覆盖范围。我仍然希望保持县覆盖图提供的详细程度,只是不适用于所有州。
我该怎么做呢?
谢谢!
I'm looking to display only certain states using Polymaps. I'm using the Unemployment graph as an example:
http://polymaps.org/ex/unemployment.html
I realize the tiles that are returned are from polymaps.appspot.com, and I've tried creating a callback function as such:
map.add(po.geoJson().url("http://polymaps.appspot.com/state/{Z}/{X}/{Y}.json").on("load", load2).id("state"));
function load2(c) {
for (var b = 0; b < c.features.length; b++) {
if (c.features.length > 1) {
if (c.features[b].data.properties.name == "California") {
var a = c.features[b];
a.element.setAttribute("class", "hidden");
}
}
}
}
but the problem here is that a) it doesn't work (even with the right CSS) and if it did, it would just hide the outlines for the states, not the county overlays. I'd still like to maintain the level of detail afforded by the county overlays, just not for all the states.
How do I go about doing this?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了回答我自己的问题(供其他人参考),事实证明县的 FIPS 代码也包含州的信息。因此,您可以从 FIPS 代码中选择前两个数字并向它们添加类以删除或隐藏它们。
To answer my own question (for reference for other people) it turns out FIPS codes for counties also contain information for the state. Hence you can select the first two numbers from the FIPS code and add classes to them to remove or hide them.