Как показать несколько путей на карте Google, используя угловую 5? - PullRequest
0 голосов
/ 08 октября 2018

Я пытаюсь отобразить несколько путей на карте Google, используя «AgmDirectionModule» и «AgmCoreModule» в угловых значениях 5.

Как удерживать несколько мест отправления и назначения и показывать пути на карте?

Мой component.ts, как показано ниже:

import { Component, ViewChild } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
    title = 'Google Map';
    //lat: number = 28.4595;
    //lng: number = 77.0266;
    public origin: any=[]
    public destination: any=[]
    public source = [
        {lat :18.506307, lng : 73.8983345},
        {lat :18.461210, lng : 73.8773918}
        ];
    public dest = [
        {lat :18.500284, lng: 73.8588523},
        {lat :18.499796, lng: 73.8585090}
        ]
    ngOnInit() {
      this.getDirection()
    }

    getDirection() {

        for (var i = 0; i <= 1; i++) {
            this.origin = {lat: this.source[i].lat, lng: this.source[i].lng};
            this.destination = { lat: this.dest[i].lat, lng: this.dest[i].lng };
        }

    }
}

Мой component.html

<style type="text/css">
  agm-map {
    height: 400px;
    width: 600px;
  }

</style>

<h1>{{ title }}</h1>
<agm-map [latitude]="lat" [longitude]="lng">
      <agm-direction [origin]="origin" [destination]="destination">
      </agm-direction>
</agm-map>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...