如何使用多个坐标在Google地图中绘制多边形 [英] How to draw a polygon in google map using many coordinates

查看:458
本文介绍了如何使用多个坐标在Google地图中绘制多边形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含不同位置纬度和经度的数组,显示在谷歌地图中。现在我需要制作一个通过所有这些点的多边形。我已经在google apis中找到了很好的教程,但是该示例仅适用于3分。



任何人都可以帮助或引荐任何教程,我可以创建一个多边形而不会在各行之间相交。



感谢您。

解决方案

只需示例,然后添加更多分数。然而,随着更多如果您不正确地排序坐标,您将遇到交叉点麻烦。



要修复它,您需要一个算法:



以下是答案:将点排序避免交叉点



您可以在答案的第二个点停下来,您只需计算多边形的中心,然后计算角度以对点进行排序。

但是,您无法使用经度和纬度使用此算法。



对于此比例,您可以将您的坐标投影到2d平面。



这: merkator预测 p>

I have an array containing latitude and longitude of different location which is displayed in the google map. Now I need to make a polygon passing through all these points. I have found the good tutorial in google apis but that example works well only for 3 points.

Can anybody please help or refer me any tutorial where I can create a polygon without intersecting between lines.

Thank You.

解决方案

Just take the example you took and add more points.

However, with more than three points, you'll have intersection trouble if you don't sort the coordinates properly.

To fix it you'll need an algorithm:

Here is the answer: Sorting points to avoid intersections.

You can stop at the second point of the answer, you just calculate the center of your polygon and then the angles to sort the points.

However, you can't use latitude and longitude with this algorithm.

For this scale you can just project your coordinates to a 2d plane.

Go for this: merkator projection

这篇关于如何使用多个坐标在Google地图中绘制多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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