Skip to content

Instantly share code, notes, and snippets.

@mager
Created April 14, 2011 16:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mager/919917 to your computer and use it in GitHub Desktop.
Save mager/919917 to your computer and use it in GitHub Desktop.
Polymaps example for shading polygons
<!DOCTYPE html>
<html>
<head>
<title>San Francisco Street Pavement</title>
<script type="text/javascript" src="https://github.com/simplegeo/polymaps/raw/master/lib/protovis/protodata.js"></script>
<script type="text/javascript" src="https://github.com/simplegeo/polymaps/raw/master/polymaps.js"></script>
<style type="text/css">
@import url("https://github.com/simplegeo/polymaps/raw/master/examples/example.css");
body {
background: #021019;
}
.compass .back {
fill: #256574;
}
.compass .fore, .compass .chevron {
stroke: #1AA398;
}
#streets path {
fill: #567851;
opacity: 0.6;
stroke-linecap: round;
}
#copy, #copy a {
color: #1AA398;
}
</style>
</head>
<body id="map">
<script type="text/javascript" src="parks.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>
var po = org.polymaps;
var color = pv.Scale.linear()
.domain(0, 50, 70, 100)
.range("#F00", "#930", "#FC0", "#3B0");
var map = po.map()
.container(document.getElementById("map").appendChild(po.svg("svg")))
.center({lat: 37.76, lon: -122.44})
.zoom(13)
.zoomRange([12, 16])
.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("parks.json")
.id("streets")
.zoom(12)
.tile(false)
.on("load", po.stylist()
.attr("stroke", function(d) { return color(d.properties.PCI).color; })
.title(function(d) { return d.properties.STREET + ": " + d.properties.PCI + " PCI"; })));
map.add(po.compass()
.pan("none"));
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment