You had one job!
September 3, 2013 8:27 PM   Subscribe

I want to make a simple website where you can put in your coordinates and it will tell you how far you are from the Clark Street subway station in Brooklyn New York. What's the easiest way to do this?

You would put in your location (or coordinates) from anywhere in the world and it would tell yo number of miles to the sation. Obviously I'd need some location coordinates service. I think Google provides some, but I'm not really a programmer so I don't know the latest.

This is just a chuckle for a friend based on an inside joke.

I know it's a basic thing but I didn't see a decent similar tutorial.
posted by sweetkid to Computers & Internet (9 answers total) 3 users marked this as a favorite
 
I googled the coordinates of the station, put that and my location into google maps. I'm 23 hours, 12 minutes from there or 1607 miles.
posted by tamitang at 8:36 PM on September 3, 2013


That was on a GPS enabled iPhone if that helps.
posted by tamitang at 8:37 PM on September 3, 2013


It's a little anticlimactic, but Google Maps direction request urls are in this format:

https://maps.google.com/maps?saddr=central+park&daddr=40.6974,-73.9931&hl=en&sll=40.6974,-73.9931&sspn=0.313395,0.471039&geocode=Fe8nbgIdXkqX-yEZQamHcx_fuSnjMYUBmljCiTEZQamHcx_fuQ%3BFTj-bAIddPSW-w&dirflg=w&mra=ls&t=m&z=13

So, you could make a little web app that redirects to Google Apps, replacing that saddr parameter ("central+park" in this example) with the user's address. (40.6974,-73.9931 is the station's coordinates.)
posted by ignignokt at 8:40 PM on September 3, 2013 [1 favorite]


Best answer: If you don't want to show any map whatsoever in your app, there's the Google Geocoding API, which will let you get the user's latitude and longitude (the geocode) and then do the math to see how far it is from 40.6974,-73.9931.
posted by ignignokt at 8:41 PM on September 3, 2013 [1 favorite]


Best answer: You don't really need to query a service for this kind of thing -- just include the coordinates of the station and use some geometrical reasoning to find the distance from the given.

If you want users to be able to input locations in different formats, you want a "geocoding" service.
posted by wayland at 8:43 PM on September 3, 2013


Response by poster: When you say "geometrical reasoning," you mean..?
posted by sweetkid at 8:51 PM on September 3, 2013


Best answer: ... using the Great Circle equations.

Exampling including javascript
posted by trialex at 9:06 PM on September 3, 2013 [1 favorite]


Best answer: Hey, instead of doing what I should have been doing, I decided to glue together a version, incorporating the calculation linked above. Feel free to fork and build on it! Here's a running version you can try.
posted by ignignokt at 9:55 PM on September 3, 2013 [6 favorites]


Response by poster: Wowza! Thank you!
posted by sweetkid at 5:06 AM on September 4, 2013


« Older That taste nasty   |   How do I store macarons overnight for maximum... Newer »
This thread is closed to new comments.