Reputation: 225
Here I have a demo that use nearbySearch
to search for objects inside boxes (route boxer utility):
http://www.geocodezip.com/v3_SO_RouteBoxerPlaces.html 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<br>"
for (var i = 0, result; result = results[i]; i++) {
var marker = createMarker(result);
}
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}
Now when I try to use textSearch
instead nearbySearch
I see that code with textSearch and query search for objects outside boxes... http://jsbin.com/ifUZIti/1/edit
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<br>"
for (var i = 0, result; result = results[i]; i++) {
var marker = createMarker(result);
}
searchIndex++;
if (searchIndex < boxes.length)
findPlaces(boxes,searchIndex);
});
}
What is difference beetween textSearch
and nearbySearch
and WHY when I try to use textSearch code search and looking for objects outside defined boxes ? What is problem here?
with nearbySearch
all works fine but I can't use query with nearbySearch so I must use textSearch but with textSearch
script search objects outside boxes ?
How I can solve this?
Upvotes: 1
Views: 1837
Reputation: 2399
If you zoom in on the places that look like they are way outside the box on a high level rendering, you will see they are all either well inside the box, or just out side the box. It isn't nearly as bad as it looks at first blush. See my version of your code to see the results.
Upvotes: 1