https://www.echartsjs.com/examples/zh/editor.html?c=map-bin
这个例子用的百度地图,但怎么在vue中整合这种网格效果呢。
<template>
<baidu-map class="map" :center="{lng: 116.404, lat: 39.915}" :zoom="15" :scroll-wheel-zoom="true">
<bm-navigation anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-navigation>
<bm-scale anchor="BMAP_ANCHOR_TOP_RIGHT"></bm-scale>
<bm-geolocation anchor="BMAP_ANCHOR_BOTTOM_RIGHT" :showAddressBar="true" :autoLocation="true"></bm-geolocation>
<bm-city-list anchor="BMAP_ANCHOR_TOP_LEFT"></bm-city-list>
<bm-panorama></bm-panorama>
</baidu-map>
</template>
<script>
export default {
data () {
return {
center: {lng: 0, lat: 0},
zoom: 3
}
},
methods: {
handler ({BMap, map}) {
console.log(BMap, map)
this.center.lng = 116.404
this.center.lat = 39.915
this.zoom = 15
},
}
}
</script>
<style>
.map {
width: 100%;
height: 800px;
}
</style>
这是我vue现在的地图页面,想把网格效果融入进去,怎么操作
<template>
<div>
<!-- 百度地图容器 -->
<div id="map"></div>
</div>
</template>
<script>
import echarts from 'echarts'
export default {
mounted() {
// 初始化地图
const map = new BMap.Map("map");
const point = new BMap.Point(116.404, 39.915);
map.centerAndZoom(point, 15);
// 初始化echarts
const chart = echarts.init(document.getElementById('map'));
// 使用示例数据
const option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [{
data: [820, 932, 901, 934, 1290, 1330, 1320],
type: 'line'
}]
};
// 将echarts与百度地图联动
map.addEventListener('moving', function () {
chart.setOption({
bmap: {
center: map.getCenter(),
zoom: map.getZoom()
}
});
});
chart.setOption(option);
}
}
</script>