Google Maps v3 - 删除多边形上的顶点 [英] Google Maps v3 - Delete vertex on Polygon

查看:180
本文介绍了Google Maps v3 - 删除多边形上的顶点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谷歌地图有绘图库绘制多义线和多边形以及其他东西。

此功能的示例: http://gmaps-samples-v3.googlecode.com/svn-history/r282/trunk/drawing/drawing-tools.html



在绘制和编辑多边形时,我希望能够删除路径上的一个点/顶点。 API文档似乎没有提示任何东西。

解决方案

这是一项杰出的功能请求(由Google确认), issue 3760

以下是我的解决方案: http://jsbin.com / ajimur / 10 。它使用一个函数,将删除按钮添加到传入的多边形(在撤消按钮下方)。




或者,某人建议采用这种方法:右键单击以删除最近的顶点,它可以正常工作,但有点缺乏UI技巧。我建立在链接代码上,检查点击是否在节点内部(或在1像素内) - 在JSBin中: http://jsbin.com/ajimur/



编辑:as Amr Bekhit 指出 - 这种做法目前已被破坏,因为事件需要附加到多边形。


Google Maps has the Drawing library to draw Polylines and Polygons and other things.

Example of this functionality here: http://gmaps-samples-v3.googlecode.com/svn-history/r282/trunk/drawing/drawing-tools.html

I want, when drawing and editing the polygon, to be able to delete one point/vertex on the path. The API docs haven't seemed to hint at anything.

解决方案

This is currently an outstanding feature request (acknowledged by Google), issue 3760.

Here's my solution: http://jsbin.com/ajimur/10. It uses a function that adds a delete button to the passed in polygon (below the undo button).


Alternatively, someone suggested this approach: right-click to delete closest vertex, which works fine but is somewhat lacking in UI finesse. I built on the code from the link to check if the click was inside (or within 1 pixel of) the node - in a JSBin here: http://jsbin.com/ajimur/.

EDIT: as Amr Bekhit pointed out - this approach is currently broken, as the events need to be attached to the polygon.

这篇关于Google Maps v3 - 删除多边形上的顶点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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