marker.setDraggable(false) 在 API Google 地图的 main.js 中引发异常
我在 JavaScript 中有这段代码:
google.maps.event.addListener(mark, 'dragend',x(mark));
function x(mark)
{
mark.setDraggable(false);
}
当我将标记移动到另一个位置时,它会在 main.js 中抛出此异常:
SCRIPT5007:Can not get value of property 'apply': the object is null or undefined
main.js, Línea 23 Carácter 104
它只发生在 IE 中,在 Chrome 和 Firefox 中,代码运行完美。
I have this code in JavaScript:
google.maps.event.addListener(mark, 'dragend',x(mark));
function x(mark)
{
mark.setDraggable(false);
}
When I move a marker to another position it throws this exception in main.js:
SCRIPT5007:Can not get value of property 'apply': the object is null or undefined
main.js, Línea 23 Carácter 104
It only happens in IE, in Chrome and Firefox the code runs perfectly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试使用 google.maps.event.addListener(mark, 'dragend', x);
Try to use
google.maps.event.addListener(mark, 'dragend', x)
;您可以将标记设为全局变量:
假设您在初始化函数中初始化地图和标记。
You could make the marker a global variable:
Assuming that you initialize your map and marker in the initialize function.