简体   繁体   English

标记setIcon方法奇怪地破坏了标记对象

[英]marker setIcon method strangely destroying marker object

See http://www.milebymile.com/main/highway-1777.html 参见http://www.milebymile.com/main/highway-1777.html

Go to the right navigation bar and press on the campground + to see a selection of campgrounds. 转到右侧导航栏,然后在露营地上按+,以查看一系列露营地。 Click on the campground. 点击露营地。

The first alert shows the getIcon url prior to the setIcon. 第一个警报在setIcon之前显示getIcon URL。 The second getIcon alert after the setIcon shows undefined because the marker appears now to be undefined. setIcon之后的第二个getIcon警报显示为undefined,因为该标记现在看来是undefined。

The marker changes so the marker.setIcon is working but then after that fires. 标记发生变化,所以marker.setIcon正常工作,但随后触发。 The corresponding marker can not be referenced again. 不能再次引用相应的标记。

Have I done something wrong, or is this a bug? 我做错了什么,还是这是个错误? Thanks in advance. 提前致谢。

I am using Chrome Version 28.0.1500.44 beta-m. 我正在使用Chrome版本28.0.1500.44 beta-m。

The issue is not that the marker is being destroyed but that the marker.getIcon method no longer returns anything with a .url property. 问题不是标记被销毁,而是marker.getIcon方法不再返回带有.url属性的任何内容。

So the second of these statements: 因此,这些语句的第二个:

var old_icon_url = marker.getIcon().url;    
var new_icon_url = old_icon_url.replace(".png","_selected.png");

generates an error, and execution stops, so you don't see the alerts. 生成错误,并且执行停止,因此您不会看到警报。

Error (in chrome): 错误(Chrome):

Uncaught TypeError: Cannot call method 'replace' of undefined mapGenerate.js:111

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM