{% extends 'base.html.twig' %}{% block title %}Addresse{% endblock %}{% block body %} <div class="row"> <div class="col-12"> <div class="card"> <div class="card-body"> <h4>Geocoder l'adresse : {{ addresse.toString() }}</h4> <div class="row"> <div class="col-lg-12"> <div class="card"> <div class="card-body"> <h4 class="card-title mb-4">Adresses trouvées :</h4> <div class="row"> <div class="col-md-6"> <div> <form method="post" action="{{ path('app_addresse_geocode', {'id': addresse.id }) }}" /> {% for possibilite in possibilites %} <div class="form-check mb-2"> <input class="form-check-input" type="radio" name="geocodingChoice" id="geocodingChoice{{ loop.index }}" {% if loop.index == 1%}checked="checked"{% endif %} value="{{ possibilite.lat }}||{{ possibilite.lon }}" /> <label class="form-check-label" for="geocodingChoice{{ loop.index }}" onclick="showme({{ loop.index - 1 }});"> {{ possibilite.label }} ( Score: {{ possibilite.score|round(3, 'floor') }}) </label> </div> {% endfor %} <input type="hidden" name="_token" value="{{ csrf_token('geocode' ~ addresse.id) }}"> <button class="btn btn-primary" type="submit">Choisir</button> </form> </div> </div> <div class="col-md-6"> <div class="card"> <div class="card-body"> <div id="map" class="gmaps"></div> </div> </div> </div> </div> <script type="text/javascript"> function initMap() { var locations = [ {% for possibilite in possibilites %} ['{{ possibilite.label }}', {{ possibilite.lat }},{{ possibilite.lon }}, 4], {% endfor %} ]; var bounds = new google.maps.LatLngBounds(); var markers = []; var map = new google.maps.Map(document.getElementById('map'), { zoom: 10, center: new google.maps.LatLng(-33.92, 151.25), mapTypeId: google.maps.MapTypeId.ROADMAP }); var infowindow = new google.maps.InfoWindow(); var marker, i; for (i = 0; i < locations.length; i++) { marker = new google.maps.Marker({ position: new google.maps.LatLng(locations[i][1], locations[i][2]), map: map }); google.maps.event.addListener(marker, 'click', (function(marker, i) { return function() { infowindow.setContent(locations[i][0]); infowindow.open(map, marker); } })(marker, i)); markers.push(marker); bounds.extend(marker.position); } map.fitBounds(bounds); showme = function (index) { markers[index].setAnimation(google.maps.Animation.DROP); //markers[index].setAnimation(null); /* if (markers[index].getAnimation() != google.maps.Animation.DROP) { markers[index].setAnimation(google.maps.Animation.DROP); } else { markers[index].setAnimation(null); }*/ } } $( document ).ready(function() { window.initMap = initMap; }); </script> </div> </div> </div> </div> </div> </div> </div> </div>{% endblock %}