1
Googleマップのオートコンプリート機能を追加しようとしています。 しかし、私は "場所未定義"エラーを取得しています。Googleマップの自動補完場所が未定義
<html>
<body>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places"></script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', function() {
var places = new google.maps.places.Autocomplete(document.getElementById('txtPlaces'));
google.maps.event.addListener(places, 'place_changed', function() {
var place = places.getPlace();
var address = place.formatted_address;
var latitude = place.geometry.location.lat();
var longitude = place.geometry.location.lng();
var mesg = "Address: " + address;
mesg += "\nLatitude: " + latitude;
mesg += "\nLongitude: " + longitude;
alert(mesg);
});
});
</script>
<span>Location:</span>
<input type="text" id="txtPlaces" style="width: 250px" placeholder="Enter a location" />
</body>
</html>
スクリプトタグを置き換えようとしました。しかし、私はオートコンプリートの提案を得ていません。時にはそれは特定の手紙のためだけに機能します。それは手紙 'B'のためだけに示唆を与え、それ以外は何も提示しない。 – user3266972