1
我一直在試圖在谷歌地圖上繪製多個圓圈。一個具有巨大半徑的外圈覆蓋了其中的所有其他圓圈和多個圓圈。當兩個較小的圓圈重疊時,我希望從交叉部分刪除alpha。這是我創建的屏幕截圖。 在谷歌地圖上繪製多個重疊的圓圈
下面是代碼:
var bounds = null;
var google_maps = null;
initialize();
function drawCircle(point, radius, dir) {
var d2r = Math.PI/180; // degrees to radians
var r2d = 180/Math.PI; // radians to degrees
var earthsradius = 3963; // 3963 is the radius of the earth in miles
var points = 32;
// find the raidus in lat/lon
var rlat = (radius/earthsradius) * r2d;
var rlng = rlat/Math.cos(point.lat() * d2r);
var extp = new Array();
if (dir==1) {var start=0;var end=points+1} // one extra here makes sure we connect the
else{var start=points+1;var end=0}
for (var i=start; (dir==1 ? i < end : i > end); i=i+dir)
{
var theta = Math.PI * (i/(points/2));
ey = point.lng() + (rlng * Math.cos(theta)); // center a + radius x * cos(theta)
ex = point.lat() + (rlat * Math.sin(theta)); // center b + radius y * sin(theta)
extp.push(new google.maps.LatLng(ex, ey));
bounds.extend(extp[extp.length-1]);
}
return extp;
}
function initialize()
{
var map_options = {
center: new google.maps.LatLng(17.385044,78.486671),
zoom: 15,
minZoom:9,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.SMALL
},
mapTypeId: google.maps.MapTypeId.ROADMAP
};
google_map = new google.maps.Map(document.getElementById("map_canvas"), map_options);
google_map.setOptions({styles: $scope.opt.styles});
bounds = new google.maps.LatLngBounds();
var myCircles = new google.maps.Polygon({
paths: [drawCircle(new google.maps.LatLng(17.385044,78.486671), 100, 1),
drawCircle(new google.maps.LatLng(17.385044,78.486671), 0.5, -1),
drawCircle(new google.maps.LatLng(17.383044,78.486671), 0.5, -1)],
strokeColor: "#bababa",
strokeOpacity: 0.4,
fillColor: "#bababa",
fillOpacity: 0.35
});
myCircles.setMap(google_map);
}
兩個圓的交集部分也必須transparent.Is有這樣做的可能性,我不能在互聯網上找到任何東西。