Merge pull request #1594 from vitalisator/issue-1593

add support for Google API key in geocoding
This commit is contained in:
Daniel Preussker
2015-08-03 17:41:49 +00:00

View File

@ -431,7 +431,13 @@ function location_to_latlng($device) {
case "google":
default:
d_echo("Google geocode engine being used\n");
$api_url = "https://maps.googleapis.com/maps/api/geocode/json?address=$new_device_location";
$api_key = ($config['geoloc']['api_key']);
if (!empty($api_key)) {
d_echo("Use Google API key: $api_key\n");
$api_url = "https://maps.googleapis.com/maps/api/geocode/json?address=$new_device_location&key=$api_key";
} else {
$api_url = "https://maps.googleapis.com/maps/api/geocode/json?address=$new_device_location";
}
break;
}
$curl_init = curl_init($api_url);