Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools

Distance calculator to measure distance from my shop to customers address

Hi

I'm working on a project where I need this functionality:

It's a webshop with Indonesion food, that can be delivered at home. Shipping price is variable with the distance of the address of the client.

The customer fills in his address (postal code + street) and by clicking a "Measaure distance" button, the distance from the fixed shopadrress gets displayed.

Any recommendations on how to implement such functionality? I think the most common answer will be to use Google Maps API, but I don't know where to start looking there.

Thanks!

2 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

Interesting idea, Sam.

I found a few links to hopefully get you started or, at least, point you in the direction you want to go ( punny ;-p ).

You didn't specify which language you were hoping to do this in so here's 2 each in PHP and JavaScript.

PHP:

JavaScript:

Best of luck!

Hi Sean I got the thing that I want thanks to your answer and this tutorial: http://www.1stwebdesigner.com/distance-finder-google-maps-api/

Thank you very much!