GeoCommons GeoJSON in OpenLayers
June 26, 2011 at 7:23 pm | Posted in geo, geodata, Mapping, neogeography | 5 CommentsTags: geocommons, geoiq, openlayers
So, with GeoCommons you can export all the features from a dataset in GeoJSON format. This is very useful. Then can it be displayed in Openlayers? Why yes it can!
I use the following strategy, wrapping the response with a little bit extra so that the GeoJSON format can read it properly.
var url = "http://geocommons.com/overlays/128725/features.json?limit=100";
var p = new OpenLayers.Format.GeoJSON();
OpenLayers.loadURL(url, {}, null, function (response) {
var gformat = new OpenLayers.Format.GeoJSON();
gg = '{"type":"FeatureCollection", "features":' +
response.responseText + '}';
var feats = gformat.read(gg);
vector_layer.addFeatures(feats);
});
Have a look a the live demo of this example of loading points from a Geocommons dataset straight into an OpenLayers map
(Note that I am using an OpenLayers.ProxyHost proxy to make it work in FF)
It is of course very basic in terms of styling, but it’s a start!
Incidentally the points are from “CARMA, India Power Plant Emissions, India, 2000/ 2007/Future” (carbon monitoring)
5 Comments »
RSS feed for comments on this post. TrackBack URI
Leave a Reply
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.

[...] weeks ago, I wrote about how to display data from GeoCommons quickly on an OpenLayers map. The resulting little map was not that interactive, but it showed how [...]
Pingback by Pubs in England: How to do it with Polymaps and GeoCommons Filters « thinkwhere— August 2, 2011 #
[...] weeks ago, I wrote about how to display data from GeoCommons quickly on an OpenLayers map. The resulting little map was not that interactive, but it showed how [...]
Pingback by Pubs in England: How to do it with Polymaps and GeoCommons Filters | J2ME GPS— August 2, 2011 #
[...] weeks ago, I wrote about how to display data from GeoCommons quickly on an OpenLayers map. The resulting little map was not that interactive, but it showed how [...]
Pingback by Open Mobile Map » Pubs in England: How to do it with Polymaps and GeoCommons Filters— August 4, 2011 #
[...] This blog follows up from two posts on my personal blog, showing GeoCommons features with OpenLayers and with [...]
Pingback by Leaflet & GeoCommons JSON | GeoIQ Developer— October 31, 2011 #
[...] This blog follows up from two posts on my personal blog, showing GeoCommons features with OpenLayers and with [...]
Pingback by Leaflet & GeoCommons JSON « Another Word For It— November 24, 2011 #