获取地图的坐标

这里的坐标是除以1000的

方法一:

    var uploadedDataURL = {
        "新疆": [91.110, 29.970],
        "海口": [109.300, 18.150],
        "北京": [116.231, 39.452]
    }

    var weiboData;
    for (var key in uploadedDataURL) {     

        weiboData.push(uploadedDataURL[key]);
    }

 

方法二:

var uploadedDataURL = [[91110, 29970, 90170, 29440, 116231, 39452,109300,18150]];

 var weiboData = uploadedDataURL.map(function (serieData, idx) {
       var px = serieData[0] / 1000;
       var py = serieData[1] / 1000;
       var res = [[px, py]];

       for (var i = 2; i < serieData.length; i += 2) {
           var dx = serieData[i] / 1000;
           var dy = serieData[i + 1] / 1000;
           var x = px + dx;
           var y = py + dy;
           res.push([dx, dy]);

           px = x;
           py = y;
       }
       console.log('结果');
       console.log(res);
       return res;
   })

 

 

这个res的结果是:

 

 

   chart('middle-map', {
        // backgroundColor: '#404a59',
        title: {
            // text: '微博签到数据点亮中国',
            // subtext: 'From ThinkGIS',
            //  sublink: 'http://www.thinkgis.cn/public/sina',
            left: 'center',
            top: 'top',
            textStyle: {
                color: '#fff'
            }
        },
        legend: {
            left: 'left',
            data: ['强', '中', '弱'],
            textStyle: {
                color: '#ccc'
            }
        },
        geo: {
            name: '强',
            type: 'scatter',
            map: 'china',
            label: {
                emphasis: {
                    show: false
                }
            },
            itemStyle: {
                normal: {
                    areaColor: '#323c48',
                    borderColor: '#111'
                },
                emphasis: {
                    areaColor: '#2a333d'
                }
            }
        },
        series: [    
        {
            name: '强',
            type: 'scatter',
            coordinateSystem: 'geo',
            symbolSize: 10,// 修改圆圈大小
            large: true,
            itemStyle: {
                normal: {
                    shadowBlur: 2,
                    shadowColor: 'rgba(255, 255, 255, 0.8)',
                    color: 'yellow'

                }
            },
            data: weiboData
            //  data: weiboData[0]
        }]
    })

转载于:https://www.cnblogs.com/dreamhouse/p/9274043.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值