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

Problems with getFeatureInfo #14

Open
Rudolf-May opened this issue Feb 10, 2021 · 4 comments
Open

Problems with getFeatureInfo #14

Rudolf-May opened this issue Feb 10, 2021 · 4 comments
Labels
upstream Bug in upstream repo

Comments

@Rudolf-May
Copy link

Hallo trafficonese,

I had been very happy when i found your plugin for leaflet which enables to retrieve the feature info from a wms when clicking on some feature of a wms layer.
It worked perfectly when I tested this in my local RStudio environment. But -
when I upload the app to my productive server (where shiny server is configured to run behind an apache proxy) I get blank popups instead of the feature information.
This is my simplified code for testing (you can try it here: https://floraweb.de/shiny/wmstest):

library(leaflet)
library(leaflet.extras)
library(leaflet.extras2)
library(shiny)

ui <- fluidPage(
  leafletOutput("myMap", height = "600"))

server <- function(input, output, session) {
  output$myMap <- renderLeaflet(leaflet() %>% 
                    setView(lng=10,lat=51.2, zoom = 6) %>% addTiles(group = "OSM") %>%
                    addProviderTiles(providers$OpenTopoMap, group = "Topo") %>%
                    addProviderTiles(providers$Esri.WorldImagery, group = "ESRI Sat") %>%
                    addWMS(baseUrl = "http://geodienste.bfn.de/ogc/wms/schutzgebiet?",
                           group="NP",
                           layers = "Nationalparke",
                           options = WMSTileOptions(format="image/png",transparent=TRUE,opacity=0.7,info_format = "text/html",tiled = FALSE),
                           attribution = "Overlaykarten: (c) Bundesamt für Naturschutz (BfN) 2015") %>%
                    addWMS(baseUrl = "http://geodienste.bfn.de/ogc/wms/schutzgebiet?",
                           group="BSR",
                           layers = "Biosphaerenreservate",
                           options = WMSTileOptions(transparent = TRUE,opacity=0.7,format = "image/png",info_format = "text/html",tiled = FALSE),
                           attribution = "Overlaykarten: (c) Bundesamt für Naturschutz (BfN) 2015" ) %>%
                    addWMS(baseUrl = "http://geodienste.bfn.de/ogc/wms/gliederungen?",
                           group="RGL",
                           layers = "Naturraeume",
                           options = WMSTileOptions(format="image/png",transparent=TRUE,opacity=0.7,info_format = "text/html",tiled = FALSE),
                           attribution = "Overlaykarten: (c) Bundesamt für Naturschutz (BfN) 2015" ) %>%
                    addWMS(baseUrl = "http://sg.geodatenzentrum.de/wms_vg250-ew?",
                           group="VG250",
                           layers = "vg250_krs",
                           options = WMSTileOptions(format="image/png",transparent=TRUE,opacity=0.7,info_format = "text/html",tiled = FALSE),
                           attribution = "Overlaykarte: (c) Bundesamt für Kartographie und Geodäsie (BKG) 2014" ) %>%
                    addLayersControl(
                          baseGroups = c("OSM", "Topo", "ESRI Sat"),
                          overlayGroups = c("NP","BSR","RGL","VG250"),
                          options = layersControlOptions(collapsed = TRUE)) %>%
                    hideGroup("NP") %>% hideGroup("BSR") %>% hideGroup("RGL") %>% hideGroup("VG250") %>%
                    addResetMapButton()
        )
}
shinyApp(ui, server)

I would be very happy if you could help to find out what might be the reason for this (I have read the issue #4, but this did'nt put me on the right track...

@Rudolf-May
Copy link
Author

I think I have located the cause of the problem.
Having a shiny-server working behind an apache proxy a response status code "301 moved permanently" is returned by the shiny-server.
In the source code of the wms.leaflet plugin there is a helper function to return the "request.responseText" when the request.status === 200 (line 484 of the source on github). So in the scenario with the apache proxy the responseText will not be returned.
The getfeatureinfo works as expected when the example app in my first post is served directly from the shiny server which then gives us a response status code 200.
I have posted an issue on the github page https://github.com/heigeo/leaflet.wms/issues asking to add request.status===301. If this will be accepted I would kindly ask to provide an updated version of the leaflet.extras2 package.
Beste regards
Rudolf

@trafficonese
Copy link
Owner

Hey, thank you very much for digging into this.
I'll just link the issue here (heigeo/leaflet.wms#72)

Did you try it out with accepting the response code 301?

@Rudolf-May
Copy link
Author

Hey, thank you very much for digging into this.
I'll just link the issue here (heigeo/leaflet.wms#72)

Did you try it out with accepting the response code 301?

No, that is beyond my abilities since I am not fit in writing javascript code, though I can read and grasp most of what the code is meant to produce...

@trafficonese
Copy link
Owner

I uploaded a new branch, which accepts the request code 200 and 301.

You can install it with:
remotes::install_github("trafficonese/leaflet.extras2@wms_301")

Could you please check if that works?

@trafficonese trafficonese added the upstream Bug in upstream repo label Feb 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Bug in upstream repo
Projects
None yet
Development

No branches or pull requests

2 participants