rstudio / leaflet

R Interface to Leaflet Maps
http://rstudio.github.io/leaflet/
Other
805 stars 508 forks source link

Utilize fontawesome icon as a floating icon without a marker #711

Open nash1119 opened 3 years ago

nash1119 commented 3 years ago

Is it possible to place a fontawesome icon as simply a floating icon on my map, with no marker? Or is it possible to add a marker with no "tail" (so the marker is simply a circle/square/etc rather than a pin)? Basically, I want to utilize fontawesome icons on specific lat/long coordinates but do not want markers underneath them. From searching through stackoverflow, I do not seem to be the only one who has had this question, but I did not find any available solutions. Thank you!!

For example, I would want this to just be the briefcase hovering over these coordinates with either no marker or just a circle/square (with no "tail") underneath.

library(shiny)
library(leaflet)
library(fontawesome)

ui <- fluidPage(

    mainPanel(
      leafletOutput("map", height = 700),
      width = 9
    )
  )

server <- function(input, output) {

  awesomeIcon <- reactive({
    makeAwesomeIcon(icon = "briefcase", library = "fa", iconColor = "black")
  })

  output$map <- renderLeaflet({
    leaflet()%>%addProviderTiles("Esri.WorldGrayCanvas")%>%
      addAwesomeMarkers(lng = -74.96, lat = 39.77, icon = awesomeIcon(), popup = "test")
  })

}

shinyApp(ui = ui, server = server)
#> 
#> Listening on http://127.0.0.1:8461

Created on 2020-11-08 by the reprex package (v0.3.0)

janehuber commented 9 months ago

This would be so helpful!

I am currently working to create a PDF knit from an RMarkdown file. When transforming the leaflet into a PDF, it drops the marker and only preserves the icon itself. While this likely has to do with the process of rendering and capturing the image of the map in order to transform into a PDF, it is extremely difficult to get around.

The ability to simply place an "awesomeIcon" wherever you want on the map would be a game changer!