Menage de printemps et Marseille devant
[lhc/web/spip_carte_de_sites.git] / contenu / page-carte_de_sites.html
old mode 100644 (file)
new mode 100755 (executable)
index 5609079..71eb8a0
@@ -1,69 +1,97 @@
-<script src="#CONFIG{adresse_site}/lib/CloudMade-Leaflet-404b097/dist/leaflet.js"></script>
+[(#REM)
+    Modele carte_de_site
+    
+    Parametres :
+
+    - legende = oui : ne pas afficher la legende
+    - coord    = 46.8,2.52   : pour un centrage optimal sur la carte de France
+    - zoom    = 5   : pour un centrage optimal sur la carte de France
+    - larg  = 540   : largeur
+    - haut  = 400   : hauteur
+    - style = 14189 : style de carte. Voir http://maps.cloudmade.com/editor
+    - boite = oui   : affiche la boite avec calques et types
+    - popup = oui   : autoriser les popups
+    - images = oui  : afficher les images
+    - groupe = XXXX : Groupe de mot-clé dont il faut générer la carte
+    - lien  = oui   : Lien automatique vers la grande carte
+    - iframe= oui   : Affichage du code iframe par défaut
+]
+
+<!-- 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>
 
-<div id="map" style="width: 540px; height: 400px">
 <script>
-       var map = new L.Map('map');
-       
-       var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
-               cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
-               cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18, attribution: cloudmadeAttribution});
-       
-       map.setView(new L.LatLng(46.8, 2.52), 5).addLayer(cloudmade);
-  
+   <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)
+                     });
+                     gisIcon = new templateIcon()
+                     var markerGis = new L.Marker(new L.LatLng(#LAT, #LON), {icon: gisIcon});
+                           [(#ENV{popup}|!={non}|oui)
+                         markerGis.bindPopup("[(#ENV{images}|!={non}|oui)<span style='float: left; width: 45px;'><img src='[(#LOGO_SYNDIC||extraire_attribut{src}|url_absolue)]' alt='' style='width: 45px;' width='45'></span>]<h4>#TITRE</h4>#DESCRIPTIF[(#ENV{images}|!={non}|oui)<span class='spip_documents spip_documents_right' style='float: right; width: 100px;'>\<img src='[(#LOGO_SYNDIC_SURVOL||extraire_attribut{src}|url_absolue)]' alt='' style='width: 100px;' width='100'></span>]#ADRESSE<br/> #CODE_POSTAL #VILLE<br/><a href='#URL_SITE' target='_blank'>#NOM_SITE - #URL_SITE</a><br/><br/><em>Statut: [(#_mots_types:TITRE|supprimer_numero)]</em>");
+                     ]
+                     group_#ID_MOT.addLayer(markerGis)
+               </BOUCLE_coord>
+         </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=900[&coord=(#ENV{coord})][&zoom=(#ENV{zoom})][&legende=(#ENV{legende})]" rel="external" target="_blank">Voir la carte en plus grand</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}),
+      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{coord}|sinon{'46.8,2.52'})]),[(#ENV{zoom}|sinon{5})]).addLayer(minimal);
        
-<BOUCLE_ateliers_types(MOTS){type = Ateliers}{par num titre}>
-               <BOUCLE_sites(SITES){id_mot}>
-                               <BOUCLE_coord(GIS){id_syndic}>
-                                               var WorkshopIcon = L.Icon.extend({
-                                                   iconUrl: '#CONFIG{adresse_site}/IMG/[(#LOGO_MOT|fichier)]',
-                                                   shadowUrl: '#CONFIG{adresse_site}/IMG/[(#LOGO_MOT_SURVOL|fichier)]',
-                                                   iconSize: new L.Point(25, 41),
-                                                   shadowSize: new L.Point(41, 41),
-                                                   iconAnchor: new L.Point(13, 41),
-                                                   popupAnchor: new L.Point(0, -33)
-                                               });
-                                               siteIcon = new WorkshopIcon()
-                                               var markerAtelier = new L.Marker(new L.LatLng(#LAT, #LON), {icon: siteIcon});
-                                               map.addLayer(markerAtelier);
-                                               markerAtelier.bindPopup("<span style='float: left; width: 45px;'> <img src='#CONFIG{adresse_site}/IMG/#LOGO_SYNDIC**' alt='' style='width: 45px;' width='45'></span><a href='#URL_SITE'>#NOM_SITE</a><br/>#_sites:DESCRIPTIF<span class='spip_documents spip_documents_right' style='float: right; width: 100px;'> <img src='#CONFIG{adresse_site}/IMG/#LOGO_SYNDIC_SURVOL**' alt='' style='width: 100px;' width='100'></span>#ADRESSE<br/> #CODE_POSTAL #VILLE<br/><br/><em>Statut: [(#_ateliers_types:TITRE|supprimer_numero)]</em>");
-                               </BOUCLE_coord>
-               </BOUCLE_sites>
-</BOUCLE_ateliers_types>
+       //Ajout des marqueurs   
+   <BOUCLE_map(MOTS){type = (#ENV{groupe})}{!par num titre}>
+      map.addLayer(group_#ID_MOT);
+   </BOUCLE_map>
 
-                       
-       map.on('click', onMapClick);
+       [(#ENV{boite}|!={non}|oui)
+          <INCLURE{fond=inclure/boite}{env}>
+       ]
+
+   map.on('click', onMapClick);
        
-       var popup = new L.Popup();
+   var popup = new L.Popup();
 
-             function onMapClick(e) {
-                     var latlngStr = '(' + e.latlng.lat.toFixed(3) + ', ' + e.latlng.lng.toFixed(3) + ')';
+   function onMapClick(e) {
+      var latlngStr = '(' + e.latlng.lat.toFixed(5) + ',' + e.latlng.lng.toFixed(5) + ')';
+      popup.setLatLng(e.latlng);
+      popup.setContent("Coordonnees de votre clic (Latitude, Longitude)" + latlngStr);
+      map.openPopup(popup);
+   }
 
-                     popup.setLatLng(e.latlng);
-                     popup.setContent("You clicked the map at " + latlngStr);
-                     map.openPopup(popup);
-       }                               
-       
 </script>
 </div>
 
+[(#ENV{iframe}|!={non}|oui)
+<INCLURE{fond=inclure/iframe_carte}{ajax}{env}>
+]
 
-
-<h2 class='h2 spip'>Legende</h2>
-<BOUCLE_legende(MOTS){type = Ateliers}{par num titre}>
-       <p>#LOGO_MOT [(#TITRE|supprimer_numero)]</p>
+<B_legende>
+<!-- Legende -->
+    [(#ENV{legende}|!={non}|oui)
+        <h2 class='h2 spip'>Legende</h2>
+    ]
+<BOUCLE_legende(MOTS){type = (#ENV{groupe})}{par num titre}>
+    [(#ENV{legende}|!={non}|oui)
+       <p>#LOGO_MOT_NORMAL [(#TITRE|supprimer_numero)]</p>
+   ]   
 </BOUCLE_legende>
-
-
-
-<h2 class='h2 spip'>Ateliers</h2>
-<BOUCLE_liste_pays(GIS){par pays}{fusion pays}>
-       <h3 class='h3 spip'>#PAYS</h3>
-               <BOUCLE_liste_region(GIS){par region}{pays}{fusion region}>
-                       <h4 class='h4 spip'>#REGION</h4>
-                               <BOUCLE_liste_ateliers(GIS){par ville}{region}>
-                                       <li>#VILLE (#CODE_POSTAL) #TITRE - #ADRESSE</li>
-                               </BOUCLE_liste_ateliers>
-               </BOUCLE_liste_region>
-</BOUCLE_liste_pays>   
-
+</B_legende>