js开发中,做地图用到百度地图,API中怎么让椭圆倾斜

如题所述

根据网上的代码,利用Polygon绘制覆盖物,方法如下
function createSectorArea(point2, radius, sDegree, eDegree, strokeColour, strokeWeight, Strokepacity, fillColour, fillOpacity, opts){

var points = [];

var step = ((eDegree - sDegree) / 50) || 50;

points.push(point2);

for (var i = sDegree; i < eDegree + 0.0001; i += step) {

points.push(EOffsetBearing(point2, radius, i));

}

points.push(point2);

var polygon = new BMap.Polygon(

points , {strokeColor:strokeColour, strokeWeight:strokeWeight, strokeOpacity:Strokepacity, fillColor: fillColour, fillOpacity:fillOpacity});

return polygon;

}

function EOffsetBearing(point3, dist, bearing) {

var latConv = map.getDistance(point3, new BMap.Point(point3.lng + 0.01, point3.lat)) * <font color="#00ff00">50</font>;

var lngConv = map.getDistance(point3, new BMap.Point(point3.lng, point3.lat + 0.01)) * <font color="#00ff00">50</font>;

var lat = dist * Math.cos(bearing * Math.PI / 180) / latConv;

var lng = dist * Math.sin(bearing * Math.PI / 180) / lngConv;

return new BMap.Point(point3.lng + lng, point3.lat + lat);

}追问

这个样子,就是那种垂直或者水平的,要能实现那种倾斜45度角的。。

温馨提示:答案为网友推荐,仅供参考
相似回答