From 8cb1cdbee874842af44683dea8b0f0ff8087d0ea Mon Sep 17 00:00:00 2001 From: lixuliang <lixuliang_hd@126.com> Date: 星期四, 12 十月 2023 21:54:36 +0800 Subject: [PATCH] 更新 --- src/assets/js/rpc.js | 289 ++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 193 insertions(+), 96 deletions(-) diff --git a/src/assets/js/rpc.js b/src/assets/js/rpc.js index 939495f..337ca94 100644 --- a/src/assets/js/rpc.js +++ b/src/assets/js/rpc.js @@ -6,7 +6,8 @@ liushisijiayuanqudizhibianmafuwu, findAddressCandidates, getDiKuanFanWei, - ent_selectByName + ent_selectByName, + shengwuSearch } from "../../api/api"; import vueEvents from "@/utils/vueEvent.js"; let PoiLayerConstructor = Vue.extend(coord); @@ -25,9 +26,30 @@ pointerFly: null, //瀹氱偣婕父 isShow: false, objArr: [], + pointrange: null, + //鍏抽敭瀛楁煡璇� getFuzzyQuery(res) { - store.queryLayer.val = res.message; + if (res.message.indexOf('濂旈┌') > -1) { + store.queryLayer.val = '濂旈┌鍏徃' + } else if (res.message.indexOf('浜笢') > -1) { + store.queryLayer.val = '浜笢' + } else if (res.message.indexOf('灏忕背') > -1) { + store.queryLayer.val = '灏忕背' + } else if (res.message.indexOf('鍗氬ぇ') > -1) { + store.queryLayer.val = '鍗氬ぇ澶у帵' + } else if (res.message.indexOf('淇℃伅鎶�鏈�') > -1) { + store.queryLayer.val = '淇℃伅鎶�鏈�' + } else if (res.message.indexOf('鐢熺墿鍖昏嵂') > -1) { + store.queryLayer.val = '鐢熺墿鍖昏嵂' + } else if (res.message.indexOf('鏈哄櫒浜�') > -1) { + store.queryLayer.val = '鏈哄櫒浜�' + } else if (res.message.indexOf('姹借溅') > -1) { + store.queryLayer.val = '姹借溅' + } else { + store.queryLayer.val = res.message; + } + this.setClearAllMsg(); if (!res.baidu_keys) return; var flag = true; @@ -70,86 +92,150 @@ this.dataQuery = []; this.objArr = []; + this.pointrange = 2000; for (var i = 0; i < length; i++) { var world = keyWorld[i].word; - console.log("world", world); + if (world.indexOf('濂旈┌') > -1) { + world = '濂旈┌'; + this.pointrange = 12000 + } else if (world.indexOf('浜笢') > -1) { + world = '浜笢' + } else if (world.indexOf('灏忕背') > -1) { + world = '灏忕背' + } else if (world.indexOf('鍗氬ぇ澶у帵') > -1) { + world = '鍗氬ぇ澶у帵' + } else if (world.indexOf('淇℃伅鎶�鏈�') > -1) { + world = '淇℃伅鎶�鏈�' + } else if (world.indexOf('鐢熺墿鍖昏嵂') > -1) { + world = '鐢熺墿鍖昏嵂' + } else if (world.indexOf('鏈哄櫒浜�') > -1) { + world = '鏈哄櫒浜�' + } else if (world.indexOf('姹借溅') > -1) { + world = '姹借溅' + } this.setFuzzyQueryData(world, i, length - 1); } } }, async setFuzzyQueryData(res, index, length) { - Promise.all([ - ent_selectByName(res), //浼佷笟 - liushisijiayuanqudizhibianmafuwu(res), //鍥尯 - findAddressCandidates(res) //鍦板潡 - ]).then(result => { - var that = this; - store.queryLayer.data = []; - //浼佷笟 - var EntArr = result[0].result.filter(item => { - return item.entName.includes(res); - }); - EntArr.forEach(val => { - let itemObj = { - type: "浼佷笟", - name: val.entName, - address: val.address, - lon: val.x, - lat: val.y - }; - that.objArr.push(itemObj); - }); - //鍥尯 - var YQArr = result[1].candidates.filter(item => { - return item.attributes.YQmingchen.includes(res); - }); - YQArr.forEach(val => { - let itemObj = { - type: "鍥尯", - name: val.attributes.YQmingchen, - address: val.attributes.YQdizhi, - lon: val.location.x, - lat: val.location.y - }; - that.objArr.push(itemObj); - }); - //鍦板潡 - var LandArr = result[2].candidates.filter((item) => { - return item.attributes.QYMC.includes(res); - }) - // 缁撴灉鏍规嵁QYMC浠庣煭鍒伴暱鎺掑簭 - LandArr.sort((a, b) => (b.attributes.QYMC.length === a.attributes.QYMC.length ? 0 : a.attributes.QYMC.length > b.attributes.QYMC.length ? 1 : -1)) - LandArr.forEach((val) => { - let itemObj = { - type: "鍦板潡", - name: val.attributes.QYMC, - area: val.attributes.area, - code: val.attributes["鍦板潡缂�"], - lon: val.location.x, - lat: val.location.y, - }; - that.objArr.push(itemObj); - }); - if (index == length) { - if (that.objArr.length <= 0) { + if (res == "淇℃伅鎶�鏈�" || res == "鐢熺墿鍖昏嵂" || res == "鏈哄櫒浜�" || res == "姹借溅") { + shengwuSearch(res).then(result => { + var that = this; + result.features.forEach(val => { + let itemObj = { + type: "鍥尯", + name: val.properties.YQmingchen, + address: val.properties.YQdizhi, + lon: val.properties.longtitude, + lat: val.properties.latitude, + geom: val.geometry.coordinates[0].flat() - vueEvents.$emit("queryData", true); - return; - } - var num = that.objArr.length; - for (var i = 0; i < num; i++) { - if (i < 6) { - that.dataQuery.push(that.objArr[i]); + }; + that.objArr.push(itemObj); + }); + if (index == length) { + if (that.objArr.length <= 0) { + vueEvents.$emit("queryData", true); + return; } + var num = that.objArr.length; + for (var i = 0; i < num; i++) { + if (i < 6) { + that.dataQuery.push(that.objArr[i]); + } + } + store.queryLayer.data = that.dataQuery; + that.setClearAllMsg(); + setTimeout(() => { + vueEvents.$emit("queryData", true); + that.setLocation(that.dataQuery[0]); + }, 1000); } - store.queryLayer.data = that.dataQuery; - that.setClearAllMsg(); - setTimeout(() => { - vueEvents.$emit("queryData", true); - that.setLocation(that.dataQuery[0]); - }, 1000); - } - }); + }) + } else { + Promise.all([ + ent_selectByName(res), //浼佷笟 + liushisijiayuanqudizhibianmafuwu(res), //鍥尯 + findAddressCandidates(res),//鍦板潡, + ]).then(result => { + var that = this; + store.queryLayer.data = []; + //浼佷笟 + var EntArr = result[0].result.filter(item => { + return item.entName.includes(res); + }); + EntArr.forEach(val => { + let itemObj = { + type: "浼佷笟", + name: val.entName, + address: val.address, + lon: val.x, + lat: val.y + }; + that.objArr.push(itemObj); + }); + //鍥尯 + var YQArr = result[1].features.filter(item => { + return item.properties.YQmingchen.includes(res); + }); + + YQArr.forEach(val => { + let itemObj = { + type: "鍥尯", + name: val.properties.YQmingchen, + address: val.properties.YQdizhi, + lon: val.properties.longtitude, + lat: val.properties.latitude, + geom: val.geometry.coordinates[0].flat() + // lon: val.geometry.coordinates[0], + // lat: val.geometry.coordinates[1], + // geom: val.properties.Coor1 + val.properties.Coor2 + + }; + that.objArr.push(itemObj); + }); + //鍦板潡 + var LandArr = result[2].candidates.filter((item) => { + return item.attributes.QYMC.includes(res); + }) + // 缁撴灉鏍规嵁QYMC浠庣煭鍒伴暱鎺掑簭 + LandArr.sort((a, b) => (b.attributes.QYMC.length === a.attributes.QYMC.length ? 0 : a.attributes.QYMC.length > b.attributes.QYMC.length ? 1 : -1)) + LandArr.forEach((val) => { + let itemObj = { + type: "鍦板潡", + name: val.attributes.QYMC, + area: val.attributes.area, + code: val.attributes["鍦板潡缂�"], + lon: val.location.x, + lat: val.location.y, + }; + that.objArr.push(itemObj); + }); + + if (index == length) { + if (that.objArr.length <= 0) { + + vueEvents.$emit("queryData", true); + return; + } + var num = that.objArr.length; + for (var i = 0; i < num; i++) { + if (i < 6) { + that.dataQuery.push(that.objArr[i]); + } + } + store.queryLayer.data = that.dataQuery; + that.setClearAllMsg(); + setTimeout(() => { + vueEvents.$emit("queryData", true); + that.setLocation(that.dataQuery[0]); + }, 1000); + } + }); + } + + + }, getFuzzyQueryData(res, index, length, flag) { @@ -177,12 +263,18 @@ }, // 鏄剧ず鍦板潡鑼冨洿 getLandmass(res) { - let that = this; if (res.type == "鍥尯") { + this.setDrawPolyExtent(res.geom) - } else if (res.type == "鍦板潡") { + // var geom = res.geom.split(','); + // var coord = []; + // for (var i in geom) { + // coord.push(parseFloat(geom[i])) + // } + // this.setDrawPolyExtent(coord) + } else if (res.type == "鍦板潡" || res.type == "浼佷笟") { getDiKuanFanWei(res.lon, res.lat).then(response => { let center = { lon: 0, lat: 0 }; let polygon = that.read(response.geometry); @@ -196,27 +288,32 @@ geometry.push(parseFloat(point[0]), parseFloat(point[1])) } - that.setLacationLineClear() - var position = Cesium.Cartesian3.fromDegreesArray(geometry) - - that.lacationLine = Viewer.entities.add({ - name: "绔嬩綋澧欐晥鏋�", - wall: { - positions: position, - - - material: new Cesium.DynamicWallMaterialProperty({ - color: Cesium.Color.RED, - duration: 4000 - }), - // 璁剧疆楂樺害 - maximumHeights: Array(position.length).fill(80), - minimumHeights: Array(position.length).fill(10), - } - }) + that.setDrawPolyExtent(geometry) } }); } + }, + setDrawPolyExtent(res) { + this.setLacationLineClear() + var position = Cesium.Cartesian3.fromDegreesArray(res) + + this.lacationLine = Viewer.entities.add({ + name: "绔嬩綋澧欐晥鏋�", + wall: { + positions: position, + + + material: new Cesium.DynamicWallMaterialProperty({ + // color: new Cesium.Color.fromCssColorString('#73DB0E'), + color: new Cesium.Color.fromCssColorString('#1f1fa8'), + duration: 4000, + + }), + // 璁剧疆楂樺害 + maximumHeights: Array(position.length).fill(80), + minimumHeights: Array(position.length).fill(10), + } + }) }, read(wkt) { @@ -455,7 +552,7 @@ data.showLine = false; data.mode = 1; data.pitch = -10; - data.height = 75; + data.height = 500; data.speed = 25; that.LineRoaming = sgworld.Creator.createDynamicObject( @@ -538,7 +635,7 @@ ); this.position = window.Viewer.entities.add({ name: "FLYToMap", - position: Cesium.Cartesian3.fromDegrees(res.lon, res.lat, 200), + position: Cesium.Cartesian3.fromDegrees(res.lon, res.lat, 0), point: { pixelSize: 1, color: Cesium.Color.WHITE.withAlpha(0), @@ -548,9 +645,9 @@ }); window.Viewer.flyTo(this.position, { offset: { - heading: Cesium.Math.toRadians(0.0), + heading: Cesium.Math.toRadians(-200), pitch: Cesium.Math.toRadians(-45), - range: 700 + range: this.pointrange }, duration: 3 }); -- Gitblit v1.9.3