开发者

Restrict polymaps to only show certain states?

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.na开发者_开发问答me == "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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜