1
我努力學習與rCharts的單張功能,並想繪製多個標記和彈出窗口從data.frame
對象囊括在R
使用單張及rCharts從緯度和經度數據幀繪製標記值
df <- data.frame(location = c("White House", "Impound Lot", "Bush Garden", "Rayburn", "Robertson House", "Beers Elementary"), latitude = c(38.89710, 38.81289, 38.94178, 38.8867787, 38.9053894, 38.86466), longitude = c(-77.036545, -77.0171983, -77.073311, -77.0105317, -77.0616441, -76.95554))
df
location latitude longitude
1 White House 38.89710 -77.03655
2 Impound Lot 38.81289 -77.01720
3 Bush Garden 38.94178 -77.07331
4 Rayburn 38.88678 -77.01053
5 Robertson House 38.90539 -77.06164
6 Beers Elementary 38.86466 -76.95554
我嘗試修改Ramnanth's rCharts page上的示例代碼。這是我的修改:
map <- Leaflet$new()
map$setView(c(38.89710, -77.03655), 12)
map$tileLayer(provider = 'Stamen.TonerLite')
map$marker(c(df$latitude, df$longitude), bindPopup = df$location)
此代碼不會產生任何標記。我正在尋找一種解決方案,我可以爲每次觀察繪製經緯度和緯度,並在位置欄中填入由彈出式填充的彈出式標記。
只是爲了澄清,如果另一個新手這個,我在我原來的帖子中加入@ iH8的代碼來代替'map $ marker'這一行。 – user3334472 2015-02-24 19:29:42