function geocoder_mapzen in Geocoder 7
Process Markup.
1 call to geocoder_mapzen()
- geocoder_mapzen_field in plugins/
geocoder_handler/ mapzen.inc - Plugin callback.
1 string reference to 'geocoder_mapzen'
- mapzen.inc in plugins/
geocoder_handler/ mapzen.inc
File
- plugins/
geocoder_handler/ mapzen.inc, line 19
Code
function geocoder_mapzen($address, $options = array()) {
geophp_load();
$api_url = 'https://search.mapzen.com/v1/search';
$geocoder_settings = variable_get('geocoder_settings', array());
if (!empty($geocoder_settings['geocoder_apikey_mapzen'])) {
$api_key = $geocoder_settings['geocoder_apikey_mapzen'];
}
else {
throw new Exception('You must specify an API key for Mapzen.');
}
$params = array(
'api_key' => $api_key,
'size' => 1,
);
$request = drupal_http_request($api_url . '?text=' . str_replace(' ', '+', $address) . '&' . drupal_http_build_query($params));
$data = $request->data;
return geoPHP::load($data, 'json');
}