guoshipeng
2023-08-14 9086f457d6404a0cd7f74b351c3889f82d02a91d
fix:修改
3 files modified
77 ■■■■■ changed files
public/index.html 2 ●●● patch | view | raw | blame | history
src/components/map/pickCoordinate1.vue 73 ●●●●● patch | view | raw | blame | history
src/main.ts 2 ●●● patch | view | raw | blame | history
public/index.html
@@ -137,7 +137,7 @@
  window._AMapSecurityConfig = {
    securityJsCode: '20fcbbc1782d2853f433831e61fab769',
  }
</script>
</html>
src/components/map/pickCoordinate1.vue
@@ -12,18 +12,21 @@
      <div style="display: flex">
        <div style="display: flex; width: 300px">
          <div>地址:</div>
            <a-input
          <!-- <a-input
            placeholder="关键字搜索"
            id="tipinput"
            style="width: 160px; height: 26px"
          ></a-input>
          <!-- <a-input
          ></a-input> -->
          <a-input
            v-model="input"
            placeholder="关键字搜索"
            id="tipinput"
            style="width: 160px; height: 26px"
            @change="searchMap"
          ></a-input> -->
          ></a-input>
          <!-- <input v-model="input" id="tipinput" /><button @click="searchAddress">
            搜索
          </button> -->
          <!-- <a-button
            size="small"
            type="primary"
@@ -156,44 +159,43 @@
  //   this.zoom = 19
  // }
  private selectPoi(e){
    console.log(e);
    let poi = e
      if (poi.length > 0) {
         this.clickPoint = [poi[0].lng, poi[0].lat]
         }
  }
  // private selectPoi(e){
  //   console.log(e);
  //   let poi = e
  //     if (poi.length > 0) {
  //        this.clickPoint = [poi[0].lng, poi[0].lat]
  //        }
  // }
  private input:any=''
  private mark:any=''
  private searchMap(){
     var autoOptions = {
        input: "tipinput"
    };
    var auto = new AMap.AutoComplete(autoOptions);
    const placeSearch = new AMap.PlaceSearch(this.input);
    console.log(window);
    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) {
          console.log(e.poi.adcode);
            placeSearch.setCity(e.poi.adcode);
            placeSearch.search(e.poi.name);  //关键字查询查询
            self.clickPoint = [e.poi.location.lng, e.poi.location.lat]
        }
  // 关键字查询
  // console.log(this.input);
  //  placeSearch.search(this.input, (status, result) => {
  //   // 查询成功时,result即对应匹配的POI信息
  //   console.log(result);//打印这句话报错,第一遍可以打印出来,第二遍就会报错
  // });
  // // 监听选中节点事件
  // AMap.event.addListener(placeSearch, "selectChanged", (SelectChangeEvent) => {
  //   // 获取节点信息自行处理逻辑代码
  //   this.mark = SelectChangeEvent.selected.data;
  //   console.log(SelectChangeEvent.selected.data,'苏轼');
  // });
  }
  // private searchAddress() {
  //        var placeSearch = new AMap.PlaceSearch({
  //           pageSize: 5, // 单页显示结果条数
  //           pageIndex: 1, // 页码
  //           city: "全国", // 兴趣点城市
  //           citylimit: true,  //是否强制限制在设置的城市内搜索
  //           panel: "panel", // 结果列表将在此容器中进行展示。
  //           autoFitView: true // 是否自动调整地图视野使绘制的 Marker点都处于视口的可见范围
  //       });
  //       //关键字查询
  //       placeSearch.search('北京大学');
  //   }
  // 初始定位到星虹国际
  private clickPoint: any = this.lnglat === '' ?  [
          120.720262,
@@ -268,9 +270,18 @@
}
.amap-sug-result {
  position: absolute;
  z-index: 9999 !important;;
  z-index: 9999 !important;
  background-color: #fefefe;
  border: 1px solid #d1d1d1;
  bottom: auto;
}
#panel {
  z-index: 999;
  position: absolute;
  background-color: white;
  max-height: 100%;
  overflow-y: auto;
  right: 0;
  width: 280px;
}
</style>
src/main.ts
@@ -20,7 +20,7 @@
  key: 'c4e73f2c6972766d6a54dffd2f501cac',
  plugin: ['AMap.moveAnimation', 'AMap.PlaceSearch', 'AMap.Scale',
    'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor',
    'AMap.DistrictSearch', 'AMap.Geocoder', 'AMap.AutoComplete'],
    'AMap.DistrictSearch', 'AMap.Geocoder', 'AMap.Autocomplete'],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4'
})