Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Directive, Input, OnInit } from '@angular/core';
- import {GoogleMapsAPIWrapper} from '@agm/core';
- declare let google: any;
- @Directive({
- // tslint:disable-next-line:directive-selector
- selector: 'appCycleDirection'
- })
- export class CycleDirectionDirective implements OnInit {
- @Input() org;
- @Input() dst;
- @Input() originPlaceId: any;
- @Input() destinationPlaceId: any;
- @Input() waypoints: any;
- @Input() directionsDisplay: any;
- @Input() estimatedTime: any;
- @Input() estimatedDistance: any;
- constructor(private gmapsApi: GoogleMapsAPIWrapper) { }
- ngOnInit() {
- console.log(' In directive ');
- console.log(this.org);
- this.gmapsApi.getNativeMap().then(map => {
- const directionsService = new google.maps.DirectionsService;
- const directionsDisplay = new google.maps.DirectionsRenderer;
- directionsDisplay.setMap(map);
- directionsService.route({
- origin: {lat: this.org.latitude, lng: this.org.longitude},
- destination: {lat: this.dst.latitude, lng: this.dst.longitude},
- waypoints: [],
- optimizeWaypoints: true,
- travelMode: 'TRANSIT'
- }, function(response, status) {
- if (status === 'OK') {
- directionsDisplay.setDirections(response);
- console.log(response);
- } else {
- window.alert('Directions request failed due to ' + status);
- }
- });
- });
- }
- }
- <agm-map *ngIf="Address !== undefined" [latitude]="lat" [longitude]="lng" [zoom]="zoom">
- <appCycleDirection *ngIf="dst !== undefined" [org]="org" [dst]="dst"></appCycleDirection>
- <agm-marker [style.height.px]="map.offsetHeight" [latitude]="lat" [longitude]="lng"></agm-marker>
- </agm-map>
- > Uncaught (in promise): Error: Template parse errors: Can't bind to
- > 'org' since it isn't a known property of 'appCycleDirection'.
- > ("[latitude]="lat" [longitude]="lng" [zoom]="zoom">
- > <appCycleDirection *ngIf="dst !== undefined" [ERROR ->][org]="org" [dst]="dst"></appCycleDirection>
- > <agm-marker [style.height.px]="map.offsetHeight" ["): ng:///LayoutModule/FindCycleComponent.html@9:50 Can't bind to 'dst'
- > since it isn't a known property of 'appCycleDirection'. ("lat"
- > [longitude]="lng" [zoom]="zoom">
- > <appCycleDirection *ngIf="dst !== undefined" [org]="org" [ERROR ->][dst]="dst"></appCycleDirection>
- > <agm-marker [style.height.px]="map.offsetHeight" [latitude]="l"): ng:///LayoutModule/FindCycleComponent.html@9:62
- > 'appCycleDirection' is not a known element:
- > 1. If 'appCycleDirection' is an Angular component, then verify that it is part of this module.
- > 2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("> <agm-map
- > *ngIf="cycleAddress !== undefined" [latitude]="lat" [longitude]="lng" [zoom]="zoom">
- > [ERROR ->]<appCycleDirection *ngIf="dst !== undefined" [org]="org" [dst]="dst"></appCycleDirection>
- > <agm-m"): ng:///LayoutModule/FindCycleComponent.html@9:4
Add Comment
Please, Sign In to add comment