|
18 | 18 | // !!! no config below this line.................................................
|
19 | 19 |
|
20 | 20 | //added by Lucas to return the data for database (this could be better implemented)
|
21 |
| -function get_address($q) |
| 21 | +function get_geocoder_address($q) |
22 | 22 | {
|
23 | 23 | $ggeo = get_ggeocoder_json($q);
|
24 | 24 |
|
25 |
| - $address['formatted_address']=str_replace("'","\'",$ggeo->results['formatted_address']); |
| 25 | + if (isset($_POST['formatted_address'])) |
| 26 | + $address['formatted_address']=$ggeo->results['formatted_address']; |
26 | 27 |
|
27 |
| - $address['latitude']=$ggeo->results['latitude']; |
28 |
| - |
29 |
| - $address['longitude']=$ggeo->results['longitude']; |
| 28 | + if (isset($_POST['latitude'])) |
| 29 | + $address['latitude']=$ggeo->results['latitude']; |
30 | 30 |
|
31 |
| - $address['viewport_lat_southwest']=$ggeo->results['viewport_lat_southwest']; |
| 31 | + if (isset($_POST['longitude'])) |
| 32 | + $address['longitude']=$ggeo->results['longitude']; |
32 | 33 |
|
33 |
| - $address['viewport_lng_southwest']=$ggeo->results['viewport_lng_southwest']; |
| 34 | + if (isset($_POST['viewport_lat_southwest'])) |
| 35 | + $address['viewport_lat_southwest']=$ggeo->results['viewport_lat_southwest']; |
34 | 36 |
|
35 |
| - $address['viewport_lat_northeast']=$ggeo->results['viewport_lat_northeast']; |
| 37 | + if (isset($_POST['viewport_lng_southwest'])) |
| 38 | + $address['viewport_lng_southwest']=$ggeo->results['viewport_lng_southwest']; |
36 | 39 |
|
37 |
| - $address['viewport_lng_northeast']=$ggeo->results['viewport_lng_northeast']; |
| 40 | + if (isset($_POST['viewport_lat_northeast'])) |
| 41 | + $address['viewport_lat_northeast']=$ggeo->results['viewport_lat_northeast']; |
38 | 42 |
|
39 |
| - $address['bounds_lat_southwest']=$ggeo->results['bounds_lat_southwest']; |
| 43 | + if (isset($_POST['viewport_lng_northeast'])) |
| 44 | + $address['viewport_lng_northeast']=$ggeo->results['viewport_lng_northeast']; |
40 | 45 |
|
41 |
| - $address['bounds_lng_southwest']=$ggeo->results['bounds_lng_southwest']; |
| 46 | + if (isset($_POST['bounds_lat_southwest'])) |
| 47 | + $address['bounds_lat_southwest']=$ggeo->results['bounds_lat_southwest']; |
42 | 48 |
|
43 |
| - $address['bounds_lat_northeast']=$ggeo->results['bounds_lat_northeast']; |
| 49 | + if (isset($_POST['bounds_lng_southwest'])) |
| 50 | + $address['bounds_lng_southwest']=$ggeo->results['bounds_lng_southwest']; |
44 | 51 |
|
45 |
| - $address['bounds_lng_northeast']=$ggeo->results['bounds_lng_northeast']; |
| 52 | + if (isset($_POST['bounds_lat_northeast'])) |
| 53 | + $address['bounds_lat_northeast']=$ggeo->results['bounds_lat_northeast']; |
46 | 54 |
|
47 |
| - $address['country']=str_replace("'","\'",$ggeo->find_address_components('country','long_name')); |
| 55 | + if (isset($_POST['bounds_lng_northeast'])) |
| 56 | + $address['bounds_lng_northeast']=$ggeo->results['bounds_lng_northeast']; |
48 | 57 |
|
49 |
| - $address['country_id']=$ggeo->find_address_components('country','short_name'); |
| 58 | + if (isset($_POST['country'])) |
| 59 | + $address['country']=$ggeo->find_address_components('country','long_name'); |
50 | 60 |
|
51 |
| - $address['administrative_area_level_1']=str_replace("'","\'",$ggeo->find_address_components('administrative_area_level_1','long_name')); |
| 61 | + if (isset($_POST['country_id'])) |
| 62 | + $address['country_id']=$ggeo->find_address_components('country','short_name'); |
52 | 63 |
|
53 |
| - $address['administrative_area_level_2']=str_replace("'","\'",$ggeo->find_address_components('administrative_area_level_2','long_name')); |
| 64 | + if (isset($_POST['administrative_area_level_1'])) |
| 65 | + $address['administrative_area_level_1']=$ggeo->find_address_components('administrative_area_level_1','long_name'); |
54 | 66 |
|
55 |
| - $address['locality']=str_replace("'","\'",$ggeo->find_address_components('locality','long_name')); |
| 67 | + if (isset($_POST['administrative_area_level_2'])) |
| 68 | + $address['administrative_area_level_2']=$ggeo->find_address_components('administrative_area_level_2','long_name'); |
56 | 69 |
|
57 |
| - $address['postal_code']=$ggeo->find_address_components('postal_code','long_name'); |
| 70 | + if (isset($_POST['locality'])) |
| 71 | + $address['locality']=$ggeo->find_address_components('locality','long_name'); |
58 | 72 |
|
59 |
| - $address['route']=str_replace("'","\'",$ggeo->find_address_components('route','long_name')); |
| 73 | + if (isset($_POST['postal_code'])) |
| 74 | + $address['postal_code']=$ggeo->find_address_components('postal_code','long_name'); |
60 | 75 |
|
61 |
| - $address['street_number']=str_replace("'","\'",$ggeo->find_address_components('street_number','long_name')); |
| 76 | + if (isset($_POST['route'])) |
| 77 | + $address['route']=$ggeo->find_address_components('route','long_name'); |
62 | 78 |
|
63 |
| - return $address; |
| 79 | + if (isset($_POST['street_number'])) |
| 80 | + $address['street_number']=$ggeo->find_address_components('street_number','long_name'); |
| 81 | + |
| 82 | + if (isset($address)) |
| 83 | + return $address; |
| 84 | + else |
| 85 | + return FALSE; |
64 | 86 | }
|
65 | 87 |
|
66 | 88 | //sanitization and encoding functions (this could be better implemented)
|
|
0 commit comments