Angular-google-maps panTo 不起作用

Nor*_*wak 5 typescript angular-google-maps bootstrap-4 angular

嗨,我有一些角度/引导代码并试图平移到位置。我认为问题出在 GoogleMapsAPI Wrapper 的不同实例中。顺便提一句。缩放和打印圆圈也不起作用。

  constructor(private _service: MapService,
              private route: ActivatedRoute,
              private wrapper: GoogleMapsAPIWrapper) {
  }

  show(measurement: MeasurementDTO) {
    const latlng = new google.maps.LatLng(measurement.latLng.lat, measurement.latLng.lng());
    console.log(latlng.lat);
    this.map.panTo(latlng);
  }
Run Code Online (Sandbox Code Playgroud)

和这里的部分观点。测量来自表,但我认为它是无用的信息。

  <agm-map style="height: 600px" [latitude]="1" [longitude]="1" [usePanning]="true">
    <agm-marker-cluster [imagePath]="'https://googlemaps.github.io/js-marker-clusterer/images/m'">
      <agm-marker
        *ngFor="let measurement of measurements"
        [latitude]="measurement.latLng.lat"
        [longitude]="measurement.latLng.lng">
      </agm-marker>
    </agm-marker-cluster>
  </agm-map>
        <button (click)="show(measurement)">Show</button>
Run Code Online (Sandbox Code Playgroud)

2018 年 12 月 6 日更新

我通过在组件中添加地图来解决这个问题:

  map: any;

  setMap(map) {
    console.log(map);
    this.map = map;
  }
Run Code Online (Sandbox Code Playgroud)

这个 onReady 在 html 中:

<agm-map #mapka style="height: 600px" [latitude]="52.279986" [longitude]="17.35229389999995" [usePanning]="true"
               (mapReady)="setMap($event)">
Run Code Online (Sandbox Code Playgroud)