Commit dbf0a7b1 authored by 华国豪's avatar 华国豪 🙄

地图

parent 18f24286
...@@ -5,9 +5,7 @@ ...@@ -5,9 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="renderer" content="webkit"> <meta name="renderer" content="webkit">
<!-- <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=z58ZwNa8oYvzEYI6dD8hAS0GFbfKpttP"></script> --> <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=ZzGBZF6L0sgFDLlDohyvYhCnWy4dwksX"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=ZzGBZF6L0sgFDLlDohyvYhCnWy4dwksX" ></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/CurveLine/1.5/src/CurveLine.min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/TextIconOverlay/1.2/src/TextIconOverlay_min.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script> <script type="text/javascript" src="http://api.map.baidu.com/library/MarkerClusterer/1.2/src/MarkerClusterer_min.js"></script>
<script src="http://mapv.baidu.com/build/mapv.min.js"></script> <script src="http://mapv.baidu.com/build/mapv.min.js"></script>
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.BMap_noprint,.anchorBL{ /* .BMap_noprint,.anchorBL{
display: none; display: none;
} } */
.centerMpBaidu-box .BMap_Marker img{ .centerMpBaidu-box .BMap_Marker img{
} }
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
</div> </div>
</template> </template>
<script> <script>
import BMap from 'BMap'
export default { export default {
props: ['baiduMapData'], props: ['baiduMapData'],
data(){ data(){
return { return {
map: {}
} }
}, },
watch: { watch: {
...@@ -32,124 +32,109 @@ export default { ...@@ -32,124 +32,109 @@ export default {
},mounted() { },mounted() {
},methods:{ },methods:{
markerClick(e){
alert(111)
},
creatMap(){ creatMap(){
let _this = this let _this = this
let data = this.baiduMapData; let data = this.baiduMapData;
const BMap = window.BMap
//实例化,并设置最大最小缩放层级 //实例化,并设置最大最小缩放层级
const map = new BMap.Map("centerMpBaidu", { const map = new BMap.Map("centerMpBaidu", {
minZoom: 3, minZoom: 3,
maxZoom: 20, maxZoom: 20,
}); });
//清楚覆盖物
map.clearOverlays();
//设置中心点、默认缩放层级 //设置中心点、默认缩放层级
if (data.length > 0) { if (data.length > 0) {
map.centerAndZoom(new BMap.Point(data[0].Lng, data[0].Lat), 10); map.centerAndZoom(new BMap.Point(data[0].Lng, data[0].Lat), 10);
} else { } else {
map.centerAndZoom(new BMap.Point(104.0727017791, 30.6643622306), 10); map.centerAndZoom(new BMap.Point(104.0727017791, 30.6643622306), 10);
} }
//可以鼠标缩放 //可以鼠标缩放
map.enableScrollWheelZoom(true); map.enableScrollWheelZoom(true);
//2、 设置 默认主题 和 自定义主题 // 主题
// 默认主题 normal blueSky light dark googlelite grassgreen midnight pink bluish grayscale map.setMapStyle({
// 还有几个默认主题,但是发现并不好使 style: 'midnight'
map.setMapStyle({ });
style: 'midnight' const points = data
const markerClusterers = [[], [], []]
points.forEach(item => {
//实例化点
const point = new BMap.Point(item.Lng, item.Lat)
//自定义点的样式
// type 0 激活 蓝色五角星 20191119035847676
// 1 未拜访 黄色五角星 20191119035853676
// 2 未激活 红色五角星 20191119035858082
const icon = new BMap.Icon(
item.type === 0 ? 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035847676.png' : item.type === 1 ? 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035853676.png' : 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035858082.png',
new BMap.Size(48, 48)
);
//生成点标注
const marker = new BMap.Marker(point, { icon: icon });
// const infoWindow = new BMap.InfoWindow('简易的信息窗口')
//绑定事件,显示窗口
marker.addEventListener("click", function(){
_this.markerClick(point, item)
// map.openInfoWindow(infoWindow,point);
}); });
const points = data markerClusterers[item.type || 0].push(marker)
const markerClusterers = [[], [], []] //添加点标注即添加覆盖物
points.forEach(item => { map.addOverlay(marker);
//实例化点 })
const point = new BMap.Point(item.Lng, item.Lat) // //2种聚合的实现
//自定义点的样式 const size = new BMap.Size( 48, 48 )
// type 0 激活 蓝色五角星 20191119035847676 var markerClusterer1 = new window.BMapLib.MarkerClusterer(map, {
// 1 非正式 黄色五角星 20191119035853676 markers: markerClusterers[1],
// 2 未激活 红色五角星 20191119035858082 styles: [{
const icon = new BMap.Icon( url:'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035853676.png',
item.type === 0 ? 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035847676.png' : item.type === 1 ? 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035853676.png' : 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035858082.png', size: size,
new BMap.Size(48, 48) textSize: 18,
); textColor: 'white',
}, {
//生成点标注 url: 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035853676.png',
const marker = new BMap.Marker(point, { icon: icon }); size: size,
//动画 textSize: 18,
// marker.setAnimation(BMAP_ANIMATION_BOUNCE) textColor: 'white',
//文字标签 }, {
// const label = new BMap.Label( url: 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035853676.png',
// '我是文字描述', size: size,
// { offset: new BMap.Size( 20, 20 ) } textSize: 18,
// ) textColor: 'white',
// label.setStyle({ }]
// color : "red", })
// fontSize : "12px", var markerClusterer2 = new window.BMapLib.MarkerClusterer(map, {
// height : "20px", markers: markerClusterers[2],
// lineHeight : "20px", styles: [{
// fontFamily:"微软雅黑" url:'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035858082.png',
// }); size: size,
// marker.setLabel(label); textSize: 18,
textColor: 'white',
//绑定事件 }, {
// if (item.func) marker.addEventListener("click", function () {alert('你好')}); url: 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035858082.png',
marker.addEventListener("click", function(e){ //点击marker显示label size: size,
_this.markerClick(e) textSize: 18,
}); textColor: 'white',
markerClusterers[item.type || 0].push(marker) }, {
//添加点标注即添加覆盖物 url: 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035858082.png',
map.addOverlay(marker); size: size,
}) textSize: 18,
//清除覆盖物 textColor: 'white',
// markerClusterers.forEach((item, index) => { }]
// if (window[`markerClusterer${index}`]) window[`markerClusterer${index}`].clearMarkers() })
// // delete this.markerClusterer var markerClusterer4 = new window.BMapLib.MarkerClusterer(map, { markers: markerClusterers[0] })
// window[`markerClusterer${index}`] = null this.map = map
// }) },
//2种聚合的实现 markerClick(point, item){
const size = new BMap.Size( 48, 48 ) this.apipost('financestatistics_post_GetCustomerInfoForB2BKB', {CustomerId: item.CustomerId}, res=>{
var markerClusterer1 = new window.BMapLib.MarkerClusterer(map, { if(res.data.resultCode == 1) {
markers: markerClusterers[1], const infoWindow = new BMap.InfoWindow(`
styles: [{ <p>联系人:${res.data.data.Contact}</p>
url:'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035853676.png', <p>联系电话:${res.data.data.ContactNumber}</p>
size: size, <p>门店名称:${res.data.data.CustomerName}</p>
textSize: 18, <p>门店地址:${res.data.data.Address}</p>
textColor: 'white', `)
}, { this.map.openInfoWindow(infoWindow, point);
url: 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035853676.png', }
size: size, })
textSize: 18,
textColor: 'white',
}, {
url: 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035853676.png',
size: size,
textSize: 18,
textColor: 'white',
}]
})
var markerClusterer2 = new window.BMapLib.MarkerClusterer(map, {
markers: markerClusterers[2],
styles: [{
url:'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035858082.png',
size: size,
textSize: 18,
textColor: 'white',
}, {
url: 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035858082.png',
size: size,
textSize: 18,
textColor: 'white',
}, {
url: 'http://imgfile.oytour.com/New/Upload/Cloud/2019-11/20191119035858082.png',
size: size,
textSize: 18,
textColor: 'white',
}]
})
var markerClusterer4 = new window.BMapLib.MarkerClusterer(map, { markers: markerClusterers[0] })
} }
} }
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
align-items: center; align-items: center;
} }
.BMap_noprint,.anchorBL{ .BMap_noprint,.anchorBL{
display: none; /* display: none; */
} }
</style> </style>
<template> <template>
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
import echarts from "echarts"; import echarts from "echarts";
// import '../../node_modules/echarts/map/js/world.js' // import '../../node_modules/echarts/map/js/world.js'
import "../../../../node_modules/echarts/map/js/china.js"; // 引入中国地图数据 import "../../../../node_modules/echarts/map/js/china.js"; // 引入中国地图数据
import BMap from 'BMap';
export default { export default {
name: "echarts", name: "echarts",
props: ["userJson","dataArea"], props: ["userJson","dataArea"],
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
import echarts from "echarts"; import echarts from "echarts";
// import '../../node_modules/echarts/map/js/world.js' // import '../../node_modules/echarts/map/js/world.js'
import "../../../../node_modules/echarts/map/js/china.js"; // 引入中国地图数据 import "../../../../node_modules/echarts/map/js/china.js"; // 引入中国地图数据
import BMap from 'BMap';
export default { export default {
name: "echarts", name: "echarts",
props: ["userJson","dataArea", "newArr"], props: ["userJson","dataArea", "newArr"],
......
...@@ -347,9 +347,9 @@ ul li { ...@@ -347,9 +347,9 @@ ul li {
<p class="name">印象之旅数据看板</p> <p class="name">印象之旅数据看板</p>
</div> </div>
<el-row> <el-row>
<el-col :span="20" v-if="dataArea.length>0 && newArr.length>0"> <el-col :span="20" >
<div class="map-box" style="position:relative;top:-50px;left:-140px;"> <div class="map-box" style="position:relative;top:-50px;left:-140px;">
<centerMp :dataArea="dataArea" :newArr="newArr"></centerMp> <centerMp v-if="dataArea.length>0 && newArr.length>0" :dataArea="dataArea" :newArr="newArr"></centerMp>
</div> </div>
</el-col> </el-col>
<el-col :span="4"> <el-col :span="4">
......
...@@ -335,7 +335,7 @@ ...@@ -335,7 +335,7 @@
<div class="color-type"> <div class="color-type">
<div> <div>
<p>激活 <span class="b"></span></p> <p>激活 <span class="b"></span></p>
<p>非正式 <span class="y"></span></p> <p>未拜访 <span class="y"></span></p>
<p>未激活 <span></span></p> <p>未激活 <span></span></p>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment