[OpenLayers-Users] layer by name or by id events
Luis Ortiz (lortiz)
lortiz at compegps.com
Mon Apr 6 10:30:28 EDT 2009
oh!!! quite easy!!!
Thank you!
Christopher Schmidt escribió:
> On Mon, Apr 06, 2009 at 04:06:55PM +0200, Luis Ortiz (lortiz) wrote:
>
>> 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);
>>
>
> gml_new.events.register("featureselected", etc.)
>
> just use the variable you created...
>
> -- Chris
>
>
>> Thank you
>>
>>
>>
>>
>>
>>
>
>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090406/1560d4ee/attachment.html
More information about the Users
mailing list