Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Around me places

(Sorry for my bad english; i'm french)


I have a SQlite database, withy latitude and longitude data inside.

I can show correctly on a map, but I can't show "Around me" places…

I tried a code witch gives a result in meters, the rows aren't ordered by distance, and the distance is impossible, like 554658165184684514456513 meters for something at 100 meters…

Does someone have a code sample to calculate distances in meters, orders SQL by distance? Thanks!


EDIT: I can't give you the code, my Mac isn't usable for now

— asked September 8th 2010 by Ivan Mathy
  • iphone

2 Answers

  • If it's something still needed, I'd suggest you to have a look at this Guide so you may got accurate help from community.

    — answered November 14th 2012 by Eduardo Gomez
  • Hi

    I have found the solution. We can put following code in PHP server.

    set @orig_lat=22.980141148209555; 
    set @orig_lon=72.4916124343872;
    set @dist=10;
    SELECT *, 3956 * 2 * ASIN(SQRT( POWER(SIN((@orig_lat - abs(lat)) * pi()/180 / 2),2)
     + COS(@orig_lat * pi()/180 ) * COS(abs(lat) *  pi()/180) * 
    POWER(SIN((@orig_lon - lon) *  pi()/180 / 2), 2) )) * 1.60934
    as distance FROM hotels ;


    — answered April 23rd 2013 by Kapil Maheshwari
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.