Groupement de calques: premier jet - Attention, ne fonctionne qu'avec Leaflet >= 3
[lhc/web/spip_carte_de_sites.git] / contenu / page-carte_de_sites.html
1 <div id="map" style="width: 540px; height: 400px">
2 <script src="#CONFIG{adresse_site}/lib/CloudMade-Leaflet-404b097/dist/leaflet.js"></script>
3
4 <script>
5 <BOUCLE_ateliers_types(MOTS){type = Ateliers}{par num titre}>
6 var group_#ID_MOT = new L.LayerGroup();
7 <BOUCLE_sites(SITES){id_mot}>
8 <BOUCLE_coord(GIS){id_syndic}>
9 var WorkshopIcon = L.Icon.extend({
10 iconUrl: '#CONFIG{adresse_site}/IMG/[(#LOGO_MOT|fichier)]',
11 shadowUrl: '#CONFIG{adresse_site}/IMG/[(#LOGO_MOT_SURVOL|fichier)]',
12 iconSize: new L.Point(25, 41),
13 shadowSize: new L.Point(41, 41),
14 iconAnchor: new L.Point(13, 41),
15 popupAnchor: new L.Point(0, -33)
16 });
17 siteIcon = new WorkshopIcon()
18 var markerAtelier = new L.Marker(new L.LatLng(#LAT, #LON), {icon: siteIcon});
19 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>");
20 group_#ID_MOT.addLayer(markerAtelier)
21 </BOUCLE_coord>
22 </BOUCLE_sites>
23 </BOUCLE_ateliers_types>
24
25 var cloudmadeAttribution = 'Map data &copy; 2011 OpenStreetMap contributors, Imagery &copy; 2011 CloudMade',
26 cloudmadeOptions = {maxZoom: 18, attribution: cloudmadeAttribution},
27 cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/{styleId}/256/{z}/{x}/{y}.png';
28
29 var minimal = new L.TileLayer(cloudmadeUrl, cloudmadeOptions, {styleId: 22677}),
30 midnightCommander = new L.TileLayer(cloudmadeUrl, cloudmadeOptions, {styleId: 999}),
31 motorways = new L.TileLayer(cloudmadeUrl, cloudmadeOptions, {styleId: 46561});
32
33 <B_map>
34 var map = new L.Map('map', {center: new L.LatLng(46.8, 2.52), zoom: 5, layers: [<BOUCLE_map(MOTS){type = Ateliers}> group_#ID_MOT,</BOUCLE_map> minimal, midnightCommander, motorways]});
35 </B_map>
36
37 var baseMaps = {
38 "Minimal": minimal,
39 "Night View": midnightCommander
40 };
41
42 <B_groups>
43 var overlayMaps = {
44 <BOUCLE_groups(MOTS){type = Ateliers}{par num titre}>
45 "[(#TITRE|supprimer_numero)]": group_#ID_MOT,</BOUCLE_groups>
46 "Motorways": motorways
47 };
48 </B_groups>
49
50
51 layersControl = new L.Control.Layers(baseMaps, overlayMaps);
52
53 map.addControl(layersControl);
54
55 map.on('click', onMapClick);
56
57 var popup = new L.Popup();
58
59 function onMapClick(e) {
60 var latlngStr = '(' + e.latlng.lat.toFixed(3) + ', ' + e.latlng.lng.toFixed(3) + ')';
61 popup.setLatLng(e.latlng);
62 popup.setContent("You clicked the map at " + latlngStr);
63 map.openPopup(popup);
64 }
65
66 </script>
67 </div>
68
69 <h2 class='h2 spip'>Legende</h2>
70 <BOUCLE_legende(MOTS){type = Ateliers}{par num titre}>
71 <p>#LOGO_MOT [(#TITRE|supprimer_numero)]</p>
72 </BOUCLE_legende>
73
74 <h2 class='h2 spip'>Ateliers</h2>
75 <BOUCLE_liste_pays(GIS){par pays}{fusion pays}>
76 <h3 class='h3 spip'>#PAYS</h3>
77 <BOUCLE_liste_region(GIS){par region}{pays}{fusion region}>
78 <h4 class='h4 spip'>#REGION</h4>
79 <BOUCLE_liste_ateliers(GIS){par ville}{region}>
80 <li>#VILLE (#CODE_POSTAL) #TITRE - #ADRESSE</li>
81 </BOUCLE_liste_ateliers>
82 </BOUCLE_liste_region>
83 </BOUCLE_liste_pays>