| xqd
@@ -1,10 +1,10 @@
|
|
|
<template>
|
|
|
- <view>
|
|
|
- <view class="page-body">
|
|
|
- <view class="page-section page-section-gap">
|
|
|
- <map scale="10" ubkey='CQIBZ-P2MR5-PM3IB-QRKTX-SEVJE-GYF34' :showScale="false" :showLocation="true" :showCompass="false" enableZoom="true" enableScroll="true" enableBuilding="true" enable3D="true" id="myMap" style="width: 100%; height: 600px;"
|
|
|
- :latitude="latitude"
|
|
|
- :longitude="longitude"
|
|
|
+ <view style="height:100%;">
|
|
|
+ <view class="page-body" style="height:100%;">
|
|
|
+ <view class="page-section page-section-gap" style="height:100%;">
|
|
|
+ <map scale="10" ubkey='CQIBZ-P2MR5-PM3IB-QRKTX-SEVJE-GYF34' :showScale="false" :showLocation="true" :showCompass="false" enableZoom="true" enableScroll="true" enableBuilding="true" enable3D="true" id="myMap" style="width: 100%; height: 100%;"
|
|
|
+ :latitude="innerGeo.latitude"
|
|
|
+ :longitude="innerGeo.longitude"
|
|
|
:markers="markersIn"
|
|
|
:layerStyle="mapStyle"
|
|
|
@markertap='markertap'
|
| xqd
@@ -17,7 +17,8 @@
|
|
|
style="position: fixed;left:0px;top: -500px;"
|
|
|
isRenderImage
|
|
|
:board="painter.base"
|
|
|
- @success="(e)=>{painter.path = e; painter.wait=0}"
|
|
|
+ @success="canvasSuccess"
|
|
|
+ @fail="canvasFail"
|
|
|
/>
|
|
|
</view>
|
|
|
</view>
|
| xqd
@@ -52,15 +53,25 @@
|
|
|
},
|
|
|
},
|
|
|
]
|
|
|
+ },
|
|
|
+ geo:{
|
|
|
+ type: Object,
|
|
|
+ default:{
|
|
|
+ latitude:30.6034799,
|
|
|
+ longitude:104.1132550,
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
+ updateMode: true,
|
|
|
isisMarkering: false,
|
|
|
isActiveMarker: 0,
|
|
|
isActiveMarkerIndex: -1,
|
|
|
- latitude: 30.6034799,
|
|
|
- longitude: 104.1132550,
|
|
|
+ innerGeo:{
|
|
|
+ latitude: 30.6034799,
|
|
|
+ longitude: 104.1132550,
|
|
|
+ },
|
|
|
mapStyle: 1, //个性化地图
|
|
|
markersIn: [],
|
|
|
isUpdate: false,
|
| xqd
@@ -117,72 +128,60 @@
|
|
|
},
|
|
|
methods: {
|
|
|
goLocation(la,lo){
|
|
|
- this.latitude = la
|
|
|
- this.longitude = lo
|
|
|
- },
|
|
|
- //生成图片
|
|
|
- generateImg(imgUrl){
|
|
|
- this.painter.base.views[1].src = imgUrl;
|
|
|
- this.painter.wait = 1;
|
|
|
-
|
|
|
- return new Promise(resolve=>{
|
|
|
- let timer = setInterval(()=>{
|
|
|
- if(this.painter.wait === 0){
|
|
|
- clearInterval(timer);
|
|
|
- resolve(this.painter.path);
|
|
|
- }else if(this.painter.wait <= 3000){
|
|
|
- this.painter.wait += 10
|
|
|
- }else{
|
|
|
- clearInterval(timer);
|
|
|
- this.painter.wait = 0;
|
|
|
- resolve(this.painter.path);
|
|
|
- }
|
|
|
- }, 10);
|
|
|
- })
|
|
|
+ this.innerGeo = {
|
|
|
+ latitude:la,
|
|
|
+ longitude:lo
|
|
|
+ }
|
|
|
},
|
|
|
// 点击标记点时触发,e.detail = {markerId}
|
|
|
- markertap(e, mode = true, isQt = false) {
|
|
|
-
|
|
|
-
|
|
|
- let index = 0;
|
|
|
- if(typeof e.index !== 'undefined'){
|
|
|
- index = e.index;
|
|
|
- }else if(typeof e.index === 'undefined'){
|
|
|
- index = e.markerId;
|
|
|
- }
|
|
|
-
|
|
|
- if(!isQt && (this.isActiveMarkerIndex === index || this.isMarkering)) return;
|
|
|
- this.isMarkering = true;
|
|
|
- setTimeout(()=>{
|
|
|
- this.isMarkering = false
|
|
|
- }, 200)
|
|
|
- const itemOld = this.markersIn[this.isActiveMarkerIndex];
|
|
|
- if(itemOld){
|
|
|
- itemOld.width = itemOld.noActive.width;
|
|
|
- itemOld.height = itemOld.noActive.height;
|
|
|
- itemOld.iconPath = itemOld.noActive.iconPath;
|
|
|
- itemOld.isActive = false;
|
|
|
- this.$set(this.markersIn, this.isActiveMarkerIndex, itemOld);
|
|
|
+ markertap(index, mode = true, isQt = false) {
|
|
|
+ console.log(index)
|
|
|
+ this.updateMode = mode
|
|
|
+ if(typeof index == 'object'){
|
|
|
+ index = index.markerId
|
|
|
}
|
|
|
- this.isActiveMarkerIndex = index;
|
|
|
- const item = this.markersIn[this.isActiveMarkerIndex];
|
|
|
- item.width = item.active.width;
|
|
|
- item.height = item.active.height;
|
|
|
- item.iconPath = this.painter.path;
|
|
|
- item.isActive = true;
|
|
|
- this.$set(this.markersIn, index, item);
|
|
|
- this.latitude = item.latitude
|
|
|
- this.longitude = item.longitude
|
|
|
if(this.painter.wait != 0) return;
|
|
|
- this.generateImg(item.active.iconPath).then(()=>{
|
|
|
- // if(this.isActiveMarker != item.id) return;
|
|
|
- item.width = item.active.width;
|
|
|
- item.height = item.active.height;
|
|
|
- item.iconPath = this.painter.path;
|
|
|
- item.isActive = true;
|
|
|
- this.$set(this.markersIn, index, item);
|
|
|
- })
|
|
|
- mode&&this.$emit('moveToMarkId',index);
|
|
|
+ if(this.isActiveMarkerIndex === index) return;
|
|
|
+ if(this.markersIn[this.isActiveMarkerIndex]){
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].width = '34rpx';
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].height = '40rpx';
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].iconPath = '../../static/icon/late02.png';
|
|
|
+ }
|
|
|
+ this.isActiveMarkerIndex = index;
|
|
|
+ this.innerGeo = {
|
|
|
+ latitude: this.markersIn[this.isActiveMarkerIndex].latitude,
|
|
|
+ longitude: this.markersIn[this.isActiveMarkerIndex].longitude
|
|
|
+ }
|
|
|
+ this.painter.wait = 1;
|
|
|
+ this.painter.base.views[1].src = this.markersIn[this.isActiveMarkerIndex].activeIconPath
|
|
|
+ },
|
|
|
+ canvasSuccess(e){
|
|
|
+ if(this.isActiveMarkerIndex == -1)return;
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].width = '82rpx';
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].height = '90rpx';
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].iconPath = e;
|
|
|
+ this.markersIn = Object.assign(this.markersIn);
|
|
|
+ this.painter.wait=0
|
|
|
+ uni.vibrateShort({
|
|
|
+ success: function () {
|
|
|
+ console.log('success');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.updateMode&&this.$emit('moveToMarkId',this.isActiveMarkerIndex);
|
|
|
+ },
|
|
|
+ canvasFail(){
|
|
|
+ if(this.isActiveMarkerIndex == -1)return;
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].width = '82rpx';
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].height = '90rpx';
|
|
|
+ this.markersIn[this.isActiveMarkerIndex].iconPath = "";
|
|
|
+ this.markersIn = Object.assign(this.markersIn);
|
|
|
+ this.painter.wait=0
|
|
|
+ uni.vibrateShort({
|
|
|
+ success: function () {
|
|
|
+ console.log('fail');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ this.updateMode&&this.$emit('moveToMarkId',this.isActiveMarkerIndex);
|
|
|
},
|
|
|
//点击定位标时触发,e.detail = {longitude, latitude}
|
|
|
anchorpointtap(e) {
|
| xqd
@@ -208,6 +207,12 @@
|
|
|
})
|
|
|
},
|
|
|
},
|
|
|
+ 'geo':{
|
|
|
+ handler(v){
|
|
|
+ this.latitude = v.latitude
|
|
|
+ this.longitude = v.longitude
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|