Browse Source

修改地图编辑

master
邓宏 2 years ago
parent
commit
2f41daa56b
  1. 31
      uni_modules/d-form/components/d-form/d-form.vue

31
uni_modules/d-form/components/d-form/d-form.vue

@ -277,6 +277,11 @@ import {computeArea} from '@/common/utils'
} }
return [] return []
} }
/* #ifdef APP-PLUS */
var polyline=new plus.maps.Polyline([])
polyline.setLineWidth(8)
polyline.setStrokeColor("#10C176")
/* #endif */
export default{ export default{
props:{ props:{
@ -353,6 +358,17 @@ import {computeArea} from '@/common/utils'
}) })
} }
}, },
showMap(n){
if(!n){
if(this.value.length<=0){
this.markerList=this.$defineArray([])
this.temp_markerList=this.$defineArray([])
this.areaPolygon=null
polyline.setPath([])
this.maps.clearOverlays()
}
}
}
}, },
computed:{ computed:{
date(){ date(){
@ -445,14 +461,10 @@ import {computeArea} from '@/common/utils'
this.maps.setMapType(plus.maps.MapType.MAPTYPE_SATELLITE) this.maps.setMapType(plus.maps.MapType.MAPTYPE_SATELLITE)
this.maps.centerAndZoom(new plus.maps.Point(102.712251,25.040609),10) this.maps.centerAndZoom(new plus.maps.Point(102.712251,25.040609),10)
var polyline=new plus.maps.Polyline([])
polyline.setLineWidth(8)
polyline.setStrokeColor("#10C176")
if(this.value.length>0){ if(this.value.length>0){
var bound=computeArea(this.value) var bound=computeArea(this.value)
for(var i=0;i<this.value.length;i++){ for(var i=0;i<this.value.length;i++){
this.maps.addOverlay(this.addMarker(this.value[i],polyline)) this.maps.addOverlay(this.addMarker(this.value[i]))
} }
this.markerList[0].pre=this.markerList[this.markerList.length-1].value this.markerList[0].pre=this.markerList[this.markerList.length-1].value
this.markerList[this.markerList.length-1].next=this.markerList[0].value this.markerList[this.markerList.length-1].next=this.markerList[0].value
@ -463,7 +475,7 @@ import {computeArea} from '@/common/utils'
this.markerList.length<=0 && this.maps.addOverlay(polyline) this.markerList.length<=0 && this.maps.addOverlay(polyline)
if(this.value.length<=0){ if(this.value.length<=0){
var marker=this.addMarker(e, polyline) var marker=this.addMarker(e)
this.maps.addOverlay(marker); this.maps.addOverlay(marker);
this.markerList.length>=2 && polyline.setPath(this.markerList.map(({value})=>{ this.markerList.length>=2 && polyline.setPath(this.markerList.map(({value})=>{
@ -490,7 +502,7 @@ import {computeArea} from '@/common/utils'
marker.value.onclick= this.onClick marker.value.onclick= this.onClick
}) })
}, },
addMarker({longitude,latitude},polyline){ addMarker({longitude,latitude}){
var marker=new plus.maps.Marker(new plus.maps.Point(longitude, latitude)); var marker=new plus.maps.Marker(new plus.maps.Point(longitude, latitude));
marker.setIcon("/static/map_point_3.png"); marker.setIcon("/static/map_point_3.png");
marker.bringToTop() marker.bringToTop()
@ -549,9 +561,10 @@ import {computeArea} from '@/common/utils'
this.reComputArea() this.reComputArea()
}else{ }else{
this.markerList=[] this.markerList=this.$defineArray([])
this.temp_markerList=[] this.temp_markerList=this.$defineArray([])
this.areaPolygon=null this.areaPolygon=null
polyline.setPath([])
this.maps.clearOverlays() this.maps.clearOverlays()
} }

Loading…
Cancel
Save