在 Google 地图中绘制匿名圆圈
我正在尝试绘制一个具有多个圆叠加层的谷歌地图,但是我不想透露正确的半径中心。
例如,myLatlng
是我的半径的纬度/经度中心,我想绘制一个不是围绕它的圆,而是一个将包含该点的圆。
这就是我目前绘制圆圈的方式:
var myLatlng = new google.maps.LatLng(33.33333,22.22222);
var circle = new google.maps.Circle({
map: map,
radius: 3218,
strokeColor: "#FFAA00",
fillColor: "#00AAFF",
fillOpacity: 0.3,
center: myLatlng,
zIndex: 99999,
});
33.33333,22.22222
是一个我不想透露的“秘密”位置,但我希望该点位于圆圈内。
这可能吗?
谢谢!
I'm trying to draw a google maps that has multiple Circle overlays, however I do not want to reveal the correct center of the radius.
So for example, myLatlng
is my lat/lon center of the radius, I want to draw a circle not around it, but a circle that will include that point.
This is how I currently draw my circle:
var myLatlng = new google.maps.LatLng(33.33333,22.22222);
var circle = new google.maps.Circle({
map: map,
radius: 3218,
strokeColor: "#FFAA00",
fillColor: "#00AAFF",
fillOpacity: 0.3,
center: myLatlng,
zIndex: 99999,
});
33.33333,22.22222
is a 'secret' location that I do not want to reveal, however I would like to have that point within the circle.
Is that possible?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在你的示例代码中。该圆可以移动到任何地方,从而仍然可以包含 33.3 和 22.2。
一种方法是简单地添加随机偏移量。
棘手的一点是确保随机偏移不会将圆移出边界。维基百科上的将纬度和经度表示为线性单位部分应该会有所帮助。
In your example code. The circle could move anywhere such that 33.3 and 22.2 could still be included.
One way to do this would be to simply add a random offset.
The tricky bit you've got is to ensure that the random offset doesn't move the circle out of bounds. The section Expressing latitude and longitude as linear units on Wikipedia should help.