1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
// Add a select control (note: this control is added to the map, but is disabled)
var selectControl = new OpenLayers.Control.SelectFeature(
layerCommune1,
// SelectFeature options
{}
);
// add control to the map
viewer1.getMap().addControl(selectControl);
// Handler to intercept click.
handler = new OpenLayers.Handler.Click(
selectControl, // The select control
// callbacks options
{
click: function(evt){
var feature = this.layer.getFeatureFromEvent(evt);
clicCommune(feature);
},
dblclick: function(evt){
var feature = this.layer.getFeatureFromEvent(evt);
dblclicCommune(feature);
}
},
// handlerOptions
{
single: true,
double: true,
stopDouble: true,
stopSingle: true
}
);
// select.activate(); // The select control must NOT be active
handler.activate(); // The handler will handles the click events for the select control |
Partager