[OpenLayers-Users] Help with events on a KML layer

Dan Lear dble at MBA.ac.uk
Thu Nov 20 08:01:55 EST 2008


Hi,

I'm just starting to get to grips with openlayers, but am struggling to
get events to work in the way I would like.

I add a KML layer:

map.addLayer(new OpenLayers.Layer.GML("Results layer",
"http://www.test.co.uk/test/openlayers.inc.php?format=kml", 
               {
                format: OpenLayers.Format.KML, 
                projection: map.displayProjection,
                formatOptions: {
                  extractStyles: true, 
                  extractAttributes: true
                }
               }));

I want the added layer to respond to click and hover events.  The hover
is working fine with:

selectControl = new OpenLayers.Control.SelectFeature(map.layers[1],
                {hover: testEvent, onSelect: testEvent});
  
map.addControl(selectControl);
selectControl.activate();

but I am unsure how to add a click event.

Can anyone help?

Many thanks in advance,
Dan   



More information about the Users mailing list