Skip to content

Instantly share code, notes, and snippets.

@mattb
Created November 16, 2008 15:58
Show Gist options
  • Save mattb/25502 to your computer and use it in GitHub Desktop.
Save mattb/25502 to your computer and use it in GitHub Desktop.
$.getJSON('http://api.flickr.com/services/rest/?method=flickr.places.getInfo&api_key=get_your_own&woe_id=44418&format=json&jsoncallback=?', function(data) {
if(data.place.has_shapedata == 1) {
var bounds = new GLatLngBounds();
$.each(data.place.shapedata.polylines.polyline, function(index,polyline) {
thepoints = [];
$.each(polyline._content.split(/ /), function(pindex, point) {
lat = parseFloat(point.split(/,/)[0]);
lng = parseFloat(point.split(/,/)[1]);
thepoints[pindex] = new GLatLng(lat, lng);
});
// we use jquery.jmap2.js for a convenience addPolygon method, but it's only a thin wrapper
$("#iconmap").addPolygon({
points:thepoints,
geodesic: true, // needs local patch to jmap2
strokeWeight: 1,
fillopacity: 0.4,
fillColor:'#59ead8'
});
$.each(thepoints, function(pindex, point) {
bounds.extend(point);
});
});
if(!bounds.isEmpty()) {
$.jmap.GMap2.setCenter(bounds.getCenter(),$.jmap.GMap2.getBoundsZoomLevel(bounds));
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment