我对R不熟悉,并尝试根据此示例使用Flexdashboard开发仪表板: https://matt-dray.github.io/earl18-crosstalk/04_leaflet-flexdash-dt-crosstalk.html
我可以使用它,但是我要完成的是我不希望一开始就显示出所有观点。 当用户选择过滤器时,我想在地图上添加一个标记并缩放到这一点。我没有使用datatables元素
我到目前为止的代码
---
title: "Leaflet + Flexdashboard + DT + Crosstalk"
author: "Matt Dray"
output:
flexdashboard::flex_dashboard:
theme: paper
favicon: img/ios7-location-outline.png
source_code: embed
---
```{r setup, include=FALSE}
# prep workspace
library(dplyr) # tidy data manipulation
library(leaflet) # interative mapping
library(DT) # interactive tables
library(crosstalk) # inter-widget interactivity
library(varhandle) # change column type
sch <- readRDS("data/gias_sample.RDS")
#sch <- readRDS("data/grafinformatie.rds")
#sch <- as.data.frame(sch)
#sch <- unfactor(sch) # change column type
sd <- SharedData$new(sch)
```
Interactives {data-icon="ion-stats-bars"}
=====================================
Column {data-width=400}
-------------------------------------
### Filters
```{r filters}
filter_select(
id = "geo_la",
label = "NAME",
sharedData = sd,
group = ~geo_la
)
```
Column {data-width=600}
-------------------------------------
### Interactive map
```{r map}
sd %>%
leaflet::leaflet() %>%
leaflet::addProviderTiles(providers$OpenStreetMap)
# leaflet::addAwesomeMarkers(
# icon = awesomeIcons(
# library = "ion",
# iconColor = "white"
# )
# ) %>% # end addAwesomeMarkers()
#leaflet::addMeasure()
```
$(document).ready(function () {
FlexDashboard.init({
theme: "paper",
fillPage: true,
orientation: "columns",
storyboard: false,
defaultFigWidth: 576,
defaultFigHeight: 460,
defaultFigWidthMobile: 360,
defaultFigHeightMobile: 460
});
});
希望有人可以提供帮助!谢谢