File

projects/ngx-amap/src/shared/pixel.service.ts

Index

Methods

Constructor

constructor()

Methods

create
create(options: IPixel | AMap.Pixel)
Parameters :
Name Type Optional
options IPixel | AMap.Pixel No
Returns : AMap.Pixel | null
import { Injectable } from '@angular/core';
import { IPixel } from '../interfaces';

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

  create(options: IPixel | AMap.Pixel): AMap.Pixel | null {
    if (!options) {
      return null;
    }
    if (options instanceof AMap.Pixel) {
      return options;
    }
    if (Array.isArray(options)) {
      return new AMap.Pixel(options[0], options[1]);
    }
    return new AMap.Pixel(options.x || 0, options.y || 0, options.round);
  }
}

result-matching ""

    No results matching ""