仿照ECHARTS里引用百度地图的例子做的 ,求高手帮我看下这段代码哪里出错了
<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>ECharts</title>
</head>
<body>
<div id="main" style="height:800px whith=800px"></div>
<script src="echarts.min.js"></script>
<script src="bmap.js"></script>
<script src="http://api.map.baidu.com/api?v=2.0&ak=KXAeZ5yDse7Ci4m8ZRyEZ9wFnHKncr5i"></script>
<script type="text/javascript">
    var myChart = echarts.init(document.getElementById('main'));
    var option = {
            var data = [
                 {name: '海门', value: 9},
                 {name: '鄂尔多斯', value: 12},
                 {name: '招远', value: 12},
                 {name: '舟山', value: 12},
                 {name: '齐齐哈尔', value: 14},
                 {name: '盐城', value: 15},
                 {name: '赤峰', value: 16},
                 {name: '青岛', value: 18},
                 {name: '乳山', value: 18},
                 {name: '金昌', value: 19},
                 {name: '泉州', value: 21},
                 {name: '莱西', value: 21},
                 {name: '日照', value: 21},
                 {name: '胶南', value: 22},
                 {name: '南通', value: 23},
                 {name: '拉萨', value: 24},
                 {name: '云浮', value: 24},
                 {name: '梅州', value: 25},
                 {name: '文登', value: 25},
                 {name: '上海', value: 31},
                 {name: '攀枝花', value: 31},
                 {name: '威海', value: 31},
                 {name: '承德', value: 31},
                 {name: '厦门', value: 31}
            ];
            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]
            };

            var convertData = function (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;
            };

            option = {
                title: {
                    text: '全国主要城市空气质量',
                    left: 'center'
                },
                tooltip : {
                    trigger: 'item'
                },
                bmap: {
                    center: [104.114129, 37.550339],
                    zoom: 5,
                    roam: true

                },
                series : [
                    {
                        name: 'pm2.5',
                        type: 'scatter',
                        coordinateSystem: 'bmap',
                        data: convertData(data),
                        symbolSize: function (val) {
                            return val[1];
                        },
                        label: {
                            normal: {
                                formatter: '{b}',
                                position: 'right',
                                show: false
                            },
                            emphasis: {
                                show: true
                            }
                        },
                        itemStyle: {
                            normal: {
                                color: 'purple'
                            }
                        }
                    }
                ]
            };  
    };
    myChart.setOption(option);
</script>
</body>

心好累,自己打的代码没一次成功过。。。。
我太菜了唉

2个回答

写出你的问题描述或者贴出运行报错截图...

div 宽高之间没 ; 导致div没有宽度高度,当然不会显示,书写要认真

weixin_44268967
同步渐冷 非常感谢您!谢谢!
8 个月之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!