林火综合应急信息管理系统前端
guoshilong
2023-03-13 9ecc792eb82c7a94f35ea7f2056567202c6efbff
src/components/OpenLayersMap/index.vue
@@ -19,7 +19,7 @@
      </div>
    </div>
    <div v-if="!mapLocation.isDetail" style="position: absolute;right:51%;top:7%;z-index: 999999;">
      <el-button type="info" icon="el-icon-location-outline" circle @click="createPoint"></el-button>
      <el-button type="info" icon="el-icon-location-outline" circle @click="setCenterByDistrict()"></el-button>
    </div>
  </div>
</template>
@@ -102,6 +102,8 @@
        if (this.mapLocation.location[0]&&this.mapLocation.location[1]){
          this.setCenter(this.mapLocation.location[0],this.mapLocation.location[1])
        }
      }else {
        this.createPoint()
      }
    },
@@ -136,7 +138,6 @@
    getLocation(regionCode,regionName){
      this.region = regionCode
      this.regionName = regionName
      this.setCenterByDistrict(regionName)
    },
    //搜索框选择
    handleSelect(item) {
@@ -156,8 +157,13 @@
      view.setZoom(20);
    },
    //根据区域名设置中心点
    setCenterByDistrict(regionName){
    setCenterByDistrict(){
      const that = this
      let regionName = this.regionName
      if (regionName.length ==0){
        this.$message.warning("请先选择行政区");
        return
      }
      AMap.plugin('AMap.DistrictSearch', function () {
        // 创建行政区查询对象
        var district = new AMap.DistrictSearch({