pyecharts对于经纬度_echarts 根据经纬度坐标在地图上描点

javaScript向对象数组赋值存储以下格式的数据:

var mapData = [

{'latitude':30.67, 'longitude':104.07 , 'name':'四川', 'value':1, 'color':'#0394d9'},

{'latitude':34.76, 'longitude':113.65 , 'name':'河南', 'value':3, 'color':'#d94d02'},

{'latitude':29.65, 'longitude':91.13 , 'name':'西藏', 'value':4, 'color':'#b42fd5'},

{'latitude':43.82, 'longitude':87.62 , 'name':'新疆', 'value':5, 'color':'#0394d9'},

]

//改变成动态数据

$.ajax({

url: "xxxx.do",

type: "POST",

dataType: "json",

data: {

treeId:86

},

success: function (data) {

var dmtData = [];

for (var i = 0; i < data.length; i++) {

latitude= data[i].latitude;

longitude= data[i].longitude;

dmtData.push({latitude:latitude,longitude:longitude});

}

}

})

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
function getGzMap(_data) { if (_chinaMap == undefined) { var dom = document.getElementById("container"); _chinaMap = echarts.init(dom); _chinaMap.on('click', function(params) { console.log(params); var _type = params.seriesType; if (_type == "map") { //window.parent.aaa('aa') //调用父页面方法 } else if (_type == "effectScatter") { window.parent.showMap(); } }) } var option = { backgroundColor: 'rgba(0,0,0,0)', visualMap: { type: 'piecewise', show: false, min: 0, max: 300, splitNumber: 3, itemWidth: 10, itemHeight: 10, itemGap: 5, seriesIndex: [1], pieces: [ { min: 0, max: 100, label: '优' }, { min: 101, max: 200, label: '良' }, { min: 201, max: 300, label: '高风险' } ], //color: ['#FA4D08', '#4BD94F', '#FBD32B'], //红、绿、黄 color: ['#F8DAE6', '#FEF9B5', '#B0D8B3'], //红、黄、绿 textStyle: { color: '#9EA8B1', fontSize: 10 } }, tooltip: { formatter: '{b}' }, geo: { map: 'guangdong', roam: true, aspectScale: 1, zoom: 1.5, layoutCenter: ['55%', '40%'], layoutSize: 500, label: { normal: { show: true }, emphasis: { show: true } }, itemStyle: { normal: { areaColor: '#323c48', borderColor: '#111', borderColor: '#3BB4DF', shadowColor: '#25A3FC', shadowBlur: 10 }, emphasis: { areaColor: '#ddb926' } } }, series: [{ type: 'effectScatter', coordinateSystem: 'geo', data: unitData, symbolSize: 10, symbol: 'image://../../../../Content/images/One/fire.png', //symbolRotate: 35, rippleEffect: { period: 4, scale: 5, brushType: 'fill', }, label: { normal: { formatter: '{b}', position: 'right', show: false }, emphasis: { show: false } }, itemStyle: { normal: { color: '#fff' } } }, { name: '', type: 'map', geoIndex: 0, mapType: 'guangdong', // 自定义扩展图表类型 label: { normal: { show: true, } }, itemStyle: { normal: { label: { show: true, fontSize: 10, color: '#111' }, shadowColor: '#ddb926', shadowBlur: 5, }, emphasis: { label: { show: true }, shadowColor: 'rgba(0, 0, 0, 0.5)', shadowBlur: 10 } }, data: _data }, { type: 'effectScatter', coordinateSystem: 'geo', data: windData, symbolSize: 10, symbol: 'image://../../../../Content/images/One/wind.png', //symbolRotate: 35, rippleEffect: { period: 4, scale: 5, brushType: 'fill', }, label: { normal: { formatter: '{b}', position: 'right', show: false }, emphasis: { show: false } }, itemStyle: { normal: { color: '#fff' } } }, ] }; $.getJSON('../../MapCN/guangdong.json', function(chinaJson) { echarts.registerMap('guangdong', chinaJson); _chinaMap.setOption(option, true); }); }
以下是一个使用 Pyecharts 实现经纬度动态轨迹图的示例代码: ```python import pandas as pd from pyecharts import options as opts from pyecharts.charts import Geo, Timeline # 读取数据 data = pd.read_csv('data.csv') # 创建时间轴 timeline = Timeline() # 创建地理图 geo = Geo(init_opts=opts.InitOpts(width='1000px', height='600px')) # 遍历数据 for i, row in data.iterrows(): # 添加时间点 timeline.add( geo.add_schema( maptype='world', center=[row['lon'], row['lat']], zoom=4, ).add_coordinate( row['name'], row['lon'], row['lat'], ).add( row['name'], [(row['lon'], row['lat'])], type_='scatter', symbol_size=8, label_opts=opts.LabelOpts(is_show=False), itemstyle_opts=opts.ItemStyleOpts(color='red'), ).set_series_opts( label_opts=opts.LabelOpts(is_show=False), ).set_global_opts( title_opts=opts.TitleOpts( title='动态轨迹图', subtitle=f'{row["time"]}', pos_left='20%', ), visualmap_opts=opts.VisualMapOpts( min_=0, max_=100, is_piecewise=True, pieces=[ {'min': 0, 'max': 20, 'label': '0-20'}, {'min': 20, 'max': 40, 'label': '20-40'}, {'min': 40, 'max': 60, 'label': '40-60'}, {'min': 60, 'max': 80, 'label': '60-80'}, {'min': 80, 'max': 100, 'label': '80-100'}, ], ), ), f'{row["time"]}', ) # 渲染图像 timeline.render('timeline_geo.html') ``` 其中,`data.csv` 是包含数据的 CSV 文件,示例数据如下: ``` name,time,lat,lon New York,2022-01-01 00:00:00,40.712776,-74.005974 Beijing,2022-01-01 01:00:00,39.904200,116.407396 Sydney,2022-01-01 02:00:00,-33.865143,151.209900 Paris,2022-01-01 03:00:00,48.856613,2.352222 ``` 运行代码后,将会生成 `timeline_geo.html` 文件,用浏览器打开即可查看动态轨迹图。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值