Echarts地图坐标geoCoordMap数据动态获取

这是一组geoCoordMap格式的数据:

    var geoCoordMap = {
    '台湾': [121.5135,25.0308],
    '黑龙江': [127.9688, 45.368],
    '内蒙古': [110.3467, 41.4899],
    "吉林": [125.8154, 44.2584],
    '北京市': [116.4551, 40.2539],
    "辽宁": [123.1238, 42.1216],}

刚开始想的方法是获取到三个参数,前端循环拼接,但以失败告终。

于是切换成java后台进行数据格式转换。

首先封装一个类型:和数据相似

 Map<String, double[]> geocoordMap=new HashMap<String, double[]>();

然后循环获取的数据,以key,value的形式封装进去。

  List<AnimalCheckandPass>  list = iAnimalCheckandPassService.selectAllData();
        Map<String, double[]> geocoordMap=new HashMap<String, double[]>();
        for(int i = 0; i < list.size(); i++){
            AnimalCheckandPass s = list.get(i);
            double[] value=new double[]{s.getSmx(),s.getSmy()};
            String key= s.getJczmc();
            geocoordMap.put(key, value);
        }

 

已标记关键词 清除标记
各位早安 我以Echart做了中国地图,目前功能是可以显示各省的总销量 我想实现,比如某一省,在某个坐标(经伟度)上的店舖的所在地 一般会设所有的位置 geoCoordMap = {"北京库":[116.53,40.16],"成都库":[103.95,30.56],…… 某一店舖的值 var data = [{name:"北京库",value:199900},{name:"成都库DC",value:133693}…… 我希望在不改变这张图的基础上(维持现在的色及格式),加入上面的讯息。 用圆圈之类的 , 请问我js的语法要怎么写呢 无论值大小,圆圈大小一样就可以了 ![图片说明](https://img-ask.csdn.net/upload/201805/22/1526940044_624505.png) ![图片说明](https://img-ask.csdn.net/upload/201805/22/1526939567_201514.png) 附上图二,中国地图的语法 <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=EDGE"> <title>ECharts</title> <link rel="stylesheet" type="text/css" href="css/main.css"/> <script src="js/jquery-1.9.1.min.js"></script> <script src="js/echarts.min.js"></script> <script src="js/china.js"></script> <style>#china-map {width:1000px; height: 700px;margin: auto;}</style> </head> <body> <div id="china-map"></div> <script> var myChart = echarts.init(document.getElementById('china-map')); function randomData() { return Math.round(Math.random()*1000); } option = { title: { text: '省份销量额', subtext: '-', left: 'center' }, tooltip: { trigger: 'item' }, legend: { orient: 'vertical', left: 'left', data:['销售额'] }, visualMap: { min: 0, max: 1000000, left: 'left', top: 'bottom', text: ['高','低'], // 文本,默认为数值文本 calculable: true }, toolbox: { show: true, orient: 'vertical', left: 'right', top: 'center', feature: { dataView: {readOnly: false}, restore: {}, saveAsImage: {} } }, series: [ { name: 'iphone5', type: 'map', mapType: 'china', label: { normal: { show: true }, emphasis: { show: true } }, data:[{name:"广东",value:426661},{name:"江苏",value:230421},{name:"浙江",value:220367},{name:"北京",value:202471},{name:"上海",value:163766},{name:"四川",value:163676},{name:"山东",value:148341},{name:"河南",value:120000},{name:"湖北",value:114175},{name:"福建",value:101498},{name:"辽宁",value:95904},{name:"湖南",value:93790},{name:"河北",value:91469},{name:"重庆",value:89959},{name:"安徽",value:80801},{name:"陕西",value:78940},{name:"云南",value:63423},{name:"广西",value:62782},{name:"黑龙江",value:58703},{name:"江西",value:58093},{name:"天津",value:56108},{name:"吉林",value:50502},{name:"贵州",value:47750},{name:"山西",value:46641},{name:"新疆",value:44705},{name:"内蒙古",value:41472},{name:"甘肃",value:28612},{name:"海南",value:24648},{name:"宁夏",value:13047},{name:"青海",value:9576},{name:"西藏",value:5352},{name:"香港",value:467},{name:"台湾",value:139} ] } ] }; myChart.setOption(option); myChart.on('mouseover', function (params) { var dataIndex = params.dataIndex; console.log(params); }); </script> </body> </html>
©️2020 CSDN 皮肤主题: 撸撸猫 设计师:设计师小姐姐 返回首页