|
@@ -37,6 +37,7 @@ import SetLocation from "../units/map/SetLocation.js";
|
|
import GeometryMeshPrismEffect from "../units/map/GeometryMeshPrismEffect.js";
|
|
import GeometryMeshPrismEffect from "../units/map/GeometryMeshPrismEffect.js";
|
|
import ReRenderingEvent from "../units/map/ReRenderingEvent.js";
|
|
import ReRenderingEvent from "../units/map/ReRenderingEvent.js";
|
|
import PathPipeEvent from "../units/map/PathPipeEvent.js";
|
|
import PathPipeEvent from "../units/map/PathPipeEvent.js";
|
|
|
|
+import FlyGLTFEvent from "../units/map/FlyGLTFEvent.js";
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "mapJK",
|
|
name: "mapJK",
|
|
@@ -58,6 +59,7 @@ export default {
|
|
let limitHeightAnalysisEvent = null;
|
|
let limitHeightAnalysisEvent = null;
|
|
let reRenderingEvent = null;
|
|
let reRenderingEvent = null;
|
|
let pathPipeEvent = null;
|
|
let pathPipeEvent = null;
|
|
|
|
+ let flyGLTFEvent = null;
|
|
onMounted(() =>{
|
|
onMounted(() =>{
|
|
bus.on('CreateMap',() =>{
|
|
bus.on('CreateMap',() =>{
|
|
MapReady = $.Deferred();
|
|
MapReady = $.Deferred();
|
|
@@ -147,6 +149,9 @@ export default {
|
|
case "ThreeGrid":
|
|
case "ThreeGrid":
|
|
threeGrid(params);
|
|
threeGrid(params);
|
|
break;
|
|
break;
|
|
|
|
+ case "RealPositionGrid":
|
|
|
|
+ realPositionGrid(params);
|
|
|
|
+ break;
|
|
case "LimitHeightAnalysis":
|
|
case "LimitHeightAnalysis":
|
|
limitHeightAnalysis(params);
|
|
limitHeightAnalysis(params);
|
|
break;
|
|
break;
|
|
@@ -156,6 +161,9 @@ export default {
|
|
case "PathPipe":
|
|
case "PathPipe":
|
|
pathPipe(params);
|
|
pathPipe(params);
|
|
break;
|
|
break;
|
|
|
|
+ case "FlyGLTF":
|
|
|
|
+ flyGLTF(params);
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function setBackground(params){
|
|
function setBackground(params){
|
|
@@ -414,9 +422,10 @@ export default {
|
|
m_handles.add(addScaleEvent.scaleHandle,scale_handle_id);
|
|
m_handles.add(addScaleEvent.scaleHandle,scale_handle_id);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- function getEyeExtent(){
|
|
|
|
|
|
+ function getEyeExtent() {
|
|
const screenWidth = m_view.width;
|
|
const screenWidth = m_view.width;
|
|
const screenHeight = m_view.height;
|
|
const screenHeight = m_view.height;
|
|
|
|
+
|
|
// 四个角的像素坐标
|
|
// 四个角的像素坐标
|
|
const screenCorners = [
|
|
const screenCorners = [
|
|
{ x: 0, y: 0 }, // 左上角
|
|
{ x: 0, y: 0 }, // 左上角
|
|
@@ -425,35 +434,58 @@ export default {
|
|
{ x: 0, y: screenHeight }, // 左下角
|
|
{ x: 0, y: screenHeight }, // 左下角
|
|
];
|
|
];
|
|
|
|
|
|
- const mapPoints = screenCorners.map((screenPoint) => {
|
|
|
|
- return m_view.toMap(screenPoint);
|
|
|
|
- });
|
|
|
|
- mapPoints.forEach((item)=>{
|
|
|
|
- if(item == null || item == undefined){
|
|
|
|
- return false;
|
|
|
|
|
|
+ // 将屏幕角坐标转为地图坐标
|
|
|
|
+ const mapPoints = screenCorners.map((screenPoint) => m_view.toMap(screenPoint)).filter(p => p);
|
|
|
|
+
|
|
|
|
+ // 添加 camera.position 到 mapPoints
|
|
|
|
+ const cameraPoint = m_view.camera.position;
|
|
|
|
+
|
|
|
|
+ if (mapPoints.length < 4) {
|
|
|
|
+ if (cameraPoint) {
|
|
|
|
+ const bufferDistance = 2000; // 2公里
|
|
|
|
+ const spatialReference = m_view.spatialReference;
|
|
|
|
+
|
|
|
|
+ const screenExtent = {
|
|
|
|
+ xmin: cameraPoint.x - bufferDistance,
|
|
|
|
+ ymin: cameraPoint.y - bufferDistance,
|
|
|
|
+ xmax: cameraPoint.x + bufferDistance,
|
|
|
|
+ ymax: cameraPoint.y + bufferDistance,
|
|
|
|
+ spatialReference: spatialReference,
|
|
|
|
+ };
|
|
|
|
+ console.warn("视图范围不足4个有效点,使用摄像机位置生成的2公里范围。");
|
|
|
|
+ console.log(screenExtent);
|
|
|
|
+ return screenExtent;
|
|
|
|
+ } else {
|
|
|
|
+ console.warn("无法获取摄像机位置,请检查视图状态。");
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
- })
|
|
|
|
- try{
|
|
|
|
- // 获取最小和最大坐标值
|
|
|
|
- const xmin = Math.min(...mapPoints.map((p) => p.x));
|
|
|
|
- const ymin = Math.min(...mapPoints.map((p) => p.y));
|
|
|
|
- const xmax = Math.max(...mapPoints.map((p) => p.x));
|
|
|
|
- const ymax = Math.max(...mapPoints.map((p) => p.y));
|
|
|
|
- const screenExtent = {
|
|
|
|
- xmin: xmin,
|
|
|
|
- ymin: ymin,
|
|
|
|
- xmax: xmax,
|
|
|
|
- ymax: ymax,
|
|
|
|
- spatialReference: m_view.spatialReference,
|
|
|
|
- };
|
|
|
|
- console.log(screenExtent);
|
|
|
|
- return screenExtent
|
|
|
|
- }catch (e){
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+ try {
|
|
|
|
+ // 获取最小和最大坐标值
|
|
|
|
+ const xmin = Math.min(...mapPoints.map((p) => p.x));
|
|
|
|
+ const ymin = Math.min(...mapPoints.map((p) => p.y));
|
|
|
|
+ const xmax = Math.max(...mapPoints.map((p) => p.x));
|
|
|
|
+ const ymax = Math.max(...mapPoints.map((p) => p.y));
|
|
|
|
|
|
|
|
+ const screenExtent = {
|
|
|
|
+ xmin: xmin,
|
|
|
|
+ ymin: ymin,
|
|
|
|
+ xmax: xmax,
|
|
|
|
+ ymax: ymax,
|
|
|
|
+ spatialReference: m_view.spatialReference,
|
|
|
|
+ };
|
|
|
|
+ console.log(screenExtent);
|
|
|
|
+ return screenExtent;
|
|
|
|
+ } catch (e) {
|
|
|
|
+ console.error("获取地图范围时出错:", e);
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
function showLayersWithScaleEventsReturn(scaleValue){
|
|
function showLayersWithScaleEventsReturn(scaleValue){
|
|
let eyeExtent = getEyeExtent();
|
|
let eyeExtent = getEyeExtent();
|
|
if(!eyeExtent){
|
|
if(!eyeExtent){
|
|
@@ -476,6 +508,8 @@ export default {
|
|
addThreeGridEvent.height = height>1200?1200:height;
|
|
addThreeGridEvent.height = height>1200?1200:height;
|
|
addThreeGridEvent.size = size;
|
|
addThreeGridEvent.size = size;
|
|
addThreeGridEvent.layerHeight = layerHeight;
|
|
addThreeGridEvent.layerHeight = layerHeight;
|
|
|
|
+ addThreeGridEvent.gridEnabled = true;
|
|
|
|
+ addThreeGridEvent.netEnabled = true;
|
|
addThreeGridEvent.start();
|
|
addThreeGridEvent.start();
|
|
}else{
|
|
}else{
|
|
addThreeGridEvent = new AddThreeGridEvent({
|
|
addThreeGridEvent = new AddThreeGridEvent({
|
|
@@ -483,6 +517,8 @@ export default {
|
|
extent: {minX:eyeExtent.xmin,maxX:eyeExtent.xmax,minY:eyeExtent.ymin,maxY:eyeExtent.ymax},
|
|
extent: {minX:eyeExtent.xmin,maxX:eyeExtent.xmax,minY:eyeExtent.ymin,maxY:eyeExtent.ymax},
|
|
height:height>1200?1200:height,
|
|
height:height>1200?1200:height,
|
|
size:size,
|
|
size:size,
|
|
|
|
+ gridEnabled : true,
|
|
|
|
+ netEnabled : true,
|
|
layerHeight:layerHeight,
|
|
layerHeight:layerHeight,
|
|
})
|
|
})
|
|
addThreeGridEvent.start();
|
|
addThreeGridEvent.start();
|
|
@@ -577,6 +613,8 @@ export default {
|
|
addThreeGridEvent.size = params.size;
|
|
addThreeGridEvent.size = params.size;
|
|
addThreeGridEvent.layerHeight = params.layerHeight;
|
|
addThreeGridEvent.layerHeight = params.layerHeight;
|
|
addThreeGridEvent.animationEnabled = animationEnabled;
|
|
addThreeGridEvent.animationEnabled = animationEnabled;
|
|
|
|
+ addThreeGridEvent.gridEnabled = true;
|
|
|
|
+ addThreeGridEvent.netEnabled = true;
|
|
addThreeGridEvent.start();
|
|
addThreeGridEvent.start();
|
|
}else{
|
|
}else{
|
|
addThreeGridEvent = new AddThreeGridEvent({
|
|
addThreeGridEvent = new AddThreeGridEvent({
|
|
@@ -585,11 +623,19 @@ export default {
|
|
height : params.height,
|
|
height : params.height,
|
|
size : params.size,
|
|
size : params.size,
|
|
layerHeight :params.layerHeight,
|
|
layerHeight :params.layerHeight,
|
|
|
|
+ gridEnabled:true,
|
|
|
|
+ netEnabled:true,
|
|
animationEnabled
|
|
animationEnabled
|
|
})
|
|
})
|
|
addThreeGridEvent.start();
|
|
addThreeGridEvent.start();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ function realPositionGrid(params){
|
|
|
|
+ let status = params.status;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
function limitHeightAnalysis(params){
|
|
function limitHeightAnalysis(params){
|
|
let status = params.status;
|
|
let status = params.status;
|
|
if(limitHeightAnalysisEvent){
|
|
if(limitHeightAnalysisEvent){
|
|
@@ -637,7 +683,6 @@ export default {
|
|
if(status == "hide"){
|
|
if(status == "hide"){
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- debugger
|
|
|
|
pathPipeEvent = new PathPipeEvent({
|
|
pathPipeEvent = new PathPipeEvent({
|
|
view:m_view,
|
|
view:m_view,
|
|
paths:params.paths,
|
|
paths:params.paths,
|
|
@@ -646,6 +691,25 @@ export default {
|
|
});
|
|
});
|
|
pathPipeEvent.start()
|
|
pathPipeEvent.start()
|
|
}
|
|
}
|
|
|
|
+ function flyGLTF(params){
|
|
|
|
+ let status = params.status;
|
|
|
|
+ if(flyGLTFEvent){
|
|
|
|
+ flyGLTFEvent.clear();
|
|
|
|
+ flyGLTFEvent = null;
|
|
|
|
+ }
|
|
|
|
+ if(status == "hide"){
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ flyGLTFEvent = new FlyGLTFEvent({
|
|
|
|
+ view:m_view,
|
|
|
|
+ path:params.paths,
|
|
|
|
+ speed:0.0001
|
|
|
|
+ })
|
|
|
|
+ flyGLTFEvent.start();
|
|
|
|
+ if(params.isFollow){
|
|
|
|
+ flyGLTFEvent.followPath();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
})
|
|
})
|
|
}
|
|
}
|
|
}
|
|
}
|