Giter Club home page Giter Club logo

Comments (6)

jcheng5 avatar jcheng5 commented on June 14, 2024

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.

pssguy avatar pssguy commented on June 14, 2024

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.

blmoore avatar blmoore commented on June 14, 2024

Use layerId (e.g. set polygon layerId's to respective county), then capture as shown above?

from leaflet.

pssguy avatar pssguy commented on June 14, 2024

Thanks guys. layerId = data$country looks good

from leaflet.

jcheng5 avatar jcheng5 commented on June 14, 2024

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.

efh0888 avatar efh0888 commented on June 14, 2024

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)

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.