Thanks for the info, Charles!

Yes, the info is quite over my head as jQuery is my first experience
with Javascript, and I only started with jQuery a couple of months ago.

I'll keep your pointers on file if I ever get an opportunity to
develop an app that I've been considering for my area.

Thanks, again!

Rick


-----Original Message-----
From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of polyrhythmic
Sent: Thursday, September 20, 2007 7:10 PM
To: jQuery (English)
Subject: [jQuery] Re: ANNOUNCE: Meijer.com launches -- using jQuery


Very cool, jQuery is showing up everywhere!

Unfortunately, the Store Locator does not locate any stores for me, no
matter what I ask it.  Regardless...

Rick, the way to create a store locator from Google Maps is a pretty
easy process, once you learn how to leverage the powerful API.  I
created a store locator with GMaps (before I was jQuery enlightened)
at http://www.pave-eze.com/distributors.php .  The GMaps API works
best with lat/long coordinates, and can find a latitude and longitude
for you with the geocoder method.  However, the geocoder will return
an approximate lat/long if it can't find the address, so I ran my
store addresses through the geocoder, doublechecked the lat/long, and
then committed the lat/long into the database along with the addresses
& phone numbers.  Once you have the store lat/long coords in your db,
the code is similar to the following:

Run the geocoder on the user's address input:
geocoder method is async, and requires an anonymous callback function
(just like jQuery) to which it passes a point object (GLatLng object).

var address = document.getElementById('address').value;
if (geocoder) {
     geocoder.getLatLng(address,
          function(point) {
               findDistanceFrom(point);
    });
}

Have your callback function call your distance calculating function.
GMaps will find a distance (in meters) from any point object to
another point object with the distanceFrom method:

distance = point.distanceFrom(store);

(I had to then convert meter distance to miles for us
estadounidenses.)

In my case, I have an array of stores loaded from the DB, and I create
a new sorted stores array in order of distance, and then I redraw the
page with stores in order of distance.  I am assuming you are a)
familiar with JS and b) familiar with the GMaps API.  The source code
is viewable (but not always pretty) at
http://www.pave-eze.com/distributors.php
and http://www.pave-eze.com/d_searcher.php .

Hope this helps!  Let me know if this doesn't make sense / you have
further questions.

Charles
doublerebel.com




Reply via email to