regan008 / MGG-LC-Data

0 stars 1 forks source link

Plotly to Leaflet #28

Open Hmknipp opened 3 hours ago

Hmknipp commented 3 hours ago

@regan008

https://rstudio.github.io/leaflet/articles/markers.html#circle-markers https://rstudio.github.io/leaflet/articles/shapes.html

It looks like moving over to Leaflet should be fairly straight forward. Plots from simple lat/long data. There are two options for circle markers on maps, and these can be color coded based on attributes. Links above have info on the different options ("Circle Markers" seems like the better option?)


"Data frame with latitude and longitude columns. You can explicitly tell the marker function which columns contain the coordinate data (e.g., addMarkers(lng = ~Longitude, lat = ~Latitude)), or let the function look for columns named lat/latitude and lon/lng/long/longitude (case insensitive)."

" # Create a palette that maps factor levels to colors pal <- colorFactor(c("navy", "red"), domain = c("ship", "pirate"))

leaflet(df) %>% addTiles() %>% addCircleMarkers( radius = ~ifelse(type == "ship", 6, 10), color = ~pal(type), stroke = FALSE, fillOpacity = 0.5 ) "

regan008 commented 2 hours ago

Great lets proceed with moving over to this version. I agree that circle markers are the better option here. I prefer the solid circles to the outlined circles on that first link -- I think they'll be easier to see.

Go ahead and work on swapping out the plotly map with the leaflet map. Once you have a static version of that running we can worry about reactivity. If you need an example the MGG-App repo on the Mapping the Gay Guides GitHub org has an example of a leaflet map.

Let me know if you have trouble getting this running. I'll be on campus Friday for a few things.