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

前端 未结 10 1032
既然无缘
既然无缘 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:19

    I haven't used Google's API, but my understanding is that if you get ((33.564398518424134, -79.38014701875002), (35.375726155241175, -76.08424858125002)) back from a getBounds call then (33.564398518424134, -79.38014701875002) is the Southwest corner and (35.375726155241175, -76.08424858125002) is the Northeast. I say that as I think they return the Northeast and Southwest corners and I'm assuming the points are latitude, longitude.

    If that's correct, then Bensiu's query would work. Typically using BETWEEN is more efficient.

    SELECT * FROM tilistings WHERE lat BETWEEN a AND c AND lng between b AND  d
    

提交回复
热议问题