How do I differentiate between entries after merging an array? I'm trying to plot entries from two different Solspace Calendars and an Entries section on one map, and use different markers for all types. Alll of the events are related to the current Entry through a field set on the Event, and a field set on the Entry. I have:


E Waste - Solspace Calendar
Community Events - Solspace Calendar
Disposal Sites - Craft Entry


All three of those above have address fields, and I'll be plotting them on a Smart Map. Currently, I'm doing this:

{# Get all eWaste events related to material #}
{% set eWaste = craft.calendar.events({
calendar: 'eWaste',
    relatedTo: [ 'or', { targetElement: entry.materialCategory }, { targetElement: entry } ],
    rangeStart: now|date('Y-m-d'),
    rangeEnd: now|date_modify('+3 months')
}) %}

{# Get related sites #}
{% set sites = craft.entries.section('sites').relatedTo([ 'or', { targetElement: entry.materialCategory }, { targetElement: entry }]) %}

{# Merge events and entries #}
{% set locations = eWaste|merge( sites ) %}

{{ craft.smartMap.map(locations, options) }}


That gets events from one calendar, and the entries in to a single array so I can plot them on one map, but I can't work out how to differentiate between the types in order to give them different markers. As an example, entry.type doesn't work, and neither does {% if entry.eventField is defined %}

Am I going about this the wrong way? How do I achieve what I'm after? Will the above approach also work for two different calendars + entries?
Not sure if I totally got it but you can check the class of an object via

{% if element is instance of ('craft\\elements\\Entry') %}


or via switch statement

{% switch className(element) %}
    {% case 'craft\\elements\\Entry' %}