0
Google Maps API를 사용하여지도를 렌더링하는 클래스를 작성하고 있습니다. 내가 테스트 Uncaught Typeerror: undefined is not a function
Undefined가 Google Maps API의 함수가 아닙니다.
그러나 :
this.map.setMap(this.directions_service);
오류는 다음과 같습니다
이
내가이 클래스를 사용할 때,이 라인에서 오류가 발생function Map() {
}
Map.prototype.map = null;
Map.prototype.map_options = null;
Map.prototype.div_map = null;
Map.prototype.directions_service = null;
Map.prototype.center = null;
Map.prototype.points = null;
Map.prototype.start = function() {
this.map_options = {
zoom: 14,
center: this.center,
mapTypeId: google.maps.MapTypeId.ROADMAP,
streetViewControl: false
};
this.map = new google.maps.Map(document.getElementById(this.div_map), this.map_options);
this.directions_service = new google.maps.DirectionsRenderer();
this.directions_service.setOptions({
preserveViewport: true,
suppressInfoWindows: true,
polylineOptions: {
strokeWeight: 2,
strokeOpacity: 0.8,
strokeColor: "blue"
}
});
this.map.setMap(this.directions_service);
};
내 클래스 this.map
변수는 typeof()
이며, 'object'
을 반환합니다.
this.div_map
도 정상적으로 설정되며 렌더링 된 초기지도도 설정됩니다.
내가 잘못하고있는 것이 있습니까?
으로 변경해야합니다. 고맙습니다. –