Description

The angular-ready wrapper for the native google.maps.Data.Feature class.

Extends

GoogleMapsNativeObjectEmittingWrapper

Implements

IGoogleMapsFeature

Index

overlays/modules/data/feature/google-maps-feature.ts

Properties
Methods

Constructor

constructor(data: IGoogleMapsData, api: GoogleMapsApiService, native: any)
Parameters:
Name Type Optional
data IGoogleMapsData No
api GoogleMapsApiService No
native any No

Properties

Public Readonly data
Type: IGoogleMapsData
Public custom
Type: any
Public Readonly native
Type: TNative
The instantiated native object to be wrapped.

Methods

Public getBounds
getBounds()
Returns: google.maps.LatLngBounds
Public getId
getId()
Returns: string | number
Public getProperties
getProperties()
Public setMarker
setMarker(position: Coord)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
position Coord No
Returns: void
Public setPolygon
setPolygon(path: CoordPath)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
path CoordPath No
Returns: void
Public setPolyline
setPolyline(path: Path)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
path Path No
Returns: void
Public setProperties
setProperties(properties: FeatureProperties)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
properties FeatureProperties No
Returns: void
Public toGeoJson
toGeoJson()
Returns: Promise<any>
Public clearListeners
clearListeners()

Unregisters all handlers of any previously registered native event.

Returns: void
Public listenTo
listenTo(eventName: string, handleEvent: (args: any[]) => void)

Registers a handler to a specific event of the native object and takes care of executing the handler inside angular's zone.

Parameters:
Name Type Optional Description
eventName string No

The name of the native event to register the handler for.

handleEvent function No

The function to execute when the event is triggered by the native object.

Returns: void

An function for unregistering the handler from the event.

Public stopListeningTo
stopListeningTo(eventName: string)

Unregisters all handlers previously registered to handle a specific event.

Parameters:
Name Type Optional Description
eventName string No

The name of the native event for which to unregister all handlers.

Returns: void
Public setCustom
setCustom(custom: any)
Parameters:
Name Type Optional
custom any No
Returns: void
import { GoogleMapsApiService, GoogleMapsNativeObjectEmittingWrapper, NativeObjectWrapper, Coord, CoordPath, OutsideAngular, Path } from '@bespunky/angular-google-maps/core';
import { IGoogleMapsData                                                } from '../i-google-maps-data';
import { IGoogleMapsFeature, WrappedFeatureFunctions, FeatureProperties } from './i-google-maps-feature';

/** Extends intellisense for `GoogleMapsFeature` with native geometry feature functions. */
export interface GoogleMapsFeature extends WrappedFeatureFunctions { }

/**
 * The angular-ready wrapper for the native `google.maps.Data.Feature` class.
 *
 * @export
 * @class GoogleMapsFeature
 * @extends {GoogleMapsNativeObjectEmittingWrapper<google.maps.Data.Feature>}
 * @implements {IGoogleMapsFeature}
 */
// @dynamic
@NativeObjectWrapper<GoogleMapsFeature>()
export class GoogleMapsFeature extends GoogleMapsNativeObjectEmittingWrapper<google.maps.Data.Feature> implements IGoogleMapsFeature
{
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    constructor(public readonly data: IGoogleMapsData, api: GoogleMapsApiService, native: any /* See super for docs on `any` */)
    {
        super(api, native);
    }

    public getBounds(): google.maps.LatLngBounds
    {
        return this.api.geometry.defineGeometryBounds(this.getGeometry());
    }

    public getId(): string | number
    {
        return this.native.getId();
    }

    public getProperties(): FeatureProperties
    {
        const properties = {};

        this.native.forEachProperty((value, name) => properties[name] = value);

        return properties;
    }
    
    @OutsideAngular
    public setProperties(properties: FeatureProperties): void
    {
        Object.keys(properties).forEach(name => this.native.setProperty(name, properties[name]));
    }

    @OutsideAngular
    public setMarker(position: Coord): void
    {
        this.native.setGeometry(this.api.geometry.createDataPoint(position));
    }

    @OutsideAngular
    public setPolygon(path: CoordPath): void
    {
        this.native.setGeometry(this.api.geometry.createDataPolygon(path));
    }

    @OutsideAngular
    public setPolyline(path: Path): void
    {
        this.native.setGeometry(this.api.geometry.createDataPolyline(path));
    }

    public toGeoJson(): Promise<any>
    {
        return new Promise(resolve => this.native.toGeoJson(resolve));
    }
}

results matching ""

    No results matching ""