Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which is the best way to work with PostGIS and OpenLayers?

I have a postgresql db table with a City table that has a geography field with the city coordinates.

I have made a php page that loops through these records, converts geo field in latit/longit and draws a marker in an OpenLayers map to the city during an ajax call.

I don't know if this is the correct way to do it: is there a way to directly bind the sql query to the map without having to loop? Is there a more direct relation between the database and the OpenLayers maps?

like image 558
Cris Avatar asked Oct 19 '11 08:10

Cris


People also ask

How do I start PostGIS?

Once PostgreSQL is installed, launch Application Stack Builder from (Start->Programs->PostgreSQL .. ->Application Stackbuilder and pick the version of PostgreSQL you want to install PostGIS on and the version of PostGIS to install. You can upgrade from 2.

How do I add a layer in PostGIS?

Open QGIS, select Layer -> Add layer -> Add PostGIS layers, it should open the interface to connect a PostGIS table. 2. In the dialogue, click “New”, it should open the dialogue to configure the PostGIS server, and database (nyc1). Enter relevant information in Step 3, click Ok.


1 Answers

I am not sure about what is the software stack that you are using, but usually, OpenLayers do not work directly with PostGIS.

A common configuration is PostGIS -> GeoServer -> OpenLayers

GeoServer will get your data from the database (or many other sources) and publish it in a valid format for openlayers like wms.

For more specific questions you can post your question in https://gis.stackexchange.com/

like image 85
Francisco Puga Avatar answered Oct 19 '22 10:10

Francisco Puga