根据输入自动居中绘制地图

时间:2019-03-28 10:16:47

标签: r maps plotly

我有一个带有4个坐标的数据框,可以进行几种观察:经度从,纬度从,经度到和纬度至。我想使显示在地图上的路段像在plotly的机场示例https://plot.ly/r/lines-on-maps/

中一样

但是我希望我的输出地图基于我要给它的坐标为中心。目标是制作一个闪亮的仪表板,使人们可以选择机场并以该中心为中心。

因此,根据机场示例,我将得到类似的信息:

selected_airport <- "Denver Intl"   # my input variable in shiny
center_lat <- air$lat[air$airport == selected_airport]
center_lon <- air$lon[air$airport == selected_airport]

我的理解是,我需要在布局部分中将其作为输入,但是当将其放在xaxis和yaxis中时却无法正常工作:

layout(
title = 'Feb. 2011 American Airline flight paths<br>(Hover for airport names)',
geo = geo, showlegend = FALSE, height=800 , xaxis = center_lon, yaxis= center_lat )

我应该使用此python示例中提供的mapbox吗? https://plot.ly/python/scattermapbox/

mapbox=go.layout.Mapbox(
    accesstoken=mapbox_access_token,
    bearing=0,
    center=go.layout.mapbox.Center(
        lat=center_lat,
        lon=center_lon)

0 个答案:

没有答案