0
Google Maps API v2를 v3으로 사용하는 기존 프로젝트를 변환하는 중 일부 작업을 수행하고 있습니다.Dojo를 사용하여 Google Maps 이벤트에서 포함 된 클래스를 어떻게 참조합니까?
이처럼 보이는 도조 클래스가있다 :
dojo.declare
(
"MyNamespace.MapControl",
null,
{
constructor: function() {
var mapElement = document.getElementById("map");
this._map = new google.maps.Map(mapElement, {});
google.maps.event.addListenerOnce(this._map, "idle", this.map_load);
},
map_load: function() {
this.onLoad();
},
onLoad: function() { }
}
);
문제가 map_load 함수가 호출 될 때, 이의 내용은 구글 맵이 아닌 클래스, 점이다.
나는 클래스 내에서 지역 변수 자기를 만들고 생성자 내부_self = this;
를 사용하지만, 변수가에 onLoad 기능이 없습니다 시도했다. 이은을 사용하여 코드 :
dojo.declare
(
"MyNamespace.MapControl",
null,
{
_self: null,
constructor: function() {
var mapElement = document.getElementById("map");
this._map = new google.maps.Map(mapElement, {});
google.maps.event.addListenerOnce(this._map, "idle", this.map_load);
_self = this;
},
map_load: function() {
_self.onLoad(); // fails as onLoad is undefined
},
onLoad: function() { }
}
);
도장 내에서 방법은 * map_load * 함수 내에서 부모 클래스에 대한 참조를 얻을 수있을 경우, 또는이를 접선의 다른 방법이?
볼은 마법처럼 일했다. 감사! –