値が変更された後、Google マップのオートコンプリート フィールドの値を変更するにはどうすればよいですか?
私の究極の願いは、このフィールドに住所を表示し、市、州などを別のフィールドに表示することです。
http://jsbin.com/wiye/2/ (以下にスクリプトを複製) で見られるように、値を変更しますが、後で元に戻ります。
show just the street address in google.maps.event.addListener()は同じ質問をしますが、もはや機能していないようです。 Google マップのオートコンプリートのテキスト ボックスの値を変更すると、同じ質問が表示されますが、適切な回答がありません。
ありがとうございました
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Places search box</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js" type="text/javascript"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places"></script>
<script>
$(function(){
var input_auto = document.getElementById('input_auto');
autocomplete = new google.maps.places.Autocomplete(input_auto,{types: ['geocode'],radius: 10});
google.maps.event.addListener(autocomplete, 'place_changed', function() {
setTimeout(function(){$('#input_auto').val('yyy');},50);
alert('pause1');
console.log(autocomplete,input_auto);
input_auto.value='xxx';
//autocomplete.set('xxx');
//autocomplete.setValues('xxx');
alert('pause2');
});
});
</script>
</head>
<body>
<input id="input_auto" type="text">
</body>
</html>