Because the project needs to calculate the nearby restaurant according to the current user's location and sort the restaurant according to the distance, and can only place orders in the restaurant within the distribution range.
I want to know if there is any map API to help me implement this function.
What I'm thinking now is this:
1: Get the accurate latitude and longitude of the user's current location,
2: Each of our restaurant tables also has a latitude and longitude field information, and there is a distribution radius within a few kilometers,
3: According to the latitude and longitude of the user to find a restaurant can order, and calculate the distance,
The current problem is step 1, step 3, how to achieve?
Add one more question:
Step 2 In fact, the distribution radius is a relatively simple practice, it is best to have a distribution range, can draw an area on the map out, but this is more complex, I just this idea, still do not know can be achieved by how. (last time asked and this similar question, some people say that the calculation distance needs a special map location computing server to do, then this is not the threshold is too high, I think there is no more convenient map API can be implemented in part, and then through the program Php+mysql implementation)
I hope the great God help me, thank you ^_^
PS: If the API can be implemented can also, want to know the principle
Reply content:
Because the project needs to calculate the nearby restaurant according to the current user's location and sort the restaurant according to the distance, and can only place orders in the restaurant within the distribution range.
I want to know if there is any map API to help me implement this function.
What I'm thinking now is this:
1: Get the accurate latitude and longitude of the user's current location,
2: Each of our restaurant tables also has a latitude and longitude field information, and there is a distribution radius within a few kilometers,
3: According to the latitude and longitude of the user to find a restaurant can order, and calculate the distance,
The current problem is step 1, step 3, how to achieve?
Add one more question:
Step 2 In fact, the distribution radius is a relatively simple practice, it is best to have a distribution range, can draw an area on the map out, but this is more complex, I just this idea, still do not know can be achieved by how. (last time asked and this similar question, some people say that the calculation distance needs a special map location computing server to do, then this is not the threshold is too high, I think there is no more convenient map API can be implemented in part, and then through the program Php+mysql implementation)
I hope the great God help me, thank you ^_^
PS: If the API can be implemented can also, want to know the principle
You can call the map's API to get the latitude and longitude of the restaurant, then use the H5 navigator.geolocation to get the latitude and longitude of the current user, and then calculate the distance.
Step 1, you can use the HTML5 API to get latitude and longitude like the 1 floor.
Step 3, you can find a map, such as Baidu Map, the developer documentation of the gold map, there will be a corresponding method, directly call on it can be
Give you a few links you can see
HTML5 Location
HTML5 geolocation (geo-location)
Baidu Map API
German Map API
If you get the latitude and longitude of the user directly (the interface is provided), then calculate the distance based on the latitude and longitude of your restaurant.
Our current approach is to get the user's location through the API
Distance calculation can be calculated using the MySQL earth radius, but this query is slower.
The current project uses but Geohash algorithm to calculate the distance. or refer to the program of a regiment for a mission document.