{% set idmap = id|default('mapid') %}
<script type="text/javascript">
	$(function () {
	  $('[data-toggle="tooltip"]').tooltip()
	  if ($('#{{idmap}}').length) {
	  	var mymap = L.map('{{idmap}}').setView({{KOH_MAP_CENTER}}, {{KOH_MAP_ZOOM}});

	  	L.tileLayer('https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png', {maxZoom: 18, attribution: '&copy; Openstreetmap France | &copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'}).addTo(mymap);

		{# AJOUTER LES MARQUEURS SUR LA CARTE #}
		{% set prestataires = getAllPrestataires() %}
		{% set count = 1 %}
		{% for presta in prestataires %}
			{% if presta.geoloc != null and presta.geoloc.lat != null and presta.geoloc.lon != null %}
				var marker_{{count}} = L.marker([{{presta.geoloc.lat}}, {{presta.geoloc.lon}}]).addTo(mymap);
	            marker_{{count}}.bindPopup("{% spaceless %}{% if presta.media != null %}{% thumbnail presta.media, 'small' %}<br/><br/>{% endif %}
	            	<a href='{{ path('show_prestataire', {'slug': presta.slug}) }}'>
	            		<strong>{{presta.__toString()}}</strong>
	            	</a>
	            	<br/>
	            	{% for rubrique in presta.rubriques %}
	            		<a class='maprubrique' href='{{ path('show_rubrique', {'slug': rubrique.slug}) }}'>{{rubrique.name|replace({"\n": '<br/>'})}}</a>
	            	{% endfor %}
	            	{% endspaceless %}");
	            {% set count = count+1 %}
	        {% endif %}
		{% endfor %}
	  }
	})
</script>
