Answer the question
In order to leave comments, you need to log in
How to select and prioritize coordinates on the map over others?
There is a table of user requests with coordinates:
+----+-----+-----+
| id | lat | lon |
+----+-----+-----+
| 1 | ... | ... |
+----+-----+-----+
+----+-----+-----+------+---------+-----+
| id | lat | lon | name | address | ... |
+----+-----+-----+------+---------+-----+
| 1 | ... | ... | ... | ... | |
+----+-----+-----+------+---------+-----+
Answer the question
In order to leave comments, you need to log in
With this type of request, there will be no exact hit in the organization's coordinates and you need to determine the size of the area around the user's coordinates and its shape (square, rectangle, circle, something else).
The size of the area will limit the list of selected organizations.
You can set the size, for example, like this, let's show everything around the user within a radius of 2 km.
And let the area for simplicity be a square.
From the wiki, you can find that the average length of one degree of latitude / longitude is approximately 111 km.
Then the variation in latitude/longitude from the user's current position would be plus/minus 2/111 degrees = 0.018 degrees.
And then you can use this query to display a list of suitable organizations:
SELECT us.id,
lc.name,
lc.address
FROM tb_user us
JOIN tb_location lc
ON lc.lat BETWEEN us.lat - 0.018 AND us.lat + 0.018
AND lc.lon BETWEEN us.lon - 0.018 AND us.lon + 0.018
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question