templates/accueil.html.twig line 1

Open in your IDE?
  1. {% extends "layout.twig" %}
  2. {% block titre %} Les fiches masse d'eau du département de la Vienne {% endblock %}
  3. {% block titre_menu %} Les fiches masse d'eau  {% endblock %}
  4. {% block script %}
  5. <script>
  6. var map,closer;
  7. $(document).ready( function () {
  8.   jQuery(function () {
  9.     jQuery('[data-toggle="tooltip"]').tooltip()
  10.   })
  11.   // cours d'eau
  12.   vectorLayer = new ol.layer.Vector({
  13.     source: new ol.source.Vector({
  14.       {#  // url: '{{ asset('/data/mece_86.geojson')}}',
  15.       #}
  16.       url: '{{ asset('/json/trace_mece_ok.json')}}',
  17.       // url: '{{ asset('/json/trace_mece_cible.json')}}',
  18.       {# génére dansle controleur #}
  19.       format: new ol.format.GeoJSON(),
  20.     }),
  21.     style:new ol.style.Style({
  22.       // fill: new ol.style.Fill({
  23.       //   color: 'rgba(239, 22, 64, 0.38)',
  24.       // }),
  25.       stroke: new ol.style.Stroke({
  26.         color: '#063970',
  27.         width: 1,
  28.       }),
  29.     }),
  30.     name:'coursdeau'
  31.   });
  32.   const styleMECE = new ol.style.Style({
  33.    stroke: new ol.style.Stroke({
  34.      // color: '#e52a5c',
  35.      color: '#000',
  36.      width: 2,
  37.    }),
  38.    fill: new ol.style.Fill({
  39.      // color: 'rgba(0, 0, 0, 0)',
  40.      color: 'rgba(239, 22, 64, 0.38)'
  41.    })
  42.    });
  43.   // Masse d'eau
  44.   vectorLayer_contour = new ol.layer.Vector({
  45.     source: new ol.source.Vector({
  46.       {#  // url: '{{ asset('/data/mece86ok.geojson')}}',
  47.       #}
  48.       // url: '{{ asset('/json/contour_mece_ok.json')}}',
  49.       url: '{{ asset('/json/contour_mece_cible.json')}}',
  50.       {# génére via qgis en sql #}
  51.       format: new ol.format.GeoJSON(),
  52.     }),
  53.     style: function (feature) {
  54.       // const color = feature.get('COLOR') || '#eeeeee';
  55.       const cible = feature.get('cible');// || '#eeeeee';
  56.       // if (properties.cible == undefined) {
  57.       if (cible == undefined) {
  58.         // e.selected[0].setStyle(highlightStyle);
  59.         // console.log(cible);
  60.         styleMECE.getFill().setColor('rgba(239, 22, 64, 0.38)');
  61.       }
  62.       // else if (properties.cible.trim() == 'MECE cible SDE') {
  63.       else if (cible.trim() == 'MECE cible SDE') {
  64.         // e.selected[0].setStyle(highlightStyleCible);
  65.         styleMECE.getFill().setColor('rgba(40, 243, 84 , 0.38)');
  66.         // console.log(cible.trim());
  67.       }
  68.       // styleMECE.getFill().setColor(color);
  69.       return styleMECE;
  70.     },
  71.         name:'mece'
  72.   });
  73.  map = new ol.Map({
  74.         target: "map",
  75.         layers: [
  76.           new ol.layer.Tile({
  77.             source: new ol.source.OSM()
  78.           }),
  79.           vectorLayer_contour,
  80.           vectorLayer,
  81.           new ol.layer.Tile({
  82.             source: new ol.source.TileWMS ({
  83.               url: "https://wms.observatoire-environnement.org/sigore?",
  84.               //params: {"LAYERS": "regions_France" ,"SLD":"https://wms.biodiversite-nouvelle-aquitaine.fr/SLD/region_NASeul.sld"},
  85.               params: {"LAYERS": "departement_86_inversed"},
  86.                serverType: "mapserver"
  87.             })
  88.           })
  89.         ],
  90.         view: new ol.View({
  91.             projection : "EPSG:3857",
  92.           //center: ol.proj.fromLonLat([37.41, 8.82]),
  93.           //center: [-104667.82049552513, 5605076.301251277],
  94.           center: [ 75875.0800440154, 5861329.337154213],
  95.           // zoom: 8
  96.           zoom: 9
  97.         })
  98. });
  99. const pos = ol.proj.fromLonLat([16.3725, 48.208889]);
  100. const container = document.getElementById('popup');
  101. const content = document.getElementById('popup-content');
  102. const closer = document.getElementById('popup-closer');
  103. const overlay = new ol.Overlay({
  104.   element: container,
  105.   /*
  106.   // positioning: "top-center",
  107.   autoPan:true,
  108.   stopEvent: false,
  109.   offset: [0,0]
  110.   */
  111.   autoPan: {
  112.     animation: {
  113.       duration: 250,
  114.     },
  115.   },
  116. });
  117. map.addOverlay(overlay);
  118. closer.onclick = function () {
  119.   overlay.setPosition(undefined);
  120.   closer.blur();
  121.   return false;
  122. };
  123. // CLICK
  124. map.on('click', function (e) {
  125.   var hitTest = map.forEachFeatureAtPixel(e.pixel, function (f,layer) {
  126.      if (layer.get('name')=='mece') {
  127.       const coordinate = e.coordinate;
  128.       content.innerHTML = '<div class="header-popup"><h3>'+f.get('code_sandre')+'</h3></div><div class="contenu-popup"><p>'+f.get('nom')+'<br><a target="_blank" href="/fiche?fiche='+f.get('code_sandre')+'">Voir la fiche > </a></p></div>';
  129.         overlay.setPosition(coordinate);
  130.       }
  131.   });
  132. });
  133. // HOVER
  134.  var selected = null;
  135.  map.on('pointermove', function (e) {
  136.    if (selected !== null) {
  137.      selected.setStyle(undefined);
  138.      selected = null;
  139.      // map.getTargetElement().style.cursor = '';
  140.    }
  141.    var hit = map.forEachFeatureAtPixel(e.pixel, function (f,layer) {
  142.       if (layer.get('name')=='mece')  {
  143.        selected = f;
  144.        if (f.get('cible') == undefined) {
  145.          f.setStyle(highlightStyle);
  146.        }
  147.        else if (f.get('cible').trim() == 'MECE cible SDE') {
  148.          f.setStyle(highlightStyleCible);
  149.        }
  150.        return true;
  151.       }
  152.    });
  153.    /*
  154.    if (hit) {
  155.      map.getTargetElement().style.cursor = 'pointer';
  156.    }
  157.    else map.getTargetElement().style.cursor = '';
  158.    */
  159.  });
  160.   var highlightStyle = new ol.style.Style({
  161.     fill: new ol.style.Fill({
  162.       color: 'rgba(239, 22, 64, 0.78)',
  163.     }),
  164.     stroke: new ol.style.Stroke({
  165.       // color: '#e52a5c',
  166.       color: '#000',
  167.       width: 3,
  168.     }),
  169.   });
  170.   var highlightStyleCible = new ol.style.Style({
  171.     fill: new ol.style.Fill({
  172.       // color: 'rgba(40, 243, 84 , 0.38)',
  173.       color: 'rgba(40, 243, 84 , 0.78)',
  174.     }),
  175.     stroke: new ol.style.Stroke({
  176.       // color: '#28f354',
  177.       color: '#000',
  178.       width: 3,
  179.     }),
  180.   });
  181. });
  182. </script>
  183. {% endblock %}
  184. {% block main %}
  185. <main role="main" class="container-fluid">
  186. {% endblock %}
  187. {% block contenu %}
  188. <style>
  189.       .map {
  190.         width: 100%;
  191.         /* height:400px; */
  192.         height:800px;
  193.       }
  194.       .legende-me {
  195.         background-color:rgba(239, 22, 64 , 0.38);
  196.         border:solid 1px black;
  197.         padding:5px 18px 5px 18px;
  198.         vertical-align:middle;
  199.         dispaly:inline-block;
  200.         margin-right:8px;
  201.       }
  202.       .legende-me#legende-me-cible {
  203.         background-color:rgba(40, 243, 84 , 0.38);
  204.       }
  205.     .ol-popup h3 {
  206.       background-color:rgb(240, 240, 240);
  207.       border-bottom:solid 1px grey;
  208.       width:100%;
  209.       font-size:16px;
  210.       font-weight:700;
  211.       border-top-left-radius:10px;
  212.       border-top-right-radius:10px;
  213.       padding: 15px;
  214.       font-family:system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  215.     }
  216.     .ol-popup a,
  217.     .ol-popup p
  218.      {
  219.       font-size:14px;
  220.       font-weight:400;
  221.       font-family:system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  222.     }
  223.     .ol-popup .contenu-popup {
  224.         padding: 0px 15px 10px 15px;
  225.     }
  226.     .ol-popup {
  227.         position: absolute;
  228.         background-color: white;
  229.         box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  230.         border-radius: 10px;
  231.         border: 1px solid #cccccc;
  232.         bottom: 12px;
  233.         left: -50px;
  234.         min-width: 280px;
  235.       }
  236.       .ol-popup:after, .ol-popup:before {
  237.         top: 100%;
  238.         border: solid transparent;
  239.         content: " ";
  240.         height: 0;
  241.         width: 0;
  242.         position: absolute;
  243.         pointer-events: none;
  244.       }
  245.       .ol-popup:after {
  246.         border-top-color: white;
  247.         border-width: 10px;
  248.         left: 48px;
  249.         margin-left: -10px;
  250.       }
  251.       .ol-popup:before {
  252.         border-top-color: #cccccc;
  253.         border-width: 11px;
  254.         left: 48px;
  255.         margin-left: -11px;
  256.       }
  257.       .ol-popup-closer {
  258.         text-decoration: none;
  259.         position: absolute;
  260.         top: 2px;
  261.         right: 8px;
  262.       }
  263.       .ol-popup-closer:after {
  264.         content: "✖";
  265.       }
  266. </style>
  267.  <div class="row justify-content-center">
  268.    <div class='col-12 col-md-5 py-3'>
  269.      <div id="map"  class="map">
  270.        <!-- <p>test</p> -->
  271.      </div>
  272.      <div id="popup" class="ol-popup">
  273.       <a href="#" id="popup-closer" class="ol-popup-closer"></a>
  274.       <div id="popup-content"></div>
  275.     </div>
  276.   </div>
  277.   <div class='col-12 col-md-5 py-3'>
  278.     <div class="pt-5">
  279.       <p>Pour accéder à la fiche d'une masse d'eau, vous pouvez utiliser les <b>menus déroulants</b> ci-dessous : le choix se fait par le nom de la masse d'eau ou par son code Sandre.</p>
  280.      <form method="get" action="fiche/" >
  281.        <div class="input-group  ">
  282.          <select class="form-control form-inline " name="fiche" >
  283.            {% for masseEau in mece|sort((a, b) => a.nom <=> b.nom) %}
  284.            {#  <option value="{{masseEau.cdeumassed}}" >{{masseEau.nommassede}} </option>
  285.            #}
  286.            <option value="{{masseEau.getcodeSandre()}}" >{{masseEau.nom}} </option>
  287.            {% endfor %}
  288.          </select>
  289.          <div class="input-group-append mb-3">
  290.            <input type='submit' class="btn btn-primary" value="Accèder à la fiche">
  291.          </div>
  292.        </div>
  293.      </form>
  294.      <form method="get" action="fiche/" >
  295.        <div class="input-group  ">
  296.          <select class="form-control form-inline " name="fiche" >
  297.            {% for masseEau in mece|sort((a, b) => a.codeSandre <=> b.codeSandre) %}
  298.            {# <option value="{{masseEau.cdeumassed}}" >{{masseEau.cdeumassed}} </option> #}
  299.            <option value="{{masseEau.getcodeSandre}}" >{{masseEau.getcodeSandre}} </option>
  300.            {% endfor %}
  301.          </select>
  302.          <div class="input-group-append">
  303.            <input type='submit' class="btn btn-primary" value="Accèder à la fiche">
  304.          </div>
  305.        </div>
  306.      </form>
  307.     </div>
  308.     <div _style="max-width:75%;justify-content:center" class="pt-5">
  309.       <p>Ou alors <b>sur la carte</b>, cliquer sur la masse d'eau de votre choix pour accéder à sa fiche en cliquant le lien.</p>
  310.       <p style="display:inline-block" class="mt-4 mb-3"><b><u>Légende</u></b></p>
  311.       <p><span class="legende-me"></span> Masse d'eau</p>
  312.       <p style="line-height:1.2">
  313.         <span class="legende-me" id="legende-me-cible"></span>
  314.         Masse d'eau cible
  315.         <span class="badge badge-tooltip badge-pill badge-info" data-toggle="tooltip"  data-trigger="hover" data-placement="bottom" data-html="true" title="<div class='_mt-5 explique-donnee py-2'>
  316.           <p>Dans le cadre du Plan d’Actions Opérationnel Territorialisé (PAOT), outil opérationnel de l’Etat pour la mise en œuvre des programmes de mesures (PDM) des SDAGE à l’échelle départementale, 10 masses d’eau cibles ont été identifiées sur le département de la Vienne sur lesquelles une attention particulière est portée.  Ces masses d’eau cibles concernent  principalement des masses d’eau altérées dont la qualité peut s’améliorer rapidement par des actions ciblées sur les pressions identifiées.</p>
  317.         </div>">
  318.         i
  319.         </span>
  320.       </p>
  321.       <p style="line-height:1.2">
  322.         <span class="legende-badge badge badge-tooltip badge-pill badge-info" >
  323.         i
  324.         </span>
  325.         <span _class="legende-me" id="legende-me-cible">Informations</span>
  326.       </p>
  327.       <p style="line-height:1.2">
  328.         <span class="legende-badge badge badge-tooltip badge-pill badge-info" >
  329.         s
  330.         </span>
  331.         <span _class="legende-me" id="legende-me-cible">Sources de la donnée</span>
  332.       </p>
  333.     </div>
  334.    </div>
  335.  </div>
  336. {% endblock %}