I was using google-vector-layers and leaflet-vector-layers from Jason Sanford (https://github.com/JasonSanford) to easily display, style and add customized popups for data from PostGIS-databases. This works in combination with a modified version of the PHP-Database-GeoJSON from Bryan McBride.
Is there something comparable to use with OpenLayers 3?
I must admit, that I don't have the programming skills to write such a library. Might be that someone knows about a comparable code. After doing a lot of Googling around, I found a lot of answers to particular problems and managed to implement things on how to load GeoJSON using Ajax and boundingBox strategy, styling the vector layers and to add popups, but I'm still missing an easy way on how to put all these things together.
I'm wondering if there is maybe an existing solution I didn't find till today, since I think PostGIS > GeoJSON > OpenLayers 3 (including styling and displaying features via popup) should be a quite standardized way?
Best Answer
I tried to get inspired by other already existing code, and went on developing a basic GeoJSON-constructor in OpenLayers 3, that fulfills my needs.
I actually can
So it's already a funny package, that can be adapted (and improved) very easily. Therefore I want to share the code here. The whole consists of three parts:
In order to work correct the ol3Vector.js needs to be loaded first. Here is the code:
here an example of the map.js
Finally we need the get_geojson.php to fetch data from PostGis-database.