谷歌地图Javascript API V3:搜索请求
调用搜索服务api时谷歌地图Javascript API V3:搜索请求,javascript,google-maps-api-3,Javascript,Google Maps Api 3,调用搜索服务api时 var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316); var request = { location: pyrmont, radius: '500', types: ['store'] }; service = new google.maps.places.PlacesService(map); service.search(request, callback); 是否需要给出搜索区域的位置/半径 如
var pyrmont = new google.maps.LatLng(-33.8665433,151.1956316);
var request = { location: pyrmont, radius: '500', types: ['store'] };
service = new google.maps.places.PlacesService(map);
service.search(request, callback);
var keyword='search placename';
var request = { name : keyword,
bounds : new google.maps.LatLngBounds(
google.maps.LatLng(-89.999999,-179.999999),
google.maps.LatLng(89.999999,179.999999)
)};
service = new google.maps.places.PlacesService(map);
service.search(request, callback);
function callback(results, status)
{
console.log("status="+status);
if ( status == google.maps.places.PlacesServiceStatus.OK)
{
for (var i = 0; i < results.length; i++)
console.log(results[i]);
}
}
var关键字='search placename';
var请求={name:关键字,
边界:新的google.maps.LatLngBounds(
google.maps.LatLng(-89.999999,-179.999999),
google.maps.LatLng(89.999999 179.999999)
)};
服务=新的google.maps.places.PlacesService(地图);
服务搜索(请求、回调);
函数回调(结果、状态)
{
console.log(“status=“+status”);
if(status==google.maps.places.PlacesServiceStatus.OK)
{
对于(var i=0;i
我做错了什么
search()
的调用必须包含位置和半径,或者边界(作为LatLngBounds对象)。这记录在var sw = new google.maps.LatLng(-89.999999,-179.999999);
var ne = new google.maps.LatLng(89.999999,179.999999);
var bounds = new google.maps.LatLngBounds(sw,ne);
search()
的调用必须包含位置和半径,或者边界(作为LatLngBounds对象)。这记录在var sw = new google.maps.LatLng(-89.999999,-179.999999);
var ne = new google.maps.LatLng(89.999999,179.999999);
var bounds = new google.maps.LatLngBounds(sw,ne);
谢谢@Trott的回复,我得到了你的2分,但很抱歉,我没有足够的关于LatLong的知识来构建覆盖全世界的边界。你能帮我做吗。谢谢。好的,我添加了我认为应该创建一个覆盖(几乎)整个世界的边界的代码。谢谢,我将尝试此代码,并让您知道它是否有效。谢谢@Trott,您对我的帮助够多了。谢谢@Trott的回复,我得到了你的2分,但很抱歉,我没有足够的关于拉特朗的知识来组成覆盖全世界的边界。你能帮我做吗。谢谢。好的,我添加了一些代码,我认为这些代码应该可以创建一个覆盖(几乎)整个世界的边界。谢谢,我会尝试这些代码,并让你知道它是否有效。谢谢@Trott,你帮了我很多忙。现在正在进行中,但很快:我强烈怀疑Google placename搜索结果会是空的,特别是考虑到目前Google Places数据库的稀疏程度。尝试搜索“museum”,看看是否有结果。现在就开始,但很快:我强烈怀疑Google Places搜索“search placename”的结果会是空的,特别是考虑到Google Places数据库目前的稀疏程度。尝试搜索“博物馆”,看看是否有结果。