I'm trying to have some very basic functionality with vector points with Openlayers 2.12 and I can't figure out how to track a click event on a point.
I create a map using the following code and add one point:
var map;
function init(){
map = new OpenLayers.Map('map');
var gsat = new OpenLayers.Layer.Google(
"Google Satellite",
{type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22}
);
map.addLayer(gsat);
var vectorLayer = new OpenLayers.Layer.Vector("vector");
vectorLayer.addFeatures(
new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(-57.635021, -25.276987).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
)
)
)
map.setCenter(new OpenLayers.LonLat(10.2, 48.9).transform(
new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject()
), 2
);
map.addLayer(vectorLayer);
Then, I've tried to identify when the point is clicked:
// detect when points are clicked
pointClick = new OpenLayers.Control.GetFeature(vectorLayer, OpenLayers.Handler.Point,
{eventListeners:{"click": clickNotice}};
map.addControl(pointClick);
// detect point events
function clickNotice(evt) {
alert('Point clicked');
point.deactivate();
}
}
This is not working, (although I don't get any errors in Firebug), but I'm not sure of the correct syntax for handling points.