[OpenLayers-Users] Newbie question - displaying layer of text
objects on a map
Andrew Smith
laconical at gmail.com
Sun Mar 22 11:53:09 EDT 2009
Thanks for the info guys. I'm glad it wasn't something simple that I was
overlooking. I'm surprised that there aren't more OpenLayers-based apps out
there that have a need for layers of text that don't come across as part of
the image with the geometric data. It's an absolute necessity for mine.
It turns out that I have an extra database I need to connect to which is a
proprietary format (no way GeoServer or anything else will connect to it) so
I'm going to need to write a web service to get the data out of it and into
OpenLayers somehow (maybe in GeoJSON format as suggested). Or write an app
to automatically transfer it into PostGIS.
Andreas, you mentioned that if my data was in PostGIS I could use either a
WMS or WFS to get the data. If I went down the WMS path, I would have one
WMS for my base map layer, and another one for my text objects layer. My
understanding is that the text WMS would return a tile map of images which
would be largely empty space with the occasional text value here and there.
I guess this layer would be transparent so as not to occlude the underlying
map images. Meanwhile, the WFS would return the details about the text
labels and rely on OpenLayers to actually render the vector representations.
You mentioned that WMS would be preferred if there were a 'huge number of
features' - I'm surprised that creating all those image tiles on the server
side is faster than adding x vector objects on the browser side (I will
probably have a few dozen at most). Is there a certain point where it just
makes more sense to do it on the server based on the number of objects you
want to display?
Regards,
Andrew
On Sun, Mar 22, 2009 at 11:08 PM, Chris Holmes <cholmes at opengeo.org> wrote:
>
> 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.
>>
>>
> Note also that if you can turn your oracle lat/longs in to point objects in
> Oracle Locator or Oracle spatial than you can serve WMS directly from there
> with GeoServer or MapServer. Both connect to oracle pretty well. PostGIS
> is a bit better for both, but GeoServer has a new Oracle NG datastore that
> is almost as fast.
>
>
> 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.
>>
>>
> --
> Chris Holmes
>
> OpenGeo - http://opengeo.org
> Expert service straight from the developers.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090322/d7ac4a47/attachment.html
More information about the Users
mailing list