星巴克全美门店数字地图显示

starbucks <- read.csv("D:/starbucks.csv" ) ; #普通的CSV格式就行,不必是UTF8的
starbucks <- read.csv(“D:/starbucks.csv” , stringsAsFactors=FALSE); # 数据框将会把First、Last 等存储为因子,尽管此时将它们视为字符串(或使用R 中的术语,字符:character)更为合理。为了区别这一点,可以设置stringsAsFactors=FALSE
 View(starbucks); #console显示正常,但view显示有乱码,没关系,数据可用
head(starbuck,5)

library(“leafletR”)
dat<-toGeoJSON(data=starbucks,lat.lon=c(21,22))

map<-leaflet(dat,title=”星巴克全美门店”,popup=”Brand”)

使用中的几个注意问题:

1、popup只能显示 GEOJSON文件中的”properties”的内容,其他的内容(如经纬度)不能弹出显示

2、GEOJSON文件不认 \r, \n字符,需要进行转换,否则报错;

3、leaflet默认的地图OpenStreetMap,坐标位置与百度地图不一致,需要确认哪个有问题。注意:Please note: data only accepts GeoJSON/TopoJSON files with one geometry type and geographical coordinates (longlat, WGS84).

转载自:https://blog.csdn.net/wa2003/article/details/45490023

You may also like...