3

Thanks to the leaflet.extras package it is easy to draw a polygon and/or a marker on a leaflet map as shown in the picture below.

enter image description here

Once clicked on those buttons it is possible to trigger an event like this:

observeEvent(input$map_draw_new_feature, { random_function() })

However I'm looking for a way to differentiate the observeEvent according if the user draw a polygon or a marker on the leaflet map. Something like that for instance:

observeEvent(input$map_draw_new_polygon, { random_function() })
observeEvent(input$map_draw_new_marker, { random_function() })

Is there a way to do such thing or there is no way to detect the feature type selected by the user before drawing it on the map ?!

wanderzen
  • 119
  • 2
  • 12
  • 3
    Not directly related to your question, but did you see that `leaflet.extras`'s author [doesn't recommend](https://github.com/bhaskarvk/leaflet.extras#readme) using this package? You should use [`leafpm`](https://github.com/r-spatial/leafpm) instead, which is supported by r-spatial – bretauv Feb 08 '22 at 16:15
  • 1
    I had no idea 'leaflet.extras' had become obsolete, thanks for the tips @bretauv. (for those who may be looking at my question, I'm still looking for an answer !) – wanderzen Feb 10 '22 at 14:49

0 Answers0