0

If I have a WMTS URL, is it possible to feed in the URL and have it automatically add all the layers onto my map instance?

Currently, I can replicate the demo, but only if I pass in options, etc. Unfortunately, these streams are going to be dynamic and I will only be given the URL.

https://openlayers.org/en/latest/examples/wmts-layer-from-capabilities.html

1

In a WMS this can be done by requesting the root layer, not sure about WMTS, of course it's not actually that useful, because the maps all overlay each other, so you're likely to obscure some data

So if you look at this service you can see it has six layers:

<Layer>
   <Name>BGS_EN_Bedrock_and_Superficial_Geology</Name>
   <Title>BGS bedrock and superficial geology</Title>
   <Abstract>
   ...
   <Layer queryable="1" opaque="0" cascaded="0">
     <Name>GBR_BGS_625k_BLT</Name>
     ...
   <Layer queryable="1" opaque="0" cascaded="0">
     <Name>GBR_BGS_625k_BLS</Name>
     ...
   <Layer queryable="1" opaque="0" cascaded="0">
     <Name>GBR_BGS_625k_BA</Name>
     ...
   <Layer queryable="1" opaque="0" cascaded="0">
     <Name>GBR_BGS_625k_SLT</Name>  
     ...
   <Layer queryable="1" opaque="0" cascaded="0">
     <Name>GBR_BGS_625k_SLS</Name>
     ...
   <Layer queryable="1" opaque="0" cascaded="0">
     <Name>UKCoShelf_BGS_1M_SBS</Name>
     ...

but if you want all of them in one call you can ask for the root layer BGS_EN_Bedrock_and_Superficial_Geology like:

http://ogc.bgs.ac.uk/cgi-bin/BGS_Bedrock_and_Superficial_Geology/wms?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&LAYERS=BGS_EN_Bedrock_and_Superficial_Geology&STYLES=default&FORMAT=image/png&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&CRS=EPSG:4326&BBOX=49.8639,-9.80586479568672,60.8622,2.92769479568672&WIDTH=1020&HEIGHT=881&

WMS root layer

But you can't see some of the data like the layer called BR_BGS_625k_BLT, because it is hidden beneath the others, and there's no way to discover it, because the map image is rendered on the server. It's not a case of somehow dissolving the top layers.

hidden layer

Or you can ask for multiple layers, like:

http://ogc.bgs.ac.uk/cgi-bin/BGS_Bedrock_and_Superficial_Geology/wms?REQUEST=GetMap&SERVICE=WMS&VERSION=1.3.0&LAYERS=GBR_BGS_625k_SLT,GBR_BGS_625k_BA,GBR_BGS_625k_BLS,GBR_BGS_625k_BLT,GBR_BGS_625k_SLS,UKCoShelf_BGS_1M_SBS&STYLES=default&FORMAT=image/png&BGCOLOR=0xFFFFFF&TRANSPARENT=TRUE&CRS=EPSG:4326&BBOX=49.8639,-9.80586479568672,60.8622,2.92769479568672&WIDTH=1020&HEIGHT=881&

multiple layer request

but the result is similar, you get one image, though you can determine which one comes out on top.

  • Thanks for the response. The images only overlay on top of one another only if the layers overlap, no? For example, I could have Canadian layers, USA layers, etc. All independent of each others geospatial region. – John Lippson Apr 26 '18 at 15:36
  • Sure, so in the last example the data from three layers is visible, though one layer partially obscures the other – nmtoken Apr 26 '18 at 15:43
  • So you're saying for (WMS, not WMTS) I can query for the root layer? How exactly does that look? – John Lippson Apr 26 '18 at 15:45
  • The request is the second link – nmtoken Apr 26 '18 at 15:46
  • I coded up a simple example for WMS and WMTS github.com/Schachte/WMTS-Layer-Parser. This allows me to loop through all settings for each type and dynamically add the layers. Since the layers are going to be toggle-able by the client, I feel adding all of them is fine. – John Lippson Apr 26 '18 at 18:10

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.