Skip to content Skip to sidebar Skip to footer

Google Maps - Panning And Zooming Into Areas - Markers Not Appearing When I Zoom In Or Pan

I'm implementing some boundary based clustering on the server end of markers to display on my google maps. What I'm doing is that I have a function that is called everytime the map

Solution 1:

I have a page that works exactly the same way that you have described yours. Here's how I get the bounds:

var bounds = map.getBounds();
var sw = bounds.getSouthWest();
var ne = bounds.getNorthEast();
var s = sw.lat();
var w = sw.lng();
var n = ne.lat();
var e = ne.lng();

I then send each value to the server. I previously checked for points within the bounds with a query like this:

WHERE (lat BETWEEN $sBound AND $nBound) AND (lng BETWEEN $wBound AND $eBound)

However, I recently discovered that this query fails when the bounds area includes the international date line. This doesn't look like the problem that you're having (it's probably happening in parsing the bounds), but it's definitely something you should consider. Here's how I fixed it:

if ($wBound > $eBound) { // if bounds includes the intl. date line$sql .= "WHERE (lat BETWEEN $sBound AND $nBound) AND ((lng BETWEEN -180 AND $eBound) OR (lng BETWEEN $w AND 180))";
} else {
    $sql .= "WHERE (lat BETWEEN $sBound AND $nBound) AND (lng BETWEEN $wBound AND $eBound)";
}

Solution 2:

If this is literally copied from the code:

$sql.= ' (a.`latitude` >=$lbound) AND (a.`latitude` <=$ubound)';

then the issue may simply be that you're using single quotes rather than double on the PHP literals. As such, the $lbound and $ubound interpolation doesn't happen, and you're using an invalid SQL query.

Try:

$sql .= " (a.`latitude` >= $lbound) AND (a.`latitude` <= $ubound)";

etc.

Post a Comment for "Google Maps - Panning And Zooming Into Areas - Markers Not Appearing When I Zoom In Or Pan"