【发布时间】:2016-08-28 01:53:50
【问题描述】:
我已经设置了自动完成文本框,它会显示选项。但是,“place_changed”事件返回 [object Object] 作为输出。下面是我的代码。
<script src="https://maps.googleapis.com/maps/api/js?libraries=places&language=en"></script>
<script>
var pos;
var mylocation;
function initAutocomplete(){
var input = document.getElementById('autocomplete');
var autocomplete = new google.maps.places.Autocomplete(input);
google.maps.event.addListener(autocomplete, 'place_changed', function(){
mylocation = autocomplete.getPlace();
alert(mylocation);
})
}
</script>
以下是我使用的 CSS:
#pac-input {
background-color: #fff;
font-size: 15px;
font-weight: 300;
margin-left: 12px;
padding: 0 11px 0 13px;
text-overflow: ellipsis;
width: 350px;
}
#pac-input:focus {
border-color: #4d90fe;
}
.pac-container {
z-index: 2000000 !important;
width: 350px;
}
.pac-item {
height: 35px;
font-size: 12px;
color: #101010;
}
#autocomplete {
height: 35px;
width: 100%;
padding-left: 10px;
}
任何解决此问题的帮助将不胜感激。
【问题讨论】:
标签: jquery autocomplete google-places-api