mirror of
https://github.com/librenms/librenms.git
synced 2024-09-22 19:08:15 +00:00
Add Mapquest API Geocode support (#9316)
* Add Mapquest API Geocode support Since the Google API for geocoding is no longer free, I added support to use the Mapquest geocoding API which currently offers a free tier. * Update functions.inc.php
This commit is contained in:
parent
f8ec6c51b6
commit
74d4a7c778
@ -556,6 +556,16 @@ function location_to_latlng($device)
|
||||
$api_url = "https://maps.googleapis.com/maps/api/geocode/json?address=$new_device_location";
|
||||
}
|
||||
break;
|
||||
case "mapquest":
|
||||
d_echo("Mapquest geocode engine being used\n");
|
||||
$api_key = ($config['geoloc']['api_key']);
|
||||
if (!empty($api_key)) {
|
||||
d_echo("Use Mapquest API key: $api_key\n");
|
||||
$api_url = "http://open.mapquestapi.com/geocoding/v1/address?key=$api_key&location=$new_device_location&thumbMaps=false";
|
||||
} else {
|
||||
d_echo("No geocode API key set\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
$curl_init = curl_init($api_url);
|
||||
set_curl_proxy($curl_init);
|
||||
@ -574,6 +584,13 @@ function location_to_latlng($device)
|
||||
$bad_loc = true;
|
||||
}
|
||||
break;
|
||||
case "mapquest":
|
||||
if ($data['info']['statuscode'] == 0) {
|
||||
$loc['lat'] = $data['results'][0]['locations'][0]['latLng']['lat'];
|
||||
$loc['lng'] = $data['results'][0]['locations'][0]['latLng']['lng'];
|
||||
} else {
|
||||
$bad_loc = true;
|
||||
}
|
||||
}
|
||||
if ($bad_loc === true) {
|
||||
d_echo("Bad lat / lng received\n");
|
||||
|
Loading…
Reference in New Issue
Block a user