From bcb686607ddff77f83b5e6d597f483b3d49e596e Mon Sep 17 00:00:00 2001 From: 少年 <1392120328@qq.com> Date: 星期六, 20 一月 2024 21:26:31 +0800 Subject: [PATCH] youhua --- src/components/leftMenu/sousuo.vue | 344 +++++++++++++++++++++++++++++++++++++-------------------- 1 files changed, 224 insertions(+), 120 deletions(-) diff --git a/src/components/leftMenu/sousuo.vue b/src/components/leftMenu/sousuo.vue index 993092d..6adbe67 100644 --- a/src/components/leftMenu/sousuo.vue +++ b/src/components/leftMenu/sousuo.vue @@ -58,6 +58,14 @@ @input="changeInput" clearable > + <el-select v-model="select" slot="prepend" placeholder="璇烽�夋嫨"> + <el-option + v-for="(item, index) in options" + :key="index" + :label="item.label" + :value="item.value" + ></el-option> + </el-select> <el-button slot="append" icon="el-icon-search" @@ -128,7 +136,10 @@ height: 100%; top: 0; background-color: #f3f3f3; - z-index: 3000; + z-index: 99; +} +.el-select { + width: 80px; } /* 姣忔潯鎼滅储缁撴灉 */ @@ -178,8 +189,8 @@ import axios from "axios"; import store from "@/utils/store.js"; import common from "@/components/common"; -let flyPoint; -let flyLine; +window.flyPoint = null; +window.flyLine = null; let Allresults = []; export default { @@ -193,25 +204,40 @@ showList: false, total: 0, poiList: [], + select: "鍏ㄩ儴", + options: [ + { + label: "鍏ㄩ儴", + value: "鍏ㄩ儴", + }, + { + label: "POI", + value: "POI", + }, + { + label: "鍦板潡", + value: "鍦板潡", + }, + ], }; }, methods: { clearval() { this.syssval = "璇疯緭鍏ュ叧閿瘝鎼滅储鍦板浘"; - flyPoint && Viewer.entities.remove(flyPoint); - flyPoint = undefined; - flyLine && sgworld.Creator.DeleteObject(flyLine); - flyLine = undefined; + window.flyPoint && Viewer.entities.remove(window.flyPoint); + window.flyPoint = undefined; + window.flyLine && sgworld.Creator.DeleteObject(window.flyLine); + window.flyLine = undefined; this.poi_text = ""; this.ssjgxs = false; }, changeInput() { if (this.poi_text === "") { this.ssjgxs = false; - flyPoint && Viewer.entities.remove(flyPoint); - flyPoint = undefined; - flyLine && sgworld.Creator.DeleteObject(flyLine); - flyLine = undefined; + window.flyPoint && Viewer.entities.remove(window.flyPoint); + window.flyPoint = undefined; + window.flyLine && sgworld.Creator.DeleteObject(window.flyLine); + window.flyLine = undefined; } else { clearTimeout(timers); timers = setTimeout(() => { @@ -262,111 +288,189 @@ this.ssjgxs = true; Allresults = []; this.poiList = []; - axios - .all([ - // 115鎺ュ彛锛堝彲鏌ュ湴鍧楀悕锛� - axios.post(common.poiserve2, { - adcode: "110115", - address: { - name: "", - type: "", - }, - adname: "澶у叴鍖�", - cityname: "鍖椾含甯�", - name: { - name: this.poi_text, - type: "", - }, - page: 1, - perPageCount: 20, - pcode: "110000", - pname: "", - resType: "", - }), - // // 甯傜骇骞冲彴锛堢櫨搴︼細浼氭煡鍒板鍦帮級 - // axios.get(common.poiserve, { - // params: { - // request: "bdPoi", - // query: this.poi_text, - // output: "json", - // coord: "cgcs2000", - // page_num: 0, - // page_size: 20, - // }, - // }), - // 甯傜骇骞冲彴锛堥珮寰凤級 - axios.get(common.poiserve, { - params: { - request: "GdPoi", - keywords: this.poi_text, - output: "json", - coord: "cgcs2000", - offset: 20, - page: 1, - }, - }), - ]) - .then( - (data) => { - // this.total = data.data.pois.length; - // this.poiList = - // data.data && data.data.pois; - //115鎺ュ彛 - if (data[0].status == 200) { - data[0].data.data.res - .filter((item) => { - return item.name.includes(this.poi_text); - }) - .forEach((val) => { - Allresults.push(val); + switch (this.select) { + case "鍏ㄩ儴": + axios + .all([ + // 115鎺ュ彛锛堝彲鏌ュ湴鍧楀悕锛� + axios.post(common.poiserve2, { + adcode: "110115", + address: { + name: "", + type: "", + }, + adname: "澶у叴鍖�", + cityname: "鍖椾含甯�", + name: { + name: this.poi_text, + type: "", + }, + page: 1, + perPageCount: 20, + pcode: "110000", + pname: "", + resType: "", + }), + // // 甯傜骇骞冲彴锛堢櫨搴︼細浼氭煡鍒板鍦帮級 + // axios.get(common.poiserve, { + // params: { + // request: "bdPoi", + // query: this.poi_text, + // output: "json", + // coord: "cgcs2000", + // page_num: 0, + // page_size: 20, + // }, + // }), + // 甯傜骇骞冲彴锛堥珮寰凤級 + axios.get(common.poiserve, { + params: { + request: "GdPoi", + keywords: this.poi_text, + output: "json", + coord: "cgcs2000", + offset: 20, + page: 1, + }, + }), + ]) + .then( + (data) => { + // this.total = data.data.pois.length; + // this.poiList = + // data.data && data.data.pois; + //115鎺ュ彛 + if (data[0].status == 200) { + data[0].data.data.res + .filter((item) => { + return item.name.includes(this.poi_text); + }) + .forEach((val) => { + Allresults.push(val); + }); + } + // 甯傜骇骞冲彴 + // // 鐧惧害 + // if (data[1].data.status == 0) { + // data[1].data.results.forEach((val) => { + // let obj = { + // address: val.address, + // adname: val.area, + // cityname: val.city, + // id: val.uid, + // lat: val.location.lat, + // lng: val.location.lng, + // name: val.name, + // pname: val.province, + // }; + // Allresults.push(obj); + // }); + // } + // 楂樺痉 + if (data[1].data.status == 1) { + data[1].data.pois.forEach((val) => { + let poiarr = val.location.split(","); + let poi = { + lon: parseFloat(poiarr[0]), + lat: parseFloat(poiarr[1]), + }; + let obj = { + address: val.address, + adname: val.area, + cityname: val.city, + id: val.uid, + lat: poi.lat, + lng: poi.lon, + name: val.name, + pname: val.province, + }; + Allresults.push(obj); + }); + } + this.total = Allresults.length; + this.poiList = Allresults; + this.showList = true; + }, + (response) => { + console.log("error"); + } + ); + break; + case "POI": + axios + .get(common.poiserve, { + params: { + request: "GdPoi", + keywords: this.poi_text, + output: "json", + coord: "cgcs2000", + offset: 20, + page: 1, + }, + }) + .then((res) => { + // 楂樺痉 + if (res.data.status == 1) { + res.data.pois.forEach((val) => { + let poiarr = val.location.split(","); + let poi = { + lon: parseFloat(poiarr[0]), + lat: parseFloat(poiarr[1]), + }; + let obj = { + address: val.address, + adname: val.area, + cityname: val.city, + id: val.uid, + lat: poi.lat, + lng: poi.lon, + name: val.name, + pname: val.province, + }; + Allresults.push(obj); }); - } - // 甯傜骇骞冲彴 - // // 鐧惧害 - // if (data[1].data.status == 0) { - // data[1].data.results.forEach((val) => { - // let obj = { - // address: val.address, - // adname: val.area, - // cityname: val.city, - // id: val.uid, - // lat: val.location.lat, - // lng: val.location.lng, - // name: val.name, - // pname: val.province, - // }; - // Allresults.push(obj); - // }); - // } - // 楂樺痉 - if (data[1].data.status == 1) { - data[1].data.pois.forEach((val) => { - let poiarr = val.location.split(","); - let poi = { - lon: parseFloat(poiarr[0]), - lat: parseFloat(poiarr[1]), - }; - let obj = { - address: val.address, - adname: val.area, - cityname: val.city, - id: val.uid, - lat: poi.lat, - lng: poi.lon, - name: val.name, - pname: val.province, - }; - Allresults.push(obj); - }); - } - this.total = Allresults.length; - this.poiList = Allresults; - this.showList = true; - }, - (response) => { - console.log("error"); - } - ); + } + this.total = Allresults.length; + this.poiList = Allresults; + this.showList = true; + }); + break; + case "鍦板潡": + axios + .post(common.poiserve2, { + adcode: "110115", + address: { + name: "", + type: "", + }, + adname: "澶у叴鍖�", + cityname: "鍖椾含甯�", + name: { + name: this.poi_text, + type: "", + }, + page: 1, + perPageCount: 20, + pcode: "110000", + pname: "", + resType: "", + }) + .then((res) => { + if (res.status == 200) { + res.data.data.res + .filter((item) => { + return item.name.includes(this.poi_text); + }) + .forEach((val) => { + Allresults.push(val); + }); + } + this.total = Allresults.length; + this.poiList = Allresults; + this.showList = true; + }); + break; + } } }, getPosition(geo) { @@ -380,8 +484,8 @@ // let degrees = item.location.split(','); // let degrees = [item.location.lng, item.location.lat]; let degrees = [item.lng, item.lat]; - flyPoint && Viewer.entities.remove(flyPoint); - flyLine && sgworld.Creator.DeleteObject(flyLine); + window.flyPoint && Viewer.entities.remove(window.flyPoint); + window.flyLine && sgworld.Creator.DeleteObject(window.flyLine); sgworld.Navigate.flyToPointsInterest({ destination: Cesium.Cartesian3.fromDegrees( degrees[0], @@ -390,7 +494,7 @@ ), }); // 娣诲姞鐐逛綅 - flyPoint = Viewer.entities.add({ + window.flyPoint = Viewer.entities.add({ position: Cesium.Cartesian3.fromDegrees(degrees[0], degrees[1]), billboard: { verticalOrigin: Cesium.VerticalOrigin.BOTTOM, @@ -399,7 +503,7 @@ heightReference: 1, disableDepthTestDistance: Number.POSITIVE_INFINITY, }, - properties:item + properties: item, }); // 濡傛灉鏄湴鍧楋紝娣诲姞鑼冨洿绾� if (item.type == "澶у叴鐢ㄥ湴") { @@ -428,7 +532,7 @@ z: 0, }); } - flyLine = sgworld.Creator.createPolyline( + window.flyLine = sgworld.Creator.createPolyline( geometry, "#ff0000", 1, -- Gitblit v1.9.3