Gossamer Forum
Home : Products : DBMan : Customization :

Mapquest MOD

Quote Reply
Mapquest MOD
Hi,

I made this small MOD for a client who wanted a database of their clients with addresses. He wanted to have a link on the bottom of every record that will bring up a map from mapquest.com with the address of the record.

For this to work, you must have 4 fields included in your .cfg file.

Address #This is the street address
City #This is the City
State #This is the State
Zip #This is the Zip Code

I.e.
Code:
%db_def = (
'ID' => [ 0, 'numer', -1, 255, 0, '1', ''],
'Name' => [ 1, 'alpha', 20, 255, 0, '', ''],
'Address' => [ 2, 'alpha', 20, 255, 0, '', ''],
'City' => [ 3, 'alpha', 20, 255, 0, '', ''],
'State' => [ 4, 'alpha', 20, 255, 0, '', ''],
'Zip' => [ 5, 'numer', 20, 255, 0, '', '']
);

Once you have your fields set, go to your hmtl.pl file and add the following under
my (%rec) = @_; in the sub html_record routine.

Code:
$map_street = $rec{'Address'};
$map_city = $rec{'City'};
$map_state = $rec{'State'};
$map_zip = $rec{'Zip'};

$map_street =~ s/ /\+/g;
$map_street =~ s/ /\+/g;
$map_street =~ s/&/ampersand/g;
$map_street =~ s/=/equalsign/g;

$map_city =~ s/ /\+/g;
$map_city =~ s/ /\+/g;
$map_city =~ s/&/ampersand/g;
$map_city =~ s/=/equalsign/g;

$map_state =~ s/ /\+/g;
$map_state =~ s/ /\+/g;
$map_state =~ s/&/ampersand/g;
$map_state =~ s/=/equalsign/g;

$map_zip =~ s/ /\+/g;
$map_zip =~ s/ /\+/g;
$map_zip =~ s/&/ampersand/g;
$map_zip =~ s/=/equalsign/g;

$map_url =
"http://www.mapquest.com/cgi-bin/mqfreeconnect?width=500&height=300&level=9&icontitles=no&style=2&streetaddress=$map_street&city=$map_city&s tate=$map_state&zip=$map_zip";

Whenever you want to print out the link to the map in html_record use
<a href="$map_url">Show Map</a>.

I hope this works for you. If you have any questions let me know.

Thanks
Eli
Quote Reply
Re: Mapquest MOD In reply to
Hi,

Can anyone please let me know if this MOD is working for you. I want to know if I can use it again on all my clients, or if it just worked by chance for me.

Thanks
Eli
Quote Reply
Re: Mapquest MOD In reply to
I have tested it. And it doesn't seem to work very well. I prefer to use Yahoo Maps because they have a better error checking system. The variable that did not show up well was City. (Yes, I made sure that my fields in the .cfg matched with their defining variables in the html_record sub-routine.)

But a decent mod.

One thing that I would add to your mod are some codes that Carol (JPDeni) wrote:

Code:
if (($rec{'Country'} eq 'US') && ($rec{'Address'} && $rec{'City'} && $rec{'State'})) {
print qq|<a href="$map_url">Show Map</a>|;
}

Of course, people would have to add "Country" to their %db_def array.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Mapquest MOD In reply to
what a cool idea for a dbman mod! is there a way this could be modified even further to be used as a "get directions" kind of tool? where the destination address would always be the same, but all the visitor would have to do is type their originating address in and a mapquest map would print giving them directions from their location to the given preset destination? this would only be used for directions within one state primarily, for a local car dealership. thanx!

chuck

------------------
pres@cantonconnection.com
Quote Reply
Re: Mapquest MOD In reply to
I'm sure it could be done. You'd just need to get the format for the MapQuest (or Yahoo Maps) search.


------------------
JPD





Quote Reply
Re: Mapquest MOD In reply to
I personally like Yahoo Maps because it is more forgiving than MapQuest, and I may be wrong with this...But I have observed sites like MapQuest that change their search strings periodically to avoid people linking to them.

Yahoo is a more open and friendly site to use , especially with driving directions. JPDeni (Carol) wrote a lovely mod for using Yahoo for Driving Directions.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us