[OpenLayers-Users] How to add text label and image (maybe a freely editable box?) to a vector layer?
Jürgen Dankoweit
Juergen.Dankoweit at T-Online.de
Thu Apr 11 00:51:38 PDT 2013
Hello Manuel,
Am 11.04.2013 08:54, schrieb Manuel Reimer:
> 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:
did you try using a stylemap in your code?
Something like this:
var styleMap_Gebiet = new OpenLayers.StyleMap({
'default':{
label : "${text}",
...
´
},
'select':{
label : "${text}",
}
});
Look at my code here:
http://www.dankoweit.de/Wetterdienste/hp_wetterdienste_auswahlkarte.html
This is a map which uses polygons to draw the selectable areas. Look at
lines 968ff in the source code http://www.dankoweit.de/Skripte/metarkarte.js
This File generates the following map for a special region:
http://www.dankoweit.de/cgi-bin/metar_karte.pl?geo=1&typ=metar
>
> 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.
I have done this. It is not very difficult but tricky :)
Here too look at the code between line 426 and 668.
Best regards
Juergen
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
--
Meine stets unfertige Homepage: www.dankoweit.de
More information about the Users
mailing list