求web gis 标绘实现思路?
想问一下如何定义单箭头,双箭头标绘控制点?
我的对象只有点,线
目前用贝塞尔曲线可以实现弧线。
[解决办法]
箭头要自己填写的
// 单个的
function arrowHead(p1,p2)
{
var dir = bearing(p1,p2);
var dir = Math.round(dir/3) * 3;
while (dir >= 120) {dir -= 120;}
arrowIcon.image = "http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png";
map.addOverlay(new GMarker(p2, arrowIcon));
}
//多个箭头
function midArrows(points)
{
for (var i=1; i < points.length; i++)
{
var p1=points[i-1];
var p2=points[i];
var dir = bearing(p1,p2);
var dir = Math.round(dir/3) * 3;
while (dir >= 120) {dir -= 120;}
arrowIcon.image = "http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png";
map.addOverlay(new GMarker(points[i], arrowIcon));
//alert(dir);
}
}
var degreesPerRadian = 180.0 / Math.PI;
function bearing( from, to )
{
var lat1 = from.latRadians();
var lon1 = from.lngRadians();
var lat2 = to.latRadians();
var lon2 = to.lngRadians();
var angle = - Math.atan2( Math.sin( lon1 - lon2 ) * Math.cos( lat2 ), Math.cos( lat1 ) * Math.sin( lat2 ) - Math.sin( lat1 ) * Math.cos( lat2 ) * Math.cos( lon1 - lon2 ) );
if ( angle < 0.0 )
angle += Math.PI * 2.0;
angle = angle * degreesPerRadian;
angle = angle.toFixed(1);
return angle;
}