1

I am taking the context and taking it to a canvas which was asked here and the answer can be found in this JSfiddle example.

enter image description here

However, I am looking to load a WMS layer from geoserver and extract only this WMS layer to make a process and display something on canvas. On Openlayers 2 it could be done with layerContainerDiv extracting the element that contains all the layers and taking the required one. But it seems that in Openlayers 3 cannot be done. I have tried something similar to this example (take into account that this example gives a cross-origin error, but not in my server), but without success as all the layers are processed and cannot be distinguished.

enter image description here

Does someone know how can layers can be distinguished or separated to process them independently?

I found the Layer Spy Example which it seems that making use of precompose and postcompose could be a possibility, but using the options of ol.Map I can find the 2 layers by map.getLayers().getLength(). And I can find the array of the WMS with map.getLayers().getArray()[0] but how to take the layer context?

1

Did you look at the Shaded Relief sample?

It uses operation from ol.source.Raster. They enable data processing on raster (your WMS is a raster)

Like with precompose/precompose, you can also set some functions on raster with afteroperations/beforeoperations from ol.source.RasterEvent.html

  • the example as you said, it is a raster, but I am also trying it with a XYZ tile for different zooms. Is there any similar event for these kind of layers? As I checked, it doesn't seem to be possible. Is there any other way? – iblasi Sep 14 '15 at 20:34
  • An ol.source.Raster can use an ol.source.XYZ if you look again at the Shaded Relief sample mentioned before. So, not need to look elsewhere for other events: just use ol.source.Raster or otherwise I missed the point maybe. – ThomasG77 Sep 14 '15 at 23:50
  • @thomasg77it works! Very good example the "Shaded Relief" which shows exactly how operations can be done on a layer. Thank you. – iblasi Sep 15 '15 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.