[PLUGINS] +clavettes et dependances
[lhc/web/clavette_www.git] / www / plugins / gis / modeles / carte_gis_preview.html
1 <BOUCLE_gis(GIS){objet ?}{id_objet ?}{id_gis ?}{0,1}>
2 <div id="map_preview" class="carte_gis" style="width: 100%; height: 150px;"></div>
3
4 <script type="text/javascript">
5 /*<![CDATA[*/
6 (function($){
7 var init_map_preview = function() {
8 var map_preview;
9 var map_preview_container = 'map_preview';
10 var marker;
11
12 map_preview = new L.Map(map_preview_container);
13
14 map_preview.attributionControl.setPrefix('');
15
16 var base_layer = [new (#EVAL{$GLOBALS\['gis_layers'\]}|table_valeur{[(#REM|gis_layer_defaut)]/layer})];
17 map_preview.addLayer(base_layer);
18
19 map_preview.setView(new L.LatLng([(#LAT)],[(#LON)]),[(#ZOOM|sinon{#CONFIG{gis/zoom,0}})]);
20
21 [(#REM) On ajoute les points ou le point unique suivant les params ]
22 <B_points>
23 var data = {
24 "type": "FeatureCollection",
25 "features": [
26 <BOUCLE_points(GIS){id_objet}{objet}{","}>
27 {"type": "Feature",
28 "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
29 "id":"#ID_GIS",
30 "properties": {
31 "title":[(#TITRE|supprimer_numero|json_encode)],
32 "description":[(#DESCRIPTIF|json_encode)][,(#LOGO_GIS|oui)
33 [(#SET{logo_doc,#LOGO_GIS|image_passe_partout{28,28}|image_recadre{28,28}|image_recadre{32,32,center}|image_aplatir{jpg,ffffff}})]
34 #SET{icon_w,#GET{logo_doc}|extraire_attribut{src}|largeur}
35 #SET{icon_h,#GET{logo_doc}|extraire_attribut{src}|hauteur}
36 ["icon": (#GET{logo_doc}|extraire_attribut{src}|url_absolue|json_encode)],
37 "icon_size": \[#GET{icon_w},#GET{icon_h}\],
38 "icon_anchor": \[[(#GET{icon_w}|div{2})],[(#GET{icon_h})]\],
39 "popup_anchor": \[1,[-(#GET{icon_h}|div{1.2})]\]]
40 }
41 }
42 </BOUCLE_points>
43 ]
44 };
45 [(#TOTAL_BOUCLE|>{1}|oui) #SET{autocenter,oui} ]
46 </B_points>
47 <BOUCLE_point(GIS){id_gis}>
48 var data = {
49 "type": "FeatureCollection",
50 "features": [
51 {"type": "Feature",
52 "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
53 "id":"#ID_GIS",
54 "properties": {
55 "title":[(#TITRE|supprimer_numero|json_encode)],
56 "description":[(#DESCRIPTIF|json_encode)][,(#LOGO_GIS|oui)
57 [(#SET{logo_doc,#LOGO_GIS|image_passe_partout{28,28}|image_recadre{28,28}|image_recadre{32,32,center}|image_aplatir{jpg,ffffff}})]
58 #SET{icon_w,#GET{logo_doc}|extraire_attribut{src}|largeur}
59 #SET{icon_h,#GET{logo_doc}|extraire_attribut{src}|hauteur}
60 ["icon": (#GET{logo_doc}|extraire_attribut{src}|url_absolue|json_encode)],
61 "icon_size": \[#GET{icon_w},#GET{icon_h}\],
62 "icon_anchor": \[[(#GET{icon_w}|div{2})],[(#GET{icon_h})]\],
63 "popup_anchor": \[1,[-(#GET{icon_h}|div{1.2})]\]]
64 }
65 }]
66 };
67 </BOUCLE_point>
68 <//B_points>
69 if (data) {
70 var geojson = new L.geoJson('', {
71 onEachFeature: function (feature, layer) {
72 if (feature.properties && feature.properties.icon){
73 layer.setIcon(new L.Icon({
74 iconUrl: feature.properties.icon,
75 iconSize: new L.Point( feature.properties.icon_size\[0\], feature.properties.icon_size\[1\] ),
76 iconAnchor: new L.Point( feature.properties.icon_anchor\[0\], feature.properties.icon_anchor\[1\] ),
77 popupAnchor: new L.Point( feature.properties.popup_anchor\[0\], feature.properties.popup_anchor\[1\] )
78 }));
79 }
80 if (feature.properties && feature.properties.title){
81 var popupContent = '<strong>' + feature.properties.title + '</strong>';
82 if (feature.properties.description)
83 popupContent = popupContent + feature.properties.description;
84 layer.bindPopup(popupContent);
85 }
86 }
87 }).addTo(map_preview);
88 geojson.addData(data);
89 [(#GET{autocenter}|oui)
90 map_preview.fitBounds(geojson.getBounds());]
91 }
92 [(#REM) On ajoute les KML attachés à l'objet ]
93 <BOUCLE_kml(DOCUMENTS){tous}{objet}{id_objet}{extension=kml}>
94 map_preview.addLayer(new L.KML('[(#URL_DOCUMENT|url_absolue)]', {async: true}));
95 </BOUCLE_kml>
96 [(#REM) On ajoute les GPX attachés à l'objet ]
97 <BOUCLE_gpx(DOCUMENTS){tous}{objet}{id_objet}{extension=gpx}>
98 map_preview.addLayer(new L.GPX('[(#URL_DOCUMENT|url_absolue)]', {async: true}));
99 </BOUCLE_gpx>
100 }
101
102 $(function(){
103 jQuery.getScript('[(#PRODUIRE{fond=javascript/gis.js}|compacte)]',function(){
104 init_map_preview();
105 });
106 //onAjaxLoad(init_map_preview(true));
107 });
108
109 })(jQuery);
110 /*]]>*/
111 </script>
112 </BOUCLE_gis>