[GIS] Openlayers Vector Feature Popup

featureslayersmarkersopenlayers-2

im trying to create a popup in Openlayers that would open when someone clicks a marker. And the marker is setup like this: new OpenLayers.Feature.Vector() and not with the ordinary marker layer.

The marker is then placed inside another layer vesselLayer.addFeatures([markerLayer])

which is then added to the map: map.addLayer([vesselLayer])

Now, How can i get a popup to show when someone selects one of the markers?

Let it be noted that each vesselLayer has only 1 marker. But there can be a 100 dynamically added vesselLayers to the map. (Made it that way for easy access trough the LayerSwitcher).

I tried reading the docs:
http://openlayers.org/dev/examples/select-feature-openpopup.html

But i could not figgure it out.

The error that comes out of the console is saying that it cannot read the property "events" of null..
I double checked the object instantiation and it does get instantiated and the property is a part of the name.

Heres the object logged out right after instantiation.

Object Overview

Best Answer

try to use following code.

   vesselLayer.addMarker(marker);
   vesselLayer.events.register("click", vesselLayer, function(evt){
   popup = new OpenLayers.Popup("chicken",
                   evt.lonlat,
                   new OpenLayers.Size(200,200),
                   "My Content",
                   true);

   map.addPopup(popup);

i hope it helps you...