qianlingo
2018-08-31 05:49
采纳率: 100%
浏览 10.2k
已采纳

请教echarts地图自定义标点的问题

图片说明

想请教下各位大佬:
①echarts怎样才能将地图上原本的蓝色圆点替换成五角星?我搜索了很多文档说替换为star即可,但是我在地图实例里测试并没有用。。
②需求是当前数据若≤最低价才将五角星标上,这个有自定义方法吗?

求指教求代码示例。。。急在线等

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • 已采纳

    参考这个示例:http://www.echartsjs.com/gallery/editor.html?c=geo-map-scatter

    坐标系改为geo,配置symbol为图片地址就行了,默认的配置没有星星的。。
    http://echarts.baidu.com/option.html#series-scatter.symbol

    显示不显示五角星自己整好数据,小于你的最低价才添加数据就行了

      symbol: 'image://data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7',
    

    你可以访问上面的地址,将下面的代码贴入左边的输入框运行下就看到效果了

    
    var data = [
        {name: '海门', value: 9},
        {name: '鄂尔多斯', value: 12},
        {name: '招远', value: 12},
        {name: '舟山', value: 12},
        {name: '齐齐哈尔', value: 14},
        {name: '盐城', value: 15},
        {name: '赤峰', value: 16},
    ];
    
    var geoCoordMap = {
       '海门':[121.15,31.89],
       '鄂尔多斯':[109.781327,39.608266],
       '招远':[120.38,37.35],
       '舟山':[122.207216,29.985295],
       '齐齐哈尔':[123.97,47.33],
       '盐城':[120.13,33.38],
       '赤峰':[118.87,42.28],
       '青岛':[120.33,36.07],
       '乳山':[121.52,36.89],
       '金昌':[102.188043,38.520089],
       '泉州':[118.58,24.93],
       '莱西':[120.53,36.86],
       '日照':[119.46,35.42],
       '胶南':[119.97,35.88],
       '南通':[121.05,32.08],
       '拉萨':[91.11,29.97],
       '云浮':[112.02,22.93],
       '梅州':[116.1,24.55],
       '文登':[122.05,37.2],
       '上海':[121.48,31.22],
       '攀枝花':[101.718637,26.582347],
       '威海':[122.1,37.5],
       '承德':[117.93,40.97],
       '厦门':[118.1,24.46],
       '汕尾':[115.375279,22.786211],
       '潮州':[116.63,23.68],
       '丹东':[124.37,40.13],
       '太仓':[121.1,31.45],
       '曲靖':[103.79,25.51],
       '烟台':[121.39,37.52],
    };
    
    function convertData(data) {
       var res = [];
       for (var i = 0; i < data.length; i++) {
           var geoCoord = geoCoordMap[data[i].name];
           if (geoCoord) {
               res.push({
                   name: data[i].name,
                   value: geoCoord.concat(data[i].value)
               });
           }
       }
       return res;
    }
    
    function randomValue() {
        return Math.round(Math.random()*1000);
    }
    
    
    
    option = {
        tooltip: {},
        visualMap: {
            min: 0,
            max: 1500,
            left: 'left',
            top: 'bottom',
            text: ['High','Low'],
            seriesIndex: [1],
            inRange: {
                color: ['#e0ffff', '#006edd']
            },
            calculable : true
        },
        geo: {
            map: 'china',
            roam: true,
            label: {
                normal: {
                    show: true,
                    textStyle: {
                        color: 'rgba(0,0,0,0.4)'
                    }
                }
            },
            itemStyle: {
                normal:{
                    borderColor: 'rgba(0, 0, 0, 0.2)'
                }
            }
        },
        series : [
           {
               type: 'scatter',
               coordinateSystem: 'geo',
               data: convertData(data),
               symbolSize: 20,
               symbol: 'image://data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7',
    
               label: {
                   normal: {
                       formatter: '{b}',
                       position: 'right',
                       show: false
                   },
                   emphasis: {
                       show: true
                   }
               },
               itemStyle: {
                   normal: {
                        color: '#F06C00'
                   }
               }
            }
        ]
    };
    
    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题