SELECT ""tract_name"", ST_AsGeoJSON(""geom"") FROM the_layer;
After querying the database the result ends up in the PostGres DataAdapter as a DataSet.
var geojson_format = new OpenLayers.Format.GeoJSON(); var vector_layer = new OpenLayers.Layer.Vector("query_POSTGIS_layer"); map.addLayer(vector_layer); vector_layer.addFeatures(geojson_format.read(postGISqueryResult));
What I can't figure out is how to convert the PostGres DataSet into a GeoJSON format that can be handled by the code above.
Application stack is PostGres/PostGIS, GeoServer, and OpenLayers.