Description

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

Extends

GoogleMapsDrawableOverlay

Implements

IGoogleMapsMarker

Index

overlays/modules/marker/google-maps-marker.ts

Properties
Methods

Constructor

constructor(map: IGoogleMap, api: GoogleMapsApiService, native: any)
Parameters:
Name Type Optional
map IGoogleMap No
api GoogleMapsApiService No
native any No

Properties

Public map
Type: IGoogleMap
The map to which this overlay should be added.
Public Readonly type
Type: OverlayType
The type of overlay this wrapper holds. Used by the `OverlayTracker` to distinguish between types.
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 getPosition
getPosition()
Returns: google.maps.LatLngLiteral
Public setPosition
setPosition(position: BoundsLike)
Decorators :
@OutsideAngular()
Parameters:
Name Type Optional
position BoundsLike No
Returns: void
Public attach
attach(map: IGoogleMap)

Assigns the overlay to the specified map. If possible, prefer using the appropriate GoogleMap.createXXX() method instead. If not possible, it is the responsability of the caller to add the overlay to the OverlayTracker in the GoogleMap.overlays object. Otherwise, inconsistencies and unexpected behaviours might occur.

Parameters:
Name Type Optional Description
map IGoogleMap No

The map to dispaly the overlay on.

Returns: void
Public detach
detach()

Removes the overlay from the map it is attached to. If possible, prefer using the GoogleMap.removeOverlay() method instead. If not possible, it is the responsability of the caller to remove the overlay from the OverlayTracker in the GoogleMap.overlays object. Otherwise, inconsistencies and unexpected behaviours might occur.

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 { GoogleMapsApiService, NativeObjectWrapper, IGoogleMap, OutsideAngular, BoundsLike, Delegation } from '@bespunky/angular-google-maps/core';
import { GoogleMapsDrawableOverlay                 } from '../../abstraction/base/google-maps-drawable-overlay';
import { OverlayType                               } from '../../abstraction/base/overlay-type.enum';
import { IGoogleMapsMarker, WrappedMarkerFunctions } from './i-google-maps-marker';

/** Extends intellisense for `GoogleMapsMarker` with native marker functions. */
export interface GoogleMapsMarker extends WrappedMarkerFunctions { }

/**
 * The angular-ready wrapper for the native `google.maps.Marker` class.
 *
 * @export
 * @class GoogleMapsMarker
 * @extends {GoogleMapsDrawableOverlay<google.maps.Marker>}
 * @implements {IGoogleMapsMarker}
 */
// @dynamic
@NativeObjectWrapper<GoogleMapsMarker>({
    getMap: Delegation.Exclude,
    setMap: Delegation.Exclude
})
export class GoogleMapsMarker extends GoogleMapsDrawableOverlay<google.maps.Marker> implements IGoogleMapsMarker
{
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    constructor(map: IGoogleMap, api: GoogleMapsApiService, native: any /* See super for docs on `any` */)
    {
        super(OverlayType.Marker, map, api, native);
    }
    
    public getBounds(): google.maps.LatLngBounds
    {
        return this.api.geometry.defineCoordBounds(this.getPosition());
    }

    public getPosition(): google.maps.LatLngLiteral
    {
        return this.api.geometry.toLiteralCoord(this.native.getPosition());
    }
    
    @OutsideAngular
    public setPosition(position: BoundsLike): void
    {
        this.native.setPosition(this.api.geometry.centerOf(position));
    }
}

results matching ""

    No results matching ""