最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Google location autocomplete not working inside modal - Stack Overflow

programmeradmin3浏览0评论

I'm using google autoplete inside a modal. When I click the input field it display the results behind the modal. I didn't use any css. It work perfect outside the modal. But it is not working fine inside the modal. Please help me.

HTML code

<div class="form-group">
    <p class="control-label1">City</p>
    <input type="text" id="locationTextField" placeholder="" name="city" class="form-control">
</div>

Javascript code

//Google Map
function initialize() {
    var input = document.getElementById('locationTextField');
    var autoplete = new google.maps.places.Autoplete(input);
}

function validateCity() {
    searchfield = $('#locationTextField').val();
    if (searchfield == "" || searchfield == null) {
        return false;
    }
    else {
        $('#locationTextField').val('');
        return false;
    }
}
google.maps.event.addDomListener(window, 'load', initialize);

I'm using google autoplete inside a modal. When I click the input field it display the results behind the modal. I didn't use any css. It work perfect outside the modal. But it is not working fine inside the modal. Please help me.

HTML code

<div class="form-group">
    <p class="control-label1">City</p>
    <input type="text" id="locationTextField" placeholder="" name="city" class="form-control">
</div>

Javascript code

//Google Map
function initialize() {
    var input = document.getElementById('locationTextField');
    var autoplete = new google.maps.places.Autoplete(input);
}

function validateCity() {
    searchfield = $('#locationTextField').val();
    if (searchfield == "" || searchfield == null) {
        return false;
    }
    else {
        $('#locationTextField').val('');
        return false;
    }
}
google.maps.event.addDomListener(window, 'load', initialize);
Share Improve this question asked Dec 13, 2016 at 11:47 user7152572user7152572 3331 gold badge4 silver badges16 bronze badges 2
  • can you please provide your html code – RonyLoud Commented Dec 13, 2016 at 11:50
  • @RonyLoud I found the answer. – user7152572 Commented Dec 13, 2016 at 11:55
Add a ment  | 

1 Answer 1

Reset to default 9

I found the answer by adding below code inside css

div.pac-container {
   z-index: 1050 !important;
}
发布评论

评论列表(0)

  1. 暂无评论