File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 137137
138138$ js = osm_get_js ($ conf , $ local_conf , $ js_data );
139139
140+ // Fetch the template.
141+ global $ prefixeTable ;
142+ // Easy access
143+ define ('osm_place_table ' , $ prefixeTable .'osm_places ' );
144+ // Save location, eg Place
145+ $ query = '
146+ SELECT id, name, latitude, longitude
147+ FROM ' .osm_place_table.'
148+ ; ' ;
149+ $ result = pwg_query ($ query );
150+ // JS for the template
151+ while ($ row = pwg_db_fetch_assoc ($ result ))
152+ {
153+ $ list_of_places [$ row ['id ' ]] = [$ row ['name ' ], $ row ['latitude ' ], $ row ['longitude ' ] ];
154+ $ available_places [$ row ['id ' ]] = $ row ['name ' ];
155+ }
156+
157+ $ jsplaces = "\nvar arr_places = " . json_encode ($ list_of_places ) ."; \n" ;
158+
140159$ template ->assign (array (
141160 'PWG_TOKEN ' => get_pwg_token (),
142161 'F_ACTION ' => $ self_url ,
146165 'OSM_JS ' => $ js ,
147166 'LAT ' => $ lat ,
148167 'LON ' => $ lon ,
168+ 'AVAILABLE_PLACES ' => $ available_places ,
169+ 'LIST_PLACES ' => $ jsplaces ,
149170));
150171
151172$ template ->assign_var_from_handle ('ADMIN_CONTENT ' , 'plugin_admin_content ' );
Original file line number Diff line number Diff line change 3939 <div style =" float : left ; margin : auto ;" >
4040 <ul >
4141 <li >
42- <label ><input type =" text" size =" 9" name =" osmlat" value =" { $LAT } " > { ' LATITUDE' |@translate} (-90=S to 90=N)</label >
42+ <label ><input type =" text" size =" 9" id = " osmlat " name =" osmlat" value =" { $LAT } " > { ' LATITUDE' |@translate} (-90=S to 90=N)</label >
4343 </li >
4444 <li >
45- <label ><input type =" text" size =" 9" name =" osmlon" value =" { $LON } " > { ' LONGITUDE' |@translate} (-180=W to 180=E)</label >
45+ <label ><input type =" text" size =" 9" id =" osmlon" name =" osmlon" value =" { $LON } " > { ' LONGITUDE' |@translate} (-180=W to 180=E)</label >
46+ </li >
47+ </ul >
48+ <hr >
49+ <ul >
50+ <li >
51+ <label >Save places :</label >
52+ <select id =" osmplaces" name =" osmplaces" onchange =" place_to_latlon(this)" >
53+ <option value =" NULL" >--</option >
54+ { html_options options= $AVAILABLE_PLACES }
55+ </select >
4656 </li >
4757 </ul >
4858 </div >
119129
120130 map.addControl( new L.Control.Search(searchOpts) );
121131 /* END leaflet-search */
132+
133+ function place_to_latlon()
134+ {
135+ var select = document.getElementById(" osmplaces" ).value;
136+ {/literal } { $LIST_PLACES } {literal }
137+ //alert(arr_places[select]);
138+ var lat_elem = document.getElementById("osmlat");
139+ var lon_elem = document.getElementById("osmlon");
140+ if (arr_places[select] == "NULL")
141+ {
142+ lat_elem.value = "0";
143+ lon_elem.value = "0";
144+ }
145+ else
146+ {
147+ lat_elem.value = arr_places[select][1];
148+ lon_elem.value = arr_places[select][2];
149+ }
150+ }
151+
122152</script >
123- {/literal }
153+ {/literal }
You can’t perform that action at this time.
0 commit comments