0

我一整天都在尝试创建地图并将其导出为 pdf。问题是我真的不明白如何设置“宽度”和“高度”或使用“fitBounds”。我也想在右下角裁剪这个“传单”标志。我试图做一个随机的可重现示例,我只想裁剪蓝色矩形。有任何想法吗?



remove(list = ls())
library(leaflet)
library(sf)
library(mapview)


### create random sf polygon
pol = st_sfc(st_polygon(list(cbind(c(0,3,3,0,0),c(0,0,3,3,0)))))
h = st_sf(r = 5, pol)


### create "map"
df <- leaflet(width = 1000, height = 1000) %>%  
  #fitBounds(100, 100, 100, 100) %>% 
  addPolygons(data = h,
              color = "blue",
              weight = 1,
              opacity = 1,
              fillOpacity = 1) %>% 
  setMapWidgetStyle(style = list(background = "transparent"))

### show map and export
df
mapshot(df, file = "leaflet.pdf")


在此处输入图像描述

4

0 回答 0