guoshipeng
2023-08-16 c58bd2354c5cb0f0cd66d01d819979ab0f0e132f
fix:
5 files modified
122 ■■■■■ changed files
package-lock.json 11 ●●●●● patch | view | raw | blame | history
package.json 1 ●●●● patch | view | raw | blame | history
src/components/map/pickCoordinate1.vue 106 ●●●●● patch | view | raw | blame | history
src/main.ts 2 ●●● patch | view | raw | blame | history
tsconfig.json 2 ●●● patch | view | raw | blame | history
package-lock.json
@@ -20,6 +20,7 @@
        "date-fns": "^2.8.1",
        "echarts": "^4.5.0",
        "font-awesome": "^4.7.0",
        "jquery": "^3.7.0",
        "lodash": "^4.17.15",
        "moment": "^2.24.0",
        "numeral": "^2.0.6",
@@ -11267,6 +11268,11 @@
      "engines": {
        "node": ">=6"
      }
    },
    "node_modules/jquery": {
      "version": "3.7.0",
      "resolved": "https://registry.npmmirror.com/jquery/-/jquery-3.7.0.tgz",
      "integrity": "sha512-umpJ0/k8X0MvD1ds0P9SfowREz2LenHsQaxSohMZ5OMNEU2r0tf8pdeEFTHMFxWVxKNyU9rTtK3CWzUCTKJUeQ=="
    },
    "node_modules/js-beautify": {
      "version": "1.13.13",
@@ -29300,6 +29306,11 @@
        }
      }
    },
    "jquery": {
      "version": "3.7.0",
      "resolved": "https://registry.npmmirror.com/jquery/-/jquery-3.7.0.tgz",
      "integrity": "sha512-umpJ0/k8X0MvD1ds0P9SfowREz2LenHsQaxSohMZ5OMNEU2r0tf8pdeEFTHMFxWVxKNyU9rTtK3CWzUCTKJUeQ=="
    },
    "js-beautify": {
      "version": "1.13.13",
      "resolved": "https://registry.npmjs.org/js-beautify/-/js-beautify-1.13.13.tgz",
package.json
@@ -22,6 +22,7 @@
    "date-fns": "^2.8.1",
    "echarts": "^4.5.0",
    "font-awesome": "^4.7.0",
    "jquery": "^3.7.0",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "numeral": "^2.0.6",
src/components/map/pickCoordinate1.vue
@@ -17,16 +17,17 @@
            id="tipinput"
            style="width: 160px; height: 26px"
          ></a-input> -->
          <a-input
          <!-- <a-input
            v-model="input"
            placeholder="关键字搜索"
            id="tipinput"
            style="width: 160px; height: 26px"
            @change="searchMap"
          ></a-input>
          <!-- <input v-model="input" id="tipinput" /><button @click="searchAddress">
          ></a-input> -->
          <input v-model="input" id="tipinput" /><button @click="searchAddress">
            搜索
          </button> -->
          </button>
          <div id="panel"></div>
          <!-- <a-button
            size="small"
            type="primary"
@@ -64,6 +65,7 @@
        :zoom="zoom"
        :scroll-wheel-zoom="true"
        style="height: 400px; width: 100%; margin-top: 20px"
        id="amap"
      >
        <el-amap-marker
          :position="clickPoint"
@@ -71,6 +73,7 @@
          :dragging="true"
        ></el-amap-marker>
      </el-amap>
      <!--      :scroll-wheel-zoom="true"-->
      <!-- <baidu-map
        :center="center"
@@ -107,6 +110,8 @@
} from 'vue-property-decorator';
import any = jasmine.any;
import { get, post } from "@/util/request";
import $ from 'jquery'
import func from 'vue-temp/vue-editor-bridge';
@Component({
@@ -149,7 +154,7 @@
    // this.center.lat = newVal.lat
  }
  private created() {
    console.log(this.clickPoint,'clickPoint');
    // console.log(this.clickPoint,'clickPoint');
  }
  // 初始化地图
@@ -168,34 +173,64 @@
  // }
  private input:any=''
  private mark:any=''
  private searchMap(){
     var autoOptions = {
        input: "tipinput"
    };
    var self=this
    var auto = new AMap.Autocomplete(autoOptions);
    const placeSearch = new AMap.PlaceSearch(self.input);
    // console.log(window);
     auto.on("select", select);//注册监听,当选中某条记录时会触发
        function select(e) {
            placeSearch.setCity(e.poi.adcode);
            placeSearch.search(e.poi.name);  //关键字查询查询
            self.clickPoint = [e.poi.location.lng, e.poi.location.lat]
  // private searchMap(){
  //    var autoOptions = {
  //       input: "tipinput"
  //   };
  //   var self=this
  //   var auto = new AMap.Autocomplete(autoOptions);
  //   const placeSearch = new AMap.PlaceSearch(self.input);
  //   // console.log(window);
  //    auto.on("select", select);//注册监听,当选中某条记录时会触发
  //       function select(e) {
  //           placeSearch.setCity(e.poi.adcode);
  //           placeSearch.search(e.poi.name);  //关键字查询查询
  //           self.clickPoint = [e.poi.location.lng, e.poi.location.lat]
  //       }
  // }
  private searchAddress() {
           var map = new AMap.Map("amap", {
                resizeEnable: true
            });
         var placeSearch = new AMap.PlaceSearch({
            pageSize: 5, // 单页显示结果条数
            pageIndex: 1, // 页码
            city: "全国", // 兴趣点城市
            citylimit: false,  //是否强制限制在设置的城市内搜索
            panel: "panel", // 结果列表将在此容器中进行展示。
            map: map, // 展现结果的地图实例
            autoFitView: true // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
        });
        //关键字查询
        placeSearch.search(this.input)
        var salf=this
        var markerone=0
        map.on('click',click);
        function click(e){
          if(markerone===1){
            map.remove(map.Marker)
          }
          salf.mapClick(e)
          map.Marker=new AMap.Marker({
            map: map,
            position: salf.clickPoint,
            animation:"AMAP_ANIMATION_BOUNCE"
          })
          markerone=1
        }
  }
  // private searchAddress() {
  //        var placeSearch = new AMap.PlaceSearch({
  //           pageSize: 5, // 单页显示结果条数
  //           pageIndex: 1, // 页码
  //           city: "全国", // 兴趣点城市
  //           citylimit: true,  //是否强制限制在设置的城市内搜索
  //           panel: "panel", // 结果列表将在此容器中进行展示。
  //           autoFitView: true // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
  //       });
  //       //关键字查询
  //       placeSearch.search('北京大学');
  //   }
        // function click(e){
        //   console.log(e);
        //   salf.clickPoint=[e.lnglat.lng,e.lnglat.lat]
        // }
        // placeSearch.search(this.input,function(status, result){
        //   console.log(result);
        //   auto.on('click',click);
        //     function click(e){
        //      console.log(e);
        //     }
        // });
        // console.log(this.input);
    }
  // 初始定位到星虹国际
  private clickPoint: any = this.lnglat === '' ?  [
          120.720262,
@@ -206,10 +241,10 @@
  ]
  private mapClick(e: any) {
    // console.log(e);
    const { lng, lat } = e.lnglat 
    this.clickPoint=[ lng, lat]
    this.$forceUpdate()
    // console.log(this.clickPoint);
    console.log(this.clickPoint);
  }
  private handleMapCancel() {
@@ -281,7 +316,8 @@
  background-color: white;
  max-height: 100%;
  overflow-y: auto;
  right: 0;
  left: 25px;
  width: 280px;
  top: 126px;
}
</style>
src/main.ts
@@ -11,7 +11,7 @@
//百度地图
import BaiduMap from 'vue-baidu-map'
Vue.use(BaiduMap, {
  ak: '9FrZ6v3P8xS290ygi40M5Ik3Fgwes4KY'//你申请的key
  ak: 'c4e73f2c6972766d6a54dffd2f501cac'//你申请的key
})
import AMap from 'vue-amap'
tsconfig.json
@@ -37,5 +37,5 @@
,   ],
  "exclude": [
    "node_modules"
  ]
  ],
}