GoogleMap中扩展图形的画法

最近在帮一个朋友在GoogleMap上画扇形,GoogleMap本身不提供这种画法,所以需要自己去实现,无赖原来学过的数学也忘记的差不多了,只能求助网络。

国外有一个高手写了一个扩展,地址是:http://econym.org.uk/gmap/eshapes.htm

但里面没有扇形的画法,在此基础上自己增加了扇形的画法:

GoogleMap中扩展图形的画法

GPolyline扩展方法:

GPolyline.Sector = function(point, radius, sDegree, eDegree, colour, weight, opacity,opts) {
    var points = [];
    var step = ((eDegree - sDegree) / 10) || 10;
       
    points.push(point);
    for(var i=sDegree;i
        points.push(EOffsetBearing(point,radius,i));                                 
    }
    points.push(point);
       
    return new GPolyline(points, colour, weight, opacity, opts);
}

GPolygon扩展方法:

GPolygon.Sector = function(point, radius, sDegree, eDegree, strokeColour, strokeWeight,Strokepacity, fillColour, fillOpacity, opts) {
        var points = [];
        var step = ((eDegree - sDegree) / 10) || 10;
       
        points.push(point);
        for(var i=sDegree;i
            points.push(EOffsetBearing(point,radius,i));                                 
        }
        points.push(point);
       
        return new GPolygon(points, strokeColour, strokeWeight,Strokepacity, fillColour, fillOpacity, opts);
    }

拓展圆角矩形的方法:

 map.addOverlay(GPolyline.Sector(new GLatLng(37.014250000000004,104.24046899999999),30000,-90,0,"#000000",3,1,"#00ff00",0.5));
   map.addOverlay(GPolyline.Sector(new GLatLng(37.014250000000004,105.17796899999999),30000,0,90,"#000000",3,1,"#00ff00",0.5));
   map.addOverlay(GPolyline.Sector(new GLatLng(36.275969,105.17796899999999),30000,90,180,"#000000",3,1,"#00ff00",0.5));
   map.addOverlay(GPolyline.Sector(new GLatLng(36.275969,104.24046899999999),30000,180,270,"#000000",3,1,"#00ff00",0.5));

效果如下:

GoogleMap中扩展图形的画法

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值