BBU Appointment System Forum View new messages in your reader RSS
Homepages for Salons and Spas Online Appointment Systems
BBU Appointment System Forum BBU Online Appointment
System Forum
Welcome Guest
Please login or register
Home Help Search Login Register
RSS BBU Forum |  RSS BBU Headlines |  RSS BBU News |  Free E-mail  |    Live Help  |  Beautybyus.com  | May 12, 2008
+  BBU Online Appointment System Forum
|-+  Your Own Website Development
| |-+  Maps (Moderator: Magic)
| | |-+  PHP Script : MapQuest Link for Webpages
Pages: [1] Print
Author Topic: PHP Script : MapQuest Link for Webpages  (Read 1179 times)
Magic
Moderator
Sr. Member
*****
Online Online

Posts: 97



WWW
PHP Script : MapQuest Link for Webpages
on Jan 09 2005, 02:07 AM

Many of the free scripts I have seen for MapQuest either have improper form values, were written for the USA only or simply don't work.

Copy this entire quote and save it as yourmap.php. Make the necessary changes in lines 1 to 5 and test it in your browser. Your server must be php enabled. The link will open MapQuest® in a new browser window at your street.

When satisfied with the results then copy and paste the entire code into your own web page and rename the document extension to .php

Magic.
Logged
Magic
Moderator
Sr. Member
*****
Online Online

Posts: 97



WWW
Re: PHP Script : MapQuest Link for Webpages
Reply #1 on May 05 2008, 10:08 PM

Quote
<?php

// MapQuest® for USA and Canada in php
// simply copy and save this entire page as yourmap.php

// 1. change to "United States" if from the USA
$country = "Canada";

// 2. change to your address
$address1 = "Suite 311 - 2667 Young Street";

// do not edit this line
$address = $address1;

// 3. change this to your city
$city = "Kingston";

// 4. change this entry to your state or province exactly as written in the list below
$state = "Ontario";

// 5. enter your 6 character postal code or 5 digit zipcode
$postalcode = "K7K 6K8";

// do not edit below this line

?>
<?php

function mapquest_link($country,$address,$city,$state,$postalcode,$link = '')
{
if ($country == "United States")
{ $country="US"; }
elseif ($country == "Canada")
{ $country="CA"; }

// Convert state name to proper shortform
{
if ($state =="Alberta") { $state="AB"; }
elseif ($state == "British Columbia") { $state="BC"; }
elseif ($state == "Manitoba") { $state="MB"; }
elseif ($state == "New Brunswick") { $state="NB"; }
elseif ($state == "Newfoundland and Labrador") { $state="NL"; }
elseif ($state == "Northwest Territories") { $state="NT"; }
elseif ($state == "Nova Scotia") { $state="NS"; }
elseif ($state == "Ontario") { $state="ON"; }
elseif ($state == "Prince Edward Island") { $state="PE"; }
elseif ($state == "Quebec") { $state="QC"; }
elseif ($state == "Saskatchewan") { $state="SK"; }
elseif ($state == "Yukon Territory") { $state="YT"; }
elseif ($state == "Alabama") { $state="AL"; }
elseif ($state == "Alaska") { $state="AK"; }
elseif ($state == "Arizona") { $state="AZ"; }
elseif ($state == "Arkansas") { $state="AR"; }
elseif ($state == "California") { $state="CA"; }
elseif ($state == "Colorado") { $state="CO"; }
elseif ($state == "Connecticut") { $state="CT"; }
elseif ($state == "Delaware") { $state="DE"; }
elseif ($state == "District of Columbia") { $state="DC"; }
elseif ($state == "Florida") { $state="FL"; }
elseif ($state == "Georgia") { $state="GA"; }
elseif ($state == "Hawaii") { $state="HI"; }
elseif ($state == "Idaho") { $state="ID"; }
elseif ($state == "Illinois") { $state="IL"; }
elseif ($state == "Indiana") { $state="IN"; }
elseif ($state == "Iowa") { $state="IA"; }
elseif ($state == "Kansas") { $state="KS"; }
elseif ($state == "Kentucky") { $state="KY"; }
elseif ($state == "Louisiana") { $state="LA"; }
elseif ($state == "Maine") { $state="ME"; }
elseif ($state == "Maryland") { $state="MD"; }
elseif ($state == "Massachusetts") { $state="MA"; }
elseif ($state == "Michigan") { $state="MI"; }
elseif ($state == "Minnesota") { $state="MN"; }
elseif ($state == "Mississippi") { $state="MS"; }
elseif ($state == "Missouri") { $state="MO"; }
elseif ($state == "Montana") { $state="MT"; }
elseif ($state == "Nebraska") { $state="NE"; }
elseif ($state == "Nevada") { $state="NV"; }
elseif ($state == "New Hampshire") { $state="NH"; }
elseif ($state == "New Jersey") { $state="NJ"; }
elseif ($state == "New Mexico") { $state="NM"; }
elseif ($state == "New York") { $state="NY"; }
elseif ($state == "North Carolina") { $state="NC"; }
elseif ($state == "North Dakota") { $state="ND"; }
elseif ($state == "Ohio") { $state="OH"; }
elseif ($state == "Oklahoma") { $state="OK"; }
elseif ($state == "Oregon") { $state="OR"; }
elseif ($state == "Pennsylvania") { $state="PA"; }
elseif ($state == "Rhode Island") { $state="RI"; }
elseif ($state == "South Carolina") { $state="SC"; }
elseif ($state == "South Dakota") { $state="SD"; }
elseif ($state == "Tennessee") { $state="TN"; }
elseif ($state == "Texas") { $state="TX"; }
elseif ($state == "Utah") { $state="UT"; }
elseif ($state == "Vermont") { $state="VT"; }
elseif ($state == "Virginia") { $state="VA"; }
elseif ($state == "Washington") { $state="WA"; }
elseif ($state == "West Virginia") { $state="WV"; }
elseif ($state == "Wisconsin") { $state="WI"; }
elseif ($state == "Wyoming") { $state="WY"; }
}

// Trim address postalcode and city
{
$address = trim($address);
$address = str_replace("#","%23",$address);
$address = str_replace(" ","+",$address);
$address = str_replace(",","%2C",$address);
$city = trim($city);
$city = str_replace(" ","+",$city);
$postalcode = trim($postalcode);
$postalcode = str_replace(" ","+",$postalcode);

$link="http://www.mapquest.com/maps/map.adp".
"?country=$country".
"&amp;addtohistory=".
"&amp;address=$address".
"&amp;city=$city".
"&amp;state=$state".
"&amp;zipcode=$postalcode";
}
return $link;
}
?>
<a href="<?php echo mapquest_link($country,$address,$city,$state,$postalcode,'$link'); ?>" target="_blank">Locate with Map Quest</a>

Logged
Pages: [1] Print 
Jump to:  


Login with username, password and session length


NoWhere Radio.com
INDIE MUSIC & HOSTING

 Yahoo!
Homepages and Online Appointment Systems
Powered by MySQL Powered by PHP BBU Online Appointment System Forum | Powered by SMF 1.0.3.
© 2001-2005, Lewis Media. All Rights Reserved.
Valid XHTML 1.0! Valid CSS!

Beauty By Us Inc.
Kingston Ontario Canada K7K 6K8
Serving North America   (613) 547-3358

W3C P3P Compliant | PIPEDA Compliant