0

我正在尝试自定义我的 agm-map 中的标记,但它不起作用。根据 api文档, iconUrl 属性应该可以工作,但它不适合我。


  <agm-map [latitude]="latitude" [longitude]="longitude">
            <agm-marker [latitude]="latitude" [longitude]="longitude" [label]="labelOptions"
                [iconUrl]=" '../../../assets/navbar/box.svg'">
            </agm-marker>
        </agm-map>

我也用 url 制作了一个对象,但也不起作用

ts


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

@Component({
  selector: 'app-shelter-map',
  templateUrl: './shelter-map.component.html',
  styleUrls: ['./shelter-map.component.scss']
})
export class ShelterMapComponent implements OnInit {
  latitude = 51.688418;
  longitude = 7.809007;
  labelOptions: any;
  public iconMap: any;

  constructor() {
    this.labelOptions = {
      color: '#ee4646',
      fontFamily: '',
      fontSize: '10px',
      fontWeight: 'bold',
      letterSpacing: '0.5px',

    }

    this.iconMap = {
      iconUrl: '../../../assets/navbar/box.svg',
      iconHeight: '10'

    }

  }

  ngOnInit(): void {
  }

  

}


html

  <agm-map [latitude]="latitude" [longitude]="longitude">
            <agm-marker [latitude]="latitude" [longitude]="longitude" [label]="labelOptions"
                [iconUrl]="iconMap.iconUrl">
            </agm-marker>
        </agm-map>

感谢您的回复。

4

0 回答 0