Commit cab1c38617a96fb7e5dc5e14093f00b83dc531ba

Authored by 2c2c2c
1 parent 40c1ead7

投放点标记点优化

trash-ui/src/views/unit/dropPointInfo/index.vue
... ... @@ -244,9 +244,9 @@
244 244 </el-col>
245 245 <el-col :span="12">
246 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 248 </el-form-item>
249   - <el-button type="primary" @click="handleOpenMap">坐标点</el-button>
  249 +<!-- <el-button type="primary" @click="handleOpenMap">坐标点</el-button>-->
250 250 </el-col>
251 251 </el-row>
252 252 </el-form>
... ... @@ -286,7 +286,7 @@
286 286 </div>
287 287 <div v-loading="loading" id="dropPointInfoContainer" class="am-map" style="width:100%;height: 700px;"></div>
288 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 290 <el-button type="primary" @click="openMap = false">确 定</el-button>
291 291 </div>
292 292 </el-dialog>
... ... @@ -561,6 +561,7 @@ export default {
561 561 mapOptions: [],
562 562 openMap:false,
563 563 center: null,
  564 + circleMarker: null,
564 565 };
565 566 },
566 567 created() {
... ... @@ -572,6 +573,7 @@ export default {
572 573 this.center = null;
573 574 this.form.coordinatePoint = null;
574 575 this.map = null;
  576 + this.circleMarker = null;
575 577 this.initAMap();
576 578 },
577 579 handleOpenMap(){
... ... @@ -609,7 +611,7 @@ export default {
609 611 var radius = 10 //单位:px
610 612  
611 613 //创建圆形点标记 CircleMarker 实例
612   - var circleMarker = new AMap.CircleMarker({
  614 + _this.circleMarker = new AMap.CircleMarker({
613 615 center: _this.center, //圆心
614 616 radius: radius, //半径
615 617 strokeColor: "white", //轮廓线颜色
... ... @@ -621,14 +623,19 @@ export default {
621 623 cursor: "pointer", //鼠标悬停时的鼠标样式
622 624 });
623 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 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 640 if(_this.center==null){
634 641 //设置圆形位置
... ... @@ -637,7 +644,7 @@ export default {
637 644 var radius = 10 //单位:px
638 645  
639 646 //创建圆形点标记 CircleMarker 实例
640   - var circleMarker = new AMap.CircleMarker({
  647 + _this.circleMarker = new AMap.CircleMarker({
641 648 center: _this.center, //圆心
642 649 radius: radius, //半径
643 650 strokeColor: "white", //轮廓线颜色
... ... @@ -649,10 +656,9 @@ export default {
649 656 cursor: "pointer", //鼠标悬停时的鼠标样式
650 657 });
651 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 662 _this.$set(_this.form, "coordinatePoint", e.lnglat.lng+","+e.lnglat.lat);
657 663 }
658 664 });
... ...