Google Maps V3 Circle&我创建的圈子不匹配 [英] Google Maps V3 Circle & Circle that I created do not match

查看:118
本文介绍了Google Maps V3 Circle&我创建的圈子不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google Maps V3 API创建了一个圈子,并尝试制作具有相同半径的标记圈。



问题:我创建的是倾斜的,而Google地图提供的是一个很好的圆形圆。什么地方出错?



Google地图V3圈代码

  //绘制搜索圈
search_circle = new google.maps.Circle;
search_circle.setCenter(target_latlng);
search_circle.setRadius(travel_time * average_speed);
search_circle.setMap(map);

解决方案

有一件事你需要记住在这里,谷歌圈是给球体(地球)上的两点,这就是为什么你的圈子看起来不一样。



您没有具体说明您的示例中圆圈的用途,而是从代码段中可以看出它与旅行距离有关。在这种情况下,您可能有兴趣研究:

Haversine公式





余弦的球形定律



另外

编辑:为了正确,地球不是一个完美的球体,但为了所有实际目的,它被假定为一个。


I created a circle using the Google Maps V3 API and also tried to make a circle of markers with the same radius.

Problem: The one I created is oblique while the one by Google Maps is a nice round circle. What went wrong?

Google Maps V3 Circle Code

// Draw search circle
search_circle = new google.maps.Circle;
search_circle.setCenter(target_latlng);
search_circle.setRadius(travel_time * average_speed);
search_circle.setMap(map);

解决方案

One thing you need to remember here, the google circle is giving the distance between two points on a sphere (the earth) which is why your circle doesn't look the same.

You did not specify what the purpose of the circle in your example is, but from the code snippet I can tell it has something to do with travel distances. In that case you might be interested to look into :

The Haversine Formula

or

The Spherical Law of Cosines

Also this page could provide you with some basis on how to tweak your formula to get the correct circle shape.

Edit: For the sake of correctness, the earth is not a perfect sphere, but for all practical purposes it is assumed to be one.

这篇关于Google Maps V3 Circle&我创建的圈子不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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