templates/addresse/geocode.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Addresse{% endblock %}
  3. {% block body %}
  4.     <div class="row">
  5.         <div class="col-12">
  6.             <div class="card">
  7.                 <div class="card-body">
  8.                     <h4>Geocoder l'adresse : {{ addresse.toString() }}</h4>
  9.                     <div class="row">
  10.                         <div class="col-lg-12">
  11.                             <div class="card">
  12.                                 <div class="card-body">
  13.                                     <h4 class="card-title mb-4">Adresses trouvĂ©es :</h4>
  14.                                     <div class="row">
  15.                                         <div class="col-md-6">
  16.                                             <div>
  17.                                                 <form  method="post" action="{{ path('app_addresse_geocode', {'id': addresse.id }) }}" />
  18.                                                     {% for possibilite in possibilites %}
  19.                                                     <div class="form-check mb-2">
  20.                                                         <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 }}" />
  21.                                                         <label class="form-check-label" for="geocodingChoice{{ loop.index }}" onclick="showme({{ loop.index - 1 }});">
  22.                                                            {{ possibilite.label }}  ( Score: {{ possibilite.score|round(3, 'floor') }})
  23.                                                         </label>
  24.                                                     </div>
  25.                                                     {% endfor %}
  26.                                                     <input type="hidden" name="_token" value="{{ csrf_token('geocode' ~ addresse.id) }}">
  27.                                                     <button class="btn btn-primary" type="submit">Choisir</button>
  28.                                                 </form>
  29.                                             </div>
  30.                                         </div>
  31.                                         <div class="col-md-6">
  32.                                             <div class="card">
  33.                                                 <div class="card-body">
  34.                                                     <div id="map" class="gmaps"></div>
  35.                                                 </div>
  36.                                             </div>
  37.                                         </div>
  38.                                     </div>
  39.                                     <script type="text/javascript">
  40.                                        function initMap() {
  41.                                         var locations = [
  42.                                             {% for possibilite in possibilites %}
  43.                                                 ['{{ possibilite.label }}', {{ possibilite.lat }},{{ possibilite.lon }}, 4],
  44.                                             {% endfor %}
  45.                                         ];
  46.                                         var bounds = new google.maps.LatLngBounds();
  47.                                         var markers = [];
  48.                                         var map = new google.maps.Map(document.getElementById('map'), {
  49.                                             zoom: 10,
  50.                                             center: new google.maps.LatLng(-33.92, 151.25),
  51.                                             mapTypeId: google.maps.MapTypeId.ROADMAP
  52.                                         });
  53.                                         var infowindow = new google.maps.InfoWindow();
  54.                                         var marker, i;
  55.                                         for (i = 0; i < locations.length; i++) {
  56.                                             marker = new google.maps.Marker({
  57.                                                 position: new google.maps.LatLng(locations[i][1], locations[i][2]),
  58.                                                 map: map
  59.                                             });
  60.                                             google.maps.event.addListener(marker, 'click', (function(marker, i) {
  61.                                                 return function() {
  62.                                                     infowindow.setContent(locations[i][0]);
  63.                                                     infowindow.open(map, marker);
  64.                                                 }
  65.                                             })(marker, i));
  66.                                             markers.push(marker);
  67.                                             bounds.extend(marker.position);
  68.                                         }
  69.                                         map.fitBounds(bounds);
  70.                                         showme = function (index) {
  71.                                             markers[index].setAnimation(google.maps.Animation.DROP);
  72.                                             //markers[index].setAnimation(null);
  73.                                             /*
  74.                                             if (markers[index].getAnimation() != google.maps.Animation.DROP) {
  75.                                                 markers[index].setAnimation(google.maps.Animation.DROP);
  76.                                             } else {
  77.                                                 markers[index].setAnimation(null);
  78.                                             }*/
  79.                                         }
  80.                                        }
  81.                                        $( document ).ready(function() {
  82.                                            window.initMap = initMap;
  83.                                        });
  84.                                     </script>
  85.                                 </div>
  86.                             </div>
  87.                         </div>
  88.                     </div>
  89.                 </div>
  90.             </div>
  91.         </div>
  92.     </div>
  93. {% endblock %}