the key is the word that helps identify the name of function that builds the link. For example, a key of 'yahoo' means the name of
the
* the function that builds a link to a map on Yahoo! Maps would be 'location_map_link_us_yahoo'
* -> the value is itself an array with 3 key/value pairs:
* 'name' => points to the name of the mapping service. For 'yahoo', this would be 'Yahoo! Maps'
* 'url' => the url of the main page of the mapping service. For 'yahoo', this would be 'http://maps.yahoo.com'
* 'tos' => the url of the page that explains the map providers Terms of Service, or Terms of Use. For 'yahoo', this would be
* 'http://help.yahoo.com/help/us/maps/maps-24.html'
*/
function location_map_link_uk_providers() {
return array('google' => array('name' => 'Google Maps', 'url' => 'http://maps.google.co.uk', 'tos' =>
'http://www.google.co.uk/intl/en_uk/help/terms_local.html'), 'Multimap' => array('name' => 'Multimap', 'url' => 'http://www.multimap.com',
'tos' =>
'http://www.multimap.com/static/about6.htm')
);
}
/**
* @return
* An array of values that work as keys to the array returned by location_map_link_us_providers. The idea is that if the
* administrator of the site has not yet had a chance to visit the "Map Links" subtab on the location module's settings page,
* that we can provide deep-linking to a relatively safe default. By 'relatively safe', we mean that the Terms Of Service of
* the provider of the maps are flexible enough for most parties.
*
* For the case of the U.S., 'google' has relatively flexible Terms Of Service, whereas Yahoo! Maps and MapQuest have more
* restrictive Terms Of Service.
*
*/
function location_map_link_uk_default_providers() {
return array('google');
}
function location_map_link_uk_google($location = array()) {
$query_params = array();
// Order of priority is co-ordinates, postcode and then street/city
if ($location['lat'] && $location['lon']) {
$ll = $location['lat']. ",". $location['lon'];
}
if ($location['postal_code']) {
$query_params[] = $location['postal_code'];
}
else {
foreach (array('street', 'city') as $field) {
if ($location[$field]) {
$query_params[] = $location[$field];
}
}
}
$base = 'http://maps.google.co.uk/?';
if (isset($ll)) {
$url = $base. 'll='. $ll;
return $url;
}
elseif (count($query_params)) {
$url = $base. 'q='. urlencode(implode(" ", $query_params));
return $url;
}
else {
return NULL;
}
}
function location_map_link_uk_multimap($location = array()) {
$query_params = '';
// Order of priority is co-ordinates, postcode and then street/city
if ($location['lat'] && $location['lon']) {
$query_params .= 'lat='. $location['lat'];
$query_params .= '&lon='. $location['lon'];
}
elseif ($location['postal_code']) {
$query_params = 'pc='. urlencode($location['postal_code']);
}
else {
if ($location['street'] && $location['city']) {
$query_params = 'quicksearch='. urlencode($location['street']. ', '. $location['city']);
}
elseif ($location['city']) {
$query_params = 'quicksearch='. urlencode($location['city']);
}
}
$base = 'http://www.multimap.com/map/places.cgi?';
if ($query_params) {
$url = $base. $query_params;
return $url;
}
else {
return NULL;
}
}
/**
* Parameters:
* -> $locationA 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)
* -> $locationB is associative array that represents a full location in the same way that
* parameter $locationB does.
*
* Returns: a link to driving directions
*
* For now, assume site-admin wants UK driving directions linked to Google Driving Directions.
* Maybe later, we can add some kind of country-specific settings page that allows the site-admin to
* decide which site to link to for driving directions.
*/
function location_driving_directions_link_uk($locationA, $locationB) {
return _location_driving_directions_link_uk_google($locationA, $locationB);
}
/**
* Parameters:
* Function that is called by location_driving_directions_link_uk() under assumption that it
* is the chosen function
*
* Returns:
* 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).
*/
function _location_driving_directions_link_uk_google($locationA, $locationB) {
if ($locationA['lat'] && $locationA['lon']) {
$from = 'from '. $locationA['lat']. ','. $locationA['lon'];
}
elseif ($locationA['postal_code']) {
$from = 'from '. $locationA['postal_code'];
}
if ($locationB['lat'] && $locationB['lon']) {
$to = 'to '. $locationB['lat']. ','. $locationB['lon'];
}
elseif ($locationB['postal_code']) {
$to = 'to '. $locationB['postal_code'];
}
if ($from && $to) {
$get_query = urlencode($from. ' '. $to);
return ('http://maps.google.co.uk/?'. $get_query);
}
else {
return NULL;
}
}
function theme_location_uk($location = array()) {
$output = '';
if (count($location)) {
$output .= "\n";
$output .= '
'."\n";
if (isset($location['street'])) {
$output .= '- '. $location['street'] .'
';
}
if (isset($location['additional'])) {
$output .= '- ' . $location['additional'] . '
';
}
$postal_isset = (isset($location['postal_code']) && strlen($location['postal_code']));
$city_isset = (isset($location['city']) && strlen($location['city']));
if ($postal_isset || $city_isset) {
$output .= '- ';
if ($city_isset) {
$output .= $location['city'];
}
if ($postal_isset && $city_isset) {
$output .= ' ';
}
if ($postal_isset) {
$output .= $location['postal_code'];
}
$output .= "
\n";
}
$output .= '- '. t('United Kingdom') ."
\n";
$output .= "
\n";
}
return $output;
}
function location_province_list_uk() {
return array('GSY' => "Guernsey",
'JSY' => "Jersey",
'BDG' => "Barking and Dagenham",
'BNE' => "Barnet",
'BNS' => "Barnsley",
'BAS' => "Bath and North East Somerset",
'BDF' => "Bedfordshire",
'BEX' => "Bexley",
'BIR' => "Birmingham",
'BBD' => "Blackburn with Darwen",
'BPL' => "Blackpool",
'BOL' => "Bolton",
'BMH' => "Bournemouth",
'BRC' => "Bracknell Forest",
'BRD' => "Bradford",
'BEN' => "Brent",
'BNH' => "Brighton and Hove",
'BST' => "Bristol City of",
'BRY' => "Bromley",
'BKM' => "Buckinghamshire",
'BUR' => "Bury",
'CLD' => "Calderdale",
'CAM' => "Cambridgeshire",
'CMD' => "Camden",
'CHS' => "Cheshire",
'CON' => "Cornwall",
'COV' => "Coventry (West Midlands district)",
'CRY' => "Croydon",
'CMA' => "Cumbria",
'DAL' => "Darlington",
'DER' => "Derby",
'DBY' => "Derbyshire",
'DEV' => "Devon",
'DNC' => "Doncaster",
'DOR' => "Dorset",
'DUD' => "Dudley (West Midlands district)",
'DUR' => "Durham",
'EAL' => "Ealing",
'ERY' => "East Riding of Yorkshire",
'ESX' => "East Sussex",
'ENF' => "Enfield",
'ESS' => "Essex",
'GAT' => "Gateshead (Tyne & Wear district)",
'GLS' => "Gloucestershire",
'GRE' => "Greenwich",
'HCK' => "Hackney",
'HAL' => "Halton",
'HMF' => "Hammersmith and Fulham",
'HAM' => "Hampshire",
'HRY' => "Haringey",
'HRW' => "Harrow",
'HPL' => "Hartlepool",
'HAV' => "Havering",
'HEF' => "Herefordshire County of",
'HRT' => "Hertfordshire",
'HIL' => "Hillingdon",
'HNS' => "Hounslow",
'IOW' => "Isle of Wight",
'IOS' => "Isles of Scilly",
'ISL' => "Islington",
'KEC' => "Kensington and Chelsea",
'KEN' => "Kent",
'KHL' => "Kingston upon Hull City of",
'KTT' => "Kingston upon Thames",
'KIR' => "Kirklees",
'KWL' => "Knowsley",
'LBH' => "Lambeth",
'LAN' => "Lancashire",
'LDS' => "Leeds",
'LCE' => "Leicester",
'LEC' => "Leicestershire",
'LEW' => "Lewisham",
'LIN' => "Lincolnshire",
'LIV' => "Liverpool",
'LND' => "London City of",
'LUT' => "Luton",
'MAN' => "Manchester",
'MDW' => "Medway",
'MRT' => "Merton",
'MDB' => "Middlesbrough",
'MIK' => "Milton Keynes",
'NET' => "Newcastle upon Tyne",
'NWM' => "Newham",
'NFK' => "Norfolk",
'NEL' => "North East Lincolnshire",
'NLN' => "North Lincolnshire",
'NSM' => "North Somerset",
'NTY' => "North Tyneside",
'NYK' => "North Yorkshire",
'NTH' => "Northamptonshire",
'NBL' => "Northumberland",
'NGM' => "Nottingham",
'NTT' => "Nottinghamshire",
'OLD' => "Oldham",
'OXF' => "Oxfordshire",
'PTE' => "Peterborough",
'PLY' => "Plymouth",
'POL' => "Poole",
'POR' => "Portsmouth",
'RDG' => "Reading",
'RDB' => "Redbridge",
'RCC' => "Redcar and Cleveland",
'RIC' => "Richmond upon Thames",
'RCH' => "Rochdale",
'ROT' => "Rotherham",
'RUT' => "Rutland",
'SHN' => "St Helens",
'SLF' => "Salford",
'SAW' => "Sandwell",
'SFT' => "Sefton",
'SHF' => "Sheffield",
'SHR' => "Shropshire",
'SLG' => "Slough",
'SOL' => "Solihull",
'SOM' => "Somerset",
'SGC' => "South Gloucestershire",
'STY' => "South Tyneside",
'STH' => "Southampton",
'SOS' => "Southend-on-Sea",
'SWK' => "Southwark",
'STS' => "Staffordshire",
'SKP' => "Stockport",
'STT' => "Stockton-on-Tees",
'STE' => "Stoke-on-Trent",
'SFK' => "Suffolk",
'SND' => "Sunderland",
'SRY' => "Surrey",
'STN' => "Sutton",
'SWD' => "Swindon",
'TAM' => "Tameside",
'TFW' => "Telford and Wrekin",
'THR' => "Thurrock",
'TOB' => "Torbay",
'TWH' => "Tower Hamlets",
'TRF' => "Trafford",
'WKF' => "Wakefield",
'WLL' => "Walsall",
'WFT' => "Waltham Forest",
'WND' => "Wandsworth",
'WRT' => "Warrington",
'WAR' => "Warwickshire",
'WBK' => "West Berkshire",
'WSX' => "West Sussex",
'WSM' => "Westminster",
'WGN' => "Wigan",
'WIL' => "Wiltshire",
'WNM' => "Windsor and Maidenhead",
'WRL' => "Wirral",
'WOK' => "Wokingham",
'WLV' => "Wolverhampton",
'WOR' => "Worcestershire",
'YOR' => "York",
'ANT' => "Antrim",
'ARD' => "Ards",
'ARM' => "Armagh",
'BLA' => "Ballymena",
'BLY' => "Ballymoney",
'BNB' => "Banbridge",
'BFS' => "Belfast",
'CKF' => "Carrickfergus",
'CSR' => "Castlereagh",
'CLR' => "Coleraine",
'CKT' => "Cookstown",
'CGV' => "Craigavon",
'DRY' => "Derry",
'DOW' => "Down",
'DGN' => "Dungannon and South Tyrone",
'FER' => "Fermanagh",
'LRN' => "Larne",
'LMV' => "Limavady",
'LSB' => "Lisburn",
'MFT' => "Magherafelt",
'MYL' => "Moyle",
'NYM' => "Newry and Mourne",
'NTA' => "Newtownabbey",
'NDN' => "North Down",
'OMH' => "Omagh",
'STB' => "Strabane",
'ABE' => "Aberdeen",
'ABD' => "Aberdeenshire",
'ANS' => "Angus",
'AGB' => "Argyll and Bute",
'CLK' => "Clackmannanshire",
'DGY' => "Dumfries and Galloway",
'DND' => "Dundee",
'EAY' => "East Ayrshire",
'EDU' => "East Dunbartonshire",
'ELN' => "East Lothian",
'ERW' => "East Renfrewshire",
'EDH' => "Edinburgh",
'ELS' => "Eilean Siar",
'FAL' => "Falkirk",
'FIF' => "Fife",
'GLG' => "Glasgow",
'HLD' => "Highland",
'IVC' => "Inverclyde",
'NAY' => "North Ayrshire",
'NLK' => "North Lanarkshire",
'ORK' => "Orkney Islands",
'PKN' => "Perth and Kinross",
'MLN' => "Midlothian",
'MRY' => "Moray",
'RFW' => "Renfrewshire",
'SCB' => "Scottish Borders The",
'ZET' => "Shetland Islands",
'SAY' => "South Ayrshire",
'SLK' => "South Lanarkshire",
'STG' => "Stirling",
'WDU' => "West Dunbartonshire",
'WLN' => "West Lothian",
'BGW' => "Blaenau Gwent",
'BGE' => "Bridgend",
'CAY' => "Caerphilly",
'CRF' => "Cardiff",
'CMN' => "Carmarthenshire",
'CGN' => "Ceredigion",
'CWY' => "Conwy",
'DEN' => "Denbighshire",
'FLN' => "Flintshire",
'GWN' => "Gwynedd",
'AGY' => "Isle of Anglesey",
'MTY' => "Merthyr Tydfil",
'MON' => "Monmouthshire",
'NTL' => "Neath Port Talbot",
'NWP' => "Newport",
'PEM' => "Pembrokeshire",
'POW' => "Powys",
'RCT' => "Rhondda Cynon Taf",
'SWA' => "Swansea",
'TOF' => "Torfaen",
'VGL' => "Vale of Glamorgan",
'WRX' => "Wrexham");
}
?>