Anyone know if something like this can be filled with a color /
opacity?
function drawSector(lat,lng,r,azimuth,width) {
//Degrees to radians
var d2r = Math.PI / 180;
// Radians to degrees
var r2d = 180 / Math.PI;
var centerPoint = new google.maps.LatLng(lat,lng);
var PRlat = (r/3963) * r2d; // using 3963 miles as earth's
radius
var PRlng = PRlat/Math.cos(lat*d2r);
var PGpoints = [];
PGpoints.push(centerPoint);
with (Math) {
lat1 = lat + (PRlat * cos( d2r * (azimuth - width/2 )));
lon1 = lng + (PRlng * sin( d2r * (azimuth - width/2 )));
PGpoints.push( new google.maps.LatLng(lat1,lon1));
lat2 = lat + (PRlat * cos( d2r * (azimuth + width/2 )));
lon2 = lng + (PRlng * sin( d2r * (azimuth + width/2 )));
var theta = 0;
var gamma = d2r * (azimuth + width/2 );
for (var a = 1; theta < gamma ; a++ ) {
theta = d2r * (azimuth - width/2 +a);
PGlon = lng + (PRlng * sin( theta ));
PGlat = lat + (PRlat * cos( theta ));
PGpoints.push(new
google.maps.LatLng(PGlat,PGlon));
}
PGpoints.push( new google.maps.LatLng(lat2,lon2));
PGpoints.push(centerPoint);
}
var poly = new google.maps.Polyline({map: map, path:
PGpoints, strokeColor: "#00ff00", strokeOpacity: 1.0,
strokeWeight: 2 });
poly.setMap(map);
return poly;
}
If you use Polygon instead of Polyline you get additional options.
http://code.google.com/apis/maps/documentation/javascript/reference.html#PolygonOptions
Joe
On Dec 14, 12:15 pm, Andrew Leach <andrew.leac...@gmail.com> wrote:
> On 14 December 2011 19:44, subversionpdx <subversion...@gmail.com> wrote:
>
> > Updated someone else's previous example of this for Google Maps API V3
>
> > Anyone know if something like this can be filled with a color /
> > opacity?
>
> > var poly = new google.maps.Polyline({map: map, path:
> > PGpoints, strokeColor: "#00ff00", strokeOpacity: 1.0,
> > strokeWeight: 2 });
>
> If you use Polygon instead of Polyline you get additional options.
>
> http://code.google.com/apis/maps/documentation/javascript/reference.h...