From 585932b46cb2dda666453a493f68cb47d3a5ccd5 Mon Sep 17 00:00:00 2001 From: ansel0926 <ansel0926@gmail.com> Date: 星期二, 17 五月 2022 19:19:33 +0800 Subject: [PATCH] 提交 --- assets/service/drawService.js | 47 +++++++++++++++++++++++++++++++++++++---------- 1 files changed, 37 insertions(+), 10 deletions(-) diff --git a/assets/service/drawService.js b/assets/service/drawService.js index 7378e00..6ac310c 100644 --- a/assets/service/drawService.js +++ b/assets/service/drawService.js @@ -44,6 +44,21 @@ CesiumDraw.drawLabel(options); } +function drawText(text) { + var options = { + 'viewer': viewer, + 'label': { + 'text': text, + 'font': '30px SimSun', + 'fillColor': Cesium.Color.RED, + 'outlineColor': Cesium.Color.BLACK, + 'outlineWidth': 2, + 'style': Cesium.LabelStyle.FILL_AND_OUTLINE, + 'scaleByDistance': new Cesium.NearFarScalar(100, 1.0, 200, 0.4) + }, + } + CesiumDraw.drawText(options); +} function clearDraw() { var options = { 'viewer': viewer, //鍏ㄥ眬Cesium瀵硅薄 @@ -54,36 +69,48 @@ function saveDrawEntity(type,drawEntity,id){//zzf:淇濆瓨缁樺埗鐨勫浘褰� let saveData; if(type=='point'){ + var cartographic=Cesium.Cartographic.fromCartesian(drawEntity._position._value); + var lng=Cesium.Math.toDegrees(cartographic.longitude); + var lat=Cesium.Math.toDegrees(cartographic.latitude); + var alt=cartographic.height; saveData= { "id":id, "type": type, - "longitude": drawEntity._position._value.x, - "latitude": drawEntity._position._value.y, - "height": drawEntity._position._value.z, + "longitude": lng, + "latitude": lat, + "height": alt, } } else if(type=='polyline'||type=='polygon'){ let longitudeList=[],latitudeList=[],heightList=[] for(let i=0;i<drawEntity.length;i++){ - longitudeList.push(drawEntity[i]._position._value.x) - latitudeList.push(drawEntity[i]._position._value.y) - heightList.push(drawEntity[i]._position._value.z) + var cartographic=Cesium.Cartographic.fromCartesian(drawEntity[i]._position._value); + var lng=Cesium.Math.toDegrees(cartographic.longitude); + var lat=Cesium.Math.toDegrees(cartographic.latitude); + var alt=cartographic.height; + longitudeList.push(lng) + latitudeList.push(lat) + heightList.push(alt) } saveData= { "id":id, "type": type, "longitude": longitudeList.toString(), - "latitude":latitudeList.toString(), + "latitude": latitudeList.toString(), "height": heightList.toString(), } } else if(type=='label'){ + var cartographic=Cesium.Cartographic.fromCartesian(drawEntity._position._value); + var lng=Cesium.Math.toDegrees(cartographic.longitude); + var lat=Cesium.Math.toDegrees(cartographic.latitude); + var alt=cartographic.height; saveData= { "id":id, "type": type, - "longitude": drawEntity._position._value.x, - "latitude": drawEntity._position._value.y, - "height": drawEntity._position._value.z, + "longitude": lng, + "latitude": lat, + "height": alt, "content":drawEntity.title, "color":drawEntity._label._fillColor._value.toCssColorString(), "fontsize":30, -- Gitblit v1.9.1