SymbolixAU / mapdeck

R interface to Deck.gl and Mapbox
https://symbolixau.github.io/mapdeck/articles/mapdeck.html
361 stars 41 forks source link

Google Map support #162

Closed dcooley closed 5 years ago

dcooley commented 5 years ago

support

googleway::google_map() %>%
  mapdeck::add_polygon() %>%
  mapdeck::add_path() %>%
  .. etc

https://github.com/uber/deck.gl/blob/master/examples/get-started/pure-js-google-maps/app.js


TODO

TESTS

SymbolixAU commented 5 years ago
library(googleway)
library(mapdeck)
library(sf)

set_key("GOOGLE_MAP_KEY")

sf <- spatialwidget::widget_melbourne

googleway::google_map() %>%
    mapdeck::add_dependencies() %>%
    mapdeck::add_polygon(
        data = sf
        , fill_colour = "SA3_NAME"
    )

Screen Shot 2019-04-08 at 12 27 12 pm

Screen Shot 2019-04-08 at 12 30 41 pm

SymbolixAU commented 5 years ago

shiny example

library(shiny)
library(shinydashboard)
library(googleway)
library(mapdeck)

ui <- dashboardPage(
  dashboardHeader()
  , dashboardSidebar()
  , dashboardBody(
    mapdeck::mapdeck_dependencies()
    , box(
    width = 8
    , googleway::google_mapOutput(
      outputId = "map"
      , height = "600"
    )
  )
)
)

server <- function( input, output ) {
  output$map <- googleway::renderGoogle_map({
    googleway::google_map(
      location = c(0,0)
      , zoom = 2
    ) %>%
    mapdeck::add_dependencies() %>%
      mapdeck::add_scatterplot(
        data = mapdeck::capitals
        , lat = "lat"
        , lon = "lon"
      )
    })
}

shinyApp( ui, server )
SymbolixAU commented 5 years ago

Mixing googleway and mapdeck layers

google_map() %>%
  googleway::add_heatmap(
    data = tram_stops
    , option_radius = 0.0025
  ) %>%
  mapdeck::add_dependencies() %>%
    mapdeck::add_scatterplot(
    data = tram_stops
    , lon = "stop_lon"
    , lat = "stop_lat"
    , radius = 50
    , fill_colour = "stop_lat"
  )

Screen Shot 2019-04-18 at 8 37 16 am

But it's a bit laggy