2017-03-19 5 views
0

지도 서비스를 사용할 때이 오류에 대한 도움을 요청합니다. Google 주소록 서비스 구현을 위해 Directions service #495 문제를 수행 중이며 SebastianM/angular2-google-maps, 내가 뭔가를 놓치고 있는지 잘 모르겠다. 나는 정말로 이것에 대해 조사했고, 어디에서 오류가오고 있는지에 대한 도움이 필요하다. 여기 RangeError, Google지도 길 찾기 서비스. angular2, SebastianM/angular2-google-maps

EXCEPTION: Uncaught (in promise): RangeError: Maximum call stack size exceeded 
RangeError: Maximum call stack size exceeded 

import { Component, OnInit, Input } from '@angular/core'; 
import { MapsAPILoader, SebmGoogleMap, GoogleMapsAPIWrapper} from 'angular2-google-maps/core'; 
import { Session } from '../../../session'; 

declare var google: any; 
@Component({ 
selector: 'sebm-google-map-directions', 
templateUrl: 'app/modules/move_requests/components/sebm-google-directions.component.html', 
styleUrls: [ 
    'app/modules/move_requests/components/move_requests.component.css' 
] 
}) 

export class DirectionsMapDirective implements OnInit { 
    @Input() origin: any; 
    @Input() destination: any; 
constructor(private mapsAPI: MapsAPILoader,private mapsAPIWrapper: GoogleMapsAPIWrapper) {} 

ngOnInit(): void { 
    let latlngOrigin = Session.get('location_coordinates'); 
    let latlngDest = Session.get('to_location_coords'); 

    this.mapsAPIWrapper.getNativeMap().then(map =>{ 

    this.origin = new google.maps.LatLng(latlngOrigin.lat,latlngOrigin.lng); 
    this.destination = new google.maps.LatLng(latlngDest.lat,latlngDest.lng); 

     var directionsService = new google.maps.DirectionsService; 
     var directionsDisplay = new google.maps.DirectionsRenderer; 
     directionsDisplay.setMap(map); 
     directionsService.route({ 
      origin: this.origin, 
      destination: this.destination, 
      waypoints: [], 
      optimizeWaypoints: true, 
      travelMode: 'DRIVING', 

     },function (res: any, status: any){ 
      if(status === 'OK') { 
       console.log("STATUS WAS OK"); 
       directionsDisplay.setDirections(res) 
      } else { 
       window.alert('Directions request failed due to ' + status); 
      } 
     }); 
    }); 
} 

과의

템플릿

<sebm-google-map style="height: 300px;"> 
    <sebm-google-map-directions [origin]="origin" [destination]="destination"></sebm-google-map-directions> 
</sebm-google-map> 

어떤 지원이나이이 지침 난 내 module.ts에서 선언 한 서비스 구성 요소/지시자이다 오류를 해결할 수있는 제안을 보내 주시면 감사하겠습니다.

답변

0

내 잘못은 지침으로 방향 서비스가 없지만 구성 요소에서 방향 서비스를 지침으로 옮기고 모듈에서 선언 한 다음에 HTML 태그로 사용했습니다. 호스트 구성 요소, 누군가 코드를보고 싶다면이 질문의 스레드에 댓글을 달아주세요.