1

我正在尝试构建一个带有半径的简单谷歌地图位置标记。

我在用着 -

  • 角@11.0.4
  • 角-cli@11.0.4
  • agm/core@3.0.0

ng serve关于zoomControl我在 *.component.ts 文件中定义的属性和方法,我在终端运行时遇到错误。

以下是终端中显示的错误。

Error: src/app/Map/Map.component.html:19:16 - error TS2554: Expected 2 arguments, but got 1.

    19     (dragEnd)="markerDragEnd($event)"

    src/app/Map/Map.component.ts:41:16
    41   templateUrl: './Map.component.html',
        
    Error occurs in the template of component MapComponent.
    src/app/Map/Map.component.html:12:3 - error NG8002: Can't bind to 'AgmZoomControl' since it isn't a known property of 'agm-map'.
    1. If 'agm-map' is an Angular component and it has 'AgmZoomControl' input, then verify that it is part of this module.
    2. If 'agm-map' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
    3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

    12   [zoomControl]="true"
        
    src/app/Map/Map.component.ts:41:16
    41   templateUrl: './Map.component.html',
                          
    Error occurs in the template of component MapComponent.

markerDragEnd()*.component.ts 文件中的方法。

markerDragEnd(m: any, $event: any) {
   this.location.marker.lat = m.coords.lat;
   this.location.marker.lng = m.coords.lng;
   this.findAddressByCoordinates();
}

使用 zoomControl 属性和 markerDragEnd() 方法的段。

<agm-map
  [(latitude)]="location.lat"
  [(longitude)]="location.lng"
  [(zoom)]="location.zoom"
  [disableDefaultUI]="true"
  [zoomControl]="true"
  [(fitBounds)]="location.viewport"
>
  <agm-marker
    [(latitude)]="location.marker.lat"
    [(longitude)]="location.marker.lng"
    [markerDraggable]="location.marker.draggable"
    (dragEnd)="markerDragEnd($event)"
  ></agm-marker>
</agm-map>

错误的原因是什么?

4

0 回答 0