[OpenLayers-Users] Adding POI with description

Pirozek domaci.pirozek at gmail.com
Wed Feb 8 15:13:17 EST 2012


Hi, I want to read some POIs from text file, so I looked at Openlayers
example how to do it and its great. But now I need to add new POI manually
(when user clicks on the map). It can be done with map.addMarker and it
works great, but this marker is different from one I get from text file.

Marker from text file has a popup when I click on it, with description. But
I cant find any way how to add new marker with description to map. So how
can I do this?

I load POIs like this:

markers = new OpenLayers.Layer.Text( "My Points",
                    { location:"poi.txt",
                      projection: map.displayProjection
                    });
map.addLayer(markers);

Content of poi.txt:

lat lon title   description icon    iconSize    iconOffset
48.9459301  9.6075669   Title One   Description one<br>Second
line.<br><br>(click again to close)   Ol/img/marker-green.png 24,24   0,-24
48.9899851  9.5382032   Title Two   Description two.   
Ol/img/marker-green.png 16,16   -8,-8

And I add new marker after click like this:

var size = new OpenLayers.Size(21,25);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new
OpenLayers.Icon('http://www.openlayers.org/dev/img/marker.png',size,offset);
markers.addMarker(new OpenLayers.Marker(new
OpenLayers.LonLat(lon,lat),icon));



--
View this message in context: http://osgeo-org.1560.n6.nabble.com/Adding-POI-with-description-tp4377096p4377096.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list