如何在标记点击时获取标记选项?

How to get marker options on marker click?

我正在使用 ionic 4 并使用 google 地图 api。我有几个像这样建立的标记:

setRestaurantMarkers() {
    const markers = [];
    this.singletonService.restaurants.results.map(restaurant => {
        const restaurantPosition = {lat: restaurant['Restaurant'].Lat, lng: restaurant['Restaurant'].Long};

        this.markerOptions = new Marker({
            position: restaurantPosition,
            title: restaurant['Restaurant'].Name,
            category: restaurant['RestaurantCategory'].Name,
            map: this.map
        });

        this.marker = new google.maps.Marker(this.markerOptions);
        this.marker.addListener('click', (marker) => {
            // Set destination for navigate button
            this.destination = [marker.latLng.lat(), marker.latLng.lng()];
            console.log(marker.latLng.lat(), marker.markerOptions);
            this.markerClicked = true;
        });
    });
}

但是我在单击标记时无法获得 markerOptions 详细信息。我想要这个 markerOptions 当点击标记时可能我找不到任何关于它的东西。

在 var 中分配标记选项而不是 class 属性

setRestaurantMarkers() {
    const markers = [];
    this.singletonService.restaurants.results.map(restaurant => {
        const restaurantPosition = {lat: restaurant['Restaurant'].Lat, lng: restaurant['Restaurant'].Long};

        const markerOptions = new Marker({ // make it as const
            position: restaurantPosition,
            title: restaurant['Restaurant'].Name,
            category: restaurant['RestaurantCategory'].Name,
            map: this.map
        });

        this.marker = new google.maps.Marker(markerOptions);
        this.marker.addListener('click', (marker) => {
            // Set destination for navigate button
            this.destination = [marker.latLng.lat(), marker.latLng.lng()];
            console.log(marker.latLng.lat(), markerOptions); // get directly
            this.markerClicked = true;
        });
    });
}