IOS Get places within X miles of your current zip code?

So, I want to be able to display a list of places (specified by a zip code) when a user requests all locations within x miles of their current location (specified by a zip code).

Is there any way to do this:

  • Directly in mySQL? (i.e. only return locations in the database that are within X miles of the user's zip code). This would be much more efficient than returning ALL locations in iOS and using MapKit methods to filter those that are within X miles.
+3
source share
2 answers

lat lng , .

0

, : 111,11 . , x * (1.609/111.11). , (LAT, LONG), LAT-x * (1.609/111.11) <= lat <= LAT + x * (1.609/111.11). MySQL; 50 , .

, .

MapKit. , .

111,111 . 111.111 * cos () , . (LAT, LONG) (lat, long)

sqrt ((LAT - lat)^2 + ((LONG - long) * cos (LAT))^2)
0

All Articles