[PLUGINS] ~gis v4.41.1 --> v4.43.1
[lhc/web/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 #SET{autocenter,''}
4 <script type="text/javascript">
5 /*<![CDATA[*/
6 var jQgisloader;
7 (function (){
8 if (typeof jQuery.ajax == "undefined"){ jQuery(init_gis); } else { init_gis(); }
9 function init_gis(){
10 // Charger le javascript de GIS une seule fois si plusieurs carte
11 if (typeof jQgisloader=="undefined"){
12 jQgisloader = jQuery.ajax({url: '[(#PRODUIRE{fond=javascript/gis.js})]', dataType: 'script', cache: true});
13 }
14 // et initialiser la carte (des que js GIS charge et des que DOM ready)
15 jQgisloader.done(function(){
16 jQuery(function(){
17 var map_preview;
18 var map_preview_container = 'map_preview';
19 var marker;
20
21 map_preview = new L.Map(map_preview_container);
22
23 map_preview.attributionControl.setPrefix('');
24
25 var base_layer = [(#ENV{layer_defaut}|=={none}|?{"'none'",[new (#EVAL{$GLOBALS\['gis_layers'\]}|table_valeur{[(#ENV{layer_defaut,[(#REM|gis_layer_defaut)]})]/layer})]})];
26 if(base_layer != 'none'){
27 map_preview.addLayer(base_layer);
28 }
29
30 map_preview.setView(new L.LatLng([(#LAT)],[(#LON)]),[(#ZOOM|sinon{#CONFIG{gis/zoom,0}})]);
31
32 [(#REM) On ajoute les points ou le point unique suivant les params ]
33 <B_points>
34 var data = {
35 "type": "FeatureCollection",
36 "features": [
37 <BOUCLE_points(GIS){id_objet}{objet}{","}>
38 {"type": "Feature",
39 "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
40 "id":"#ID_GIS",
41 "properties": {
42 "title":[(#TITRE|supprimer_numero|json_encode)],
43 "description":[(#DESCRIPTIF|json_encode)][
44 (#LOGO_GIS|gis_icon_properties)]
45 }
46 }
47 </BOUCLE_points>
48 ]
49 };
50 [(#TOTAL_BOUCLE|>{1}|oui) #SET{autocenter,oui} ]
51 </B_points>
52 <BOUCLE_point(GIS){id_gis}>
53 var data = {
54 "type": "FeatureCollection",
55 "features": [
56 {"type": "Feature",
57 "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
58 "id":"#ID_GIS",
59 "properties": {
60 "title":[(#TITRE|supprimer_numero|json_encode)],
61 "description":[(#DESCRIPTIF|json_encode)][
62 (#LOGO_GIS|gis_icon_properties)]
63 }
64 }]
65 };
66 </BOUCLE_point>
67 <//B_points>
68 if (data) {
69 var geojson = new L.geoJson('', {
70 onEachFeature: function (feature, layer) {
71 if (feature.properties && feature.properties.icon){
72 layer.setIcon(new L.Icon({
73 iconUrl: feature.properties.icon,
74 iconSize: new L.Point( feature.properties.icon_size\[0\], feature.properties.icon_size\[1\] ),
75 iconAnchor: new L.Point( feature.properties.icon_anchor\[0\], feature.properties.icon_anchor\[1\] ),
76 popupAnchor: new L.Point( feature.properties.popup_anchor\[0\], feature.properties.popup_anchor\[1\] )
77 }));
78 }
79 if (feature.properties && feature.properties.title){
80 var popupContent = '<strong>' + feature.properties.title + '</strong>';
81 if (feature.properties.description)
82 popupContent = popupContent + feature.properties.description;
83 layer.bindPopup(popupContent);
84 }
85 }
86 }).addTo(map_preview);
87 geojson.addData(data);
88 [(#GET{autocenter}|oui)
89 if(data.features.length > 1)
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 }
103 })()
104 /*]]>*/
105 </script>
106 </BOUCLE_gis>