<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Verdana">oh!!! quite easy!!!<br>
</font><br>
Thank you!<br>
<br>
Christopher Schmidt escribi&oacute;:
<blockquote cite="mid:20090406140738.GC2977@metacarta.com" type="cite">
  <pre wrap="">On Mon, Apr 06, 2009 at 04:06:55PM +0200, Luis Ortiz (lortiz) wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">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);
    </pre>
  </blockquote>
  <pre wrap=""><!---->
gml_new.events.register("featureselected", etc.)

just use the variable you created...

-- Chris

  </pre>
  <blockquote type="cite">
    <pre wrap="">
Thank you





    </pre>
  </blockquote>
  <pre wrap=""><!---->
  </pre>
  <blockquote type="cite">
    <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@openlayers.org">Users@openlayers.org</a>
<a class="moz-txt-link-freetext" href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</a>
    </pre>
  </blockquote>
  <pre wrap=""><!---->

  </pre>
</blockquote>
</body>
</html>