Commit cab1c38617a96fb7e5dc5e14093f00b83dc531ba

Authored by 2c2c2c
1 parent 40c1ead7

投放点标记点优化

trash-ui/src/views/unit/dropPointInfo/index.vue
@@ -244,9 +244,9 @@ @@ -244,9 +244,9 @@
244 </el-col> 244 </el-col>
245 <el-col :span="12"> 245 <el-col :span="12">
246 <el-form-item label="坐标点" prop="coordinatePoint"> 246 <el-form-item label="坐标点" prop="coordinatePoint">
247 - <el-input v-model="form.coordinatePoint" placeholder="请输入坐标点经纬度" readonly/> 247 + <el-input v-model="form.coordinatePoint" placeholder="请输入坐标点经纬度" readonly @click.native="handleOpenMap"/>
248 </el-form-item> 248 </el-form-item>
249 - <el-button type="primary" @click="handleOpenMap">坐标点</el-button> 249 +<!-- <el-button type="primary" @click="handleOpenMap">坐标点</el-button>-->
250 </el-col> 250 </el-col>
251 </el-row> 251 </el-row>
252 </el-form> 252 </el-form>
@@ -286,7 +286,7 @@ @@ -286,7 +286,7 @@
286 </div> 286 </div>
287 <div v-loading="loading" id="dropPointInfoContainer" class="am-map" style="width:100%;height: 700px;"></div> 287 <div v-loading="loading" id="dropPointInfoContainer" class="am-map" style="width:100%;height: 700px;"></div>
288 <div slot="footer" class="dialog-footer"> 288 <div slot="footer" class="dialog-footer">
289 - <el-button type="primary" @click="clearCoordinatePoint">清除坐标点</el-button> 289 +<!-- <el-button type="primary" @click="clearCoordinatePoint">清除坐标点</el-button>-->
290 <el-button type="primary" @click="openMap = false">确 定</el-button> 290 <el-button type="primary" @click="openMap = false">确 定</el-button>
291 </div> 291 </div>
292 </el-dialog> 292 </el-dialog>
@@ -561,6 +561,7 @@ export default { @@ -561,6 +561,7 @@ export default {
561 mapOptions: [], 561 mapOptions: [],
562 openMap:false, 562 openMap:false,
563 center: null, 563 center: null,
  564 + circleMarker: null,
564 }; 565 };
565 }, 566 },
566 created() { 567 created() {
@@ -572,6 +573,7 @@ export default { @@ -572,6 +573,7 @@ export default {
572 this.center = null; 573 this.center = null;
573 this.form.coordinatePoint = null; 574 this.form.coordinatePoint = null;
574 this.map = null; 575 this.map = null;
  576 + this.circleMarker = null;
575 this.initAMap(); 577 this.initAMap();
576 }, 578 },
577 handleOpenMap(){ 579 handleOpenMap(){
@@ -609,7 +611,7 @@ export default { @@ -609,7 +611,7 @@ export default {
609 var radius = 10 //单位:px 611 var radius = 10 //单位:px
610 612
611 //创建圆形点标记 CircleMarker 实例 613 //创建圆形点标记 CircleMarker 实例
612 - var circleMarker = new AMap.CircleMarker({ 614 + _this.circleMarker = new AMap.CircleMarker({
613 center: _this.center, //圆心 615 center: _this.center, //圆心
614 radius: radius, //半径 616 radius: radius, //半径
615 strokeColor: "white", //轮廓线颜色 617 strokeColor: "white", //轮廓线颜色
@@ -621,14 +623,19 @@ export default { @@ -621,14 +623,19 @@ export default {
621 cursor: "pointer", //鼠标悬停时的鼠标样式 623 cursor: "pointer", //鼠标悬停时的鼠标样式
622 }); 624 });
623 //圆形 circleMarker 对象添加到 Map 625 //圆形 circleMarker 对象添加到 Map
624 - _this.map.add(circleMarker); 626 + _this.map.add(_this.circleMarker);
625 //将覆盖物调整到合适视野 627 //将覆盖物调整到合适视野
626 - _this.map.setFitView([circleMarker]);  
627 -  
628 - _this.form.coordinatePoint = e.lnglat.lng+","+e.lnglat.lat; 628 + _this.map.setFitView([_this.circleMarker]);
629 } 629 }
630 // 监听地图点击事件 630 // 监听地图点击事件
631 _this.map.on("click", (e) => { 631 _this.map.on("click", (e) => {
  632 + console.log(e)
  633 + if(_this.center!=null){
  634 + _this.map.remove(_this.circleMarker);
  635 + _this.center = null;
  636 + _this.form.coordinatePoint = null;
  637 + }
  638 +
632 //判断是否已有圆点标记 639 //判断是否已有圆点标记
633 if(_this.center==null){ 640 if(_this.center==null){
634 //设置圆形位置 641 //设置圆形位置
@@ -637,7 +644,7 @@ export default { @@ -637,7 +644,7 @@ export default {
637 var radius = 10 //单位:px 644 var radius = 10 //单位:px
638 645
639 //创建圆形点标记 CircleMarker 实例 646 //创建圆形点标记 CircleMarker 实例
640 - var circleMarker = new AMap.CircleMarker({ 647 + _this.circleMarker = new AMap.CircleMarker({
641 center: _this.center, //圆心 648 center: _this.center, //圆心
642 radius: radius, //半径 649 radius: radius, //半径
643 strokeColor: "white", //轮廓线颜色 650 strokeColor: "white", //轮廓线颜色
@@ -649,10 +656,9 @@ export default { @@ -649,10 +656,9 @@ export default {
649 cursor: "pointer", //鼠标悬停时的鼠标样式 656 cursor: "pointer", //鼠标悬停时的鼠标样式
650 }); 657 });
651 //圆形 circleMarker 对象添加到 Map 658 //圆形 circleMarker 对象添加到 Map
652 - _this.map.add(circleMarker); 659 + _this.map.add(_this.circleMarker);
653 //将覆盖物调整到合适视野 660 //将覆盖物调整到合适视野
654 - _this.map.setFitView([circleMarker]);  
655 - 661 + _this.map.setFitView([_this.circleMarker]);
656 _this.$set(_this.form, "coordinatePoint", e.lnglat.lng+","+e.lnglat.lat); 662 _this.$set(_this.form, "coordinatePoint", e.lnglat.lng+","+e.lnglat.lat);
657 } 663 }
658 }); 664 });