R Script如下:
library(leaflet)
setwd("C:/Users/chienhung0304/Desktop")
data = read.csv("geo.csv",header=T,sep=",")
map = leaflet(data) %>% addTiles()
map %>% addCircles(radius = ~NT_CN, lat = ~y, lng = ~x, color = "red", weight = 1, popup = ~city, fillOpacity = 1)
透過Shiny可變成Web UI介面
Shiny Script如下:
UI:
library(shiny)
shinyUI(pageWithSidebar(
# Application title
headerPanel("google map"),
# Sidebar with a slider input for number of zoom
sidebarPanel(
sliderInput("zoom",
"Number of zoom:",
min = 1,
max = 12,
value = 11)
),
# Show a plot of the generated distribution
mainPanel(
plotOutput("geoPlot")
)
))
Server:
library(shiny)
library(leaflet)
shinyServer(function(input, output) {
output$geoPlot <- p="" renderplot=""> setwd("C:/Users/chienhung0304/Desktop")
data = read.csv("geo.csv",header=T,sep=",")
map = leaflet(data) %>% addTiles()
map %>% addCircles(radius = ~NT_CN, lat = ~y, lng = ~x, color = "red", weight = 1, popup = ~city, fillOpacity = 1)
#map %>% addCircleMarkers(radius = ~NT_CN*0.1, fill = FALSE, lat = ~y, lng = ~x, color = "red")
})
})
->
Ref: https://rstudio.github.io/leaflet/shapes.html
沒有留言:
張貼留言