-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.r
54 lines (47 loc) · 1.92 KB
/
server.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
shinyServer(function(input, output) {
filteredData <- reactive({
ultimos_sismos<-na.omit(ultimos_sismos)
ultimos_sismos[ultimos_sismos$Magnitud >= input$range[1] & ultimos_sismos$Magnitud <= input$range[2],]
})
colorpal <- reactive({
colorNumeric(input$colors, ultimos_sismos$Magnitud)
})
output$map <- renderLeaflet({
ii<-which.max(ultimos_sismos_sp@data$Magnitud)
leaflet(ultimos_sismos_sp) %>%
setView(lng = ultimos_sismos_sp@coords[ii,2],
lat = ultimos_sismos_sp@coords[ii,1], zoom = 9) %>%
addProviderTiles("Esri.NatGeoWorldMap",group="NatGeoWM")%>%
addProviderTiles("CartoDB.Positron") %>%
addProviderTiles("Esri.WorldImagery",group="Visible") %>%
addProviderTiles("OpenTopoMap",group = "Topo") %>%
# Layers control
addLayersControl(position="bottomleft",
baseGroups = c("Visible","OSM","NatGeoWM","Topo"),
options = layersControlOptions(collapsed = TRUE))
})
observe({
pal <- colorpal()
Fecha<-filteredData()$'Fecha Local'
leafletProxy("map", data = filteredData()) %>%
clearShapes() %>%
addCircles(radius = ~10^Magnitud/10, weight = 2, color = "#777777",
fillColor = ~pal(Magnitud), fillOpacity = 0.7,
popup = ~paste(sep = "<br/>",
paste("<b>Lugar:",Lugar),
paste("<b>Fecha",Fecha),
paste("<b>Magnitud:",Magnitud, "Ml")
)
)
})
observe({
proxy <- leafletProxy("map", data = ultimos_sismos)
proxy %>% clearControls()
if (input$legend) {
pal <- colorpal()
proxy %>% addLegend(position = "bottomright",
pal = pal, values = ~Magnitud
)
}
})
})