0

I have built a WMS parser which I am using to retrieve all layers from a WMS url to be able to automatically build a OL map with those layers inside.

Actually, I see I can do it in two modes:

  1. MODE 1: making a ol.source.ImageWMS instance for each layer and append it to a layer_list array (to be used as ol.Map's params parameter)
  2. MODE 2: making only one instance of ol.source.ImageWMS with all the layer names inside the params:LAYERS parameter.

To my understanding, the MODE 1 should make a new request for each layer to the same WMS url, and this have the disadvantage of slowing the process, but the advantage of maybe handling the layers easier (e.g turing them on and off, zooming to one specific layer, etc.)

MODE 2 however migt be harder to handle in terms of single layer, but it's only one WMS request.

I am new to OL.

Which mode is more efficient?

2
  • 1
    If you want to turn layers on and off, change order etc, then you'll have a problem with the second method, you'll have to request all data every time, changing the draw order each time ~ you only get one image, it'll be a mess of styles too probably if the data layers significantly overlap. So efficiency will depend on what you want to do.
    – nmtoken
    Jun 19, 2018 at 20:34
  • @nmtoken Thanks for helping me one more time. I think this could be the answer I needed. Would you post it as answer?
    – umbe1987
    Jun 20, 2018 at 7:36

1 Answer 1

1

Efficiency will depend on what you (or your users) are expecting to do.

If you want to turn layers on and off, change order etc, then you'll have a problem with the second method, because you only get one image which is an amalgamation of all the requested layers. You'll have to request all the data every time, changing the draw order each time, it'll be a mess of styles too, probably, if the data layers significantly overlap.

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.