function geocoder_mapbox in Geocoder 7
Process Markup.
1 call to geocoder_mapbox()
- geocoder_mapbox_field in plugins/
geocoder_handler/ mapbox.inc - Plugin callback.
1 string reference to 'geocoder_mapbox'
- mapbox.inc in plugins/
geocoder_handler/ mapbox.inc
File
- plugins/
geocoder_handler/ mapbox.inc, line 28
Code
function geocoder_mapbox($address, $options = array()) {
global $base_path;
$geocoder_settings = variable_get('geocoder_settings', array());
if (!empty($geocoder_settings['geocoder_apikey_mapbox'])) {
$access_token = $geocoder_settings['geocoder_apikey_mapbox'];
}
else {
drupal_set_message(t('You must set up your Mapbox access token. Click !config', array(
'!config' => l(t('here'), $base_path . 'admin/config/content/geocoder'),
)), 'error');
return;
}
$request = drupal_http_request('https://api.mapbox.com/geocoding/v5/mapbox.places/' . urlencode($address) . ".json?access_token={$access_token}");
$data = json_decode($request->data);
geophp_load();
return _geocoder_mapbox_geometry($data);
}