From 19d26f24c73756001ef349c093c498a24d2c05f8 Mon Sep 17 00:00:00 2001 From: guoshipeng <3194674006@qq.com> Date: Wed, 06 Sep 2023 14:16:11 +0800 Subject: [PATCH] fix:查询添加区域 --- src/components/map/pickCoordinate1.vue | 102 ++++++++++++++++++++++++++------------------------ 1 files changed, 53 insertions(+), 49 deletions(-) diff --git a/src/components/map/pickCoordinate1.vue b/src/components/map/pickCoordinate1.vue index a114ea1..26078de 100644 --- a/src/components/map/pickCoordinate1.vue +++ b/src/components/map/pickCoordinate1.vue @@ -17,16 +17,25 @@ 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" + style=" + background-color: #1890ff; + color: white; + border: none; + margin-left: 5px; + " + > ������ - </button> --> + </button> + <div id="panel"></div> <!-- <a-button size="small" type="primary" @@ -64,6 +73,7 @@ :zoom="zoom" :scroll-wheel-zoom="true" style="height: 400px; width: 100%; margin-top: 20px" + id="amap" > <el-amap-marker :position="clickPoint" @@ -71,6 +81,7 @@ :dragging="true" ></el-amap-marker> </el-amap> + <!-- :scroll-wheel-zoom="true"--> <!-- <baidu-map :center="center" @@ -107,6 +118,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,53 +162,43 @@ // this.center.lat = newVal.lat } private created() { - console.log(this.clickPoint,'clickPoint'); + // console.log(this.clickPoint,'clickPoint'); } - // ��������������� - // private handler({BMap, map}) { - // this.center.lng = this.typeOperation === 'add' ? '120.726838' : this.lnglat.split(',')[1] - // this.center.lat = this.typeOperation === 'add' ? '31.3421' : this.lnglat.split(',')[0] - // 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 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 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('������������'); - - // } + } // ��������������������������� private clickPoint: any = this.lnglat === '' ? [ 120.720262, @@ -206,10 +209,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 +284,8 @@ background-color: white; max-height: 100%; overflow-y: auto; - right: 0; + left: 25px; width: 280px; + top: 126px; } </style> -- Gitblit v1.8.0