如何在Google地图中组合圈子 [英] How to combine circles in Google Maps

查看:113
本文介绍了如何在Google地图中组合圈子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够使用javascript在Google地图上绘制多个圆圈,但将它们组合为单一形状,以便它们的区域不会重叠,但会共享。例如,我在WalkScore.com上找到了这个例子:

I would like to be able to draw multiple circles on a Google Map with javascript, but combine them as a "single shape" so that their areas don't overlap, but are shared. For example, I found this example at WalkScore.com:

您可以看到它们是组合圆形,而不是将它们重叠为单独的形状。

You can see that they are COMBINING circles, instead of overlapping them as separate shapes.

这可能吗? (显然它似乎是,但是如何?)

Is this possible? (Clearly it seems to be, but how?)

推荐答案

您可以使用所述的多边形在其他地方

You can use a Polygon as stated here.

检查此小提琴在该解决方案中受到启发。

Check this fiddle inspired in that solution.

最重要的部分结合圈子:

The most important part is combining the circles:

var joined = new google.maps.Polygon({
    paths: [drawCircle(smallOne, 150/1609.344, 1),
            drawCircle(bigOne, 300/1609.344, 1)],
            strokeColor: "#ff0000",
            strokeOpacity: 0.35,
            strokeWeight: 0,
            fillColor: "#FF0000",
            fillOpacity: 0.35
});

joined.setMap(map);

这篇关于如何在Google地图中组合圈子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆