Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Replace the phone book widget's mapping service' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Replace the phone book widget's mapping service
Authored by: capacity on Jan 16, '06 04:24:42PM
To make clicking on the resulting address actually search Google Local for the business name near the resulting address, rather than just go to a map of the address, use this chunk of code:

var mapURL = "http://maps.google.com/maps?hl=en&q=";

mapURL += singleResult.name.replace(/\s+/g, "+");
if (singleResult.address.length > 0)
    {
	mapURL += "&near=";
	var tmpAddr = singleResult.address.replace(/(s*#.*$)/, "");
	mapURL += tmpAddr.replace(/\s+/g, "+");
    }
mapURL += "+";
mapURL += singleResult.city.replace(/\s+/g, "+");
mapURL += "+";
mapURL += singleResult.state.replace(/\s+/g, "+");
if (singleResult.zip.length > 0)
    {
	mapURL += "+";
	mapURL += singleResult.zip.replace(/\s+/g, "+");
    }
Note: After every
.replace(
there is a forward slash, back slash, the letter s, plus sign, forward slash, the letter g, comma, double quote, plus sign, double quote, end parentheses, and semicolon.

[ Reply to This | # ]