修改地图扎点的marker图标

Lvtianfang
吕天方 1 year ago
parent 0c135a48fc
commit 33734b4a6a

@ -4,7 +4,7 @@
* @Author: JC9527 * @Author: JC9527
* @Date: 2024-01-09 23:08:15 * @Date: 2024-01-09 23:08:15
* @LastEditors: JC9527 * @LastEditors: JC9527
* @LastEditTime: 2024-01-17 11:08:57 * @LastEditTime: 2024-01-31 09:15:33
*/ */
import router from './router' import router from './router'
import store from './store' import store from './store'
@ -22,7 +22,7 @@ const whiteList = ['/login', '/register', '/bigScreen']
router.beforeEach((to, from, next) => { router.beforeEach((to, from, next) => {
NProgress.start() NProgress.start()
// console.log('tototo',to.path); // console.log('tototo',to.path);
if(localStorage.getItem('accessToken') && localStorage.getItem('robotToken')) { if(localStorage.getItem('accessToken')) {
next() next()
NProgress.done() NProgress.done()
} else { } else {
@ -31,10 +31,14 @@ router.beforeEach((to, from, next) => {
var c = window.location.href.match(reg); var c = window.location.href.match(reg);
const code = c && c[1]; const code = c && c[1];
getAccesstoken({code:code}).then(res=>{ getAccesstoken({code:code}).then(res=>{
console.log(res,"res") // console.log(res,"res")
// setAccessToken(res.data.accessToken) // setAccessToken(res.data.accessToken)
localStorage.setItem('accessToken',res.data.accessToken) localStorage.setItem('accessToken',res.data.accessToken)
next() let url = window.location.href;
var modifiedUrl = url.replace(/[\?&](code)=.*?(#\/|$)/g, '');
// console.log(modifiedUrl,'modifiedUrl');
window.location.href = modifiedUrl;
// next()
NProgress.done() NProgress.done()
// return getUserinfo({accessToken:res.data.accessToken}) // return getUserinfo({accessToken:res.data.accessToken})
}) })

@ -4,7 +4,7 @@
* @Author: JC9527 * @Author: JC9527
* @Date: 2024-01-09 23:08:15 * @Date: 2024-01-09 23:08:15
* @LastEditors: JC9527 * @LastEditors: JC9527
* @LastEditTime: 2024-01-29 16:28:49 * @LastEditTime: 2024-01-31 15:25:55
--> -->
<template> <template>
<div class="map-main"> <div class="map-main">
@ -57,7 +57,6 @@
<div class="person-popup"> <div class="person-popup">
<div class="person-title"> <div class="person-title">
<div class="title">人员信息</div> <div class="title">人员信息</div>
<!-- <div class="mask" @click="markersClosePopup"></div> -->
<img src="@/assets/images/dialogbg/close.png" class="mask" @click="markersClosePopup" alt="" /> <img src="@/assets/images/dialogbg/close.png" class="mask" @click="markersClosePopup" alt="" />
</div> </div>
<div class="person-main"> <div class="person-main">
@ -309,11 +308,11 @@
@select="handleSelect" @select="handleSelect"
></el-autocomplete> ></el-autocomplete>
</div> </div>
<div class="laser-positioning" @click="positioning"> <div class="laser-positioning" @click="positioning" v-if="zadian">
<span>地图扎点</span> <span>地图扎点</span>
<img src="@/assets/images/positioning.png" alt="" /> <img src="@/assets/images/positioning.png" alt="" />
</div> </div>
<div class="creation-task" @click="createdTask"> <div class="creation-task" @click="createdTask" v-if="zadian">
<span>新增事件</span> <span>新增事件</span>
<img src="@/assets/images/createdTask.png" alt="" /> <img src="@/assets/images/createdTask.png" alt="" />
</div> </div>
@ -422,7 +421,7 @@
<!-- 商铺详情 --> <!-- 商铺详情 -->
<shop ref="shop" width="50%" title="商铺详情查看" /> <shop ref="shop" width="50%" title="商铺详情查看" />
<!-- 新增事件 --> <!-- 新增事件 -->
<new-event ref="newEvent" @cancel="cancel"></new-event> <new-event ref="newEvent" @cancel="cancel" @confirm="confirm"></new-event>
<!-- 任务派发 --> <!-- 任务派发 -->
<personage-task ref="personageTask"></personage-task> <personage-task ref="personageTask"></personage-task>
<!-- 强制观摩弹框 --> <!-- 强制观摩弹框 -->
@ -587,6 +586,7 @@ export default {
cluster:null, cluster:null,
personMarkers:[], personMarkers:[],
MyInput:true, MyInput:true,
zadian:false,
@ -838,9 +838,16 @@ export default {
// console.log(e,'this.layers.layer2'); // console.log(e,'this.layers.layer2');
if(this.isPositioning) { if(this.isPositioning) {
// console.log(e,'eeeeeeee'); // console.log(e,'eeeeeeee');
const icon = new AMap.Icon({
size: new AMap.Size(25, 34), //
image: require('../../../assets/images/icon/icon2.png'), //Icon
imageOffset: new AMap.Pixel(-9, -3), //
imageSize: new AMap.Size(135, 40), //
});
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: new AMap.LngLat(e.lnglat.lng, e.lnglat.lat), position: new AMap.LngLat(e.lnglat.lng, e.lnglat.lat),
anchor: 'bottom-center', anchor: 'bottom-center',
icon: icon
}) })
this.layers.layer4.addOverlay(marker); this.layers.layer4.addOverlay(marker);
map.add(this.layers.layer4) map.add(this.layers.layer4)
@ -937,18 +944,12 @@ export default {
var offset = new AMap.Pixel(-30.5, -48.5); var offset = new AMap.Pixel(-30.5, -48.5);
context.marker.setContent(content); context.marker.setContent(content);
context.marker.setOffset(offset); context.marker.setOffset(offset);
// let obj = {};
// obj.markers = context.marker;
// obj.imei = context.data[0].info.imei;
// this.personMarkers.push(obj)
context.marker.on('click',(ev)=>{ context.marker.on('click',(ev)=>{
// imei // imei
getUserByImei({imei:context.data[0].info.imei}).then(res=>{ getUserByImei({imei:context.data[0].info.imei}).then(res=>{
console.log(res,"获取人员信息");
if(res.code == 200) { if(res.code == 200) {
this.personInfo.position = context.data[0].position; this.personInfo.position = context.data[0].position;
this.personInfo.info = context.data[0].info; this.personInfo.info = context.data[0].info;
console.log(res.data[0],"res.data[0]");
this.personInfo.personinfo = res.data[0]; this.personInfo.personinfo = res.data[0];
this.personInfo.visible = true; this.personInfo.visible = true;
} }
@ -1033,6 +1034,7 @@ export default {
if(id == 1) { if(id == 1) {
this.personLine = []; this.personLine = [];
let videoPoint = []; let videoPoint = [];
//
getDeviceList().then((res) => { getDeviceList().then((res) => {
this.mapLoading = false; this.mapLoading = false;
// console.log(res,''); // console.log(res,'');
@ -1054,8 +1056,6 @@ export default {
} }
}) })
this.count = videoPoint.length; this.count = videoPoint.length;
// console.log(videoPoint,'videoPoint');
// console.log(this.count,'this.count');
AMap.plugin(['AMap.MarkerCluster'],()=>{ AMap.plugin(['AMap.MarkerCluster'],()=>{
this.cluster = new AMap.MarkerCluster(this.map,videoPoint,{ this.cluster = new AMap.MarkerCluster(this.map,videoPoint,{
gridSize: 60, // gridSize: 60, //
@ -1380,7 +1380,6 @@ export default {
getWanggeGeoJson(){ getWanggeGeoJson(){
bgridsetting({pageNum:1,pageSize:100,level:1}).then(res=>{ bgridsetting({pageNum:1,pageSize:100,level:1}).then(res=>{
console.log(res,"网格数据");
let W = [] let W = []
res.rows.forEach((element)=>{ res.rows.forEach((element)=>{
let shapeStr = JSON.parse(element.shapeStr) let shapeStr = JSON.parse(element.shapeStr)
@ -1413,9 +1412,6 @@ export default {
}); });
shapeStr.myPolygon = wangge; shapeStr.myPolygon = wangge;
shapeStr.text = text; shapeStr.text = text;
// this.myWange.push(wangge);
// this.layers.layer.addLayer(wangge);
// this.layers.layer.addLayer(text);
this.layers.layer2.addOverlay(wangge); this.layers.layer2.addOverlay(wangge);
this.layers.text1.addOverlay(text); this.layers.text1.addOverlay(text);
this.map.add(this.layers.layer2); this.map.add(this.layers.layer2);
@ -1426,7 +1422,7 @@ export default {
// console.log(this.layers.layer,'this.layers.layer'); // console.log(this.layers.layer,'this.layers.layer');
// this.map.add(this.layers.layer); // this.map.add(this.layers.layer);
}, },
// //
getWeilanGeoJson(){ getWeilanGeoJson(){
fence({ pageNum: 1, pageSize: 100 }).then((res) => { fence({ pageNum: 1, pageSize: 100 }).then((res) => {
// console.log(res,""); // console.log(res,"");
@ -1440,7 +1436,8 @@ export default {
radius: shapeStr.features[0].properties.radius, radius: shapeStr.features[0].properties.radius,
bubble: true, bubble: true,
extData:{ extData:{
id: '围栏polygon' id: '围栏polygon',
name: shapeStr.features[0].properties.NAME
}, },
strokeOpacity: 0.9, strokeOpacity: 0.9,
strokeColor: "#62E1FA", strokeColor: "#62E1FA",
@ -1455,7 +1452,7 @@ export default {
offset: [0, 12], offset: [0, 12],
text: element.name, text: element.name,
extData:{ extData:{
id: '围栏text' id: '围栏text',
}, },
style: { style: {
'font-size': '14px', 'font-size': '14px',
@ -1480,7 +1477,8 @@ export default {
path:shapeStr.features[0].geometry.coordinates, path:shapeStr.features[0].geometry.coordinates,
bubble: true, bubble: true,
extData:{ extData:{
id: '围栏polygon' id: '围栏polygon',
name: shapeStr.features[0].properties.NAME
}, },
strokeOpacity: 0.9, strokeOpacity: 0.9,
strokeColor: "#62E1FA", strokeColor: "#62E1FA",
@ -1497,7 +1495,7 @@ export default {
offset: [0, 12], offset: [0, 12],
text: element.name, text: element.name,
extData:{ extData:{
id: '围栏text' id: '围栏text' ,
}, },
style: { style: {
'font-size': '14px', 'font-size': '14px',
@ -1616,15 +1614,24 @@ export default {
if(this.isPositioning) { if(this.isPositioning) {
let latlng = e.lnglat let latlng = e.lnglat
let name; let name;
this.layers.layer.eachOverlay((item)=>{ this.layers.layer3.eachOverlay((item)=>{
// console.log(item,'item'); // console.log(item,'item');
if(item.getBounds().contains(latlng)){ if(item.getBounds().contains(latlng)){
name = item.getExtData().name name = item.getExtData().name
} }
}) })
// console.log(name,"");
//
const icon = new AMap.Icon({
size: new AMap.Size(26, 26), //
image: require('../../../assets/images/icon/icon2.png'), //Icon
imageOffset: new AMap.Pixel(0, 0), //
imageSize: new AMap.Size(26, 26) //
});
var marker = new AMap.Marker({ var marker = new AMap.Marker({
position: new AMap.LngLat(e.lnglat.lng, e.lnglat.lat), position: new AMap.LngLat(e.lnglat.lng, e.lnglat.lat),
anchor: 'bottom-center', anchor: 'bottom-center',
icon: icon
}) })
this.layers.layer4.addOverlay(marker); this.layers.layer4.addOverlay(marker);
this.map.add(this.layers.layer4) this.map.add(this.layers.layer4)
@ -2384,11 +2391,17 @@ export default {
}, },
// //
cancel(marker){ cancel(marker){
this.layers.layer4.removeOverlay(marker) // this.layers.layer4.removeOverlay(marker);
},
confirm() {
//
}, },
// //
changeMap(id) { changeMap(id) {
this.MyInput = true; this.MyInput = true;
this.zadian = false;
this.actionMap = id; this.actionMap = id;
this.input = ""; this.input = "";
this.personInfo.visible = false; this.personInfo.visible = false;
@ -2399,6 +2412,7 @@ export default {
if (id == 1) { if (id == 1) {
this.markerOffset = new AMap.Pixel(-35, -123); this.markerOffset = new AMap.Pixel(-35, -123);
} else if (id == 2) { } else if (id == 2) {
this.zadian = true;
this.markerOffset = new AMap.Pixel(-13.5, -15); this.markerOffset = new AMap.Pixel(-13.5, -15);
} else if (id == 3) { } else if (id == 3) {
this.markerOffset = new AMap.Pixel(-30.5, -48.5); this.markerOffset = new AMap.Pixel(-30.5, -48.5);
@ -2424,6 +2438,7 @@ export default {
}, 200); }, 200);
this.$emit("rightAnimationAction"); this.$emit("rightAnimationAction");
}, },
//
getCarList(){ getCarList(){
getCarManageList({pageNum: 1,pageSize: 10}).then(res=>{ getCarManageList({pageNum: 1,pageSize: 10}).then(res=>{
// console.log(res); // console.log(res);

@ -1677,6 +1677,9 @@ export default {
}, },
Close() { Close() {
this.$refs.formInline.resetFields(); this.$refs.formInline.resetFields();
if(this.marker) {
this.$emit('cancel',this.marker)
}
}, },
handleChange(){}, handleChange(){},
// //
@ -1703,6 +1706,7 @@ export default {
if(res.code == 200 && res.success == true) { if(res.code == 200 && res.success == true) {
this.cancel(); this.cancel();
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.$emit('confirm')
} }
}) })
} }

Loading…
Cancel
Save