[OpenLayers-Users] layer by name or by id events
Luis Ortiz (lortiz)
lortiz at compegps.com
Mon Apr 6 10:06:55 EDT 2009
Hi,
I would like to register some especial events that happend in a layer.
So i would like capture events in such layer.
My example is this:
var aktLayer = 1; //index of a vectorlayer
map.layers[aktLayer].events.register('featureselected',
map.layers[aktLayer], regFeatureSelected);
map.layers[aktLayer].events.register('featureunselected',
map.layers[aktLayer], regFeatureUnselected);
Issue comes when i add a new layer with this method:
gml_new = new OpenLayers.Layer.GML("ZONE", link, {format:
OpenLayers.Format.GeoJSON, projection: map.displayProjection, styleMap :
aStyleMap });
map.addLayer(gml_new);
I added some control.selectfeatures
ctrlSelectFeatures = new OpenLayers.Control.SelectFeature(
gml_new,
{
clickout: true, toggle: true,
multiple: false, hover: false,
toggleKey: "ctrlKey", // ctrl key removes from selection
multipleKey: "shiftKey", // shift key adds to selection
box: false
}
)
map.addControl(ctrlSelectFeatures);
ctrlSelectFeatures.activate();
how i can register events to this new layer? I don't know how obtain the
number/id of the layer just added with method map.addLayer(gml_new);
Thank you
--
*Luis Ortiz*
Technical Department
tel.: 902 512 260
int. tel.: +34 933 968 068
fax: +34 937 959 605
mobile: +34 687 703 541
skype: luis.compegps
email: lortiz at compegps.com <mailto:lortiz at compegps.com>
www.compegps.com <http://www.compegps.com>
www.twonav.com <http://www.twonav.com>
CompeGPS Team SL
Carrer d'en Draper, 13
08350 Arenys de Mar
Barcelona - Spain
UTM 31T X 461512 Y 4603162
(WGS 84)
-------------- next part --------------
Skipped content of type multipart/related
More information about the Users
mailing list