Coder Social home page Coder Social logo

Comments (4)

anthonynorth avatar anthonynorth commented on June 11, 2024

rdeck doesn't support interleaving deck.gl layers with basemap layers; all of the layers you add to an rdeck map are deck.gl layers and will be rendered on top of the basemap as an overlay. The mvt_layer is the deck.gl MVTLayer which renders tile data as a GeoJsonLayer.

You could also just use the layer_selector and toggle layers off when you need to see the basemap, unobstructed by data: rdeck(layer_selector = TRUE). Assuming that your data is more important than the basemap context the majority of the time, this should work well -- my team does this.

If you need to put basemap labels on top of your data, you can achieve that by re-drawing the labels on top of other deck.gl layers with another mvt_layer (or text_layer if the data is local).

PS: I don't intend to support deck.gl and mapbox-gl interleaving via MapboxLayer.

from rdeck.

bdbmax avatar bdbmax commented on June 11, 2024

All right, thanks for the quick answer!

Just tried with local data and add_text_layer, works fine! To avoid the addition of a layer, there's a column in my MVT with the labels of my polygons. I saw the get_text argument in the Usage part of the add_mvt_layer documentation, but couldn't make it work the same way I did with add_text_layer! Labels don't appear. Here's a reprex if you'd like to take a look:

shinyApp(
  ui = fillPage(
    rdeckOutput("map", height = "100%"),
  ),
  
  server = function(input, output) {
    
    output$map <- renderRdeck(
      rdeck(theme = "mapbox://styles/mapbox/streets-v11",
            initial_view_state = view_state(center = c(-73.58, 45.53), 
                                            zoom = 10.1)) |> 
        add_mvt_layer(id = "test", 
                      data = mvt_url("maxbdb.borough_7"),
                      pickable = TRUE, tooltip = TRUE, 
                      get_text = rlang::sym("name"),
                      get_fill_color = "#FE7D6AFF")
    )
  }
)

from rdeck.

anthonynorth avatar anthonynorth commented on June 11, 2024

mvt_layer can draw text for point features via point_type = "text" (or "circle+text", "icon+text" etc). That tileset doesn't appear to have any point features though.

Unrelated note, changing the basemap is done via map_style; theme ("kepler" or "light") is for css -- and appears to be not validated.

library(rdeck)
library(shiny)
shinyApp(
  ui = fillPage(
    rdeckOutput("map", height = "100%"),
  ),
  
  server = function(input, output) {
    
    output$map <- renderRdeck(
      rdeck(map_style = "mapbox://styles/mapbox/streets-v11",
            initial_view_state = view_state(center = c(-73.58, 45.53), 
                                            zoom = 10.1)) |> 
        add_mvt_layer(id = "test", 
                      data = mvt_url("maxbdb.borough_7"),
                      pickable = TRUE, tooltip = TRUE, 
                      get_text = rlang::sym("name"),
                      get_fill_color = "#FE7D6AFF",
                      point_type = "text")
    )
  }
)

from rdeck.

bdbmax avatar bdbmax commented on June 11, 2024

That fixes the issue. Thanks a lot!

from rdeck.

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.