Add Polygons of geojson to map
This commit is contained in:
@@ -2,9 +2,12 @@ library(rjson)
|
|||||||
library(shiny)
|
library(shiny)
|
||||||
library(bslib)
|
library(bslib)
|
||||||
library(leaflet)
|
library(leaflet)
|
||||||
|
library(sf)
|
||||||
|
|
||||||
|
|
||||||
crime_json <- fromJSON(file="C:\\Users\\milli\\Documents\\Datenbereinigung\\data.json")
|
crime_json <- fromJSON(file="C:\\Users\\milli\\Documents\\Datenbereinigung\\data.json")
|
||||||
|
geojson_data <- st_read("C:\\Users\\milli\\Documents\\Datenbereinigung\\geojson.json")
|
||||||
|
geojson_data <- st_transform(geojson_data, crs = 4326)
|
||||||
bezirke <- names(crime_json)
|
bezirke <- names(crime_json)
|
||||||
|
|
||||||
ui <- page_fillable(
|
ui <- page_fillable(
|
||||||
@@ -49,10 +52,22 @@ server <- function(input, output, session){
|
|||||||
output$hhmap <- renderLeaflet({
|
output$hhmap <- renderLeaflet({
|
||||||
leaflet() %>%
|
leaflet() %>%
|
||||||
addProviderTiles(providers$CartoDB.Positron) %>%
|
addProviderTiles(providers$CartoDB.Positron) %>%
|
||||||
|
addPolygons(
|
||||||
|
data = geojson_data,
|
||||||
|
color = "#7bb5ab",
|
||||||
|
fillColor = "#bdf0e7",
|
||||||
|
weight = 1,
|
||||||
|
fillOpacity = 0.05, # Polygon fill transparency
|
||||||
|
highlightOptions = highlightOptions(
|
||||||
|
color = "#103b57",
|
||||||
|
weight = 4,
|
||||||
|
bringToFront = TRUE
|
||||||
|
),
|
||||||
|
) %>%
|
||||||
setView(
|
setView(
|
||||||
lng = 9.98716634776887,
|
lng = 9.98716634776887,
|
||||||
lat = 53.5488439196432,
|
lat = 53.5488439196432,
|
||||||
zoom = 10
|
zoom = 11
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
2796591
geojson.json
Normal file
2796591
geojson.json
Normal file
File diff suppressed because it is too large
Load Diff
936799
geojson_nurbezirk.json
Normal file
936799
geojson_nurbezirk.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user