2013-02-06 49 views

回答

1

你應該檢查創建圍繞您的需求非常有趣的例子邁克·加扎的博客(Garzilla):http://www.garzilla.net/vemaps/CircleDragHandle.aspx

這裏是一個示例代碼來生成圓地點:

function buildCircle(latin, lonin, radius) { 
    var locs = new Array(); 
    var lat1 = latin * Math.PI/180.0; 
    var lon1 = lonin * Math.PI/180.0; 
    var d = radius/3956; 
    var x; 
    for (x = 0; x <= 360; x+=10) { 
     var tc = (x/90) * Math.PI/2; 
     var lat = Math.asin(Math.sin(lat1) * Math.cos(d) + Math.cos(lat1) * Math.sin(d) * Math.cos(tc)); 
     lat = 180.0 * lat/Math.PI; 
     var lon; 
     if (Math.cos(lat1) == 0) { 
      lon = lonin; // endpoint a pole 
     } 
     else { 
      lon = ((lon1 - Math.asin(Math.sin(tc) * Math.sin(d)/Math.cos(lat1)) + Math.PI) % (2 * Math.PI)) - Math.PI; 
     } 
     lon = 180.0 * lon/Math.PI; 
     var loc = new VELatLong(lat, lon); 
     locs.push(loc); 
    } 
    return locs; 
} 

而這裏的代碼添加它在地圖上,並使用以前的方法:

//Build circle   
circle = new VEShape(VEShapeType.Polygon, circlePoints);   
circle.HideIcon();   
circle.SetLineWidth(2);   
map.AddShape(circle); 
+0

驚人的,感謝您的幫助 –