I have an array of agm-markers displayed on an agm-map like this:
<agm-map [latitude]="mapCenterLatitude" [longitude]="mapCenterLongitude" [zoom]="getMapZoom()" [mapTypeId]="'hybrid'">
<agm-marker-cluster maxZoom="13" imagePath="https://raw.githubusercontent.com/googlemaps/v3-utility-library/master/markerclustererplus/images/m">
<agm-marker *ngFor="let marker of markers" [latitude]="marker.latitude" [longitude]="marker.longitude" [iconUrl]="marker.iconUrl">
<agm-info-window>
<h2>{{marker.title}}</h2>
<a routerLink="{{ marker.url }}">Details</a>
</agm-info-window>
</agm-marker>
</agm-marker-cluster>
</agm-map>
Now I want to be able to filter them by a category. Clicking a category-checkbox should make all markers invisible, which don't belong to that category.
How can I add this category to the marker? Is there a way to add custom properties (which is possible in the pure Google Maps API)?
As zolastro pointed out, you can simply add properties to marker. Then I made an condition on the [visible] property of the marker to make it invisible if filters do not match.