1 | <div class="formulaire_spip formulaire_configurer formulaire_configurer_gis"> |
---|
2 | |
---|
3 | [<p class="reponse_formulaire reponse_formulaire_ok">(#ENV*{message_ok})</p>] |
---|
4 | [<p class="reponse_formulaire reponse_formulaire_erreur">(#ENV*{message_erreur})</p>] |
---|
5 | |
---|
6 | <div id="map_config" class="carte_gis" style="width: 100%; height: 370px"></div> |
---|
7 | |
---|
8 | <form method="post" action="#ENV{action}"><div> |
---|
9 | #ACTION_FORMULAIRE{#ENV{action}} |
---|
10 | <ul> |
---|
11 | [(#SAISIE{input,lat, |
---|
12 | label=<:gis:lat:>, |
---|
13 | size=40})] |
---|
14 | [(#SAISIE{input,lon, |
---|
15 | label=<:gis:lon:>, |
---|
16 | size=40})] |
---|
17 | [(#SAISIE{input,zoom, |
---|
18 | label=<:gis:zoom:>, |
---|
19 | size=2, |
---|
20 | maxlength=2})] |
---|
21 | |
---|
22 | [(#SET{apis,[(#ARRAY{ |
---|
23 | cloudmade,<:gis:cfg_lbl_api_cloudmade:>, |
---|
24 | google,<:gis:cfg_lbl_api_google:>, |
---|
25 | googlev3,<:gis:cfg_lbl_api_googlev3:>, |
---|
26 | openlayers,<:gis:cfg_lbl_api_openlayers:>, |
---|
27 | ovi,<:gis:cfg_lbl_api_ovi:>, |
---|
28 | yandex,<:gis:cfg_lbl_api_yandex:>})]})] |
---|
29 | |
---|
30 | [(#VAL{_GIS_APIS}|defined|oui) |
---|
31 | [(#EVAL{_GIS_APIS}|unserialize|is_array|oui)#SET{apis,#EVAL{_GIS_APIS}|unserialize}] |
---|
32 | ] |
---|
33 | |
---|
34 | [(#SET{api_defaut,openlayers})] |
---|
35 | [(#VAL{_GIS_APIS_DEFAUT}|defined|oui) |
---|
36 | [(#SET{api_defaut,[(#EVAL{_GIS_APIS_DEFAUT})]})] |
---|
37 | ] |
---|
38 | [(#VAL{_GIS_APIS_FORCEE}|defined|oui) |
---|
39 | [(#SET{api_readonly,readonly})] |
---|
40 | [(#SET{api_disable,disabled})] |
---|
41 | [(#SET{api_forcee,[(#EVAL{_GIS_APIS_FORCEE})]})] |
---|
42 | [(#SET{api_explications,<:gis:explication_api_forcee:>})] |
---|
43 | ] |
---|
44 | |
---|
45 | [(#SAISIE{selection,api, |
---|
46 | label=<:gis:cfg_lbl_api:>, |
---|
47 | cacher_option_intro=oui, |
---|
48 | defaut=#GET{api_defaut},valeur_forcee=#GET{api_forcee},readonly=#GET{api_readonly},disable=#GET{api_disable},explication=#GET{api_explications}, |
---|
49 | datas=#GET{apis}})] |
---|
50 | |
---|
51 | [(#SET{maptypes,[(#ARRAY{ |
---|
52 | ROAD,<:gis:cfg_lbl_maptype_carte:>, |
---|
53 | SATELLITE,<:gis:cfg_lbl_maptype_satellite:>, |
---|
54 | HYBRID,<:gis:cfg_lbl_maptype_hybride:>, |
---|
55 | PHYSICAL,<:gis:cfg_lbl_maptype_relief:>})]})] |
---|
56 | |
---|
57 | [(#VAL{_GIS_MAPTYPES}|defined|oui) |
---|
58 | [(#EVAL{_GIS_MAPTYPES}|unserialize|is_array|oui)#SET{apis,#EVAL{_GIS_MAPTYPES}|unserialize}] |
---|
59 | ] |
---|
60 | |
---|
61 | [(#SET{maptype_defaut,carte})] |
---|
62 | [(#VAL{_GIS_MAPTYPES_DEFAUT}|defined|oui) |
---|
63 | [(#SET{maptype_defaut,[(#EVAL{_GIS_MAPTYPES_DEFAUT})]})] |
---|
64 | ] |
---|
65 | [(#VAL{_GIS_MAPTYPES_FORCE}|defined|oui) |
---|
66 | [(#SET{maptype_readonly,readonly})] |
---|
67 | [(#SET{maptype_disable,disabled})] |
---|
68 | [(#SET{maptype_force,[(#EVAL{_GIS_MAPTYPES_FORCE})]})] |
---|
69 | [(#SET{maptype_explications,<:gis:explication_maptype_force:>})] |
---|
70 | ] |
---|
71 | [(#SAISIE{selection,maptype, |
---|
72 | label=<:gis:cfg_lbl_maptype:>, |
---|
73 | cacher_option_intro=oui, |
---|
74 | defaut=#GET{maptype_defaut},valeur_forcee=#GET{maptype_force},readonly=#GET{maptype_readonly},disable=#GET{maptype_disable},explication=#GET{maptype_explications}, |
---|
75 | datas=#GET{maptypes}})] |
---|
76 | |
---|
77 | [(#SAISIE{oui_non,geocoder, |
---|
78 | defaut='', |
---|
79 | label=<:gis:cfg_lbl_geocoder:>, |
---|
80 | explication=<:gis:cfg_inf_geocoder:>})] |
---|
81 | |
---|
82 | [(#SAISIE{oui_non,adresse, |
---|
83 | defaut='', |
---|
84 | label=<:gis:cfg_lbl_adresse:>, |
---|
85 | explication=<:gis:cfg_inf_adresse:>})] |
---|
86 | |
---|
87 | [(#SAISIE{oui_non,geolocaliser_user_html5, |
---|
88 | defaut='', |
---|
89 | label=<:gis:cfg_lbl_geolocaliser_user_html5:>, |
---|
90 | explication=<:gis:cfg_inf_geolocaliser_user_html5:>})] |
---|
91 | |
---|
92 | [(#SAISIE{input,api_key_cloudmade, |
---|
93 | label=<:gis:cfg_lbl_api_key_cloudmade:>, |
---|
94 | explication=<:gis:cfg_inf_cloudmade{url=http://cloudmade.com/register}:>, |
---|
95 | size=40})] |
---|
96 | [(#SAISIE{input,api_key_google, |
---|
97 | label=<:gis:cfg_lbl_api_key_google:>, |
---|
98 | explication=<:gis:cfg_inf_google{url=http://www.google.com/apis/maps/signup.html}:>, |
---|
99 | size=40})] |
---|
100 | [(#SAISIE{input,api_key_yandex, |
---|
101 | label=<:gis:cfg_lbl_api_key_yandex:>, |
---|
102 | explication=<:gis:cfg_inf_yandex{url=http://api.yandex.ru/maps/}:>, |
---|
103 | size=40})] |
---|
104 | |
---|
105 | [(#SAISIE{choisir_objets,gis_objets, |
---|
106 | label=<:gis:cfg_lbl_activer_objets:>, |
---|
107 | exclus=spip_gis})] |
---|
108 | |
---|
109 | </ul> |
---|
110 | |
---|
111 | |
---|
112 | <p class="boutons"> |
---|
113 | <input type="submit" name="_cfg_ok" class="submit" value="<:bouton_enregistrer:>" /> |
---|
114 | </p> |
---|
115 | </div></form> |
---|
116 | |
---|
117 | <script type="text/javascript"> |
---|
118 | <!--- |
---|
119 | |
---|
120 | [var cloudmade_key = '(#ENV{api_key_cloudmade})';] |
---|
121 | |
---|
122 | (function($){ |
---|
123 | |
---|
124 | var maj_inputs = function(map,pos) { |
---|
125 | var zoom = map.getZoom(); |
---|
126 | $("#champ_lat").val(pos.lat); |
---|
127 | $("#champ_lon").val(pos.lon); |
---|
128 | $("#champ_zoom").val(zoom); |
---|
129 | } |
---|
130 | |
---|
131 | var init_config = function() { |
---|
132 | var map; |
---|
133 | var map_container = 'map_config'; |
---|
134 | // ne pas doublonner la carte quand on passe plusieurs fois dans ajaxload, pas propre mais bon... |
---|
135 | $('#map_config').empty(); |
---|
136 | map = new mxn.Mapstraction(map_container,'[(#REM|gis_api_utilisee)]'); |
---|
137 | map.setCenterAndZoom(new mxn.LatLonPoint(#ENV{lat,0},#ENV{lon,0}),#ENV{zoom,0}); |
---|
138 | // Pour l'API Openlayers, la methode n'existe pas |
---|
139 | try { |
---|
140 | map.setMapType([mxn.Mapstraction.(#REM|gis_maptype_utilise)]); |
---|
141 | } |
---|
142 | catch(err) { |
---|
143 | $(".editer_maptype").hide(); |
---|
144 | } |
---|
145 | |
---|
146 | map.addControls({ |
---|
147 | pan: true, |
---|
148 | zoom: '#ENV{control,small}', |
---|
149 | map_type: true |
---|
150 | }); |
---|
151 | |
---|
152 | [(#ENV{lat}|oui) |
---|
153 | point = new mxn.LatLonPoint([(#ENV{lat})],[(#ENV{lon})]); |
---|
154 | marker = new mxn.Marker(point); |
---|
155 | map.addMarker(marker);] |
---|
156 | |
---|
157 | // mettre a jour les coordonnees quand on clique la carte |
---|
158 | map.click.addHandler(function(name, source, args) { |
---|
159 | var pos = args.location; |
---|
160 | map.removeAllMarkers(); |
---|
161 | marker = new mxn.Marker(pos); |
---|
162 | map.addMarker(marker); |
---|
163 | map.setCenter(pos,{pan:true}); |
---|
164 | maj_inputs(map,pos); |
---|
165 | }); |
---|
166 | |
---|
167 | // mettre à jour le zoom quand on le modifie |
---|
168 | map.changeZoom.addHandler(function(name, source, args) { |
---|
169 | var zoom = source.getZoom(); |
---|
170 | $("#champ_zoom").val(zoom); |
---|
171 | }); |
---|
172 | |
---|
173 | } |
---|
174 | |
---|
175 | var geocoders = ['cartociudad','google','googlev3','yandex','openlayers']; |
---|
176 | |
---|
177 | var show_geocoder = function(){ |
---|
178 | if(($.inArray($('#champ_api').val(),geocoders) >= 0) && $('li.editer_geocoder').is(':hidden')){ |
---|
179 | $('li.editer_geocoder').slideDown() |
---|
180 | }else if(($.inArray($('#champ_api').val(),geocoders) < 0) && $('li.editer_geocoder').is(':visible')){ |
---|
181 | $('li.editer_geocoder').slideUp() |
---|
182 | } |
---|
183 | } |
---|
184 | |
---|
185 | var show_apis_keys = function(){ |
---|
186 | if(($('#champ_api').val() == "cloudmade") && $('.editer_api_key_cloudmade').is(':hidden')){ |
---|
187 | $('.editer_api_key_cloudmade').slideDown(); |
---|
188 | }else if(($('#champ_api').val() != "cloudmade") && $('.editer_api_key_cloudmade').is(':visible')) { |
---|
189 | $('.editer_api_key_cloudmade').slideUp(); |
---|
190 | } |
---|
191 | if(($('#champ_api').val() == "google") && $('.editer_api_key_google').is(':hidden')){ |
---|
192 | $('.editer_api_key_google').slideDown(); |
---|
193 | }else if(($('#champ_api').val() != "google") && $('.editer_api_key_google').is(':visible')) { |
---|
194 | $('.editer_api_key_google').slideUp(); |
---|
195 | } |
---|
196 | if(($('#champ_api').val() == "yandex") && $('.editer_api_key_yandex').is(':hidden')){ |
---|
197 | $('.editer_api_key_yandex').slideDown(); |
---|
198 | }else if(($('#champ_api').val() != "yandex") && $('.editer_api_key_yandex').is(':visible')) { |
---|
199 | $('.editer_api_key_yandex').slideUp(); |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | var show_config = function(){ |
---|
204 | show_geocoder(); |
---|
205 | show_apis_keys(); |
---|
206 | $('#champ_api').unbind('change').change(function(){ |
---|
207 | show_geocoder(); |
---|
208 | show_apis_keys(); |
---|
209 | }); |
---|
210 | } |
---|
211 | |
---|
212 | $(function(){ |
---|
213 | init_config(); |
---|
214 | show_config(); |
---|
215 | onAjaxLoad(init_config); |
---|
216 | onAjaxLoad(show_config); |
---|
217 | }); |
---|
218 | |
---|
219 | })(jQuery); |
---|
220 | --> |
---|
221 | </script> |
---|
222 | </div> |
---|