Learn R Programming

datamaps (version 0.0.3)

add_markers: Add markers

Description

Add custom markers at coordinates.

Usage

add_markers(p, lon, lat, ...)

markers_options(p, ...)

Arguments

p

a datamaps object.

lon, lat

coordinates.

...

any other parameter.

See Also

Plugin documentation

Examples

Run this code
# NOT RUN {
coords <- data.frame(
  city = c("London", "New York", "Beijing", "Sydney"),
  lon = c(-0.1167218, -73.98002, 116.3883, 151.18518),
  lat = c(51.49999, 40.74998, 39.92889, -33.92001),
  radius = runif(4, 5, 17)
)

icon_url <- paste0(
  "https://pbs.twimg.com/profile_images/",
  "927645314630193158/ufoYTbbi_400x400.jpg"
)

coords %>% 
  datamaps() %>% 
  markers_options(
    icon = list(
      url = icon_url,
      width = 20, height = 20
     ),
     fillOpacity = 1
  ) %>% 
  add_markers(lon, lat)
  
# }

Run the code above in your browser using DataLab