多边形不关闭 [英] Polygons are not closed

查看:91
本文介绍了多边形不关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到在使用绘图管理器绘制多边形时,它们没有关闭(即没有坐标为最后一个点的坐标)。我知道Google Maps API v3会自动关闭多边形,但Google Earth,Google Static Maps API或任何其他软件,我尝试将数据导入..

I noticed when drawing polygons with the Drawing Manager they are not closed (i.e. no coordinates for the last point to the first).. I know Google Maps API v3 will automatically close the polygon but Google Earth, Google Static Maps API or any other software I try to import the data into..

我的问题是,我使用几何库来保存编码的多边形。有什么办法推送副本第一个点到编码前的叠加对象中的最后一个点?

My problem is, I use the geometry lib to save encoded polygons.. Is there any way to push a copy of the first point to the last in the overlays object before encoding?

我的解决方法是将getPaths()。getArray()添加到我自己的数组中,复制并使用JavaScript库进行编码,的代码..只是想知道是否有一个更简单的方法吗?

My work around is to getPaths().getArray() to my own array, make the copy and then use a javascript lib to encode which works ok but is a lot of code.. Just wondering if there is an easier way?

推荐答案

类似这样的东西应该添加多边形的第一个点 MVCArrry (未测试)结束。

Something like this should add the first point of the polygon to the end of the MVCArrry (not tested).

myPoly.getPath().push(getPath().getAt(0));

(假设一个简单的带有一个路径的多边形, getPath 返回第一个路径)

(assumes a simple polygon with one path, getPath returns the first path)

这篇关于多边形不关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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