title: Google Maps - Panning and Zooming into areas - markers not appearing when I zoom in or pan
body: <p>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 is moves or panned or zoomed which takes the bound of the map and makes an ajax call which in turn the server side script runs a simple sql query to retrieve the markers and clusters them. SO far teh clustering part is working nicely however sometimes the getBounds doesn't seem to be sending the correct boundaries I feel.</p>
  
  <p>Like I may pan a map a bit on the side and regions which used to have markers now all of a sudden don't have markers and the map is blank. I checked the sql query and from the query itself it shows an outrageously different bounds than what would be expected.</p>
  
  <p>Take a look at the regions below:
  <img src="https://i.stack.imgur.com/qq6jM.jpg" alt="Orginal WitH Markers">
  <img src="https://i.stack.imgur.com/q1Myc.jpg" alt="No markers"></p>
  
  <p>The first one shows all the markers.</p>
  
  <p>The one following however has just moved a bit to the top and left but half the region is the same as in the previous picture however there are no markers at all. I have isolated the issue to be with the getBounds function of the maps.</p>
  
  <p>This is my javascript code which gets the bounds and makes the call:</p>
  
  <pre><code>var bounds = map.getBounds();
  var southWest = bounds.getSouthWest();
  
  var northEast = bounds.getNorthEast();
  var data = {ne:northEast.toUrlValue(), sw:southWest.toUrlValue(), zoom:map.getZoom()};
  //something getting messed up in the code above this point
  
  $.ajax({
      type: "POST",
      url: 'maps/get-markers',
      data: {object:$.toJSON(data)},
      dataType: 'json',
  
      success: function(response) {
          //code to add markers
      }
  });
  </code></pre>
  
  <p>On my server side code this is the php used to get the items based upon the coordinates:</p>
  
  <pre><code>$data =  Zend_Json::decode(stripslashes($this-&gt;_request-&gt;getParam('object')));
  
  //retrieve the variables from the GET vars
  list($nelat, $nelng) = explode(',', $data['ne']);
  list($swlat, $swlng) = explode(',',$data['sw']);
  
  //clean the data
  $nelng  =   (float)$nelng;
  $swlng  =   (float)$swlng;
  $nelat  =   (float)$nelat;
  $swlat  =   (float)$swlat;
  
  $ubound = $swlng &gt; $nelng ? $swlng : $nelng;
  $lbound = $swlng &gt; $nelng ? $nelng : $swlng;
  
  $sql = 'SELECT `a`.* FROM `locations` AS `a` WHERE (a.`longitude` &gt; $lbound) AND (a.`longitude` &lt; $ubound) AND';
  
  $ubound = $swlat &gt; $nelat ? $swlat : $nelat;
  $lbound = $swlat &gt; $nelat ? $nelat : $swlat;
  
  
  $sql .= ' (a.`latitude` &gt;= $lbound) AND (a.`latitude` &lt;= $ubound)';
  </code></pre>
  
  <p>I'm suspecting its the getbounds function in the javascript but need to fix it asap. Any ideas please :(</p>