trafficonese / leaflet.extras

Extra functionality for leaflet R package.
https://trafficonese.github.io/leaflet.extras/
GNU General Public License v3.0
213 stars 74 forks source link

webGL Jsonlite Issue #151

Closed mdbeh closed 5 months ago

mdbeh commented 6 years ago

When I include a WebGLHeatmap on a leaflet map in Shiny, I'm getting the following warning:

Input to asJSON(keep_vec_names=TRUE) is a named vector. In a future version of jsonlite, this option will not be supported, and named vectors will be translated into arrays instead of objects. If you want JSON object output, please use a named list instead. See ?toJSON.

Looking around a bit, it seems like this is a standard message people are getting when they use vectors instead of lists in the manner described. It's not a fatal error, but it does clog up the console (it gets printed every time I change a map parameter), and I wouldn't want to deliver something that has a soon-to-be-obsolete control.

So any help/suggestions would be appreciated. BTW, I know there are other heatmap options, but I've found this webGL one to work best for me.

bhaskarvk commented 5 years ago

I'll be resuming development of leaflet.extras in Dec and will tackle this in that round. Thanks!

trafficonese commented 6 months ago

related: https://github.com/rstudio/shiny/issues/1465 https://github.com/wch/jsonlite/commit/9091eb0b3ecb48fffc5ad4e8fbae67ca84ff673f

So far I have no idea where that "named vectors" comes from. The geojson is just a string.

reprex:

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

geoJson <- readr::read_file(
  "https://rawgit.com/benbalter/dc-maps/master/maps/historic-landmarks-points.geojson"
)

ui <- fluidPage(
  leafletOutput("map")
)

server <- function(input, output, session) {
  output$map <- renderLeaflet({
    leaflet() %>%
      setView(-77.0369, 38.9072, 12) %>%
      addProviderTiles(providers$CartoDB.Positron) %>%
      addWebGLGeoJSONHeatmap(
        geoJson, size = 30 , units = "px"
      )
  })
}
shinyApp(ui, server)