您好,登錄后才能下訂單哦!
這個有現(xiàn)成的代碼,把代碼做一個簡要的說明,具體實(shí)現(xiàn)效果,是在TE的地圖畫一個餅狀圖。
<script type="text/javascript">
function createpie() {
//設(shè)置簡單參數(shù),包括半徑等參數(shù)
var sum = 0;
var radius = 100;
var angle = 0;
var i;
//根據(jù)餅狀圖的分塊,設(shè)置不同的顏色
var color = [0x0000a0, 0x00ff60, 0x8000a0, 0xa0ff00, 0xff00ff, 0xff2000, 0x20c080, 0x402020, 0x8020a0, 0xff6060, 0xc0ffff, 0xff6060, 0x800040, 0xa00020];
for (i = 1; i < 10; i++) {
sum += i;
}
//選擇中心的位置,也可以自定義進(jìn)行設(shè)置
var cenpoint = SGWorld.Window.CenterPixelToWorld(0);
var cpoint = cenpoint.Position;
var sx = SGWorld.CoordServices.MoveCoord(cpoint.X, cpoint.Y, radius, 0).X;
var sy = SGWorld.CoordServices.MoveCoord(cpoint.X, cpoint.Y, radius, 0).Y;
//根據(jù)每塊的比例,設(shè)置旋轉(zhuǎn)的角度,在polygon添加點(diǎn)
for (i = 1; i < 10; i++) {
var color1 = color[i];
var langle = angle + parseFloat(i) / parseFloat(sum) * 360;
var east = radius * Math.cos(2 * Math.PI * langle / 360);
var north = radius * Math.sin(2 * Math.PI * langle / 360);
var movcod = SGWorld.CoordServices.MoveCoord(cpoint.X, cpoint.Y, east, north);
var polygon = "POLYGON((" + cpoint.X.toString() + " " + cpoint.Y.toString() + "," + sx.toString() + " " + sy.toString();
var spl = (langle - angle) / 2;
for (var j = 0; j < spl; j++) {
var sinint = Math.sin((angle + j * 2) * Math.PI / 180) * radius;
var cosint = Math.cos((angle + j * 2) * Math.PI / 180) * radius;
var movcodspl = SGWorld.CoordServices.MoveCoord(cpoint.X, cpoint.Y, cosint, sinint);
polygon += "," + movcodspl.X.toString() + " " + movcodspl.Y.toString();
}
polygon += "," + movcod.X.toString() + " " + movcod.Y.toString() + "," + cpoint.X.toString() + " " + cpoint.Y.toString() + "))";
var igeometry = SGWorld.Creator.GeometryCreator.CreateGeometryFromWKT(polygon);
//根據(jù)點(diǎn)創(chuàng)建polygon
var ipolygon = SGWorld.Creator.CreatePolygon(igeometry, color1, color1, 0, 0, "polygon");
ipolygon.FillStyle.Color.SetAlpha(0.5);
sx = movcod.X;
sy = movcod.Y;
angle = langle;
}
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。