22

I am very new to web-mapping, so this question may be a little misguided.

I want to have a very simple web interface using OpenLayers (or even Google Maps if that will be easier) which can display a number of point and polygon tables that are currently in PostGIS.

I want this to be as simple (and as low maintainence) as possible:

  • I don't want to have to create tiles (unless there is a very good reason), or have a massive, complex layer of middleware.
  • Performance doesn't need to be phenomenal, as this is for internal use and thus doesn't need to scale beyond a couple of concurrent users.
  • Styling of the vector layers is of minimal importance.
  • Open source tools are much preferred as I have almost no budget for this.

What is the recommended approach for this?

0

7 Answers 7

14

The easiest way to set up an online map from PostGIS sources is using Geoserver. The Geoserver User Manual contains a good introduction for using PostGIS as a data source. You basically add a data store containing the connection information and after that you can publish any table containing geometries. Besides PostGIS, you can use many other data sources as well:

alt text

From inside Geoserver's web interface, you can also preview the layers on an OpenLayers web page. You can use the source of this preview page to build your own OpenLayers application.

Geoserver offers many styling options for both vector and raster data. For the start, you might be happy enough with just customizing some of the pre-made styles that come with the installation.

By default, Geoserver doesn't tile and OpenLayers doesn't request tiles. If you don't need high-performance, you don't need to bother with tiles anyway.

Personally, I think that OpenLayers is easier to use than Google Maps API and you'll be independent from Google. If you need a background map, you might want to look into OpenStreetMap instead.

8

If you really don't want a large middleware layer you could use TinyOWS (http://tinyows.org/trac) - I've never tried it but it claims to be small and fast. Plus it uses OGC standards so if you do decide to publish to a wider audience and it can't keep up switching to GeoServer or MapServer will allow you to keep using the same client code with no changes.

4
  • ah yes, forgot about tinyOWS, seemed a bit hard to configure, and its only for PostGIS
    – dodobas
    Aug 15, 2010 at 19:07
  • the question only asked about postgis
    – Ian Turton
    Aug 15, 2010 at 19:45
  • dead link, is there an update?
    – Theo F
    May 14, 2020 at 11:28
  • 1
    I think it merged into MapServer but it was years ago
    – Ian Turton
    May 14, 2020 at 16:14
6

You can use any application that can server WFS protocol. With Openlayers you can easily use PostGIS data via WFS protocol. There are few FLOSS applications that can do this. For example, FeatureServer, Geoserver, MapServer ... If you are new to web-mapping i would recommend Geoserver because is very very easy to get it started.

See this Openlayers example with WFS.

2
  • Last link is broken.
    – Adam Matan
    Aug 15, 2010 at 15:30
  • 1
    I tried all of them and they work. Maybe last one was temporary down. Aug 15, 2010 at 20:22
4

Openlayers supports a large number of vector data formats (GeoJSON, GML, KML..), which can be displayed and styled using OpenLayers Vector layer.

Maybe the simplest middleware could be FeatureServer which can serve PostGIS data to most of the OL supported formats. It's easy to setup, and has support for simple spatial/attribute querys.

But, if you need something more powerfull Geoserver could be a viable solution.

4
  • No love for mapserver :(
    – dassouki
    Aug 15, 2010 at 12:58
  • 1
    actually mapserver was my first love, dated somewhere around 2001, but...we just started fighting a lot, so we had to brake up :)
    – dodobas
    Aug 15, 2010 at 14:17
  • So if I give openlayers an url to a geojson/gml/kml it can just render them?
    – fmark
    Aug 16, 2010 at 3:12
  • 1
    yes, but if you need filtering, even by simple bounding box, than you need to use WFS
    – dodobas
    Aug 16, 2010 at 6:42
4

You can feed json , kml amd wkt from postgis like st_asgeojson(),st_asKML() for PHP or JSP server script and then use openlayers ajax class for connect data source from your server

2
  • I think suits my current use-case best. If it is too slow, I'll try TinyOWS and the other more heavy-duty map servers. Can you provide a code example for the openlayers side, assuming I have a PHP script somewhere returning the geojson/kml/wkt?
    – fmark
    Aug 23, 2010 at 1:45
  • @chaipat: Do you have an example at hand (php script and corresponding openlayers snippet)?
    – underdark
    Apr 15, 2011 at 19:03
2

You could easily do this using Geomajas which would read your data from the database using either Hibernate or Geotools. This is all-Java, which may be a problem is you prefer other languages.

1

Well what you can do is to use the OpenLayers library and a server language to push all postgis geometry types into Openlayers. You going need:

  • Openlayers.Layer.Vector to create an Layer to vector data
  • Openlayers OpenLayers.Protocol.HTTP to read data from Postgis server
  • OpenLayers.Strategy.Fixed optional
  • OpenLayers.Feature.Vector all vectors are fro mthis class at client
  • OpenLayers.Format.GeoJSON or OpenLayers.Format.JSON
  • A server side language to make a request to Postgis and pump geometries to client
  • An JSON parser on server and client to transport data into this format

With this you can very easily display them without any more middleware.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.