Comments (6)
Yes, if the map outputId is "foo"
you could look at input$foo_shape_click
which will give you either NULL
or a list like this:
list(
lat = latitude,
lng = longitude,
id = layerId
)
from leaflet.
Thanks Joe. I can extract a lat and lon this way.
However, I want to return the country clicked on, which is, say, in the data$country field from the underlying data object. I assume I can use the data argument of addPolygons but I cannot seem to return it correctly
getMapData = function(data,location,session){
# want to return country
})
map <- leaflet(data = data) %>%
addTiles()
map %>%
addPolygons(...,
data = getMapData(map))
Any help appreciated
from leaflet.
Use layerId
(e.g. set polygon layerId's to respective county), then capture as shown above?
from leaflet.
Thanks guys. layerId = data$country looks good
from leaflet.
Yep. You don't need to pass the data
arg to addPolygons, as the
leaflet(data) argument is inherited by default. And you can do layerId = ~country
instead of data$country, if you want to. Read this whole page for
more information: http://rstudio.github.io/leaflet/map_widget.html
On Fri, Jun 5, 2015 at 6:57 AM pssguy [email protected] wrote:
Thanks guys. layerId = data$country looks good
—
Reply to this email directly or view it on GitHub
#41 (comment).
from leaflet.
Hey Joe,
This was super helpful.
I've been able to implement a drill-down leaflet map going from country to state/province with an info control that changes on hover, but it's still pretty buggy. Would you mind looking at my code at https://github.com/efh0888/leafletDrilldown for some help? The README has all the details...
Edit: you can also see a live version at https://efh0888.shinyapps.io/leafletDrilldown
from leaflet.
Related Issues (20)
- Layer control fails when using clusterOptions
- Leaflet Map not loading after window size changes
- htmlwidgets 1.6.3 breaks addEasyButton HOT 1
- Update of map not works HOT 1
- addPolyline() with SpatVector fails if terra is not loaded because check_crs_terra() is missing depency terra::crs HOT 2
- toggle baseGroups legends in the same way as overlayGroups in addLayersControl HOT 1
- Proj4Leaflet-TMS.R example is broken; broken TMS in Leaflet is possibly the culprit! HOT 2
- tms = TRUE not working with known TMS provider (from NASA!) HOT 2
- Leaflet muddling RGB rasters from terra
- No documentation on the Polyline 'offset' functionality
- Error in addLegend: unused arguments HOT 2
- addTiles does not allow display of self-hosted vector tiles
- Specifying labels as zero-length character vector causes error
- Update docs to use `{sf}` or `{terra}` HOT 1
- Remove vignettes/articles/nc after successful site build
- Broken basemaps on {pkgdown} site HOT 3
- Specifying Pop-up Location HOT 2
- modify icon size
- dependencies missing in v.2.2.2 HOT 2
- Maps are blank when previewing in RStudio on Windows with R 4.4.0 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leaflet.