VB icon

MapQuest Link Generator

Email
Submitted on: 1/1/2015 8:29:00 PM
By: Steve Schoenfeld (from psc cd)  
Level: Intermediate
User Rating: By 4 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 1569
 
     Provide your users with dynamically generated links to MapQuest using basic address, city, state, or zipcode strings with this simple function.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: MapQuest Link Generator
// Description:Provide your users with dynamically generated links to MapQuest using basic address, city, state, or zipcode strings with this simple function.
// By: Steve Schoenfeld (from psc cd)
//
// Inputs:address, city, state, zipcode, country
//
// Returns:"<a href" style link to MapQuest map engine.
//
// Assumes:Call this function from anywhere in your PHP program. Pass-in address strings and get back the "<a href" link to MapQuest.
//**************************************

#
# Provide your users with dynamically generated links to MapQuest 
# using basic address, city, state, or zipcode strings with this simple function.
#
# This function requires the Client address.
# Get the latest addres line requirements from MapQuest.
# Here's the latest as of August 31, 2006:
function generate_mapquest_link($address,$city,$state,$country,$zip)
{
	if ($country == "USA") $country="US";
	if ($country == "")$country="US";
	if ($address > "" && $city > "" && $state > "" && $zip > "")
	{
		$address = trim($address);
		$address = str_replace(","," ",$address);
		$address = str_replace(" ","+",$address);
		#$address = str_replace(",","%2C",$address);
		$city= trim($city);
		$city= str_replace(" ","+",$city);
		$link="http://www.mapquest.com/maps/map.adp".
			"?country=$country".
			"&title=Map to RepleteMeeting Location".
			"&address=$address".
			"&city=$city".
			"&state=$state".
			"&zipcode=$zip".
			"&cid=lfmaplink";
	}
	else
		$link = "*** Address Not Specified ***";
	return $link;
}


Other 1 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.