File

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

Index

Methods

Constructor

constructor()

Methods

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

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

  create(options: ISize | AMap.SizeValue): AMap.SizeValue | null {
    if (!options) {
      return null;
    }
    if (options instanceof AMap.Size || Array.isArray(options)) {
      return options;
    }
    if (options.width !== undefined && options.height !== undefined) {
      return new AMap.Size(options.width, options.height);
    }
    if (options.w !== undefined && options.h !== undefined) {
      return new AMap.Size(options.w, options.h);
    }
    return null;
  }
}

result-matching ""

    No results matching ""