Search for nearby ceps [duplicate]

4

I'm implementing a system as an online delivery, the customer will enter the tool and place their zip code, so the system should inform all restaurants / companies, close to it. I wanted to know if anyone has a good solution to do this quest. My main idea was to save all the companies in the database with their CEPS and the maximum delivery radius when the client searched with their zip code would bring all the companies from the bank and then for each company I would use a WebService which returns me to distance between the CEPS. But this solution does not seem very efficient. Would anyone know of any way to implement this?

    
asked by anonymous 06.10.2014 / 21:31

2 answers

4

You need to develop a database that contains the latitudes and longitudes of each of the companies you want displayed in the results. When the user enters your address you should integrate with some geolocation service (google maps, for example) and find the latitude and longitude of the user's address. Based on these two points it is easy to calculate.

Follow this example from Google itself:

link

    
06.10.2014 / 22:35
3

Using the PHP functions GEOIP, you can have "but the least" an idea of the position (GPS) of the figure. In case of an Android application the iPhone is easier.

After that, in your data table with restaurant, stores .. you need to indicate for each one, the position. Also with GPS.

After that, you'll need to calculate the distance between the two (the "customer" and the "store"). Here a small code to calculate the distance: link

Care has a lot that do not use the size of the land / They give a distance with weak accuracy, which, in v's case, would not be enough.

    
06.10.2014 / 22:30