Hi, On Sat, Mar 21, 2009 at 3:58 AM, Andrew Smith <laconi...@gmail.com> wrote: > I am an absolute beginner when it comes to all things GIS. I've been > playing with OpenLayers for a few days and am quite impressed with what it > can do so far. However, something I haven't been able to find any examples > of is showing a text object on a map.
This feature will be available in the upcoming 2.8 release. I am currently working on making it ready for inclusion into the code base, and it should be in the trunk in a cople of days: http://trac.openlayers.org/ticket/1895 > Here's what I want to do. I have a GeoServer map server and a PostGIS > database containing my map data. In a completely separate database > (Oracle), I have a table which has a bunch of values that are changing > regularly. Each value has a corresponding lat/lon value. I want to call a > web service from within OpenLayers which requests the text values (and > corresponding coordinates) and then shows them as a layer on the map. As in > I want to see the actual text value on the map, not a marker where the text > should be. I would then periodically redraw the layer to get the updated > values. > > I guess my questions are as follows: > > 1. Can you actually add a layer of text objects in OpenLayers? If so, what > layer type do you use? Can anyone point me to a publicly accessible > example? This will be a vector layer then. > 2. Is my approach reasonable? I could potentially copy the data from the > Oracle database into the PostGIS database if it would make things easier, > but I'm still not sure how to then get the data from PostGIS into my map. I > know that PostGIS has functions like 'AsGML' and 'AsSVG'. However, this > leads me to more questions: Copying the data from Oracle to PostGIS would make things much easier if you also consider using a WMS like GeoServer or Mapserver. Both can connect to a PostGIS data store and output your points either as WMS (map image) or WFS (vector data to be rendered on the client). This is the state-of-the-art solution, WMS being preferred if you have a huge number of features. If, however, you do not want to bother with the conversion of your data from Oracle to PostGIS and are fine writing a small server side script to provide your text data, I'd recommend sending GeoJSON to OpenLayers (but only if the number of labels does not reach into three figures): { "type": "FeatureCollection", "features": [ {"type":"Feature", "id":"ft_1721", "properties":{"label": "foo"}, "geometry":{"type":"Point", "coordinates":[-89.296875, -14.4140625]}, "crs":{"type":"OGC", "properties":{"urn":"urn:ogc:def:crs:OGC:1.3:CRS84"}}} ] } You will be able to style this in a way that just the label and not the point is shown. As you can see, you have a point feature here with a label attribute. All you need to render in OpenLayers (see my explanation on GML below, which uses the same concept). > - I know that SVG supports text objects but don't know if OpenLayers can > overlay SVG objects on maps. Is SVG even a viable option? SVG is the technology used in OpenLayers to render vector layers (including text once this feature is ready) in all browsers except Internet Explorer. But I would not recommend sending SVG output to the client, since OpenLayers is not designed to display third-party SVG. > - I know next to nothing about GML. My quick Googling tells me that GML has > things like LineString, Polygon and Point, but I haven't found anything like > a 'Text' element. Is GML just for displaying vector shape objects? GML works with features. Features have a geometry and other attributes. To display text, you will want features with a point geometry and a text attribute containing your label text. And there is no need to touch GML manually if you use a WMS. You will get images that you can display using OpenLayers.Layer.WMS. Regards, Andreas. -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. _______________________________________________ Users mailing list Users@openlayers.org http://openlayers.org/mailman/listinfo/users