public
Last active

How to display SimpleGeo Places on a map

  • Download Gist
index.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
@import url("http://github.com/simplegeo/polymaps/raw/v2.4.0/examples/example.css");
html, body {height: 100%;}
svg {display: block;}
.layer circle {fill: #ACC3CC;stroke: #000;stroke-width: 2px;}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.simplegeo.com/js/1.2/simplegeo.places.jq.min.js"></script>
<script type="text/javascript" src="http://github.com/simplegeo/polymaps/raw/v2.4.0/polymaps.js"></script>
</head>
<body>
<script type="text/javascript">
var client = new simplegeo.PlacesClient('E3mbEYGWRppsZtxAXbd3cm6PGaLUHTSz');
var address = "41 Decatur St, San Francisco, CA";
var po = org.polymaps;
var map = po.map()
.container(document.body.appendChild(po.svg("svg")))
.center({lat: 37.772326, lon: -122.405784})
.zoom(17)
.zoomRange([12, 18])
.add(po.interact());
map.add(po.image()
.url(po.url("http://{S}tile.cloudmade.com"
+ "/5814d279db61404b9e52115b06b9e7b3" // http://cloudmade.com/register
+ "/1714/256/{Z}/{X}/{Y}.png")
.hosts(["a.", "b.", "c.", ""])));
var geoJson = po.geoJson();
map.add(geoJson);
map.add(po.compass()
.pan("none"));
client.searchFromAddress(address, function(err, data) {
if (err) {
console.error(err);
} else {
geoJson.features(data.features);
}
});
</script>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.