{% extends 'base.html.twig' %}
{% block body %}
<div class="page">
<div class="container">
<div class="row animated fadeIn delay-0-2s">
<div class="col-12 mb-3 mb-lg-5">
<div class="">
<h2>Magic hobit</h2>
</div>
<div class="">
{% if debugAndFlush %}
<p>Debug and flush : Yes</p>
{% else %}
<p>Debug and flush : No</p>
{% endif %}
</div>
<hr></hr>
</div>
</div>
</div>
{% if tabHobit %}
{% if debugAndFlush %}
<div class="container">
<div class="row">
{% set i = 3 %}
{% set number = 1 %}
{% for hobit in tabHobit %}
<div class="col-12 col-lg-4 mb-3 mb-lg-5">
<div class="card animated fadeIn delay-0-{{ i }}s" style="width: 100%;">
<div class="card-img-top animated fadeIn delay-0-8s" style='text-align:center;'><iframe
width='100%'
height='300'
frameborder='0' style='border:0'
src='https://www.google.com/maps/embed/v1/place?key=AIzaSyAmbx9RsGi01srCnH_-2TVdH26TpjwvFDs
&q={{ hobit['data'].latitude }},{{ hobit['data'].longitude }}'
allowfullscreen>
</iframe>
</div>
<div class="card-body">
<h5 class="card-title">Hobit {{ number }}</h5>
<p class="card-text">Date start : {{ hobit['startDateTime']|date("d/m/Y H:i") }}</p>
<p class="card-text">Date end : {{ hobit['endDateTime']|date("d/m/Y H:i") }}</p>
<p class="card-text">Latitude : {{ hobit['data'].latitude }}</p>
<p class="card-text">Longitude : {{ hobit['data'].longitude }}</p>
<p class="card-text">Number : {{ hobit['number'] }}</p>
</div>
</div>
</div>
{% set i = i + 1 %}
{% set number = number + 1 %}
{% endfor %}
</div>
</div>
{% else %}
<div class="container">
<div class="row">
{% set number = 1 %}
{% for hobit in tabHobit %}
<div class="col-12 col-lg-6">
<div class="accordion" id="accordionExample">
<div class="accordion-item">
<div class="title">
{% if hobit['activityType'] == "still" %}
<i class="fas fa-chair"></i>
{% elseif hobit['activityType'] == "on_foot" %}
<i class="fas fa-walking"></i>
{% elseif hobit['activityType'] == "on_bicycle" %}
<i class="fas fa-bicycle"></i>
{% elseif hobit['activityType'] == "in_vehicle" %}
<i class="fas fa-car"></i>
{% endif %}
{{ hobit['activityType'] }}
</div>
{% if hobit["data"] is defined and hobit["data"].latitude and hobit["data"].longitude %}
<div>
<iframe
width='100%'
height='300'
frameborder='0' style='border:0'
src='https://www.google.com/maps/embed/v1/place?key=AIzaSyAmbx9RsGi01srCnH_-2TVdH26TpjwvFDs
&q={{ hobit["data"].latitude }},{{ hobit["data"].longitude }}'
allowfullscreen>
</iframe>
</div>
{% else %}
<div data-positions='{{ hobit['positions']|json_encode()|raw }}' id="map-multi-{{ number }}" class="animated fadeIn delay-0-8s map-multi" style="width: 100%; height: 300px;"></div>
{% endif %}
<div>
<button class="accordion-button button black mt-3 mb-3" type="button" data-bs-toggle="collapse" data-bs-target="#tab-{{ number }}-main" aria-expanded="true" aria-controls="collapseOne">Open</button>
</div>
<div id="tab-{{ number }}-main" class="accordion-collapse collapse" aria-labelledby="tab-{{ number }}-main-label" data-bs-parent="#accordionExample">
<div class="accordion-body">
<div class="line"><strong>Start date time : </strong><code>{{ hobit['startDateTime']|date("d/m/Y H:i", "Europe/Paris") }}</code></div>
<div class="line"><strong>Start date time server : </strong><code>{{ hobit['startDateTimeServer']|date("d/m/Y H:i", "Europe/Paris") }}</code></div>
<div class="line"><strong>End date time hobbit : </strong><code>{{ hobit['endDateTime']|date("d/m/Y H:i", "Europe/Paris") }}</code></div>
<div class="line"><strong>Type activity : </strong><code>{{ dump(hobit['activityType']) }}</code></div>
{% if hobit['id'] is defined %}
<div class="line"><strong>Id : </strong><code>{{ dump(hobit['id']) }}</code></div>
{% endif %}
<div class="line"><strong>Data : </strong><code>{{ dump(hobit) }}</code></div>
</div>
</div>
</div>
{% set number = number + 1 %}
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% else %}
<div class="text-center animated fadeIn delay-0-4s" style="font-size: 30px;">No data...</div>
{% endif %}
</div>
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script>
$(window).on('load', function() {
$(".map-multi").each(function( index ) {
console.log(JSON.parse($(this).attr("data-positions")));
initMap($(this).attr("id"));
});
function initMap(idMap) {
var positions = JSON.parse($("#" + idMap).attr("data-positions"));
//var myLatlng = new google.maps.LatLng(-25.363882,131.044922);
var mapOptions = {
zoom: 16,
center: new google.maps.LatLng(positions[0]['dataGps']['latitude'],positions[0]['dataGps']['longitude'])
}
var map = new google.maps.Map(document.getElementById(idMap), mapOptions);
var markers = [];
positions.forEach(function(element) {
markers.push(new google.maps.Marker({
position: new google.maps.LatLng(element['dataGps']['latitude'], element['dataGps']['longitude']),
//title: element[2] + " - " + element[0] + " - " + element[1]
}));
});
// To add the marker to the map, call setMap();
//markers[0].setMap(map);
//marker2.setMap(map);
markers.forEach(function(element) {
element.setMap(map);
});
}
});
</script>
{% endblock %}