-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeocoder.module
More file actions
59 lines (54 loc) · 1.66 KB
/
geocoder.module
File metadata and controls
59 lines (54 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* @file
* Module file for Geocoder module.
*/
/**
* The Geocoder API call.
*
* Given one or more plugin id(s), geocode the given data.
*
* @param string|string[] $plugin_ids
* The geocoder plugin id(s) to use.
* @param string $data
* Data to be passed into the handler for geocoding. For example a address string.
* @param array $options (optional)
* Additional options to pass to the handler. Exact key / values to pass depend on the handler.
*
* @return \Geocoder\Model\AddressCollection|FALSE
*
* @example:
* geocoder('googlemaps', '1600 Amphitheatre Parkway Mountain View, CA 94043');
* geocoder(array('freegeoip', 'googlemaps'), '8.8.8.8');
*/
function geocoder($plugin_ids, $data, array $options = array()) {
if ($value = \Drupal\geocoder\Geocoder::geocode($plugin_ids, $data, $options)) {
return $value;
}
return FALSE;
}
/**
* The reverse Geocoder API call.
*
* Given one or more plugin id(s), a latitude and a longitude, reverse geocode the given data.
*
* @param string|string[] $plugin_ids
* The geocoder plugin id(s) to use.
* @param string $latitude
* The latitude.
* @param string $longitude
* The longitude.
* @param array $options (optional)
* Additional options to pass to the handler. Exact key / values to pass depend on the handler.
*
* @return \Geocoder\Model\AddressCollection|FALSE
*
* @example:
* reverse('googlemaps', '37.4224504', '-122.0840859');
*/
function reverse($plugin_ids = 'googlemaps', $latitude, $longitude, array $options = array()) {
if ($value = \Drupal\geocoder\Geocoder::reverse($plugin_ids, $latitude, $longitude, $options)) {
return $value;
}
return FALSE;
}