当前在谷歌地图中查看的国家/地区
我需要一种方法来找出用户当前在地图上查看的国家/地区(如果有)。 如果查看多个国家/地区,则返回“”。 我已经为此工作了一段时间,并且知道如何使用反向地理编码器,但是,这不是一个选项,因为它对许多请求来说远。
我最好的选择是使用国家/地区周围的一些框,然后检查地图中心是否位于其中任何一个中。
简而言之:
我需要一个国家列表和拐角坐标。
我需要一种方法来循环查找哪个内容被查看
I need a way to figure out what country (if any) the user is currently viewing on the map.
If multiple countries are view'd just return "".
I've been working on this for a while, and know how to use the reverse geocoder, however, that is not an option as it would be far to many requests.
My best bet is to use some boxes around the countries, and then check if the map center is in any of them.
So in short:
i need a list of countries and there corners cordinates.
i need a way to loop through to find out which one is viewed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我不知道为什么你不能只获取地图中心,然后对其下方的国家/地区进行反向地理编码。如:
尽管加拿大位于该地图的顶部,但中心却在美国。
如果你想检查多个国家/地区,我所做的就是创建一个网格图案,查看地图上 9 个(或 4 个或 16 个或任何你想要的)均匀分布的点,并查看每个点下的国家/地区。我注意到,有时反向地理编码器即使在一个县内也会返回 null,通常是当标记落在无人居住的区域时。
如果您想要其中任何一个的代码示例,我将包括它们。
Well I am not sure why you can't just get the map center and then reverse geocode that for the country underneath it. Such as:
Even though Canada is in the top part of this map, the center is in the United States.
If you want to check for multiple countries, what I did was create a grid pattern that looks at 9 (or 4 or 16 or whatever you want) evenly distributed points on the map and looks at the countries under each point. I've noticed that sometimes the reverse geocoder returns null even within a county, usually when the marker falls on an uninhabitated region.
If you would like code examples for either of these I will include them.