Answer the question
In order to leave comments, you need to log in
How to get labels for visible area in google map?
Hello. Such a problem, there is a base with the coordinates of the marks. These labels are loaded onto the map using an ajax request, I pass the coordinates to it:
{
x1: map.getBounds().getSouthWest().lat(),
y1: map.getBounds().getSouthWest().lng(),
x2: map.getBounds().getNorthEast().lat(),
y2: map.getBounds().getNorthEast().lng()
}
Answer the question
In order to leave comments, you need to log in
$sql ="SELECT topic_id FROM table
WHERE
(CASE WHEN {$sw_lat} < {$ne_lat} THEN topic_g_lat BETWEEN {$sw_lat} AND {$ne_lat}
ELSE topic_g_lat BETWEEN {$sw_lat} AND 180 OR topic_g_lat BETWEEN -180 AND {$ne_lat}
END)
AND
(CASE WHEN {$sw_lon} < {$ne_lon}
THEN topic_g_lng BETWEEN {$sw_lon} AND {$ne_lon}
ELSE topic_g_lng BETWEEN {$sw_lon} AND 180 OR topic_g_lng BETWEEN -180 AND {$ne_lon}
END)";
So what is the problem?
The condition for the point (x, y) to enter the rectangle (x1, y1, x2, y2) is passed in the 7th grade.
If you are interested in a MySQL query for finding labels in an area, then everything is simple:
SELECT * FROM `метки`
WHERE `широта` >= `мин.широта` AND
WHERE `широта` <= `макс.широта` AND
WHERE `долгота` >= `мин.долгота` AND
WHERE `долгота` <= `макс.долгота
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question