具有不同地图投影的串扰选择

时间:2018-08-26 18:39:54

标签: r leaflet

我正在尝试使用具有极性投影的Crosstalk地图来实现leaflet地图选择。选择工具变形,无法正确选择地图点。有办法纠正这个问题吗?

library(leaflet)
library(DT)
library(crosstalk)

extent <- sqrt(2) * 6371007.2
origin = c(-extent, extent)
maxResolution <- ((extent - -extent) / 256)
defZoom <- 3
bounds <- list(c(-extent, extent),c(extent, -extent))
minZoom <- 0
maxZoom <- 18
resolutions <- maxResolution/(2^(0:18))

crss <- leafletCRS(
  crsClass = 'L.Proj.CRS',
  code = 'EPSG:3575',
  proj4def = '+proj=laea +lat_0=90 +lon_0=10 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs',
  origin = origin,
  resolutions = resolutions,
  bounds = bounds
)

# Create data points for map
dat <- data.frame(latitude = c(80, 80), longitude = c(-143, 143))

# Wrap data frame in SharedData
sd <- SharedData$new(dat)

# Use SharedData like a dataframe with Crosstalk-enabled widgets
bscols(
  leaflet(sd, options= leafletOptions(
    crs=crss, minZoom = minZoom, maxZoom = maxZoom)) %>%
    setView(0, 90, defZoom) %>%
    addTiles(urlTemplate = 'https://tile.gbif.org/3575/omt/{z}/{x}/{y}@1x.png?style=osm-bright',
             attribution = "Map © GBIF.org. Data © OpenStreetMap contributors",
             options = tileOptions(subdomains = "abc", noWrap = TRUE,
                                   continuousWorld = FALSE)) %>%
    addCircleMarkers(data = sd, lat = ~latitude, lng = ~longitude),
  datatable(sd, extensions="Scroller", style="bootstrap", class="compact", width="100%",
            options=list(deferRender=TRUE, scrollY=300, scroller=TRUE))
)

0 个答案:

没有答案