Git Product home page Git Product logo

Comments (9)

dewalex avatar dewalex commented on June 6, 2024

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.

from leaflet.extras2.

trafficonese avatar trafficonese commented on June 6, 2024

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")

from leaflet.extras2.

trafficonese avatar trafficonese commented on June 6, 2024

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")

from leaflet.extras2.

trafficonese avatar trafficonese commented on June 6, 2024

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

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

from leaflet.extras2.

dewalex avatar dewalex commented on June 6, 2024

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")

from leaflet.extras2.

dewalex avatar dewalex commented on June 6, 2024

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?

from leaflet.extras2.

trafficonese avatar trafficonese commented on June 6, 2024

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?

from leaflet.extras2.

dewalex avatar dewalex commented on June 6, 2024

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

from leaflet.extras2.

trafficonese avatar trafficonese commented on June 6, 2024

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

from leaflet.extras2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.