You are here

function _addressfield_static_map_render_mapquest_image in Address Field Static Map 7

Render static Mapquest image for a specific address.

2 calls to _addressfield_static_map_render_mapquest_image()
addressfield_staticmap_block_view in ./addressfield_staticmap.module
Implements hook_block_view().
addressfield_staticmap_field_formatter_view in ./addressfield_staticmap.module
Implements hook_field_formatter_view().

File

./addressfield_staticmap.module, line 399
Main file for the addressfield static map module.

Code

function _addressfield_static_map_render_mapquest_image($address, $settings) {
  global $is_https;
  $settings['size'] = str_replace('x', ',', $settings['size']);

  // Codes for map types are not the same, alter them.
  $map_types = array(
    'roadmap' => 'map',
    'satellite' => 'sat',
    'hybrid' => 'hyb',
    'terrain' => 'map',
  );
  $settings['maptype'] = $map_types[$settings['maptype']];
  $staticmap_url = url('http://www.mapquestapi.com/staticmap/v3/getplacemap', array(
    'external' => TRUE,
    'https' => $is_https,
    'query' => array(
      'key' => $settings['api_key'],
      'location' => $address,
      'size' => $settings['size'],
      'type' => $settings['maptype'],
      'zoom' => $settings['zoom'],
      'scale' => $settings['scale'],
      'imagetype' => 'jpeg',
      'showicon' => 'green-1',
    ),
  ));
  return theme_image(array(
    'path' => $staticmap_url,
  ));
}