Angularjs 范围错误,谷歌地图方向服务。angular2,SebastianM/angular2谷歌地图
我在使用地图方向服务时遇到这个错误,我寻求帮助,我正在关注一个关于ng-2和SebastianM/angular2谷歌地图的谷歌地图方向服务的实施问题,我不确定我是否遗漏了什么,我真的对此进行了研究,并需要有关错误来源的帮助Angularjs 范围错误,谷歌地图方向服务。angular2,SebastianM/angular2谷歌地图,angularjs,google-maps,driving-directions,Angularjs,Google Maps,Driving Directions,我在使用地图方向服务时遇到这个错误,我寻求帮助,我正在关注一个关于ng-2和SebastianM/angular2谷歌地图的谷歌地图方向服务的实施问题,我不确定我是否遗漏了什么,我真的对此进行了研究,并需要有关错误来源的帮助 EXCEPTION: Uncaught (in promise): RangeError: Maximum call stack size exceeded RangeError: Maximum call stack size exceeded 这是我在module.t
EXCEPTION: Uncaught (in promise): RangeError: Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
这是我在module.ts中声明的方向服务组件/指令
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>
任何可能导致我解决错误的帮助或建议都将不胜感激,谢谢。我的错误是我没有将方向服务作为一个指令,而是一个组件,我已将方向服务移动到一个指令,并在我的模块中声明,然后在主机组件中将其作为html标记使用,如果有人想看代码,只需评论一下这个问题的线索