抓住google.maps.Marker.prototype.setPosition调用
(function(){
var setPos = google.maps.Marker.prototype.setPosition;
google.maps.Marker.prototype.setPosition = function(latLng){
console.log(["setPos", latLng]);
setPos(latLng);
};
})();
返回错误
this.set is not a function
http://maps.gstatic.com/intl/cs_ALL/mapfiles/api-3/2/0/main.js
Line 28
为什么呢?感谢
答案 0 :(得分:0)
初始google.maps.Marker.prototype.setPosition
将在标记的范围内调用,但通过将其存储在局部变量中,您可以将其范围更改为本地变量。
因此,该函数没有所需的this
变量。您可以尝试使用dojo.hitch或阅读this stackoverflow answer
另外,您应该阅读有关范围和闭包的this 。
答案 1 :(得分:0)
答案 2 :(得分:0)
您始终可以扩展原型并添加自己的方法。
<div class="row">
<div class="col-xs-12 col-sm-10 col-md-8 col-lg-6">
<table class="table">
....
</table>
</div></div>
这样就可以保持范围不变。