Skip to contents

This function adds start and end markers to a Leaflet map based on the provided start and end coordinates.

Usage

map_add_axis_start_end(map, axis_start_end, group)

Arguments

map

A Leaflet map object created using the 'leaflet' package.

axis_start_end

A data frame containing start and end coordinates with columns 'X' for longitude and 'Y' for latitude.

Value

A Leaflet map object with start and end markers added.

Examples

library(leaflet)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union

# Create a simple Leaflet map
my_map <- leaflet() %>%
  setView(lng = 4.968697, lat = 45.103354, zoom = 8) %>%
  addProviderTiles(providers$CartoDB.Positron)

# Create a data frame with start and end coordinates
coordinates_df <- data_get_axis_start_end(network_axis %>%
                                            filter(fid == 5))

# Add start and end markers to the map
my_map <- map_add_axis_start_end(my_map, axis_start_end = coordinates_df)
#> Error: argument "group" is missing, with no default
my_map