google.maps.places.Autocomplete 502错误 [英] google.maps.places.Autocomplete 502 error
问题描述
我正在使用google.maps.places.Autocomplete API,今天早上我遇到了502 Bad Gateway错误.它持续了大约10分钟,并再次开始工作.我认为这与服务不可用有关.
I am using the google.maps.places.Autocomplete API and this morning I was getting a 502 Bad Gateway error. It lasted about 10 minutes and started working again. I assume this had to do with the service being unavailable.
我想知道发生这种情况时如何处理错误.我的(javascript)自动完成代码如下:
I was wondering how I can error handle when this happens. My (javascript) autocomplete code looks like this:
$('#StartAddress').change(function () {
google.maps.event.trigger(startAutocomplete, 'place_changed');
return false;
});
var source, destination;
var directionsDisplay;
var directionsService;
if (typeof google === 'object' && typeof google.maps === 'object') {
directionsService = new google.maps.DirectionsService();
// set up places autocomplete
var start = document.getElementById('StartAddress');
var startAutocomplete = new google.maps.places.Autocomplete(start);
var end = document.getElementById('EndAddress');
var endAutocomplete = new google.maps.places.Autocomplete(end);
// add the places auto complete listener for when the values change
startAutocomplete.addListener('place_changed', function () {
var startAddress = $('#StartAddress').val();
var endAddress = $('#EndAddress').val();
if (endAddress && startAddress) {
GetRoute(startAddress, endAddress, false);
}
});
endAutocomplete.addListener('place_changed', function () {
var endAddress = $('#EndAddress').val();
var startAddress = $('#StartAddress').val();
if (endAddress && startAddress) {
GetRoute(startAddress, endAddress, false);
}
});
directionsDisplay = new google.maps.DirectionsRenderer({ 'draggable': false });
}
GetRoute(startAddress,endAddress,false)函数是对google.maps.Map的调用,并且工作正常.只是自动完成服务失败了.
The GetRoute(startAddress, endAddress, false) function is a call to the google.maps.Map and that works fine. It was only the autocomplete service that was down.
此外,是否可能因为我使用开发人员密钥而不是生产而发生此错误?像Google开发环境一样,资源更多吗?
Also, is it possible this error occurred because I am using the developer key instead of production? Like the googles dev environment is much more resource limited?
推荐答案
这次服务已关闭.立即重试.
The service was down this time. Try again now.
这篇关于google.maps.places.Autocomplete 502错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!