[OpenLayers-Users] How to add text label and image (maybe a freely editable box?) to a vector layer?

Manuel Reimer manuel.spam at nurfuerspam.de
Wed Apr 10 23:54:44 PDT 2013


Manuel Reimer <manuel.spam at ...> writes:
> what I have is a vector layer which shows a multipolygon line. I want to
> have some description text (freely positioned) on this layer.

Hello,

I tried out some things and it seems to be impossible to use "addFeatures"
if the Layer is directly connected to some external HTTP URL. This is my
current code:

var layer = new OpenLayers.Layer.Vector("My Layer Name", {
  visibility: true,
  strategies: [new OpenLayers.Strategy.Fixed()],
  protocol: new OpenLayers.Protocol.HTTP({
    url: "mydb.cgi",
    format: new OpenLayers.Format.OSM()
  }),
  projection: map.displayProjection,
  style: {strokeColor: "red", strokeWidth: 5, strokeOpacity: 0.5}
});
map.addLayer(layer);

Can someone please help me to rewrite this to do the following:

- Fetch the features from my external file, first.
- Then add those features using "addFeatures" to my layer.

The idea is, that this should enable me to add additional features using
"addFeatures", that are not part of the ".osm" file, I want to read.

Thanks in advance

Yours

Manuel



More information about the Users mailing list