############################### Flora Incognita Beobachtungen nach R exportieren # Install the latest version of the R program: # https://www.r-project.org # Install the latest version of the program RStudio: # https://posit.co/products/open-source/rstudio/ # Install the necessary libraries install.packages("leaflet") install.packages("leaflet.extras2") install.packages("htmlwidgets") # Load the necessary libraries library(leaflet) library(leaflet.extras2) library(htmlwidgets) ######################################## Read data ############################################################################## dat<-read.csv("/your_path/your_file.csv",header=TRUE) # Reading the data from the location where they are stored #Create a zoomable map where closely spaced observations are clustered. By clicking on a cluster you get to the individual observations. ####################################### Create map with clustered observations ############################################################################## map1<-leaflet(data = dat) %>% addProviderTiles('OpenStreetMap.Mapnik' ) %>% addCircleMarkers(lng = ~longitude, lat = ~latitude, label = ~scientific.name, radius=7,labelOptions = labelOptions(style = list("color" = "black"), noHide = T, textOnly=T,textsize = "10px",offset = c(1, 12)), color="black",clusterOptions = markerClusterOptions(spiderfyOnMaxZoom=T)) map1 # Calling the map ####################################### Create map ############################################################################## map2<-leaflet(data = dat) %>% addProviderTiles('OpenStreetMap.Mapnik' ) %>% addLabelOnlyMarkers(lng = ~longitude, lat = ~latitude,group="labs", label = ~scientific.name,labelOptions = labelOptions(style = list("color" = "black"), noHide = T, textOnly=T,textsize = "10px",offset = c(1,12))) %>% addCircleMarkers(lng = ~longitude, lat = ~latitude,color="black") %>% addCircleMarkers(lng = ~longitude, lat = ~latitude, radius=2, label = ~scientific.name, color="white") addLabelgun(map2,group="labs") map2 # If the trivial name is to be displayed, "scientific.name" must be replaced by "name" ##################################### Export the map as HTML ########################################################################### saveWidget(map2, file="/your-path/map.html")