Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Case Analysis of leaflet scatter Map

Shulou Source: shulou.com Published: 2022-05-31 13:56:28 10月01日 Update

This article introduces the relevant knowledge of "leaflet scatter map example analysis". In the operation process of actual cases, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!

#Load package:

library(plyr)

library(maps)

library(mapdata)

library(leaflet)

library(stringi)

library(maptools)

library(htmltools)

library(RColorBrewer)

library(ggplot2)

For convenience of presentation, the provincial administrative map of china (imported in shp format) is uniformly used here, and the index data is mapped in the provincial capital city coordinates.

Map Material Data Import:

province_city %addTiles()%>% addCircles(lng=~jd,lat=~wd,color = ~pal(type),weight=~size,popup=~city)%>%

addLegend("bottomright",pal=pal,values = ~type,title = "GDP grade",labFormat = labFormat (suffix = "file"),opacity=1)

leaflet(province_city)%>%addTiles()%>% addCircleMarkers(lng=~jd,lat=~wd,color = ~pal(type),radius = ~size,fill=TRUE,popup=~city)

addLegend("bottomright",pal=pal,values = ~type,title = "GDP grade",labFormat = labFormat (suffix = "file"),opacity=1)

Continuous Scale Mapping:

leaflet(province_city)%>%addTiles()%>%

addCircles(lng=~jd,lat=~wd,fillColor=~cPal(size),weight=~size,stroke=FALSE,fillOpacity=0.8,popup=~city)%>%

addLegend("bottomright",pal=cPal,values = ~size,title = "GDP grade",labFormat = labFormat (suffix = "file"),opacity=1)

leaflet(province_city)%>%addTiles()%>%

addCircleMarkers(lng=~jd,lat=~wd,fillColor=~cPal(size),radius = ~size,stroke=FALSE,fillOpacity=0.8,popup=~city)%>%

addLegend("bottomright",pal=cPal,values = ~size,title = "GDP grade",labFormat = labFormat (suffix = "file"),opacity=1)

Several common map style theme effects:

The default point shape works with several common map theme styles:

leaflet(province_city)%>%addProviderTiles("Esri.WorldStreetMap")%>%addMarkers(lng=~jd,lat=~wd,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.WorldImagery")%>%addMarkers(lng=~jd,lat=~wd,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.WorldTerrain")%>%addMarkers(lng=~jd,lat=~wd,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.NatGeoWorldMap")%>%addMarkers(lng=~jd,lat=~wd,popup=~city)

#####################################################################

Solid dot shapes work with several common map theme styles:

leaflet(province_city)%>%addProviderTiles("Esri.WorldStreetMap")%>%addCircles(lng=~jd,lat=~wd,color="red",weight=~size,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.WorldImagery")%>%addCircles(lng=~jd,lat=~wd,color="red",weight=~size,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.WorldTerrain")%>%addCircles(lng=~jd,lat=~wd,color="red",weight=~size,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.NatGeoWorldMap")%>%addCircles(lng=~jd,lat=~wd,color="red",weight=~size,popup=~city)

#####################################################################

Outlined dot shapes work with several common map theme styles:

leaflet(province_city)%>%addProviderTiles("Esri.WorldStreetMap")%>%addCircleMarkers(lng=~jd,lat=~wd,radius=~size,color=~co,fill=TRUE,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.WorldImagery")%>%addCircleMarkers(lng=~jd,lat=~wd,radius=~size,color=~co,fill=TRUE,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.WorldTerrain")%>%addCircleMarkers(lng=~jd,lat=~wd,radius=~size,color=~co,fill=TRUE,popup=~city)

leaflet(province_city)%>%addProviderTiles("Esri.NatGeoWorldMap")%>%addCircleMarkers(lng=~jd,lat=~wd,radius=~size,color=~co,fill=TRUE,popup=~city)

Map types available:

addProviderTiles("Esri.WorldStreetMap") #Light

addProviderTiles("Esri.WorldImagery") #Dark satellite cloud

addProviderTiles("Esri.WorldTerrain") #Bright White

addProviderTiles("Esri.NatGeoWorldMap") #Dark Outline

addProviderTiles("Stamen.Toner") #Third-Party Tiles

addProviderTiles("Acetate.terrain") #

addProviderTiles("CartoDB.Positron")

addProviderTiles("Stamen.TonerLabels") #

The content of "leaflet scattered map example analysis" is introduced here. Thank you for reading it. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!

Tags: Maps themes variables common effects grades styles shapes examples case analysis analysis content factors coordinates values data more scales dark colors provincial capitals Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Apple MySQL MariaDB macOS