| | |
| | | 'viewer': viewer, //全局Cesium对象 |
| | | }; |
| | | CesiumDraw.clearDraw(options); |
| | | } |
| | | |
| | | 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": lng, |
| | | "latitude": lat, |
| | | "height": alt, |
| | | } |
| | | } |
| | | else if(type=='polyline'||type=='polygon'){ |
| | | let longitudeList=[],latitudeList=[],heightList=[] |
| | | for(let i=0;i<drawEntity.length;i++){ |
| | | 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(), |
| | | "height": heightList.toString(), |
| | | } |
| | | } |
| | | else if(type=='label'){ |
| | | saveData= { |
| | | "id":id, |
| | | "type": type, |
| | | "longitude": lng, |
| | | "latitude": lat, |
| | | "height": alt, |
| | | "content":drawEntity.title, |
| | | "color":drawEntity._label._fillColor._value.toCssColorString(), |
| | | "fontsize":30, |
| | | "fontstyle":'SimSun', |
| | | } |
| | | } |
| | | |
| | | let token = window.localStorage.getItem("token"); |
| | | $.ajax({ |
| | | type: "get", |
| | | async: false, |
| | | url: parent.httpConfig.webApiUrl + "landstamp/front/addDrawEntity", |
| | | data: saveData, |
| | | contentType: "application/json;charset=utf-8", |
| | | beforeSend:function(request){ |
| | | request.setRequestHeader("token",token); |
| | | }, |
| | | success: function (data) { |
| | | console.log(data) |
| | | }, |
| | | error: function (XMLHttpRequest, textStatus, errorThrown) { |
| | | console.log("ajax请求失败!"); |
| | | } |
| | | }); |
| | | } |