ed83889e49f4ccc6672087840ac88215919f1445
[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 (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 = [(#ENV{layer_defaut}|=={none}|?{"'none'",[new (#EVAL{$GLOBALS\['gis_layers'\]}|table_valeur{[(#ENV{layer_defaut,[(#REM|gis_layer_defaut)]})]/layer})]})];
17 if(base_layer != 'none'){
18 map_preview.addLayer(base_layer);
19 }
20
21 map_preview.setView(new L.LatLng([(#LAT)],[(#LON)]),[(#ZOOM|sinon{#CONFIG{gis/zoom,0}})]);
22
23 [(#REM) On ajoute les points ou le point unique suivant les params ]
24 <B_points>
25 var data = {
26 "type": "FeatureCollection",
27 "features": [
28 <BOUCLE_points(GIS){id_objet}{objet}{","}>
29 {"type": "Feature",
30 "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
31 "id":"#ID_GIS",
32 "properties": {
33 "title":[(#TITRE|supprimer_numero|json_encode)],
34 "description":[(#DESCRIPTIF|json_encode)][
35 (#LOGO_GIS|gis_icon_properties)]
36 }
37 }
38 </BOUCLE_points>
39 ]
40 };
41 [(#TOTAL_BOUCLE|>{1}|oui) #SET{autocenter,oui} ]
42 </B_points>
43 <BOUCLE_point(GIS){id_gis}>
44 var data = {
45 "type": "FeatureCollection",
46 "features": [
47 {"type": "Feature",
48 "geometry": {"type": "Point", "coordinates": [#LON, #LAT]},
49 "id":"#ID_GIS",
50 "properties": {
51 "title":[(#TITRE|supprimer_numero|json_encode)],
52 "description":[(#DESCRIPTIF|json_encode)][
53 (#LOGO_GIS|gis_icon_properties)]
54 }
55 }]
56 };
57 </BOUCLE_point>
58 <//B_points>
59 if (data) {
60 var geojson = new L.geoJson('', {
61 onEachFeature: function (feature, layer) {
62 if (feature.properties && feature.properties.icon){
63 layer.setIcon(new L.Icon({
64 iconUrl: feature.properties.icon,
65 iconSize: new L.Point( feature.properties.icon_size\[0\], feature.properties.icon_size\[1\] ),
66 iconAnchor: new L.Point( feature.properties.icon_anchor\[0\], feature.properties.icon_anchor\[1\] ),
67 popupAnchor: new L.Point( feature.properties.popup_anchor\[0\], feature.properties.popup_anchor\[1\] )
68 }));
69 }
70 if (feature.properties && feature.properties.title){
71 var popupContent = '<strong>' + feature.properties.title + '</strong>';
72 if (feature.properties.description)
73 popupContent = popupContent + feature.properties.description;
74 layer.bindPopup(popupContent);
75 }
76 }
77 }).addTo(map_preview);
78 geojson.addData(data);
79 [(#GET{autocenter}|oui)
80 if(data.features.length > 1)
81 map_preview.fitBounds(geojson.getBounds());]
82 }
83 [(#REM) On ajoute les KML attachés à l'objet ]
84 <BOUCLE_kml(DOCUMENTS){tous}{objet}{id_objet}{extension=kml}>
85 map_preview.addLayer(new L.KML('[(#URL_DOCUMENT|url_absolue)]', {async: true}));
86 </BOUCLE_kml>
87 [(#REM) On ajoute les GPX attachés à l'objet ]
88 <BOUCLE_gpx(DOCUMENTS){tous}{objet}{id_objet}{extension=gpx}>
89 map_preview.addLayer(new L.GPX('[(#URL_DOCUMENT|url_absolue)]', {async: true}));
90 </BOUCLE_gpx>
91 }
92
93 $(function(){
94 jQuery.getScript('[(#PRODUIRE{fond=javascript/gis.js}|compacte)]',function(){
95 init_map_preview();
96 });
97 //onAjaxLoad(init_map_preview(true));
98 });
99
100 })(jQuery);
101 /*]]>*/
102 </script>
103 </BOUCLE_gis>