【发布时间】:2017-12-03 23:22:54
【问题描述】:
我已经浏览了下面链接中的示例 https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete?csw=1
我尝试了这个例子,但没有得到预期的输出地址超出了我提到的半径范围,下面我添加了我的自动完成代码请告诉我我出了什么问题
var center22 = new google.maps.LatLng({ lat: 51.448386, lng: -0.199501 });
service = new google.maps.places.AutocompleteService();
service.getPlacePredictions({
input: query, location: center22, radius: 50000, strictbounds: true, componentRestrictions: { country: 'GB' }
}, function (predictions, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
dfd.resolve([]);
}
dfd.resolve(predictions);
return dfd.promise
}
});
【问题讨论】:
-
您的代码 (
Uncaught SyntaxError: missing ) after argument list) 出现语法错误。请提供一个 minimal reproducible example 来证明该问题。 -
@geocodezip ,在将代码添加到其中时,它最后错过了右大括号,但有一个大括号,我正在通过更改它来使用此代码。但是地址超出了半径限制。,请给我建议
-
它仍然不是minimal reproducible example。这只是您没有测试您发布的代码以验证它是否存在问题这一事实的一个症状。
标签: javascript jquery google-maps google-maps-api-3 autocomplete