| | |
| | | @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" |
| | |
| | | </div> |
| | | </div> |
| | | <div v-else> |
| | | <div class="ssjg" v-show="ssjgxs">请输入关键词搜索地图</div> |
| | | <div class="ssjg" v-show="ssjgxs">未搜索到结果</div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | |
| | | height: 100%; |
| | | top: 0; |
| | | background-color: #f3f3f3; |
| | | z-index: 3000; |
| | | z-index: 99; |
| | | } |
| | | .el-select { |
| | | width: 80px; |
| | | } |
| | | |
| | | /* 每条搜索结果 */ |
| | |
| | | background: rgba(218, 218, 218, 0.1); |
| | | } |
| | | </style> |
| | | |
| | | |
| | | <script> |
| | | let timers = null; |
| | | |
| | | 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 { |
| | |
| | | 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(() => { |
| | |
| | | rectangle.maxy > 31.182515322 && (rectangle.maxy = 31.182515322); |
| | | return `RECT(${rectangle.minx} ${rectangle.miny},${rectangle.maxx} ${rectangle.maxy})`; |
| | | }, |
| | | getGdPoi() { |
| | | 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 && |
| | | res.data.pois |
| | | .filter((item) => { |
| | | var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g"); |
| | | return ( |
| | | item.pname.includes("北京") && |
| | | item.name.includes(this.poi_text) && |
| | | !reg.test(item.typecode) |
| | | ); |
| | | }) |
| | | .forEach((val) => { |
| | | let poiarr = val.location.split(","); |
| | | let poi = { |
| | | lon: parseFloat(poiarr[0]), |
| | | lat: parseFloat(poiarr[1]), |
| | | }; |
| | | let obj = { |
| | | adcode: val.adcode, |
| | | address: val.address, |
| | | adname: val.area, |
| | | citycode: val.citycode, |
| | | cityname: val.cityname, |
| | | id: val.uid, |
| | | lat: poi.lat, |
| | | lng: poi.lon, |
| | | name: val.name, |
| | | pcode: val.pcode, |
| | | pname: val.province, |
| | | type: val.type, |
| | | typecode: val.typecode, |
| | | }; |
| | | Allresults.push(obj); |
| | | }); |
| | | } |
| | | this.total = Allresults.length; |
| | | this.poiList = Allresults; |
| | | this.showList = true; |
| | | }); |
| | | }, |
| | | getData() { |
| | | 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 && |
| | | res.data.data.res |
| | | .filter((item) => { |
| | | // 判断地块是否有汉字 |
| | | var reg = new RegExp("[\\u4E00-\\u9FFF]+", "g"); |
| | | return ( |
| | | item.name.includes(this.poi_text) && reg.test(item.typecode) |
| | | ); |
| | | }) |
| | | .forEach((val) => { |
| | | Allresults.push(val); |
| | | }); |
| | | } |
| | | this.total = Allresults.length; |
| | | this.poiList = Allresults; |
| | | this.showList = true; |
| | | }); |
| | | }, |
| | | search() { |
| | | if (this.poi_text === "") { |
| | | this.poiList = []; |
| | |
| | | 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); |
| | | }); |
| | | } |
| | | // 市级平台 |
| | | // // 百度 |
| | | // 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"); |
| | | } |
| | | ); |
| | | switch (this.select) { |
| | | case "全部": |
| | | this.getGdPoi(); |
| | | this.getData(); |
| | | // 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 && |
| | | // 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); |
| | | // // }); |
| | | // // } |
| | | // // 高德 |
| | | |
| | | // console.log(data, "数据"); |
| | | // if (data[0].data.status == 1) { |
| | | // data[0].data.pois && |
| | | // data[0].data.pois |
| | | // .filter((item) => { |
| | | // return ( |
| | | // item.pname.includes("北京") && |
| | | // item.name.includes(this.poi_text) |
| | | // ); |
| | | // }) |
| | | // .forEach((val) => { |
| | | // let poiarr = val.location.split(","); |
| | | // let poi = { |
| | | // lon: parseFloat(poiarr[0]), |
| | | // lat: parseFloat(poiarr[1]), |
| | | // }; |
| | | // let obj = { |
| | | // adcode: val.adcode, |
| | | // address: val.address, |
| | | // adname: val.area, |
| | | // citycode: val.citycode, |
| | | // cityname: val.cityname, |
| | | // id: val.uid, |
| | | // lat: poi.lat, |
| | | // lng: poi.lon, |
| | | // name: val.name, |
| | | // pcode: val.pcode, |
| | | // pname: val.province, |
| | | // type: val.type, |
| | | // typecode: val.typecode, |
| | | // }; |
| | | // Allresults.push(obj); |
| | | // }); |
| | | // } |
| | | // this.total = Allresults.length; |
| | | // this.poiList = Allresults; |
| | | // this.showList = true; |
| | | // console.log(Allresults); |
| | | // }, |
| | | // (response) => { |
| | | // console.log("error"); |
| | | // } |
| | | // ); |
| | | break; |
| | | case "POI": |
| | | this.getGdPoi(); |
| | | break; |
| | | case "地块": |
| | | this.getData(); |
| | | break; |
| | | } |
| | | } |
| | | }, |
| | | getPosition(geo) { |
| | |
| | | // 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], |
| | |
| | | ), |
| | | }); |
| | | // 添加点位 |
| | | flyPoint = Viewer.entities.add({ |
| | | window.flyPoint = Viewer.entities.add({ |
| | | position: Cesium.Cartesian3.fromDegrees(degrees[0], degrees[1]), |
| | | billboard: { |
| | | verticalOrigin: Cesium.VerticalOrigin.BOTTOM, |
| | | scale: 1, |
| | | image: window.SmartEarthRootUrl + "/Workers/image/mark.png", |
| | | image: window.SmartEarthRootUrl + "/Workers/image/mark1.png", |
| | | heightReference: 1, |
| | | disableDepthTestDistance: Number.POSITIVE_INFINITY, |
| | | }, |
| | | properties:item |
| | | properties: item, |
| | | }); |
| | | // 如果是地块,添加范围线 |
| | | if (item.type == "大兴用地") { |
| | |
| | | z: 0, |
| | | }); |
| | | } |
| | | flyLine = sgworld.Creator.createPolyline( |
| | | window.flyLine = sgworld.Creator.createPolyline( |
| | | geometry, |
| | | "#ff0000", |
| | | 1, |