tests/testthat/test-icon.R

test_that("icon deduping works", {
  icons <- c("leaf-green.png", "leaf-red.png")
  m <-
    leaflet(data = data.frame(color = sample.int(2, 30, replace = TRUE))) %>%
    addMarkers(1:30, 30:1, icon = icons(
      iconUrl = ~icons[color],
      shadowUrl = c("leaf-shadow.png"),
      iconWidth = 38, iconHeight = 95, iconAnchorX = 22, iconAnchorY = 94,
      shadowWidth = 50, shadowHeight = 64, shadowAnchorX = 4, shadowAnchorY = 62
    ))
  expect_equal(
    length(m$x$calls[[1]]$args[[3]]$iconUrl$data),
    2
  )
})

Try the leaflet package in your browser

Any scripts or data that you put into this service are public.

leaflet documentation built on Nov. 14, 2023, 1:08 a.m.