1 <div class=
"formulaire_spip formulaire_configurer formulaire_configurer_gis">
3 [
<p class=
"reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})
</p>]
4 [
<p class=
"reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})
</p>]
6 <div id=
"map_config" class=
"carte_gis" style=
"width: 100%; height: 370px"></div>
8 <form method=
"post" action=
"#ENV{action}"><div>
9 #ACTION_FORMULAIRE{#ENV{action}}
11 <li class=
"rechercher_adresse editer_map_config">
12 <label for=
"champ_map_config_geocoder"><:gis:label_rechercher_address:></label>
13 <input type=
"text" class=
"text" name=
"champ_map_config_geocoder" id=
"champ_map_config_geocoder" value=
"" />
14 <a id=
"map_config_rechercher_geocodage"><:info_rechercher:></a>
31 <BOUCLE_layer(DATA){source table, #EVAL{$GLOBALS['gis_layers']}}
>
32 #SET{layers,#GET{layers}|array_merge{#ARRAY{#CLE,#VALEUR|table_valeur{nom}}}}
35 [(#SET{layer_defaut,openstreetmap_mapnik})]
36 [(#VAL{_GIS_LAYER_DEFAUT}|defined|oui)
37 [(#SET{layer_defaut,[(#EVAL{_GIS_LAYER_DEFAUT})]})]
39 [(#VAL{_GIS_LAYER_DEFAUT_FORCE}|defined|oui)
40 [(#SET{layer_readonly,readonly})]
41 [(#SET{layer_disable,disabled})]
42 [(#SET{layer_forcee,[(#EVAL{_GIS_LAYER_DEFAUT_FORCE})]})]
43 [(#SET{layer_explications,
<:gis:explication_layer_forcee:>})]
45 [(#SAISIE{selection,layer_defaut,
46 label=
<:gis:cfg_lbl_layer_defaut:>,
47 cacher_option_intro=oui,
48 defaut=#GET{layer_defaut},
49 valeur_forcee=#GET{layer_forcee},
50 readonly=#GET{layer_readonly},
51 disable=#GET{layer_disable},
52 explication=#GET{layer_explications},
55 [(#SAISIE{selection_multiple,layers,
56 label=
<:gis:cfg_lbl_layers:>,
57 cacher_option_intro=oui,
58 defaut=#GET{layer_defaut},
61 [(#SAISIE{input,api_key_bing,
62 label=
<:gis:cfg_lbl_api_key_bing:>,
63 explication=
<:gis:cfg_inf_bing{url=https://www.bingmapsportal.com/}:
>,
66 [(#SAISIE{oui_non,geocoder,
68 label=
<:gis:cfg_lbl_geocoder:>,
69 explication=
<:gis:cfg_inf_geocoder:>})]
71 [(#SAISIE{oui_non,adresse,
73 label=
<:gis:cfg_lbl_adresse:>,
74 explication=
<:gis:cfg_inf_adresse:>})]
76 [(#SAISIE{oui_non,geolocaliser_user_html5,
78 label=
<:gis:cfg_lbl_geolocaliser_user_html5:>,
79 explication=
<:gis:cfg_inf_geolocaliser_user_html5:>})]
81 [(#SAISIE{choisir_objets,gis_objets,
82 label=
<:gis:cfg_lbl_activer_objets:>,
89 <input type=
"submit" name=
"_cfg_ok" class=
"submit" value=
"<:bouton_enregistrer:>" />
93 <script type=
"text/javascript">
97 var map, map_container = 'map_config', geocoder, marker;
99 var maj_inputs = function(map,pos,action) {
100 if(action == 'click'){
101 var zoom = map.getZoom();
102 $(
"#champ_lat").val(pos.lat);
103 $(
"#champ_lon").val(pos.lng);
104 $(
"#champ_zoom").val(zoom);
105 annuler_geocoder =
1;
106 }else if(annuler_geocoder !=
1){
107 if(pos.point == 'undefined'){
108 $('#champ_#ENV{champ_lat,lat}').val(pos.lat);
109 $('#champ_#ENV{champ_lon,lon}').val(pos.lng);
111 marker.setLatLng(pos);
113 $('#champ_#ENV{champ_lat,lat}').val(pos.point.lat);
114 $('#champ_#ENV{champ_lon,lon}').val(pos.point.lng);
115 map.panTo(pos.point);
116 marker.setLatLng(pos.point);
121 function geocode(query) {
123 maj_inputs(map,query,'geocoding');
125 alert('
<:gis:erreur_geocoder:> '+query.search);
128 var init_config = function() {
129 map = new L.Map(map_container);
131 map.attributionControl.setPrefix('');
134 #SET{layer_defaut,#REM|gis_layer_defaut} #SET{layers,#EVAL{$GLOBALS['gis_layers']}}
135 var [(#GET{layer_defaut})] = [new (#GET{layers}|table_valeur{#GET{layer_defaut}/layer})];
136 map.addLayer([(#GET{layer_defaut})]);
139 var layers_control = new L.Control.Layers();
140 layers_control.addBaseLayer([(#GET{layer_defaut})],[
"(#GET{layers}|table_valeur{#GET{layer_defaut}/nom})"]);
141 <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}
>[
142 (#CLE|!={#GET{layer_defaut}}|oui|et{#CLE|in_array{#CONFIG{gis/layers,#ARRAY}}|oui}|oui)
143 layers_control.addBaseLayer([new (#VALEUR|table_valeur{layer})],
"[(#VALEUR|table_valeur{nom})]");]
145 map.addControl(layers_control);
146 // classe noajax sur le layer_control pour éviter l'ajout de hidden par SPIP
147 $(layers_control._form).addClass('noajax');
150 map.setView(new L.LatLng(#ENV{lat,
0},#ENV{lon,
0}),#ENV{zoom,
0});
152 marker = new L.Marker(new L.LatLng(#ENV{lat,
0},#ENV{lon,
0}));
153 map.addLayer(marker);
155 geocoder = new L.Geocoder(geocode,{acceptLanguage:'#ENV{lang}'});
157 // mettre a jour les coordonnees quand on clique la carte
158 map.on('click', function(e) {
159 annuler_geocoder =
0;
160 marker.setLatLng(e.latlng);
162 maj_inputs(map,e.latlng,'click');
165 // geocoder si clic...
166 $('a#map_config_rechercher_geocodage').css(
"cursor",
"pointer").click(function(){
167 var address = $(
"#champ_map_config_geocoder").val();
168 annuler_geocoder =
0;
169 geocoder.geocode(address);
172 // ne pas soumettre le formulaire si on presse Entree depuis le champ de recherche
173 $('#champ_map_config_geocoder').keypress(function(e){
175 $('a#map_config_rechercher_geocodage').trigger(
"click");
180 // mettre à jour le zoom quand on le modifie
181 map.on('zoomend', function(e) {
182 $(
"#champ_zoom").val(e.target._zoom);
187 jQuery.getScript('[(#PRODUIRE{fond=javascript/gis.js}|compacte)]',function(){
190 //onAjaxLoad(init_config);