[OpenLayers-Users] Layer name
toni hernández
toni at sigte.udg.edu
Thu Oct 8 03:34:32 PDT 2015
Jair,
I am not an expert...if this doesn't work, I hope someelse helps you.
I am sure there are other ways to achive this.
once said that,
When creating your layers you need to add an "id" attribute. See the
example bellow.
Then, use get the onclic mouse event, and
earthQuakeLayer = new ol.layer.Vector({
source: new ol.source.Vector({
....
}),
id:'yourlayerid'
});
Then , when listening the clic event, you need to use something similar
to this.
map.on('click', function (e) {
map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
console.debug(layer.get('id'));
});
}
*Toni Hernández Vallès*
Servei de Sistemes d'Informació Geogràfica i Teledetecció
-
Universitat de Girona
*SIGTE*
-
Pl. Ferrater Mora 1
17071 Girona
Tel +34 972 418 039 (7026 intern)
toni at sigte.udg.edu <mailto:toni at sigte.udg.edu>
http://www.sigte.udg.edu
Twitter http://twitter.com/SIGTE_UDG
On 05/10/2015 21:30, Jair Santos wrote:
>
> Hello,
>
> In a multi-layer map how to determine the clicked layer name when the
> user click on the map?
>
> Thanks,
>
> JJ.
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20151008/e70fdf34/attachment.html>
More information about the Users
mailing list