{% macro check_full_size_map(array) %}
{% set full_size_map_exists = false %}
{% for item in array %}
{% if item is iterable %}
{% set result = _self.check_full_size_map(item) %}
{% if result %}
{% set full_size_map_exists = true %}
{% endif %}
{% elseif attribute(item, 'full_size_map') is defined %}
{% set full_size_map_exists = true %}
{% endif %}
{% if full_size_map_exists %}
{% set break_loop = true %}
{% set loop = [] %}
{% endif %}
{% else %}
{% if not loop.last %}
{% set loop = [] %}
{% endif %}
{% endfor %}
{% set _result = full_size_map_exists %}
{% endmacro %}
{% if territory_list_set is defined and territory_list_set is not empty %}
{% set full_size_map_exists = true %}
{% else %}
{% if block.map_elements is defined and block.map_elements is not empty %}
{% set full_size_map_exists = _self.check_full_size_map(block.map_elements) %}
{% endif %}
{% endif %}
<div id="map" class="experience-override{% if full_size_map_exists is defined and full_size_map_exists is not empty %} full-size{% endif %}"></div>
<div id="map-elements" data-territory="{{ block.filter == 'experiences' ? 0 : 1 }}">
{% if block.map_elements is defined and block.map_elements is not empty %}
{% set map_elements = block.map_elements %}
{% else %}
{% set map_elements = block.articles_smart_content %}
{% endif %}
{% for element in map_elements %}
{% set thematique_ids = [] %}
{% if element.content.content.adresse is defined and element.content.content.adresse is not empty %}
{% if element.excerpt.categories is defined and element.excerpt.categories is not empty %}
{% set categories = element.excerpt.categories %}
{% for category in categories %}
{% if category.id is defined and category.id is not empty %}
{% set thematique_ids = thematique_ids|merge([category.id]) %}
{% endif %}
{% endfor %}
{% endif %}
{% set type_territoire = null %}
{% if element.content.content.type_territoire is defined and element.content.content.type_territoire is not empty %}
{% set type_territoire = element.content.content.type_territoire %}
{% endif %}
<a href="#"
data-lat="{{ element.content.content.adresse[1] }}"
data-theme="{{ thematique_ids|json_encode|raw }}"
data-long="{{ element.content.content.adresse[2] }}"
data-title="{{ element.title }}"
{% if element.content.content.geoJson_set is defined and element.content.content.geoJson_set is not empty %}
data-set="{{ element.content.content.geoJson_set }}"
{% endif %}
{% set categoryColor = '' %}
{% if element.content.content.main_category is defined
and element.content.content.main_category is not empty
%}
{% set categoryColor = load_category_by_id(element.content.content.main_category.id, 'fr').entity.color %}
{% elseif thematique_ids[0] is defined and thematique_ids[0] is not null %}
{% set categoryColor = load_category_by_id(thematique_ids[0], 'fr').entity.color %}
{% endif %}
{% set categoryColor = categoryColor ?: '#354161' %}
data-main-color="{{categoryColor}}"
{% if type_territoire %}data-type="{{type_territoire}}"{% endif %}></a>
{% else %}
{% for map in element.content.content.main_content %}
{% if map.type == "map" %}
<a href="#" data-lat="{{ map.adresse[1] }}" data-long="{{ map.adresse[2] }}" data-set="{{ map.geoJson_set }}">{{ element.title }}</a>
{% if map.additional_content is defined and map.additional_content is not empty %}
{% for map_add in map.additional_content %}
<a href="#" data-lat="{{ map_add.adresse[1] }}" data-long="{{ map_add.adresse[2] }}" data-set="{{ map.geoJson_set }}">{{ element.title }}</a>
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</div>