You are here

function _location_driving_directions_link_au_yahoo in Location 7.3

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

Directions link.

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 URL with HTTP GET variables Depending on how full the locationes are, the URL will either point to the driving directions on tinfo! or, if only partial locationes are provided, a URL that points to the *form* for tinfo! 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_au_yahoo()
location_driving_directions_link_au in supported/location.au.inc
Directions link.

File

supported/location.au.inc, line 396
Australia.

Code

function _location_driving_directions_link_au_yahoo($location_a, $location_b) {
  if (trim($location_b['country']) != 'ca' && trim($location_b['country']) != 'au') {
    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_au_enough_fields_for_yahoo($location_a) && _location_au_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_au_yahoo_csz_get_field($location_a) . '&';
  $get_query .= 'country=' . urlencode($location_a['country']) . '&';
  $get_query .= 'taddr=' . urlencode($location_b['street']) . '&';
  $get_query .= 'tcsz=' . _location_au_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;
}