SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Points nearby locations database.

    Hi ,
    what is the MySQL 5.0 query needs to select geo
    coordinates( latitude,longitude) from locations database
    within a radius of 100 miles around this center :
    map.setCenter(new GLatLng(".$initial_lat.",".$initial_lng.") ;
    and display this markers in the Google Maps ?
    Please I tried before the distance calculation of My SQL :

    map.setCenter(new GLatLng(".$initial_lat.",".$initial_lng.") ;
    and display this markers in the Google Maps ?
    Please I tried before the distance calculation of My SQL :

    (3963*acos(cos(radians($initial_lat))*cos(radians(lat))*cos(radians(lng)-
    radians($initial_lng))+sin(radians($initial_lat))*sin(radians(lat))))
    AS distance FROM agoda_hotel
    WHERE agoda_hotel.country_id = 205
    HAVING distance < 100

    however it' s not select locations nearby the center above
    correctly. I am newbie in MySQL programming and may be I
    could not found the exact function.
    thanks.

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am not sure if it is really working accurately but what I had done a couple of months before something like this:
    Code php:
    if($lat && $lng){
        // 1 km = 0.6213711 miles
        $miles = $srch_within * 0.6213711; // $srch_within is in km so converting to miles
        $lat1 = $lat - ($miles / 69.1);
        $lng1 = $lng - ($miles / 53);
     
        $lat2 = $lat + ($miles / 69.1);
        $lng2 = $lng + ($miles / 53);
     
        $where[] = "(p.posLat>=$lat1 AND p.posLat<=$lat2 AND p.posLng>=$lng1 AND p.posLng<=$lng2)";
    }
    I did not give much time because this was not in my priority at that moment. Try and see if this works for you.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •