Get all records from MySQL database that are within Google Maps .getBounds?

前端 未结 10 1061
既然无缘
既然无缘 2020-12-02 12:53

Ok I have a database with about 1800 rows, each has a column lat and long, what I am trying to do, it query against Google Maps V3 .getBounds

10条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 13:13

    This works for me:

    $condition1 = $a < $c ? "lat > $a AND lat < $c" : "lat > $a OR lat < $c";
    $condition2 = $b < $d ? "lon > $b AND lon < $d" : "lon > $d OR lon < $b";
    $q = "SELECT * FROM tilistings WHERE ( $condition1 ) AND ( $condition2 )";
    

提交回复
热议问题