File

projects/ngx-amap/src/shared/marker-label.service.ts

Index

Methods

Constructor

constructor(pixel: PixelService)
Parameters :
Name Type Optional
pixel PixelService No

Methods

create
create(options: IMarkerLabel)
Parameters :
Name Type Optional
options IMarkerLabel No
Returns : AMap.Marker.Label | null
import { Injectable } from '@angular/core';
import { PixelService } from './pixel.service';
import { IMarkerLabel } from '../interfaces';

@Injectable({
  providedIn: 'root',
})
export class MarkerLabelService {
  constructor(private pixel: PixelService) {}

  create(options: IMarkerLabel): AMap.Marker.Label | null {
    if (options) {
      const label: AMap.Marker.Label = {};
      if (options.content !== undefined) {
        label.content = options.content;
      }
      if (options.offset !== undefined) {
        if (options.offset instanceof AMap.Pixel) {
          label.offset = options.offset;
        } else {
          label.offset = this.pixel.create(options.offset);
        }
      }
      if (options.direction !== undefined) {
        label.direction = options.direction;
      }
      return label;
    }
    return null;
  }
}

result-matching ""

    No results matching ""