[PLUGINS] ~maj gis v4.26.1-->4.26.10
[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 #SET{autocenter,''}
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)][
33 (#LOGO_GIS|gis_icon_properties)]
34 }
35 }
36 </BOUCLE_points>
37 ]
38 };
39 [(#TOTAL_BOUCLE|>{1}|oui) #SET{autocenter,oui} ]
40 </B_points>
41 <BOUCLE_point(GIS){id_gis}>
42 var data = {
43 "type": "FeatureCollection",
44 "features": [
45 {"type": "Feature",
46 "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
47 "id":"#ID_GIS",
48 "properties": {
49 "title":[(#TITRE|supprimer_numero|json_encode)],
50 "description":[(#DESCRIPTIF|json_encode)][
51 (#LOGO_GIS|gis_icon_properties)]
52 }
53 }]
54 };
55 </BOUCLE_point>
56 <//B_points>
57 if (data) {
58 var geojson = new L.geoJson('', {
59 onEachFeature: function (feature, layer) {
60 if (feature.properties && feature.properties.icon){
61 layer.setIcon(new L.Icon({
62 iconUrl: feature.properties.icon,
63 iconSize: new L.Point( feature.properties.icon_size\[0\], feature.properties.icon_size\[1\] ),
64 iconAnchor: new L.Point( feature.properties.icon_anchor\[0\], feature.properties.icon_anchor\[1\] ),
65 popupAnchor: new L.Point( feature.properties.popup_anchor\[0\], feature.properties.popup_anchor\[1\] )
66 }));
67 }
68 if (feature.properties && feature.properties.title){
69 var popupContent = '<strong>' + feature.properties.title + '</strong>';
70 if (feature.properties.description)
71 popupContent = popupContent + feature.properties.description;
72 layer.bindPopup(popupContent);
73 }
74 }
75 }).addTo(map_preview);
76 geojson.addData(data);
77 [(#GET{autocenter}|oui)
78 map_preview.fitBounds(geojson.getBounds());]
79 }
80 [(#REM) On ajoute les KML attachés à l'objet ]
81 <BOUCLE_kml(DOCUMENTS){tous}{objet}{id_objet}{extension=kml}>
82 map_preview.addLayer(new L.KML('[(#URL_DOCUMENT|url_absolue)]', {async: true}));
83 </BOUCLE_kml>
84 [(#REM) On ajoute les GPX attachés à l'objet ]
85 <BOUCLE_gpx(DOCUMENTS){tous}{objet}{id_objet}{extension=gpx}>
86 map_preview.addLayer(new L.GPX('[(#URL_DOCUMENT|url_absolue)]', {async: true}));
87 </BOUCLE_gpx>
88 }
89
90 $(function(){
91 jQuery.getScript('[(#PRODUIRE{fond=javascript/gis.js}|compacte)]',function(){
92 init_map_preview();
93 });
94 //onAjaxLoad(init_map_preview(true));
95 });
96
97 })(jQuery);
98 /*]]>*/
99 </script>
100 </BOUCLE_gis>