Code Monkey home page Code Monkey logo

leaflet.extras's Introduction

R-CMD-check Project Status: Active – The project is being actively developed. Last-changedate
License: GPL-3 packageversion CRAN_Status_Badge Codecov test coverage

leaflet.extras

The goal of leaflet.extras package is to provide extra functionality to the leaflet R package using various leaflet plugins.

Installation

For CRAN version

install.packages("leaflet.extras")

For latest development version

remotes::install_github("trafficonese/leaflet.extras")

Progress

Plugins integrated so far …

If you need a plugin that is not already implemented create an issue. See the FAQ section below for details.

Documentation

The R functions have been documented using roxygen, and should provide enough help to get started on using a feature. However some plugins have lots of options and it’s not feasible to document every single detail. In such cases you are encouraged to check the plugin’s documentation.

There are also plenty of examples available.

FAQ

I want to use a certain leaflet plugin not integrated so far.

  • Good Solution: Create issues for plugins you wish incorporated but before that, search the existing issues to see if issue already exists and if so comment on that issue instead of creating duplicates.
  • Better Solution: It would help in prioritizing if you can include additional details like why you need the plugin, how helpful will it be to everyone etc.
  • Best Solution: Code it yourself and submit a pull request. This is the fastest way to get a plugin into the package.

Also take a look at this Gist to include arbitrary Leaflet JS plugins

I submitted an issue for a plugin long time ago but it is still not available.

This package is being developed purely on a voluntary basis on spare time without any monetary compensation. So the development progress can stall at times. It may also not be possible to prioritize one-off requests that no one else is interested in. Getting more people interested in a feature request will help prioritize development. Other option is to contribute code. That will get you added to the contributor list and a thanks tweet.

I found a bug.

  • Good Solution: Search existing issue list and if no one has reported it create a new issue.
  • Better Solution: Along with issue submission provide a minimal reproducible code sample.
  • Best Solution: Fix the issue and submit a pull request. This is the fastest way to get a bug fixed.

Development

To make additions to the plugin dependencies, please add the plugin using npm. Make sure it is compiled within the webpack.config.js. Finally, make sure htmlwidgets finds it within your plugin’s dependency function.

To build the latest version of the plugins, please make sure Node.js is installed on your system, then run:

npm install
npm run build

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

leaflet.extras's People

Contributors

bhaskarvk avatar byzheng avatar dependabot[bot] avatar jwolfson avatar markusdumke avatar rcura avatar schloerke avatar timelyportfolio avatar trafficonese 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  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  avatar  avatar

leaflet.extras's Issues

Temporal Viz support

Currently these are the options to visualize spatiotemporal data.

  • TimeDimension
    • Perhaps the most feature complete plugin.
    • Supports WMS and GeoJSON data with time element.
    • For the WMS part requires a proxy on the server to avoid CORS issues.
    • Could be an overkill for our visualization needs.
  • TimeSlider
    • Simple and straight forward enough.
    • Supports only markers.
  • Playback
    • Supports plotting GPX point data.
  • Timeline
    • This is by far the most easiest and fairly feature rich
    • Takes GeoJSONs with time dimensions as properties
  • Realtime
    • Polls a GeoJSON/p source
    • Serves an entirely different purpose than the rest of the alternatives, so might be worthwhile to add it regardless.

My vote goes to Timeline as it's very easy to implement. But I am willing to listen to arguments for others, especially TImeDimension.

cc @tim-salabim @jcheng5 @mdsumner

clearShapes and clearMarkers doesn't work

Hi!

I'm doing a survey with Shiny on R where people have to draw polygons and markers on a map to show where they sampled. People fill the form for each sampling campaign (one page per sampling campaign) they did, and can navigate between these pages.

I create an erase button so people can erase on campaign if they did a mistake. The campaign is erased in "responses" and the form is reset, but the map doesn't update even if I use clearMarkers and clearShapes.

Here is my code:

output$map <- renderLeaflet({
leaflet() %>% addProviderTiles() %>% setView(1010, 54, 5) %>%
addDrawToolbar(targetGroup = rv$page, polygonOptions = drawPolygonOptions(),
markerOptions = drawMarkerOptions(), editOptions = editToolbarOptions(),
polylineOptions = FALSE, circleOptions = FALSE, rectangleOptions = FALSE)

########### ERASE FORM
observeEvent(input$erase, {

  if (rv$page < length(responses)) {
    responses[[rv$page]] <<- NULL
    rv$page <- length(responses) + 1
    reset("formulaire")
    #leafletProxy("map") %>% clearShapes() %>% clearMarkers()
  **} else {
    responses[[rv$page]] <<- NULL
    reset("formulaire")
    leafletProxy("map") %>% clearShapes() %>% clearMarkers()
    }
  })**

When rv$page < length(responses), it works because rv$page change so the targetGroup change too.

responses is a list with all the answers.

I hope it's clear, i'm not sure ahah
Thank you!

extend the fillOpacity option in the function addGeoJSONChoropleth()

Hi @bhaskarvk
Thank you very much for this wonderful package. You did a great job.

The option fillOpacity in the functionaddGeoJSONChoropleth() seems to work just with a constant value (e.g. fillOpacity = 0.7). Would it be possible to extend it, that it can handle also feature properties in the same way like the valueProperty can do? In this was, one could weight the opacity of the polygons e.g. according to the significance of the data. In the example below I want to control the opacity with the dist_num property, which is meaningless but it shows what I want to do.

library(leaflet)
library(leaflet.extras)   
topojson <- readr::read_file("https://rawgit.com/TrantorM/leaflet-choropleth/gh-pages/examples/basic_topo/crimes_by_district.topojson")

leaflet() %>% 
  setView(-75.14, 40, zoom = 11) %>%
  addProviderTiles("CartoDB.Positron") %>% 
  addGeoJSONChoropleth(
    topojson,
    valueProperty ='incidents',
    fillOpacity = JS("function(feature){return (feature.properties.dist_num / 100);}")
  )

Drawing polygons and retrieve the coordinates

Hi!
I'm new here and i'm francophone, so sorry if the question is not clear but i'll try to be clear as much as possible!

I'm doing a survey with Shiny on R where people have to draw polygons on map to show where they sampled. I'm using leaflet.draw to draw the polygons, but i can't manage to retrieve the coordinates of every polygons. I've searched a lot on internet but i can't find anything on it.

So i would like people to be able to draw polygons, edit them, i would want my shiny app to save the coordinate of the polygon.

Thank you!

Blur and radius in heatmap

Hi, I have a question about the Heatmap functionality in this package.
In this issue on the leaflet page: rstudio/leaflet#174 there is an option to provide the blur and radius for the heatmap, this makes them much nicer.
However, this is not available in the leaflet.extras package. Is there any way to give in these arguments?

If not, is there any way in which I will be able to use 'addHeatmap' function as described in the closed issue?

Thank you in advance!

Support Leaflet.draw

Would be really usefull, especially in combination with shiny and others interactive frameworks.
Leaflet.draw is a recommanded plugin from Leaflet, and has already been partially integred in rstudio's leaflet package (draw-toolbar branch).
More recently, it's been fixed/updated in @ssoulier fork, and updated/upgraded in mine, which is, AFAIK, the only one currently working.

It's not that difficult to include, but the hard part is that it's currently conflictual with Leaflet.heat (even in pure js versions, without using R), couldn't figure out why (probably some conflicted-name functions like draw()).

Anyway, that would be a really usefull addition to this leaflet plugins package, as the spatial selection/drawing still remains the weak part of R spatial toolset.

Full Screen Button Misbehaves in HTML Documents

It seems that the addFullscreenControl() feature fails to recognize the screen extents when it is included in an html document (e.g., r notebook, gitbook, etc.).

To reproduce this error, run the following example, knit an html document, and try toggling the full screen button:

---
output:
  html_document: default
---


*```{r setup}
library(leaflet)
library(leaflet.extras)

leaflet() %>% 
        addTiles() %>% 
        setView(-93.65, 42.0285, zoom = 17) %>% 
        addFullscreenControl()
*```

Using Chrome, I get the following result:

screen shot 2016-12-05 at 9 13 26 am

After clicking the full screen button:
screen shot 2016-12-05 at 9 13 38 am

Any suggestions for short-term fix work-arounds would be welcome – thanks!

Meta Issue to track plugins

Shiny: Search func disables input$map_marker_click

Hi, I have a function that is activated every time I click on a marker, it works well until I use the search functionality. After that, it only works on the groups of markers not affected by the search.
does anyone have a clue what happened?
I have tested that the input$map_marker_click is not triggered for the group of markers (i.e. clubs) related to the search.

This is the way I configured the search:
map%>%addSearchMarker(
targetGroup = 'clubs',
options = searchMarkersOptions(propertyName = 'label',zoom=17, openPopup = FALSE))

To catch the event I use:
observe({
click<-input$map_marker_click

Thanks in advance!
Nahuel

Return the layer id in draw plugin

Thanks for implementing draw plugin in leaflet.extras. Do you consider to implement to return layer id in all events? Like I have implemented here: https://github.com/byzheng/leaflet/blob/bc64ac8de5d009d083669b2562580fb55f46303d/inst/htmlwidgets/plugins/leaflet-draw-plugin/leaflet-draw-plugin.js

In my case, I need to link the layer id with other attributes after drawing a feature. This layer id can be used to retrieve attributes when a feature is edited and deleted, then execute extra steps, e.g. update or remove records from database.

rpubs Shape Data example not working

http://rpubs.com/bhaskarvk/topojsonv2

Code just results in the base map of Philidelphia

library(leaflet)
library(leaflet.extras)
fName <- 'https://rawgit.com/TrantorM/leaflet-choropleth/gh-pages/examples/basic_topo/crimes_by_district.topojson'


leaflet() %>%
 addBootstrapDependency() %>%
  setView(-75.14, 40, zoom = 11) %>%
  addProviderTiles(providers$CartoDB.Positron) %>%
  addTopoJSONChoropleth(
    fName,
    valueProperty ='incidents',
    scale = c('white','red'), mode='q', steps = 5,
    popupProperty = propstoHTMLTable(
      props = c('dist_numc', 'location', 'incidents', '_feature_id_string'),
      table.attrs = list(class='table table-striped table-bordered'),drop.na = T),
    labelProperty = 'dist_num',
    color='#ffffff', weight=1, fillOpacity = 0.7,
    highlightOptions =
      highlightOptions(fillOpacity=1, weight=2, opacity=1, color='#000000',
                       bringToFront=TRUE, sendToBack = TRUE)
  )

sessionInfo()

R version 3.3.1 (2016-06-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

locale:
[1] LC_COLLATE=English_Canada.1252  LC_CTYPE=English_Canada.1252    LC_MONETARY=English_Canada.1252
[4] LC_NUMERIC=C                    LC_TIME=English_Canada.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] leaflet.extras_0.1.6 leaflet_1.0.2.9006  

loaded via a namespace (and not attached):
 [1] htmlwidgets_0.7 magrittr_1.5    htmltools_0.3.5 tools_3.3.1     yaml_2.1.13     Rcpp_0.12.7     stringi_1.1.2  
 [8] jsonlite_1.1    stringr_1.1.0   digest_0.6.10  

Also look like similar issue with the point data example at same url

Question: webGLHeatmap.R

Hi Bhaskar,

Thanks for your amazing work. Could you spare some time for feedback?

I have deployed a Shiny app that uses the webGLHeatmap. The rendering of the map + heatmap is way too slow. It tries to renders 45MB of data. Is this too large? Is there a way to speed up the rendering.

Best,
Nelson

Duplicated points to draw a polygon

There are duplicated points (9) when I draw a polygon with four points.

This is the output of new_ply$geometry$coordinates after convert to a matrix

	 [,1]      [,2]
 [1,] 152.3303 -27.56613
 [2,] 152.3303 -27.56613
 [3,] 152.3311 -27.56532
 [4,] 152.3311 -27.56532
 [5,] 152.3321 -27.56587
 [6,] 152.3321 -27.56587
 [7,] 152.3316 -27.56674
 [8,] 152.3316 -27.56674
 [9,] 152.3303 -27.56613

I expect 5 rows in the coordinates but 9 rows. The first 4 rows are duplicated.

Draw bi-directional support

Currently with the draw plugin, you can

  • Create/Resize/Move/Delete features.
  • For each of the above activity you'll get Shiny events to handle data on R side.

But...

  • There is no way to specify an initial set of features to work on.
  • There is no way to programmatically add/update/delete features on Shiny side.

How critical is it to have these features ? Looking for input from the usual suspects.

Heatmap zooming

Hello, thank you very much for these extra features. In particular, I am interested in heatmaps. I succeeded to create heatmaps by using addWebGLHeatmap function. However, I noticed that while zooming in, the heatmap doesn't change. (the size parameter determines how we see the heatmap.)
I found this page http://rmaps.github.io/blog/posts/leaflet-heat-maps/index.html, and it is possible to create one that displays more detailed heatmap when zooming in.
I was wondering if it is possible to do some modifications to take this into account.

input$map_draw_created_features returns NULL

I have added the addDrawToolbar to my R Shiny leaflet map and am trying to capture the the coordinates of a drawn rectangle. However, the input$map_draw_created_features call returns NULL. When I edit the drawn rectangle and save it the input$map_draw_edited_features returns the expected geojson. I believe I saw a closed issue stating these were both incorporated into leaflet.extras. Please advise.
Thank you,
Carlee

Get the layer_id after adding an existing features into draw plugin

In my case, I need to add a few existing features into the draw plugin and get the layer id to store some variables.

For example, I can use codes below to create a polygon. Is there any ways to get the id from a layer?

library(leaflet.extras)
lat <- c(1, 2, 2, 1)
lng <- c(1, 1, 2, 2)
map <- leaflet() %>%
addDrawToolbar(targetGroup = 'drawGroup',
editOptions = editToolbarOptions()) %>%
addPolygons(lat = lat, lng = lng, group = 'drawGroup')
map

Leaflet.extra package installing error

devtools::install_github('bhaskarvk/leaflet.extras')
Downloading GitHub repo bhaskarvk/leaflet.extras@master
from URL https://api.github.com/repos/bhaskarvk/leaflet.extras/zipball/master
Installing leaflet.extras
"C:/PROGRA~1/R/R-33~1.2/bin/i386/R" --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD INSTALL  \
  "C:/Users/Kiddo/AppData/Local/Temp/RtmpWsZ8Q4/devtools22982d6b714e/bhaskarvk-leaflet.extras-3558bfe"  \
  --library="C:/Users/Kiddo/Documents/R/win-library/3.3" --install-tests 

* installing *source* package 'leaflet.extras' ...
** R
** inst
** preparing package for lazy loading
Error : package 'leaflet' 1.0.1 was found, but >= 1.0.2.9008 is required by 'leaflet.extras'
ERROR: lazy loading failed for package 'leaflet.extras'
* removing 'C:/Users/Kiddo/Documents/R/win-library/3.3/leaflet.extras'
Error: Command failed (1)

devtools::install('rstudio/leaflet')

Perhaps a small correction, but:
devtools::install('rstudio/leaflet') should be
devtools::install_github('rstudio/leaflet') right?

I wasted at least a full minute troubleshooting XD

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.