Skip to content

Instantly share code, notes, and snippets.

@mojodna
Created November 4, 2008 22:55
Show Gist options
  • Save mojodna/22241 to your computer and use it in GitHub Desktop.
Save mojodna/22241 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Flickr WOE ID Alpha Shape viewer</title>
</head>
<body>
<style type="text/css">
#ymap{
width:100%;
height:100%;
left:0px:
top:0px;
}
</style>
<div id="ymap"></div>
<script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=sIn3mHrV34HlSSiXZqrFcVzY1LQR_KTDI8OwVDgJK0Y4Totn.ljR9bm.CYr8CA--"></script>
<script>
var ymap = new YMap('ymap');
var start = new YGeoPoint(37.40630098979412 , -122.00926780700684);
ymap.drawZoomAndCenter(start,10);
ymap.addZoomShort();
ymap.addTypeControl();
//YLog.print(window.location.hash);
function jsonFlickrApi(obj) {
if (obj && obj.place) {
// add marker at woe id "center"
var place = new YGeoPoint(new Number(obj.place.latitude), new Number(obj.place.longitude));
var mrk = new YMarker(place);
mrk.addAutoExpand(obj.place.name);
var mrk_info = "WOE ID: " + obj.place.woeid;
YEvent.Capture(mrk, EventsList.MouseClick, function(){mrk.openSmartWindow(mrk_info);});
ymap.addOverlay(mrk);
// build permiter line using alpha shape
var p = [];
var str = new String(obj.place.shapedata.polylines.polyline[0]._content);
var pts = str.split(" ");
for (var i=0; i < obj.place.shapedata.count_edges; ++i) {
var pt = new String(pts[i]).split(",");
p.push(new YGeoPoint((pt[0]), (pt[1])));
}
p.push(p[0]);
var l = new YPolyline(p, 'blue', 3, 0.3);
ymap.addOverlay(l);
}
var zoomAndCenterObj = ymap.getBestZoomAndCenter(p);
ymap.drawZoomAndCenter(zoomAndCenterObj.YGeoPoint, zoomAndCenterObj.zoomLevel);
};
// add script tag to get woe shape from flickr
var woe = new Number(new String(document.location.hash).substring(1));
if (woe == 0)
{
document.location.hash = '#2487956';
woe = new Number('2487956');
}
var script = document.createElement("script");
script.setAttribute('src', 'http://api.flickr.com/services/rest/?method=flickr.places.getInfo&api_key=10bffc81f99eb81ec688f9640323ee69&format=json&woe_id=' + woe);
script.setAttribute('type','text/javascript');
document.body.appendChild(script);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment