Zip Code Search to Google Map

Hello;

I’ve been asked to add a search feature in which a user types in a zip code which will then take them to a page with a Google map of a store location.

How can I accomplish this?

Thanks


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

How many locations? Do any of the locations share a single Zip code? I
have some PHP code you can steal, but you’ll have to buy a Zip code
database or find a free one that includes the latitude and longitude
information.

On your server you will need PHP and MySQL (most have it).

Walter

On Aug 23, 2009, at 6:52 PM, Carmine5 wrote:

Hello;

I’ve been asked to add a search feature in which a user types in a
zip code which will then take them to a page with a Google map of a
store location.

How can I accomplish this?

Thanks


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

These are good questions that, at this point, I don’t have concrete answers to. The client offhandedly asked me if I could do it on their Freeway site. I’m not sure if it’s just their factory stores or if they plan to include authorized dealer stores but they are scattered through the U.S.

I have PHP activated and a MySQL database folder set up on the server. Unfortunately, I know next to nothing about MySQL although I do have the free Cocoa MySQL and YourSQL applications as well as the various PHP and MySQL Actions.

What next? Thanks.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walter mentioned a zip code lat/lon data base. If you want Google to
locate the actual store, you will need the lat/lon of the store.
Someone with a hand held GPS could get the info by going to each store.

LLE

On Aug 23, 2009, at 10:51 PM, Carmine5 wrote:

These are good questions that, at this point, I don’t have concrete
answers to. The client offhandedly asked me if I could do it on
their Freeway site. I’m not sure if it’s just their factory stores
or if they plan to include authorized dealer stores but they are
scattered through the U.S.

I have PHP activated and a MySQL database folder set up on the
server. Unfortunately, I know next to nothing about MySQL although
I do have the free Cocoa MySQL and YourSQL applications as well as
the various PHP and MySQL Actions.

What next? Thanks.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You’ll need to get a list of addresses from your client of all of
their locations. Then you’ll need to buy or get a database of US Zip
codes. The calculation of how far apart two different locations on
Earth are is called a Great Circle calculation, and I have a SQL query
that can do it, given the starting lat/long and a list of potential
destination lat/long pairs.

You would make a page that had a text field for the customer to enter
her Zip code, and a picker for the radius (in miles) that she is
willing to drive.

The script does two queries – the first to find the lat/long of the
Zip code the customer entered, and the second to find a list of Zip
codes in ascending order of distance from that starting point. You
would need to restrict it to only produce results in Zip codes that
had a dealership, but otherwise it’s a pretty straight rip of the code
I wrote a lot of years ago:

http://cheshire.walterdavisstudio.com/pluto/zip

Check out the generator tag on that one! Freeway 3.5 was the first Mac
OS X version of “just plain” Freeway – before there was a Pro or
Express.

Walter

On Aug 23, 2009, at 10:51 PM, Carmine5 wrote:

These are good questions that, at this point, I don’t have concrete
answers to. The client offhandedly asked me if I could do it on
their Freeway site. I’m not sure if it’s just their factory stores
or if they plan to include authorized dealer stores but they are
scattered through the U.S.

I have PHP activated and a MySQL database folder set up on the
server. Unfortunately, I know next to nothing about MySQL although
I do have the free Cocoa MySQL and YourSQL applications as well as
the various PHP and MySQL Actions.

What next? Thanks.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walter,

I’m looking at the source code now. Would I insert this code as a Markup item on the page or in conjunction with an Action? Would the zip code database be input through a MySQL editor such as Cocoa MySQL? How would the two items (the script and zip code database) link?

Thanks to both you and LLE for your input.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Well, all you can see from there is the HTML, not the PHP that
generated it.

You would use a SQL editor to design your database tables and load in
the Zip code database, and you could either make an HTML interface
that your client could use to load in the dealer’s addresses, or you
could use the SQL editor for that as well.

The PHP code that would interface between the database and the page
would still need to be written in PHP or another programming language,
and it would be specific to what you want to do in the results. I
would make a table for the dealers, and in each dealer’s record
include a field to hold a URL to the map. This could point to either
the Google Map, or to a page on your site where you have made a custom
map page using the Google Maps Action and Freeway.

The basic SQL query is this:

$sql = "select Zipcode, City, State,
(sqrt(power(69.1*(Latitude - $lat1),2)
+ power(69.1*(Longitude-$long1)
*cos(Latitude/57.3),2))) as dist from
zipcode where (sqrt(power(69.1
*(Latitude - $lat1),2)+ power(69.1
*(Longitude-$long1)*cos(Latitude/57.3),2)))
 <= $radius ORDER BY dist ASC" ;

That just finds you all the Zip codes in the radius. You would need to
extend the script so it also looked up your dealerships and restricted
itself to only the Zip codes that had dealerships, so the last line
would be replaced with something like this:

<= $radius AND Zipcode IN(
SELECT zip FROM dealers WHERE 1)
ORDER BY dist ASC";

Then, instead of looping through the results and displaying the Zip
code and City and State the way my page does, you would loop through
each result Zip code, find the matching dealer(s) within it, and list
them. That would need to be a different query, and it would depend on
the structure of your dealers table.

Walter

On Aug 24, 2009, at 2:12 AM, Carmine5 wrote:

Walter,

I’m looking at the source code now. Would I insert this code as a
Markup item on the page or in conjunction with an Action? Would the
zip code database be input through a MySQL editor such as Cocoa
MySQL? How would the two items (the script and zip code database)
link?

Thanks to both you and LLE for your input.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

OK, I’ll try to piece this together.

Thanks.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I did a project for a client a while back that did something similar
and I ended up using Google Maps for it all. The Maps API has methods
for finding the closest location to any given point which means you
should be able to do the lot just using JavaScript and Google Maps.

I’ve posted a very simple sample page below that shows you how the
feature works;
http://www.freewayactions.com/test/googlemaps/find-nearest-location.html

When the page loads you should see 5 locations plotted on a map of the
UK. Enter a valid post code in the search box below the map and press
“Search” (try the Softpress post code for example, OX29 8LH) and the
map should zoom in and show you the marker and balloon for the closest
store (in this example it should be Address One at Weston-Super-Mare).

Have a look at the page source code and you’ll see where you can add
your array of location coordinates, place names, and balloon text (in
the addPoints function). You’ll also need to change the Google Maps
API key at the top of the page code as this one is registered to
FreewayActions.com and won’t work on any other domain.

Unfortunately I don’t have time to action this at the moment but will
do if and when I next get a chance.

The page should work well with zip codes although I’ve not really
tested it with anything other than UK post codes.
Regards,
Tim.

On 23 Aug 2009, at 23:52, Carmine5 wrote:

Hello;

I’ve been asked to add a search feature in which a user types in a
zip code which will then take them to a page with a Google map of a
store location.

How can I accomplish this?

FreewayActions.com - Freeware and shareware actions for Freeway
Express & Pro.

Protect your mailto links from being harvested by spambots with Anti
Spam.
Only available at FreewayActions.com

http://www.freewayactions.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

This is a great idea, Tim. I should look more into what Google Maps on its own can do before setting up a complex database.

I was thinking, too, of just offering the client a map of the U.S. with rollovers for each state. The user simply clicks on the state they’re located in and a list of stores appears.

That’s simple to set up.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options