From 4aa41941b8f3ebb2c5524035ff6d2d8207c62ab6 Mon Sep 17 00:00:00 2001 From: TreeWish <1131093754@qq.com> Date: 星期一, 06 三月 2023 15:23:20 +0800 Subject: [PATCH] 空间查询线面附件 --- src/components/MapView/mapSpacePop.vue | 174 ++++++++++++++++++++++++++------------------------------- 1 files changed, 79 insertions(+), 95 deletions(-) diff --git a/src/components/MapView/mapSpacePop.vue b/src/components/MapView/mapSpacePop.vue index 21f78e7..0ba1b6c 100644 --- a/src/components/MapView/mapSpacePop.vue +++ b/src/components/MapView/mapSpacePop.vue @@ -192,7 +192,6 @@ // this.getTableselectFields(); // this.restSpacePopLayer(); }, - }, created() { this.spaceLayer = this.$store.state.mapSpaceQueryLayer @@ -411,83 +410,80 @@ } var coord = res.coordinates - if (res.type == "Point") { - var val = Cesium.Cartesian3.fromDegrees( - res.coordinates[0], - res.coordinates[1] - ) - this.$store.state.primitLayer = Viewer.entities.add({ - properties: properties, - tag: "properties_point", - position: val, - billboard: { - // 鍥惧儚鍦板潃锛孶RI鎴朇anvas鐨勫睘鎬� - image: SmartEarthRootUrl + "Workers/image/mark.png", - heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, - // 澶у皬鏄惁浠ョ背涓哄崟浣� - sizeInMeters: false, - // 鐩稿浜庡潗鏍囩殑鍨傜洿浣嶇疆 - verticalOrigin: Cesium.VerticalOrigin.CENTER, - // 鐩稿浜庡潗鏍囩殑姘村钩浣嶇疆 - horizontalOrigin: Cesium.HorizontalOrigin.LEFT, - // 搴旂敤浜庡浘鍍忕殑缁熶竴姣斾緥銆傛瘮渚嬪ぇ浜庝細1.0鏀惧ぇ鏍囩锛岃�屾瘮渚嬪皬浜庝細1.0缂╁皬鏍囩銆� - scale: 1.0, - // 鏄惁鏄剧ず - show: true, - }, - }) - this.$store.state.primitLayer.billboard.disableDepthTestDistance = - Number.POSITIVE_INFINITY + switch (res.type) { + case "Point": + var val = Cesium.Cartesian3.fromDegrees( + res.coordinates[0], + res.coordinates[1] + ) + var point = Viewer.entities.add({ + properties: properties, + tag: "properties_point", + position: val, + billboard: { + // 鍥惧儚鍦板潃锛孶RI鎴朇anvas鐨勫睘鎬� + image: SmartEarthRootUrl + "Workers/image/mark.png", + heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, + // 澶у皬鏄惁浠ョ背涓哄崟浣� + sizeInMeters: false, + // 鐩稿浜庡潗鏍囩殑鍨傜洿浣嶇疆 + verticalOrigin: Cesium.VerticalOrigin.CENTER, + // 鐩稿浜庡潗鏍囩殑姘村钩浣嶇疆 + horizontalOrigin: Cesium.HorizontalOrigin.LEFT, + // 搴旂敤浜庡浘鍍忕殑缁熶竴姣斾緥銆傛瘮渚嬪ぇ浜庝細1.0鏀惧ぇ鏍囩锛岃�屾瘮渚嬪皬浜庝細1.0缂╁皬鏍囩銆� + scale: 1.0, + // 鏄惁鏄剧ず + show: true, + }, + }) + point.billboard.disableDepthTestDistance = Number.POSITIVE_INFINITY + this.$store.state.queryInfo.push(point) + sgworld.Navigate.flyToObj(point) + this.$store.state.primitLayer = point - sgworld.Navigate.flyToObj(this.$store.state.primitLayer) - } else if (res.type == "MultiPolygon" || res.type == "LineString") { - var val = res.coordinates[0][0] - var std = [] - for (var i in val) { - std.push(val[i][0]) - - std.push(val[i][1]) - } - - this.$store.state.primitLayer = Viewer.entities.add({ - properties: properties, - tag: "properties_line", - - polyline: { - positions: Cesium.Cartesian3.fromDegreesArray(std), - width: 5, - material: new Cesium.Color(1.0, 0.0, 0.0, 0.3), - clampToGround: true, - }, - }) - - // this.$store.state.primitLayer = sgworld.Creator.createPolygon(std, { - // fillColor: '#ffff00', - // outlineColor: '#fff', - // outlineWidth: 2 - // }, 1, 0, "闈�"); - sgworld.Navigate.flyToObj(this.$store.state.primitLayer) - } else if (res.type == "MultiLineString") { - var line = res.coordinates[0] - var std = [] - for (var i in line) { - std.push({ x: line[i][0], y: line[i][1], z: 1000 }) - } - const polyline = sgworld.Creator.createPolyline( - std, - "#ffff00", - 1, - 0, - "绾�" - ) - const entity = polyline.item - entity.properties = properties - entity.tag = "properties_line" - - - this.$store.state.primitLayer = polyline - - sgworld.Navigate.flyToObj(entity) + break + case "LineString": + case "MultiLineString": + var line = res.coordinates[0] + var std = [] + for (var i in line) { + std.push(line[i][0], line[i][1]) + } + var polyline = Viewer.entities.add({ + properties: properties, + tag: "properties_line", + polyline: { + positions: Cesium.Cartesian3.fromDegreesArray(std), + width: 5, + material: new Cesium.Color(1.0, 0.0, 0.0, 0.3), + clampToGround: true, + }, + }) + this.$store.state.queryInfo.push(polyline) + sgworld.Navigate.flyToObj(polyline) + this.$store.state.primitLayer = polyline + break + case "MultiPolygon": + var val = res.coordinates[0][0] + var std = [] + for (var i in val) { + std.push(val[i][0], val[i][1]) + } + var entity = Viewer.entities.add({ + properties: properties, + tag: "properties_polygon", + polygon: { + hierarchy: Cesium.Cartesian3.fromDegreesArray(std), + //height : 100000, + material: new Cesium.Color(1.0, 0.0, 0.0, 0.3), + outline: true, + outlineColor: new Cesium.Color(1.0, 0.0, 0.0, 0.3), + }, + }) + this.$store.state.queryInfo.push(entity) + sgworld.Navigate.flyToObj(entity) + this.$store.state.primitLayer = entity + break } this.setMapHandler() }, @@ -497,24 +493,12 @@ ) window.propertieshandler.setInputAction(event => { let pick = sgworld.Viewer.scene.pick(event.position) - // ; - - if (pick && pick.id && pick.id.tag == "properties_point") { - this.$store.state.propertiesFlag = "1" - let properties = pick.id.properties - let propertyNames = pick.id.properties.propertyNames - let obj = {} - obj["eventid"] = properties["_eventid"]._value - // - this.attributeData.forEach(item => { - propertyNames.forEach(itemElement => { - if (itemElement == item.field) { - obj[item.alias] = properties[itemElement]._value - } - }) - }) - this.$store.state.propertiesInfo = obj - } else if (pick && pick.id && pick.id._polyline && pick.id.tag == "properties_line") { + if ( + pick && + pick.id && + pick.id.tag && + pick.id.tag.includes("properties_") + ) { this.$store.state.propertiesFlag = "1" let properties = pick.id.properties let propertyNames = pick.id.properties.propertyNames -- Gitblit v1.9.3