I am trying to get data from a PostGIS datatable using .NET, pass it to javascript, create a layer in OpenLayers and add the PostGIS data to the layer. I can successfully query from the PostGres/PostGIS table using the following SQL;
SELECT ""tract_name"", ST_AsGeoJSON(""geom"") FROM the_layer;
After querying the database the result ends up in the PostGres DataAdapter as a DataSet.
I was hoping to simply pass the data to javascript where I could use the following to add the data;
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.
أكثر...
SELECT ""tract_name"", ST_AsGeoJSON(""geom"") FROM the_layer;
After querying the database the result ends up in the PostGres DataAdapter as a DataSet.
I was hoping to simply pass the data to javascript where I could use the following to add the data;
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.
أكثر...