[migration GIS4] affichage de la carte OK
[lhc/web/spip_carte_de_sites.git] / contenu / page-carte_de_sites.html
index 8221417..fa95376 100755 (executable)
     - lien  = oui   : Lien automatique vers la grande carte
     - iframe = oui  : Afficher ou non le lien vers le code iframe
     - loc = non     : Afficher ou non le popup de localisation
+    - champ_lat     : Prend l'identifiant d'une balise html en argument. Change la valeur (value) de cette balise par la latitude cliquee
+    - champ_lon     : Prend l'identifiant d'une balise html en argument. Change la valeur (value) de cette balise par la longitude cliquee
 ]
 
 <!-- Carte -->
 
 <div id="map" style="[(#ENV{larg}|oui) width: [(#ENV{larg}|sinon{'540'})px;]] height: [(#ENV{haut}|sinon{'400'})]px">
 
-<script src="[(#CHEMIN{lib/CloudMade-Leaflet-538dfb4/dist/leaflet.js}|url_absolue)]"></script>
+<script src="[(#CHEMIN{lib/leaflet-gis-4.1.13/dist/leaflet.js}|url_absolue)]"></script>
 
 <script>
    <BOUCLE_mots_types(MOTS){type = (#ENV{groupe})}>
          var group_#ID_MOT = new L.LayerGroup();
          <BOUCLE_sites(SITES){id_mot}>
                <BOUCLE_coord(GIS){id_syndic}>
-                     var templateIcon = L.Icon.extend({
-                         iconUrl: '[(#LOGO_MOT||extraire_attribut{src}|url_absolue)]',
-                         shadowUrl: '[(#LOGO_MOT_SURVOL||extraire_attribut{src}|url_absolue)]',
-                         iconSize: new L.Point(17, 28),
-                         shadowSize: new L.Point(17, 17),
-                         iconAnchor: new L.Point(13, 17),
-                         popupAnchor: new L.Point(0, -33)
-                     });
+               var templateIcon = L.Icon.extend({
+                   options: {
+                        iconUrl: '[(#LOGO_MOT||extraire_attribut{src}|url_absolue)]',
+                        shadowUrl: '[(#LOGO_MOT_SURVOL||extraire_attribut{src}|url_absolue)]',
+                        iconSize: new L.Point(17, 28),
+                        shadowSize: new L.Point(17, 17),
+                        iconAnchor: new L.Point(13, 17),
+                        popupAnchor: new L.Point(0, -33)
+                    }
+                 });
                      gisIcon = new templateIcon()
                      var markerGis = new L.Marker(new L.LatLng(#LAT, #LON), {icon: gisIcon});
                            [(#ENV{popup}|!={non}|oui)
          </BOUCLE_sites>
    </BOUCLE_mots_types>
 
-   var cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade<br/>[(#ENV{lien}|!={non}|oui)(<a href="#URL_SITE_SPIP/?page=carte_de_sites_plein&lien=non&groupe=#ENV{groupe}&boite=oui&haut=400[&lat=(#ENV{lat})][&lon=(#ENV{lon})][&zoom=(#ENV{zoom})][&legende=(#ENV{legende})]" rel="external" target="_blank">Voir la carte en plus grand</a>)]',
+   var cloudmadeAttribution = 'Map data &copy; OpenStreetMap contributors<br/>[(#ENV{lien}|!={non}|oui)(<a href="#URL_SITE_SPIP/?page=carte_de_sites_plein&lien=non&groupe=#ENV{groupe}&boite=oui&haut=400[&lat=(#ENV{lat})][&lon=(#ENV{lon})][&zoom=(#ENV{zoom})][&legende=(#ENV{legende})]" rel="external" target="_blank"><:carte_de_sites:grande_carte:></a>)]',
       cloudmadeOptions = {maxZoom: 18, attribution: cloudmadeAttribution},     
       cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/{styleId}/256/{z}/{x}/{y}.png';
                
    var midnightCommander = new L.TileLayer(cloudmadeUrl, cloudmadeOptions, {styleId: 999}),
+   thunderforest = new L.TileLayer('http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png', cloudmadeOptions),
       minimal = new L.TileLayer(cloudmadeUrl, cloudmadeOptions, {styleId: [(#ENV{style}|sinon{'14189'})]});
                
        //Construction de la carte
    var map = new L.Map('map');
-   map.setView(new L.LatLng([(#ENV{lat}|sinon{'46.8'})],[(#ENV{lon}|sinon{'2.52'})]),[(#ENV{zoom}|sinon{5})]).addLayer(minimal);
+   map.setView(new L.LatLng([(#ENV{lat}|sinon{'46.8'})],[(#ENV{lon}|sinon{'2.52'})]),[(#ENV{zoom}|sinon{5})]).addLayer(thunderforest);
        
        //Ajout des marqueurs   
    <BOUCLE_map(MOTS){type = (#ENV{groupe})}{!par num titre}>
    var popup = new L.Popup();
 
    function onMapClick(e) {
-      var latlngStr = '(' + e.latlng.lat.toFixed(18) + ',' + e.latlng.lng.toFixed(18) + ')';
-      popup.setLatLng(e.latlng);
-      popup.setContent("Coordonnees de votre clic (Latitude, Longitude)" + latlngStr);
-      map.openPopup(popup);
+       document.getElementById("#ENV{champ_lat}").value=e.latlng.lat.toFixed(18);
+       document.getElementById("#ENV{champ_lon}").value=e.latlng.lng.toFixed(18);
+       popup.setLatLng(e.latlng);
+       popup.setContent("<:carte_de_sites:coordonnees_clic:>");
+       map.openPopup(popup);
    }
    ]
 
@@ -90,7 +96,7 @@
 <B_legende>
 <!-- Legende -->
     [(#ENV{legende}|!={non}|oui)
-        <h2 class='h2 spip'>Legende</h2>
+        <h2 class='h2 spip'><:carte_de_sites:legende:></h2>
     ]
 <BOUCLE_legende(MOTS){type = (#ENV{groupe})}{par num titre}>
     [(#ENV{legende}|!={non}|oui)