Map & Location Question
I'm hoping it a gap in the documentation. I'm looking at the docs for Titanium.Geolocation and Titanium.Map and have not been able to figure it out.
I have a list of sites (cordinates in terms of Lat & Long). I need to use my current location to deternine which site I'm closest to. Any ideas? Thx.
3 Answers

I'm no genius with regards to map stuff, but I think what you are looking for isn't really covered by the Ti map API (or any other eg Google API). Basically you need to do some simple math to compare your coordinates against your list and determine which has the shortest distance. If you poke around the Google Maps API groups you can find what you need (I've seen it pop up quite a bit).
For example, googling this: "calculate distance between latitude longitude" returns this: http://www.movabletype.co.uk/scripts/latlong.html which should be what you need?

The iPhone SDK supports such things as calculating distance between points, reverse geolocation lookup, etc. According to the docs, it doesn't look like these have been implemented in Titanium yet.

This might be old, but this function works fine, just sub in your lat/lons…it doesnt take routing into effect, just the direct line.
~~~
var dist = Math.sin(radlat1) Math.sin(radlat2) + Math.cos(radlat1) Math.cos(radlat2) Math.cos(radtheta);
dist = Math.acos(dist);
dist = dist 180/Math.PI;
dist = dist 60 1.1515;
if (unit=="K") {
dist = dist * 1.609344;} if (unit=="N") { dist = dist * 0.8684; } return dist;
}
var x=distance(30.5166667,86.4822222,30.7619444, 86.5705556,"N");
alert(x);
~~