You are here

function _location_driving_directions_link_us_yahoo in Location 7.3

Same name and namespace in other branches
  1. 5.3 supported/location.us.inc \_location_driving_directions_link_us_yahoo()
  2. 5 supported/location.us.inc \_location_driving_directions_link_us_yahoo()
  3. 6.3 supported/location.us.inc \_location_driving_directions_link_us_yahoo()
  4. 7.5 supported/location.us.inc \_location_driving_directions_link_us_yahoo()
  5. 7.4 supported/location.us.inc \_location_driving_directions_link_us_yahoo()

Direction link by Yahoo.

Parameters

array $location_a: is an associative array that represents a full location where 'street' => the street portions of the location 'supplemental' => additional street portion of the location 'province' => the province, state, or territory 'country' => lower-cased two-letter ISO code (REQUIRED)

array $location_b: is associative array that represents a full location in the same way that parameter $location_b does.

Return value

string a URL with HTTP GET variables Depending on how full the locationes are, the URL will either point to the driving directions on Yahoo! or, if only partial locationes are provided, a URL that points to the *form* for Yahoo! driving directions where the form is filled with whatever fields have been provided for the partial location(es).

1 call to _location_driving_directions_link_us_yahoo()
location_driving_directions_link_us in supported/location.us.inc
Returns link.

File

supported/location.us.inc, line 419
United States.

Code

function _location_driving_directions_link_us_yahoo($location_a, $location_b) {
  if (trim($location_b['country']) != 'ca' && trim($location_b['country']) != 'us') {
    return '';
  }

  // These are the fields that need to be in each location if we are to provide a direct
  // link to yahoo directions.  If all of these fields don't have values, then we generate
  // a link to the *form* for Yahoo! driving directions rather than directly to the driving
  // directions themselves.
  foreach ($location_a as $field => $value) {
    $location_a[$field] = trim($value);
  }
  foreach ($location_b as $field => $value) {
    $location_b[$field] = trim($value);
  }
  if (_location_us_enough_fields_for_yahoo($location_a) && _location_us_enough_fields_for_yahoo($location_b)) {
    $yahoo_maps_path = 'dd_result';
  }
  else {
    $yahoo_maps_path = 'dd';
  }
  $get_query = '?';
  $get_query .= 'addr=' . urlencode($location_a['street']) . '&';
  $get_query .= 'csz=' . _location_us_yahoo_csz_get_field($location_a) . '&';
  $get_query .= 'country=' . urlencode($location_a['country']) . '&';
  $get_query .= 'taddr=' . urlencode($location_b['street']) . '&';
  $get_query .= 'tcsz=' . _location_us_yahoo_csz_get_field($location_b) . '&';
  $get_query .= 'tcountry=' . urlencode($location_b['country']);
  $get_query .= '&getrte=' . urlencode('Get Directions');
  return 'http://maps.yahoo.com/' . $yahoo_maps_path . $get_query;
}