Description

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

Extends

GoogleMapsNativeObjectEmittingWrapper

Implements

IGoogleMap

Index

core/modules/map/google-map.ts

Properties
Methods

Constructor

constructor(superpowers: ISuperpowers, api: GoogleMapsApiService, native: any)
Parameters:
Name Type Optional
superpowers ISuperpowers No
api GoogleMapsApiService No
native any No

Properties

Public Readonly superpowers
Type: ISuperpowers

The superpowers loaded for this map instance. Any lazy loaded superpowers will automatically load here as well.

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

Methods

Public fitBounds
fitBounds(elements: BoundsLike[], padding?: number | google.maps.Padding)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
elements BoundsLike[] No
padding number | google.maps.Padding Yes
Returns: void
Public getMapType
getMapType()
Returns: string | google.maps.MapTypeId
Public panTo
panTo(position: Coord)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
position Coord No
Returns: void
Public panToBounds
panToBounds(elements: BoundsLike[], padding?: number | google.maps.Padding)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
elements BoundsLike[] No
padding number | google.maps.Padding Yes
Returns: void
Public setCenter
setCenter(center: Coord)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
center Coord No
Returns: void
Public setMapType
setMapType(type: string | google.maps.MapTypeId)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
type string | google.maps.MapTypeId No
Returns: void
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 { GoogleMapsNativeObjectEmittingWrapper } from '../../abstraction/base/google-maps-native-object-emitting-wrapper';
import { Coord, BoundsLike                     } from '../../abstraction/types/geometry.type';
import { NativeObjectWrapper                   } from '../../decorators/native-object-wrapper.decorator';
import { OutsideAngular                        } from '../../decorators/outside-angular.decorator';
import { Delegation                            } from '../../decorators/wrapper-definition';
import { GoogleMapsApiService                  } from '../../api/google-maps-api.service';
import { ISuperpowers                          } from './superpowers/i-superpowers';
import { IGoogleMap, WrappedGoogleMapFunctions } from './i-google-map';

/** Extends intellisense for `GoogleMapsMap` with native map functions. */
export interface GoogleMap extends WrappedGoogleMapFunctions { }

/**
 * The angular-ready wrapper for the native `google.maps.Map` class.
 *
 * @export
 * @class GoogleMap
 * @extends {GoogleMapsNativeObjectEmittingWrapper<google.maps.Map>}
 * @implements {IGoogleMap}
 */
// @dynamic
@NativeObjectWrapper<GoogleMap>({
    panBy: Delegation.OutsideAngular
})
export class GoogleMap extends GoogleMapsNativeObjectEmittingWrapper<google.maps.Map> implements IGoogleMap
{
    constructor(
        /** The superpowers loaded for this map instance. Any lazy loaded superpowers will automatically load here as well. */
        public readonly superpowers: ISuperpowers,
                        api        : GoogleMapsApiService,
                        // eslint-disable-next-line @typescript-eslint/no-explicit-any
                        native     : any /* See super for docs on `any` */
    )
    {
        super(api, native);

        superpowers.attachToMap(this);
    }

    @OutsideAngular
    public setCenter(center: Coord)
    {
        this.native.setCenter(this.api.geometry.toLiteralCoord(center));
    }

    @OutsideAngular
    public fitBounds(elements: BoundsLike[], padding?: number | google.maps.Padding): void
    {
        this.native.fitBounds(this.api.geometry.defineBounds(...elements), padding);
    }
    
    @OutsideAngular
    public panToBounds(elements: BoundsLike[], padding?: number | google.maps.Padding): void
    {
        this.native.panToBounds(this.api.geometry.defineBounds(...elements), padding);
    }
    
    @OutsideAngular
    public panTo(position: Coord): void
    {
        this.native.panTo(this.api.geometry.toLiteralCoord(position));
    }
    
    public getMapType(): string | google.maps.MapTypeId { return this.native.getMapTypeId(); }

    @OutsideAngular
    public setMapType(type: string | google.maps.MapTypeId): void { this.native.setMapTypeId(type); }
}

results matching ""

    No results matching ""