Is there an OpenLayers layer type that supports just labels on a map without an underlying feature?
I think this is called an annotations layer in GIS.
If not, I'm not sure how to approach this and any advice would be appreciated. I thought styling a vector point layer so that the point itself would be invisible might be a good approach but then the user won't be able to select/edit/delete the feature, which is part of the requirement.
The application is a bit like the 'Create Map' functionality in Google Maps. The user can add markers, lines and polygons to the map using OpenLayers vector editing controls. A popup allows them to edit a label, change the styling and delete the feature. The map settings (zoom, centre, background layer) and features are saved to a SQL Server database and stored as geometry. This is sent to the database as WKT but the layers are loaded as GeoJSON from a handler on the website.
The client has asked for the ability for users to just place labels on the map (without a marker) and save these too. As I mentioned above, I thought about implementing this as a labelled point layer with the points styled to be invisible but this stops the user from selecting/editing existing features.
My question was whether there was an annotation layer type where the user can create annotations, select them and move them around on the map – similar to vector layers.
It looks like there isn't so how should I go about approaching this?
Best Answer
It depends of what you have on the server side.
In case you use MapServer, you can create layer of TYPE annotation that will show only features names. From MapServer's documentation:
Then, the client - OpenLayers, for instance - can get this layer via WMS.
In case you use GeoServer a similar solution can be gotten by creating an style - using SLD - that will tell the server to render just the labels, and not the features. Once this style has been created, all the client has to do is requesting the WMS layer with a GetMap request with the parameter styles set to the one created for this task. In my personal blog there is a post with a detailed example that uses this approach (http://goo.gl/pKDhZ).