Giter Site home page Giter Site logo

leaflet-shiny's Introduction

leaflet-shiny's People

Contributors

jcheng5 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leaflet-shiny's Issues

leaflet : conditional color circle

Hi Jcheng5,

first, thank you for your active contributions.

I've adapted your code "Population" to my shiny application. It works very well.
The circle width is based on a data frame (df_cases). But I would like to define color according a another data frame(df_alert), 0 no alert (green color) and 1 for alert (red color). Both data frame have same dimension and structure.

Thanks so much for your answer.
regards.

addCircleMarker for json

Hello jcheng5,

I am reading in geojson data and using the map$addGeoJSON(xyz) function, I however would like to get circle markers instead of the blue teardrop markers. Will appreciate it if you can assist with this.

Thank you
-Andy

Precision of map$addCircle when lat and long are stored as numeric.

Hello,
Thanks for making this (and shiny). I had an issue when I used the map$addCircle() function. I had stored my Lat and Long data as numeric, with 7 digits after the decimal point. When I plotted the data on a mapbox map, the centers of the circles were off ~50 meters. However, when I first used as.character() on the coordinates, the error went away.

Is this implementation suitable for heatmap?

Would it be possible to use this implementation of leaflet for shiny?

Would it be possible to add it to this code or a change to the package is necessary?

I'm assuming https://github.com/Leaflet/Leaflet.heat will be used as it has been developed by Vladimir Agafonkin as a leaflet extension already.

The associated issue is to have the possibility to reset the heatmap layer to allow a shiny user to select a parameter from the UI and see different objects at choice (different items; dates etc.).

Disclaimer: I have already implemented something similar with rCharts but the layer reset does not work and all the heatmaps are shown one on top of the other.
I have posted a question with sample shiny code on stackoverflow here: http://stackoverflow.com/questions/26752589/remove-leaflet-heatmap-layer-with-rcharts-and-shiny

Trying to programmatically clear open marker popup and open another, driven by click on a different component

I have a shiny dashboard example here, with a leaflet map and a DT table. I have clicks on the map markers driving the row selection in the table, but I am also wanting to have it work the other way, where a click on a table row, triggers the selection of a map market for the popup to appear.

In other words, the end user can drive their selection from either component

library(shiny)
library(leaflet)
library(DT)
library(tidyverse)

# Define UI for application that draws a histogram
ui <- fluidPage(
   
    leafletOutput("opsMap"),
    DT::dataTableOutput('ranksDT')
)

# Define server logic required to draw a histogram
server <- function(input, output) {
   
    lats <- c(21.608889,21.693056, 24.04)
    longs <- c(-74.650833, -73.095,-74.341944)
    popups <- c('a','b','c')
    layerids <- c('a','b','c')
    iconNames <- c('cog','cog','cog')
    iconColors <- c('red','red','red')
    
    sampleData <- data_frame(lats,longs, popups,layerids,iconNames,iconColors)

    score <- c(7,3,9)
    
    locationRanks <- data_frame(popups, score)
        
    output$opsMap <- renderLeaflet({
        
        leaflet() %>%
            addTiles() %>% 
            addAwesomeMarkers(lat = sampleData$lats, 
                              lng = sampleData$longs, 
                              popup = sampleData$popups, 
                              layerId = sampleData$layerids,
                              icon = makeAwesomeIcon(icon=sampleData$iconNames, 
                                                     markerColor=sampleData$iconColors))
    })
    
    output$ranksDT <- DT::renderDataTable({
        d1 <- datatable(locationRanks,
                        selection = 'single',
                        rownames=FALSE,
                        options = list(dom = 'tpi',
                                       pageLength =5,
                                       paging=FALSE,
                                       searching=FALSE
                        )
        )
        d1
    })
    
    # create a reactive value that will store the click position
    mapClick <- reactiveValues(clickedMarker=NULL)
    mapClick <- reactiveValues(clickedGroup=NULL)
    
    # create a reactive for the DT  table
    locationClick <-reactiveValues(clickedRow = NULL)
    
    # observe click events
    observe({
        mapClick$clickedMarker <- paste(input$opsMap_marker_click$id)
        mapClick$clickedGroup <- paste(input$opsMap_marker_click$group)
        locationClick$clickedRow <- input$ranksDT_rows_selected
    })
    
    # define a proxy variable for the plant rank table
    proxy1 = dataTableProxy('ranksDT')
    # when map is clicked, make the same table row selection - need row number
    observeEvent(input$opsMap_marker_click$id, {
        a <- which(locationRanks[1] == input$opsMap_marker_click$id)
        proxy1 %>% selectRows(a)
    })
    
    
    # if table is clicked, select the same market from the map
    observeEvent(locationClick$clickedRow, {
        a <- as.character(locationRanks[locationClick$clickedRow,1])
        cat(file=stderr(),"clicked row", locationClick$clickedRow, a,'\n')

    })
    
    
}

# Run the application 
shinyApp(ui = ui, server = server)

Feedback on updated documentation

Joe,

I just saw that you updated the documentation of this package a few weeks ago and wanted to take the chance to submit some general feedback.

I used your package to reverse engineer a United Nations web app 3 months ago which was not so easy due to the lack of documentation.

Since the RStudio team uses apps based on leaflet-shiny to showcase Shiny in general, any further improvement of the package's documentation is a big plus. Therefore, I really appreciate the latest updates of the README.

Cheers,
Alex

Error while running the project

Trying to run this project in R studio. It gives following error message:

Error in force(ui) : could not find function "fluidPage"

addRectangle bug

addRectangle doesn't work. Line 304 in binding.js should read:

    self.shapes.add(rect, thisId);

instead of

    self.shapes.addLayer(rect, thisId);

How to use events?

Dear Joe,

First of all congratulation for your great package!
I have built a map with circle markers and popups, and I would like popups to appear when the mouse goes on a circle. I am not a js user, and I don't understand how I should use the events (if it's the correct concept to be invoked here) in my R code.
Could you please help me with this issue?
Thank you in advance and best regards,
Thomas

my code:
output$mapTweets <- renderLeaflet({
m = leaflet() %>% addTiles()
m
m %>% addCircleMarkers(lng = located_patient.tw$lon, lat = located_patient.tw$lat, popup = custom.popup, radius = 4, opacity = 0.2)
})
}

How to move L.Control.Zoom on the topright ?

Is it possible to move the Zoom In/Out option without using javascript ?

I have found that the options exist with leaflet,

L.Control.Zoom({ position: 'topright' }).addTo(map);

But didn't find where to put this with R.

I tried
leaflet(options=list(Control.Zoom("topright"))

and with addControls.

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.