title: Places API textSearch vs nearbySearch
body: <p>Here I have a demo that use <code>nearbySearch</code> to search for objects inside boxes (route boxer utility):</p>
  
  <p><a href="http://www.geocodezip.com/v3_SO_RouteBoxerPlaces.html" rel="nofollow">http://www.geocodezip.com/v3_SO_RouteBoxerPlaces.html</a>
  CODE:</p>
  
  <pre><code>function findPlaces(boxes,searchIndex) {
     var request = {
         bounds: boxes[searchIndex],
         types: ["gas_station"]
     };
     // alert(request.bounds);
     service.radarSearch(request, function (results, status) {
     if (status != google.maps.places.PlacesServiceStatus.OK) {
       alert("Request["+searchIndex+"] failed: "+status);
       return;
     }
     // alert(results.length);
     document.getElementById('side_bar').innerHTML += "bounds["+searchIndex+"] returns "+results.length+" results&lt;br&gt;"
     for (var i = 0, result; result = results[i]; i++) {
       var marker = createMarker(result);
     }
     searchIndex++;
     if (searchIndex &lt; boxes.length) 
       findPlaces(boxes,searchIndex);
     });
  }
  </code></pre>
  
  <p>Now when I try to use <code>textSearch</code> instead <code>nearbySearch</code> I see that code with textSearch and query search for objects outside boxes... <a href="http://jsbin.com/ifUZIti/1/edit" rel="nofollow">http://jsbin.com/ifUZIti/1/edit</a></p>
  
  <pre><code>function findPlaces(boxes,searchIndex) {
     var request = {
         bounds: boxes[searchIndex],
         query: 'gas station'
     };
     // alert(request.bounds);
     service.textSearch(request, function (results, status) {
     if (status != google.maps.places.PlacesServiceStatus.OK) {
       alert("Request["+searchIndex+"] failed: "+status);
       return;
     }
     // alert(results.length);
     document.getElementById('side_bar').innerHTML += "bounds["+searchIndex+"] returns "+results.length+" results&lt;br&gt;"
     for (var i = 0, result; result = results[i]; i++) {
       var marker = createMarker(result);
     }
     searchIndex++;
     if (searchIndex &lt; boxes.length) 
       findPlaces(boxes,searchIndex);
     });
  }
  </code></pre>
  
  <p>What is difference beetween <code>textSearch</code> and <code>nearbySearch</code> and WHY when I try to use textSearch code search and looking for objects outside defined boxes ? What is problem here?
  with <code>nearbySearch</code> all works fine but I can't use query with nearbySearch so I must use textSearch but with <code>textSearch</code> script search objects outside boxes ?
  How I can solve this?</p>