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

mapboxer_proxy doesn't work with modules #62

Closed
Camil88 opened this issue Mar 7, 2021 · 2 comments · Fixed by #63
Closed

mapboxer_proxy doesn't work with modules #62

Camil88 opened this issue Mar 7, 2021 · 2 comments · Fixed by #63
Assignees
Labels
bug Something isn't working

Comments

@Camil88
Copy link

Camil88 commented Mar 7, 2021

Hello,
I have encountered an issue with implementing mapboxer_proxy in a modularized app. Simply, after clicking a button I want points to be displayed on a map. Everything works smoothly in a non-modularized app but when I use modules then it doesn't work. Interestingly, leafletProxy works fine even in a modularized app, so I really don't know where the problem lies. Maybe there's some issue with mapboxer_proxy itself? Or maybe I make a mistake somewhere.

Here is a link to StackOverflow where I described my issue + added working app.R code (modularized and non-modularized): https://stackoverflow.com/questions/66509929/why-mapboxer-proxy-is-not-working-in-a-modularized-shiny-app

I also tried with set_data instead of add_circle_layer but it doesn't solve the problem. Could you please advise me on that issue?

@crazycapivara crazycapivara self-assigned this Mar 8, 2021
@crazycapivara crazycapivara added the bug Something isn't working label Mar 8, 2021
@crazycapivara
Copy link
Owner

@Camil88 It is a problem with the namespace and more or less a bug in mapboxer_proxy.
I need to the change the line shinyId <- session$ns(shiny_id) to shiny_id <- session$ns(shiny_id) (happened when renaming var name).

For now you can solve the issue by providing the namespace in your server function:

# Server #
mod_btn_server <- function(id) {
  moduleServer(id, function(input, output, session)  {
    ns <- NS(id)
    # ...
    observeEvent(input$btn, {
      mapboxer::mapboxer_proxy(ns("map")) %>%
      # ...
    }.
  }
}

I will fix it as soon as possible.

@Camil88
Copy link
Author

Camil88 commented Mar 8, 2021

Thank you for your fast reply! Now I can move on with my project:) However, please let me know as soon as you fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants