温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

leaflet怎么构造路径图

发布时间:2022-03-28 09:59:38 来源:亿速云 阅读:380 作者:iii 栏目:大数据

这篇文章主要介绍“leaflet怎么构造路径图”,在日常操作中,相信很多人在leaflet怎么构造路径图问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”leaflet怎么构造路径图”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

library(leaflet)

library(dplyr)

data<-read.table("D:/R/File/subwayline.txt",header=TRUE,stringsAsFactors = FALSE)

data$Type<-as.factor(data$Type)

data1<-filter(data,Type=="NO1")

data2<-filter(data,Type=="NO5")

leaflet怎么构造路径图

以上我用百度地图的坐标拾取平台采点拾取的背景地铁一号线和五号线的车站地理位置信息,(因为没有现成的数据,只能手工采点,可能不是很准确)

今天要介绍的leaflet类型是线条,也即addPolylines函数,其基本语法如下:

addPolylines(map, lng = NULL,lat = NULL, #指定数据源并做经纬度声明

     layerId = NULL, 

     group = NULL,  #图层分组(制作动态可见性交互时使用)

     stroke = TRUE, #是否呈现路径线

     color = "#03F",weight = 5,opacity = 0.5, #关于线条的颜色、宽度、透明度 

     fill = FALSE, fillColor = color, fillOpacity = 0.2, 

     dashArray = NULL, smoothFactor = 1, noClip = FALSE,  #线型参数,平滑度等

     popup = NULL, options = pathOptions(), data = getMapData(map)) #弹窗、选项控制

以下构造色盘:

pal <- colorFactor(topo.colors(2),data$Type)

作图函数:使用默认点标识

leaflet()%>%

addTiles()%>%

addPolylines(data=data1,~lon,~lat,color="blue")%>%

addPolylines(data=data2,~lon,~lat,color="green")%>%

addMarkers(data=data,~lon, ~lat,popup = ~address)

leaflet怎么构造路径图

使用可自定义的圆点标识车站位置

leaflet()%>%

addTiles()%>%

addPolylines(data=data1,~lon,~lat,color="blue")%>%

addPolylines(data=data2,~lon,~lat,color="green")%>%

addCircles(data=data,~lon, ~lat,popup = ~address,color="red")

leaflet怎么构造路径图

leaflet()%>%

addTiles()%>%

addPolylines(data=data1,~lon,~lat,color="blue")%>%

addPolylines(data=data2,~lon,~lat,color="green")%>%

addCircleMarkers(data=data,~lon, ~lat,popup = ~address,color=~Type)

leaflet怎么构造路径图

以下是几种比较常用的地图背景素材

addProviderTiles("Esri.WorldStreetMap")  

addProviderTiles("Esri.WorldImagery")   

addProviderTiles("Esri.WorldTerrain")    

addProviderTiles("Esri.NatGeoWorldMap")  

leaflet()%>%

addProviderTiles("Esri.WorldStreetMap")%>%

addPolylines(data=data1,~lon,~lat,color="blue")%>%

addPolylines(data=data2,~lon,~lat,color="green")%>%

addCircles(data=data,~lon, ~lat,popup = ~address,color=~Type)

leaflet怎么构造路径图

leaflet()%>%

addProviderTiles("Esri.WorldImagery")%>%

addPolylines(data=data1,~lon,~lat,color="blue")%>%

addPolylines(data=data2,~lon,~lat,color="green")%>%

addCircles(data=data,~lon, ~lat,popup = ~address,color=~Type)

leaflet怎么构造路径图

leaflet()%>%

addProviderTiles("Esri.WorldGrayCanvas") %>%

addPolylines(data=data1,~lon,~lat,color="blue")%>%

addPolylines(data=data2,~lon,~lat,color="green")%>%

addCircles(data=data,~lon, ~lat,popup = ~address,color=~Type)

leaflet怎么构造路径图

leaflet()%>%

addProviderTiles("Esri.NatGeoWorldMap")  %>%

addPolylines(data=data1,~lon,~lat,color="blue")%>%

addPolylines(data=data2,~lon,~lat,color="green")%>%

addCircles(data=data,~lon, ~lat,popup = ~address,color=~Type)

leaflet怎么构造路径图

是不是觉得花样不够多呀,那好吧,以下这些,全部都送给你,那好不谢!

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

# OpenStreetMap.Mapnik

# OpenStreetMap.BlackAndWhite

# OpenStreetMap.DE

# OpenStreetMap.France

# OpenStreetMap.HOT

# OpenTopoMap

# Thunderforest.OpenCycleMap

# Thunderforest.Transport

# Thunderforest.TransportDark

# Thunderforest.SpinalMap

# Thunderforest.Landscape

# Thunderforest.Outdoors

# Thunderforest.Pioneer

# OpenMapSurfer.Roads

# OpenMapSurfer.Grayscale

# Hydda.Full

# Stamen.Toner

# Stamen.TonerBackground

# Stamen.TonerLite

# Stamen.Watercolor

# Stamen.Terrain

# Stamen.TerrainBackground

# Stamen.TopOSMRelief

# Esri.WorldStreetMap

# Esri.DeLorme

# Esri.WorldTopoMap

# Esri.WorldImagery

# Esri.WorldTerrain

# Esri.WorldShadedRelief

# Esri.WorldPhysical

# Esri.OceanBasemap

# Esri.NatGeoWorldMap

# Esri.WorldGrayCanvas

# MtbMap

# CartoDB.Positron

# CartoDB.PositronNoLabels

# CartoDB.PositronOnlyLabels

# CartoDB.DarkMatter

# CartoDB.DarkMatterNoLabels

# CartoDB.DarkMatterOnlyLabels

# HikeBike.HikeBike

# HikeBike.HillShading

# NASAGIBS.ModisTerraTrueColorCR

# NASAGIBS.ModisTerraBands367CR

# NASAGIBS.ViirsEarthAtNight2012

# NASAGIBS.ModisTerraLSTDay

# NASAGIBS.ModisTerraSnowCover

# NASAGIBS.ModisTerraAOD

# NASAGIBS.ModisTerraChlorophyll

到此,关于“leaflet怎么构造路径图”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注亿速云网站,小编会继续努力为大家带来更多实用的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI