一次显示一个标记 - Google Maps API v3 [英] Showing one marker at a time - Google Maps API v3

查看:92
本文介绍了一次显示一个标记 - Google Maps API v3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://jsfiddle.net/michaelgruber/M84T7/



当codeAddress函数运行多次(当运行多个输入时),旧标记将保存在地图上。为什么是这样?不应该覆盖MyMap.marker吗?

解决方案


MyMap.marker不应该是被覆盖?


是的,但它是对标记的引用,而不是标记本身。

隐藏标记:

  marker.setMap(null); 

在您覆盖它并丢失引用之前。



http://jsfiddle.net/zbZ8p/1/


http://jsfiddle.net/michaelgruber/M84T7/

When the codeAddress function is run more than once (when multiple inputs are run) the old markers are saved on the map. Why is this? Shouldn't the MyMap.marker be overwritten?

解决方案

Shouldn't the MyMap.marker be overwritten?

Yes, but it is a reference to the marker not the marker itself.

To hide the marker:

 marker.setMap(null);

Before you overwrite it and lose the reference.

http://jsfiddle.net/zbZ8p/1/

这篇关于一次显示一个标记 - Google Maps API v3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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