Google Maps JavaScript API:如何删除个人标记? [英] Google Maps JavaScript API: How to remove individual marker?

查看:124
本文介绍了Google Maps JavaScript API:如何删除个人标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Google Maps v3资料库,并使用 Multi-Marker 库,它扩展了Google Maps的功能,以便将地图标记图标超快速添加到地图中。



我无法弄清楚如何使用上面链接的多标记库删除单个个别地图标记。



有没有人有任何想法如何使用多标记库(和/或谷歌地图)做到这一点?我已经尝试联系该项目的首席开发人员,但没有得到任何回复。



感谢您的任何帮助。



另外,链接是关于这个图书馆的更多信息

  http://blog.redfin.com/devblog/2010/ 07 / introdu_multimarker_the_fastest_way_to_add_many_hundreds_or_thousands_of_markers_on_google_maps.html 

更新

我已经链接了我正在做的事情的示例代码。我想要动态删除特定的地图标记图标(叠加层),但我正在努力如何做到这一点。任何建议,将不胜感激。感谢



实时示例:

  HTTP://multimarker.googlecode .com / svn / trunk / fast-marker-overlay / maps-v3 / example / clickable.html 


解决方案

Normaly,只使用谷歌地图API,以移除地图覆盖你需要呼吁覆盖的的setMap(空)方法。



正如我所看到的,Multi-Marker库使用一个数组来保存所有标记,并创建一个覆盖图以在地图上显示,这是一个包含标记的覆盖图。要删除一个,它应该工作从数组(你需要知道它的数组中的位置),并重绘覆盖删除标记

编辑:



你需要类似于函数clearOverlays(){var i = overlays.length; while(i--){var overlay = overlays [i]; if(overlay)overlay.setMap(null);删除重叠[i]; }}



但是您需要知道要删除的标记数组中的位置。该函数将是这样的:

 函数clearOneOverlay(VAR位置){风险覆盖=叠加[位置]。 if(overlay)overlay.setMap(null);删除叠加[position]; } 


I'm using the Google Maps v3 library, with the Multi-Marker library which extends the functionality of Google Maps for super fast adding of map marker icons to a map.

I can't figure out how to remove a single, individual map marker using the multi-marker library linked above.

Does anyone have any ideas how I'd do this using the multi-marker library (and/or Google Maps)? I've tried contacting the lead developer of the project but am not getting a response.

Thanks for any help.

Also, linked is more information on this library

http://blog.redfin.com/devblog/2010/07/introducing_multimarker_the_fastest_way_to_add_many_hundreds_or_thousands_of_markers_on_google_maps.html

UPDATE:

I have linked example code of what I'm doing. I want to dynamically remove specific map marker icons (overlays) but am struggling on how to do that. Any advise would be very appreciated. Thanks

Live example:

http://multimarker.googlecode.com/svn/trunk/fast-marker-overlay/maps-v3/example/clickable.html

解决方案

Normaly, using only the google maps api, to remove an overlay from the map you would need to call the setMap(null) method on the overlay.

As I can see, the Multi-Marker library uses an array to hold all the markers and creates an overlay to show on the map, an overlay that contains the markers. To remove one, it should work to remove the marker from the array (you need to know its position in the array) and redraw the overlay.

Edit:

You need something similar to function clearOverlays() { var i = overlays.length; while (i--) { var overlay = overlays[i]; if (overlay) overlay.setMap(null); delete overlays[i]; } }

But you'll need to know the position in the array of the marker you want to delete. The function will look like this:

 function clearOneOverlay(var position) { var overlay = overlays[position]; if (overlay) overlay.setMap(null); delete overlays[position]; }

这篇关于Google Maps JavaScript API:如何删除个人标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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