Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addWMS() no layerId argument #6

Closed
dewalex opened this issue Aug 15, 2020 · 9 comments
Closed

addWMS() no layerId argument #6

dewalex opened this issue Aug 15, 2020 · 9 comments

Comments

@dewalex
Copy link

dewalex commented Aug 15, 2020

I'm trying to make the Sidebyside with two WMS layers, but I need a layerId to do that. The addWMS() function does not have a layerId argument. Is there any way to make this work?

@dewalex
Copy link
Author

dewalex commented Aug 15, 2020

I see from testing other things with Sidebyside that it may actually be the lack of an option for pathOptions(pane="") that is keeping the addWMS() from being used in Sidebyside.

@trafficonese
Copy link
Owner

The argument layers is used as layerId.

It seems to be possible to use 1 call to addWMS with addSidebyside but not 2. I will have to dig a bit deeper to understand why it is not working correctly.


library(leaflet)
library(leaflet.extras2)

leaflet() %>%
  addMapPane("left", zIndex = 0) %>%
  addMapPane("right", zIndex = 0) %>%
  addTiles() %>%
  addWMS(baseUrl = "http://ows.terrestris.de/osm/service",
         layers = "OSM-Overlay-WMS",
         group = "wms_left",
         options = leaflet::WMSTileOptions(
           transparent = TRUE, format = "image/png", info_format = "text/html"
         )) %>% 
  addLayersControl(overlayGroups = "wms_left") %>%
  addSidebyside(layerId = "sidecontrols",
                leftId = "OSM-Overlay-WMS")

@trafficonese
Copy link
Owner

Using untiled=FALSE seems to work. However, the click event ignores the pane argument and triggers also when moving the slider.

library(leaflet)
library(leaflet.extras2)

leaflet() %>%
   addMapPane("left", zIndex = 0) %>%
   addMapPane("right", zIndex = 0) %>%
   addTiles(group = "base", layerId = "baseid",
            options = pathOptions(pane = "right")) %>%
   addProviderTiles(providers$CartoDB.DarkMatter, group = "carto", layerId = "cartoid",
                    options = tileOptions(pane = "left")) %>%
   
   addWMS(baseUrl = "https://maps.dwd.de/geoserver/dwd/wms",
          layers = "dwd:BRD_1km_winddaten_10m",
          group = "wms_right",
          options = leaflet::WMSTileOptions(untiled=FALSE,
            transparent = TRUE, format = "image/png", info_format = "text/html"
            ,pane = "right"
          )) %>% 
   addWMS(baseUrl = "http://ows.terrestris.de/osm/service",
          layers = "OSM-Overlay-WMS",
          group = "wms_left",
          options = leaflet::WMSTileOptions(untiled=FALSE,
            transparent = TRUE, format = "image/png", info_format = "text/html"
            ,pane = "left"
          )) %>% 
   addLayersControl(overlayGroups = c("wms_right", "wms_left")) %>%
   addSidebyside(layerId = "sidecontrols",
                 rightId = "baseid",
                 leftId = "cartoid")

@trafficonese
Copy link
Owner

trafficonese commented Aug 17, 2020

I just pushed 7a17032 which should make the pane argument work for tiled and untiled WMS.

This PR heigeo/leaflet.wms#58 fixed it.

@dewalex
Copy link
Author

dewalex commented Aug 17, 2020

Thanks so much for looking into this so quickly.

What I am trying to do with Sidebyside, is to compare the same satellite imagery based on two different time ranges. That means that the layers argument will be the same name, which will interfere with the layerId argument. Here is my sample code:

leaflet() %>%  setView(-86.39548,36.17889, 15) %>%
  addMapPane("left", zIndex = 0) %>%
  addMapPane("right", zIndex = 0) %>%
  addTiles(group = "base", layerId = "baseid",
           options = pathOptions(pane = "right")) %>%
  addProviderTiles(providers$CartoDB.DarkMatter, group = "carto", layerId = "cartoid",
                   options = tileOptions(pane = "left")) %>%
  
  addWMS(baseUrl = "https://services.sentinel-hub.com/ogc/wms/d0da9937-3594-4c41-9953-27dabd2bacae",
         layers = "TRUE_COLOR",
         group = "wms_right",
         options = leaflet::WMSTileOptions(untiled=TRUE,
                                           transparent = FALSE,  info_format = "text/html"
                                           ,pane = "right",
                                           time="2020-02-01/2020-08-14"
         )) %>% 
  addWMS(baseUrl = "https://services.sentinel-hub.com/ogc/wms/d0da9937-3594-4c41-9953-27dabd2bacae",
         layers = "TRUE_COLOR",
         group = "wms_left",
         options = leaflet::WMSTileOptions(untiled=TRUE,
                                           transparent = FALSE,  info_format = "text/html"
                                           ,pane = "left", 
                                           time="2018-02-01/2018-08-14"
         )) %>% 
  addLayersControl(overlayGroups = c("wms_right", "wms_left")) %>%
  addSidebyside(layerId = "sidecontrols",
                rightId = "baseid",
                leftId = "cartoid")

@dewalex
Copy link
Author

dewalex commented Aug 17, 2020

Also, is there any way to just turn the click info off, so that we don't get the issue with the box popping up every time that the slider is moved?

@trafficonese
Copy link
Owner

I will look into it, but if you dont need the click info, it might be better to just use leaflets addWMSTiles instead. You can just exchange the addWMS calls with addWMSTiles. Would that work?

@dewalex
Copy link
Author

dewalex commented Aug 17, 2020

It looks like that might be a good solution, since the only info i was trying to extract from the tiles was the date. I can call both layers (the image and date) and it will display the date over the tile. I’ll give it a try and let you know if I run into any issues. Thanks

@trafficonese
Copy link
Owner

addWMS now inherited a layerId argument and works almost identical to addWMSTiles. The only differences are the getFeatureInfo feature and the popupOptions argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants