[PLUGINS] +set de base
[lhc/web/www.git] / www / plugins / gis / formulaires / configurer_gis.html
diff --git a/www/plugins/gis/formulaires/configurer_gis.html b/www/plugins/gis/formulaires/configurer_gis.html
new file mode 100755 (executable)
index 0000000..d38bdf2
--- /dev/null
@@ -0,0 +1,152 @@
+<div class="formulaire_spip formulaire_configurer formulaire_configurer_gis">
+
+[<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>]
+[<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>]
+
+<div id="map_config" class="carte_gis" style="width: 100%; height: 370px"></div>
+
+<form method="post" action="#ENV{action}"><div>
+       #ACTION_FORMULAIRE{#ENV{action}}
+       <ul>
+               [(#SAISIE{input,lat,
+                       label=<:gis:lat:>,
+                       defaut=0,
+                       size=40})]
+               [(#SAISIE{input,lon,
+                       label=<:gis:lon:>,
+                       defaut=0,
+                       size=40})]
+               [(#SAISIE{input,zoom,
+                       label=<:gis:zoom:>,
+                       defaut=0,
+                       size=2,
+                       maxlength=2})]
+               
+               #SET{layers,#ARRAY}
+               <BOUCLE_layer(DATA){source table, #EVAL{$GLOBALS['gis_layers']}}>
+               #SET{layers,#GET{layers}|array_merge{#ARRAY{#CLE,#VALEUR|table_valeur{nom}}}}
+               </BOUCLE_layer>
+               
+               [(#SET{layer_defaut,openstreetmap_mapnik})]
+               [(#VAL{_GIS_LAYER_DEFAUT}|defined|oui)
+                       [(#SET{layer_defaut,[(#EVAL{_GIS_LAYER_DEFAUT})]})]
+               ]
+               [(#VAL{_GIS_LAYER_DEFAUT_FORCE}|defined|oui)
+                       [(#SET{layer_readonly,readonly})]
+                       [(#SET{layer_disable,disabled})]
+                       [(#SET{layer_forcee,[(#EVAL{_GIS_LAYER_DEFAUT_FORCE})]})]
+                       [(#SET{layer_explications,<:gis:explication_layer_forcee:>})]
+               ]
+               [(#SAISIE{selection,layer_defaut,
+                       label=<:gis:cfg_lbl_layer_defaut:>,
+                       cacher_option_intro=oui,
+                       defaut=#GET{layer_defaut},
+                       valeur_forcee=#GET{layer_forcee},
+                       readonly=#GET{layer_readonly},
+                       disable=#GET{layer_disable},
+                       explication=#GET{layer_explications},
+                       datas=#GET{layers}})]
+                       
+               [(#SAISIE{selection_multiple,layers,
+                       label=<:gis:cfg_lbl_layers:>,
+                       cacher_option_intro=oui,
+                       defaut=#GET{layer_defaut},
+                       datas=#GET{layers}})]
+               
+               [(#SAISIE{input,api_key_bing,
+                       label=<:gis:cfg_lbl_api_key_bing:>,
+                       explication=<:gis:cfg_inf_bing{url=https://www.bingmapsportal.com/}:>,
+                       size=40})]
+       
+               [(#SAISIE{oui_non,geocoder,
+                       defaut='',
+                       label=<:gis:cfg_lbl_geocoder:>,
+                       explication=<:gis:cfg_inf_geocoder:>})]
+               
+               [(#SAISIE{oui_non,adresse,
+                       defaut='',
+                       label=<:gis:cfg_lbl_adresse:>,
+                       explication=<:gis:cfg_inf_adresse:>})]
+               
+               [(#SAISIE{oui_non,geolocaliser_user_html5,
+                       defaut='',
+                       label=<:gis:cfg_lbl_geolocaliser_user_html5:>,
+                       explication=<:gis:cfg_inf_geolocaliser_user_html5:>})]
+
+               [(#SAISIE{choisir_objets,gis_objets,
+                       label=<:gis:cfg_lbl_activer_objets:>,
+                       exclus=spip_gis})]
+
+       </ul>
+
+
+       <p class="boutons">
+               <input type="submit" name="_cfg_ok" class="submit" value="<:bouton_enregistrer:>" />
+       </p>
+</div></form>
+
+<script type="text/javascript">
+<!---
+(function($){
+       
+       var maj_inputs = function(map,pos) {
+               var zoom = map.getZoom();
+               $("#champ_lat").val(pos.lat);
+               $("#champ_lon").val(pos.lng);
+               $("#champ_zoom").val(zoom);
+       }
+       
+       var init_config = function() {
+               var map;
+               var map_container = 'map_config';
+               map = new L.Map(map_container);
+               
+               map.attributionControl.setPrefix('');
+               
+               //default layer
+               #SET{layer_defaut,#REM|gis_layer_defaut} #SET{layers,#EVAL{$GLOBALS['gis_layers']}}
+               var [(#GET{layer_defaut})] = [new (#GET{layers}|table_valeur{#GET{layer_defaut}/layer})];
+               map.addLayer([(#GET{layer_defaut})]);
+               
+               <B_layers>
+               var layers_control = new L.Control.Layers();
+               layers_control.addBaseLayer([(#GET{layer_defaut})],["(#GET{layers}|table_valeur{#GET{layer_defaut}/nom})"]);
+               <BOUCLE_layers(DATA){source table, #GET{layers}}{si #ENV{control_type,#ENV{controle_type}}|!={non}|et{#ENV{no_control,#ENV{aucun_controle}}|!={oui}}|et{#CONFIG{gis/layers,#ARRAY}|count|>{1}|oui}|oui}>[
+               (#CLE|!={#GET{layer_defaut}}|oui|et{#CLE|in_array{#CONFIG{gis/layers,#ARRAY}}|oui}|oui)
+               layers_control.addBaseLayer([new (#VALEUR|table_valeur{layer})],"[(#VALEUR|table_valeur{nom})]");]
+               </BOUCLE_layers>
+               map.addControl(layers_control);
+               // classe noajax sur le layer_control pour éviter l'ajout de hidden par SPIP
+               $(layers_control._form).addClass('noajax');
+               </B_layers>
+
+               map.setView(new L.LatLng(#ENV{lat,0},#ENV{lon,0}),#ENV{zoom,0});
+               
+               var marker = new L.Marker(new L.LatLng(#ENV{lat,0},#ENV{lon,0}));
+               map.addLayer(marker);
+               
+               // mettre a jour les coordonnees quand on clique la carte
+               map.on('click', function(e) {
+                       marker.setLatLng(e.latlng);
+                       map.panTo(e.latlng);
+                       maj_inputs(map,e.latlng);
+               });
+               
+               // mettre à jour le zoom quand on le modifie
+               map.on('zoomend', function(e) {
+                       $("#champ_zoom").val(e.target._zoom);
+               });
+
+       }
+
+       $(function(){
+               jQuery.getScript('[(#PRODUIRE{fond=javascript/gis.js}|compacte)]',function(){
+                       init_config();
+               });
+               //onAjaxLoad(init_config);
+       });
+
+})(jQuery);
+-->
+</script>
+</div>