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?
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.
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.
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With