0

I am having a little difficulty trying to solve an issue with google GEOcode radius search. I have everything setup fine and working :-

$this->db->select('*, ( 3959 * acos( cos( radians('.$lat.') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('.$lng.') ) + sin( radians('.$lat.') ) * sin( radians( lat ) ) ) ) AS distance'); 

This returns results from the DB within a radius of where the user sets the miles to.

However one user has multiple shops in the UK so their main shop is in Manchester with the DB 'lat' 'lng' set. However they have a smaller store in London. These fields in the database are 'storelat' 'storelng'. However if someone searches london they do not appear in the result as obviously it only retrieves values from 'lat' and 'lng'.

How would I go about querying the radians for multiple lat and lng values in the database? It may not be possible but I am trying everyway I can think of and just end up with MySQL errors.

Any help or a kick in the right direction would be much appreciated.

Many Thanks J

1 Answers1

0

Do you have both lat and storelat columns in the same table? Why? The main store and the 'smaller' store should be separate rows in the same table, and using the same lat/lng pair of columns.

Rick James
  • 135,179
  • 13
  • 127
  • 222