我正在使用並使用radarSearch列出機構。但是,當我使用名稱參數進行搜索時,我遇到了問題。Google Places API - radarSearch按名稱搜索
它返回的幾個地方,但我想獲得的確切名稱。
在這種example,我想又回到「百思買」,但它返回不相關的,我尋找的字的地方。
var map;
var infoWindow;
var service;
function initialize() {
map = new google.maps.Map(document.getElementById('map'), {
mapTypeId: google.maps.MapTypeId.ROADMAP,
center: new google.maps.LatLng(33.7490, -84.3880),
zoom: 11,
styles: [
{
stylers: [
{ visibility: 'simplified' }
]
},
{
elementType: 'labels',
stylers: [
{ visibility: 'on' }
]
}
]
});
infoWindow = new google.maps.InfoWindow();
service = new google.maps.places.PlacesService(map);
performSearch();
}
function performSearch() {
var request = {
location: new google.maps.LatLng(33.7490, -84.3880),
radius: 50000,
name: "Best Buy"
};
service.radarSearch(request, callback);
}
function callback(results, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert(status);
return;
}
for (var i = 0, result; result = results[i]; i++) {
createMarker(result);
}
}
function createMarker(place) {
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location,
icon: 'http://www.google.com/intl/en_us/mapfiles/ms/micons/yellow-dot.png'
});
google.maps.event.addListener(marker, 'click', function() {
service.getDetails(place, function(result, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
alert(status);
return;
}
infoWindow.setContent(result.name);
infoWindow.open(map, marker);
});
});
}
initialize();
',我想又回到‘百思買’,但它正在返回與wo無關的地方rd我正在尋找.' =>你能否添加關於你認爲不相關的數據的細節?這個名字不完全是「百思買」的事實嗎? 看着你的樣本不明確 –
嗨尼古拉斯,沒錯。我得到的結果與「最佳購買」完全不符。 喜歡「在這裏買這裏付錢」或「我們買地」 – user2383907