function drawCircle()
{
if(sceneControl.get_scene().get_trackingLayer3D().get_count()!=0)
{
sceneControl.get_scene().get_trackingLayer3D().removeAll();
}
var drawCircleAction = new SuperMap.Web.UI.Action3Ds.MyAction(sceneControl);
sceneControl.set_sceneAction(drawCircleAction);
}
/**************************** 绘制圆形 start ****************************/
SuperMap.Web.UI.Action3Ds.MyAction = function (sceneControl) {
SuperMap.Web.UI.Action3Ds.MyAction.initializeBase(this);
this._name = "myAction";
this._sceneControl = sceneControl;
this._type = SuperMap.Web.UI.Action3Ds.SceneActionType.POINTSELECT;
};
var drawEnd = true; //判断是否结束绘制图形
var isDrawing = false; //判断是否正在绘制图形
var point3D = null; //绘制图形的起始点
var geoBoundObj = null;
SuperMap.Web.UI.Action3Ds.MyAction.prototype = {
dispose: function () {
},
onMouseUp: function (e) {
},
onMouseDown: function (e) {
if (drawEnd)
{
var pt = new SuperMap.Pixel(e.get_clientX(), e.get_clientY());
var tempPoint = this._sceneControl.pixelToGlobe(pt, SuperMap.Web.Realspace.PixelToGlobeMode.TerrainAndModel);
point3D = new SuperMap.Web.Core.Point3D(tempPoint.x, tempPoint.y,tempPoint.z);
isDrawing = true;
drawEnd = false;
}
else {
drawEnd = true; //结束绘制
isDrawing = false; //绘制状态变为 false
pan();
}
},
onMouseMove: function (e) {
if (isDrawing && point3D != null) {
var pnt1 = point3D;
var pt = new SuperMap.Pixel(e.get_clientX(), e.get_clientY());
var tempPoint = this._sceneControl.pixelToGlobe(pt, 0);
var point1=pointConverter(pnt1);
var point2=pointConverter(tempPoint);
var R=Math.sqrt(Math.pow((point1.x-point2.x),2)+Math.pow((point1.y-point2.y),2));
var GeoCircle3D = new SuperMap.Web.Core.GeoCircle3D(R);
GeoCircle3D.set_position(pnt1);
var GeoModel = new SuperMap.Web.Core.GeoModel();
GeoModel=GeoCircle3D.getGeoModel(100,100);
var feature = new SuperMap.Web.Core.Feature3D();
feature.set_geometry(GeoModel);
var style = new SuperMap.Web.Core.Style3D();
style.set_fillForeColor(new SuperMap.Web.Core.Color(255, 0, 0, 180));
style.set_lineColor(new SuperMap.Web.Core.Color(0, 0, 255, 100));
style.set_lineWidth(1);
style.set_altitudeMode(0);
style.set_bottomAltitude(1000);
style.set_extendHeight(800);
feature.set_style3D(style);
this._sceneControl.get_scene().get_trackingLayer3D().removeAll(); //删除跟踪图层上的图像
this._sceneControl.get_scene().get_trackingLayer3D().add(feature, "GeoCircle3D");
this._sceneControl.get_scene().get_trackingLayer3D().refresh();
}
}
};
SuperMap.Web.UI.Action3Ds.MyAction.registerClass('SuperMap.Web.UI.Action3Ds.MyAction', SuperMap.Web.UI.Action3Ds.SceneAction, Sys.IDisposable);
function pan(){
//设置控件的当前操作为漫游
var panAction = new SuperMap.Web.UI.Action3Ds.Pan(sceneControl);
sceneControl.set_sceneAction(panAction);
}
/**************************** 绘制圆形 end ****************************/
//wgs84经纬度坐标转UTM投影坐标
function pointConverter(point3D)
{
var xy = new Array(2);
var zone = Math.floor ((point3D.x + 180.0) / 6) + 1;
zone = LatLonToUTMXY (DegToRad(point3D.y),DegToRad(point3D.x), zone, xy);
var point3Dnew=new SuperMap.Web.Core.Point3D(xy[0], xy[1], point3D.z);
return point3Dnew;
}
function DegToRad (deg)
{
return (deg / 180.0 * pi);
}
/*
* RadToDeg
*
* Converts radians to degrees.
*
*/
function RadToDeg (rad)
{
return (rad / pi * 180.0);
}