<div class="store-list__items">
{% for store in stores %}
<div class="store-list__item">
<a href="{{ path('app_shop_store_show', {code: store.code}) }}" title="{{ store.nameWhenLinked|e('html_attr') }}"><h2 class="store-list__item-title {% if store.isReseller %}reseller{% endif %}"><span class="store-list__badge {% if store.isReseller %}reseller{% endif %}">{{ loop.index }}</span>{{ store.name }}</h2></a>
<div class="store-list__infos-section">
{% if store.address != "" and store.address is not null %}
<div class="store-list__icon-block">
<i class="fas fa-map-marker-alt"></i>
<div>{{ store.address }}</div>
</div>
{% endif %}
{% if store.email != "" and store.email is not null %}
<div class="store-list__icon-block">
<i class="fas fa-envelope"></i>
<div><a href="mailto:{{ store.email }}" title="{{ 'sylius.stores.write_to_the_store'|trans|e('html_attr') }}">{{ store.email }}</a></div>
</div>
{% endif %}
{% if store.phone != "" and store.phone is not null %}
<div class="store-list__icon-block">
<i class="fas fa-phone"></i>
<div>{{ 'sylius.stores.phone'|trans }} <a href="tel:{{ store.phone }}" target="_blank" title="{{ 'sylius.stores.call_the_store'|trans|e('html_attr') }}">{{ store.phone }}</a></div>
</div>
{% endif %}
{% if store.fax != "" and store.fax is not null %}
<div class="store-list__icon-block">
<i class="fas fa-fax"></i>
<div>{{ 'sylius.stores.fax'|trans }} {{ store.fax }}</div>
</div>
{% endif %}
{% if store.openingTimes != "" and store.openingTimes is not null %}
<div class="store-list__icon-block store-list__icon-block--opening">
<i class="fas fa-clock"></i>
<div>
<strong>{{ 'sylius.stores.opening_times'|trans }}</strong>
<br>
{{ store.openingTimes|raw }}
</div>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
<script src='https://api.mapbox.com/mapbox-gl-js/v2.3.1/mapbox-gl.js'></script>
<script type="text/javascript">
// Display the map
mapboxgl.accessToken = '{{ mapbox_key }}';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/light-v10',
center: [10, 47.8],
zoom: 3
});
var geojson = {
'type': 'FeatureCollection',
'features': [
{% for store in stores %}
{% if loop.index0 > 0 %}
,
{% endif %}
{
'type': 'Feature',
'geometry': {
'type': 'Point',
'coordinates': [{% if store.gpsLng != "" and store.gpsLng is not null %}{{ store.gpsLng }}{% else %}0{% endif %}, {% if store.gpsLat != "" and store.gpsLat is not null %}{{ store.gpsLat }}{% else %}0{% endif %}]
},
'properties': {
'reseller': {% if store.isReseller %}true{% else %}false{% endif %},
'title': '{{ store.name|e('js') }}',
'description': `
<div class="store-list__infos-section">
<div class="store-list__icon-block">
<i class="fas fa-map-marker-alt"></i>
<div>{{ store.address }}</div>
</div>
{% if store.email != "" and store.email is not null %}
<div class="store-list__icon-block">
<i class="fas fa-envelope"></i>
<div><a href="mailto:{{ store.email }}" target="_blank" title="{{ 'sylius.stores.write_to_the_store'|trans|e('html_attr') }}">{{ store.email }}</a></div>
</div>
{% endif %}
{% if store.phone != "" and store.phone is not null %}
<div class="store-list__icon-block">
<i class="fas fa-phone"></i>
<div>{{ 'sylius.stores.phone'|trans|e('html_attr') }} <a href="tel:{{ store.phone }}" target="_blank" title="{{ 'sylius.stores.call_the_store'|trans|e('html_attr') }}">{{ store.phone }}</div>
</div>
{% endif %}
{% if store.fax != "" and store.fax is not null %}
<div class="store-list__icon-block">
<i class="fas fa-fax"></i>
<div>{{ 'sylius.stores.fax'|trans|e('html_attr') }} {{ store.fax }}</div>
</div>
{% endif %}
</div>
`
}
}
{% endfor %}
]
};
// add markers to map
geojson.features.forEach(function (marker) {
// create a HTML element for each feature
var el = document.createElement('div');
el.className = marker.properties.reseller ? 'marker reseller' : 'marker';
// make a marker for each feature and add it to the map
new mapboxgl.Marker(el)
.setLngLat(marker.geometry.coordinates)
.setPopup(
new mapboxgl.Popup({ offset: 25 }) // add popups
.setHTML(
'<h3>' +
marker.properties.title +
'</h3><p>' +
marker.properties.description +
'</p>'
)
)
.addTo(map);
});
var nav = new mapboxgl.NavigationControl();
map.addControl(nav, 'top-left');
</script>