An extended MarkerCollection that can directly be used with results from the PlacesService.

const markers = new PlaceMarkerCollection({map});
const placesService = new google.maps.places.PlacesService(map);

const searchQuery = {keyword: 'coffee', radius: 2000};

placesService.nearbySearch(searchQuery, (result, status) => {
if (status !== 'OK' || !result) return;

markers.setData(result);
});

Hierarchy (View Summary)

Constructors

Properties

Accessors

Methods

Constructors

Properties

key?: (data: PlaceResult) => string

The key function used to create string ids for the records in the collection. Specifying this function is highly recommended when the data needs to be updated.

Accessors

  • get map(): null | Map

    Returns the Google Map instance this collection was added to.

    Returns null | Map

  • set map(map: null | Map): void

    Adds this collection to the specified map instance. This will add all markers to the map.

    Parameters

    • map: null | Map

    Returns void

Methods

  • Generates a key for the passed user-data record. This implementation calls the key-function if specified or generates a random key and stores it.

    Parameters

    • record: PlaceResult

    Returns string

  • Sets or updates the data for this collection. When updating data, the implementation will use the key-function provided with the Options to detrmine which records were added, removed or changed and update the underlying marker instances accordingly.

    Parameters

    • data: PlaceResult[]

    Returns void