我正在使用Google地方信息的自動填充功能。Google地方信息place_changed聆聽者無法在iPhone上工作
在任何瀏覽器(IE,Chrome,Firefox,Safari Mac)上一切正常:我開始輸入街道名稱,點擊結果,結果列表關閉,事件觸發。
然而,在Safari Mobile上記錄結果會關閉結果列表,但事件永遠不會觸發。這是在iPhone 4S,iOS 9上,但我也有類似的報告,從其他模型的用戶。
我的代碼,它在同一頁上使用谷歌地圖,是相當標準:
<div id="map"></div>
<input type="text" name="location" id="location">
<script>
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
// ...
);
var autocomplete = new google.maps.places.Autocomplete(
document.getElementById('location'), {
types: ['address'],
componentRestrictions: {country: "re"}
}
);
console.log('before listener');
autocomplete.addListener('place_changed', function() {
console.log('place changed');
});
console.log('after listener');
}
</script>
<script src="//maps.google.com/maps/api/js?libraries=places&callback=initMap&language=fr-RE" async defer></script>
連接了iPhone到Mac,檢查Web檢查,我看不出有任何錯誤。我可以在控制檯中看到「聽衆」之前和「聽衆」消息記錄之後,聽衆似乎已經註冊。但錄製結果時不會出現「已更改地點」的信息。
可能是什麼問題?
我建議你提供一個快速工作的小提琴,這樣可以測試。你還檢查了[這裏](https://code.google.com/p/gmaps-api-issues/issues/list?can=2&q=apitype:Javascript3&colspec=ID+Type+Status+Introduced+Fixed+Summary+內部+星級和細胞=瓷磚)的任何類似的問題,將已經報告? (我沒有檢查) – MrUpsidown