Google maps api 3 如何在Bootstrap modals上放置Google Map Places搜索框

Google maps api 3 如何在Bootstrap modals上放置Google Map Places搜索框,google-maps-api-3,bootstrap-modal,Google Maps Api 3,Bootstrap Modal,我现在正试图在我的网页上添加一个Google Map Places搜索框。我想把它添加到引导模态中。我已成功添加该框;但是,搜索结果隐藏在模式下,如下图所示。我不知道怎么解决这个问题。谁能给我一些建议吗?谢谢 下面是我如何使用javaScript添加搜索框: function searchBoxInit(){ var input = /** @type {HTMLInputElement} */(document.getElementById('pac-input'));

我现在正试图在我的网页上添加一个Google Map Places搜索框。我想把它添加到引导模态中。我已成功添加该框;但是,搜索结果隐藏在模式下,如下图所示。我不知道怎么解决这个问题。谁能给我一些建议吗?谢谢

下面是我如何使用javaScript添加搜索框:

function searchBoxInit(){
        var input = /** @type {HTMLInputElement} */(document.getElementById('pac-input'));
        //map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
        var searchBox = new google.maps.places.SearchBox(/** @type {HTMLInputElement} */(input));
        google.maps.event.addListener(searchBox, 'places_changed', function() {
            var places = searchBox.getPlaces();
            if (places.length == 0) {
                return;
            }
            place = places[0];
            newpName = place.name;
            newpLat = place.geometry.location.lat();
            newpLong = place.geometry.location.lng();
        });     
    }

function displaySearchEngine(){
        var objElement = document.getElementById('pac-input');
        searchBoxInit();
        objElement.style.display = 'block';
        objElement.style.visibility = 'visible';
}
引导

位置搜索框
在css中添加此样式

.pac-container {
    background-color: #FFF;
    z-index: 20;
    position: fixed;
    display: inline-block;
    float: left;
}

原始响应:

我建议为其他人粘贴一个JSFIDLE链接,以帮助您进行测试。您必须更改搜索结果的z-index属性。你能把你的全部内容粘贴到JSFIDLE上吗?这样我就可以给你看了。谢谢你的帮助!我发现了问题并解决了。modal的默认z-index为1040,搜索结果列表pac-container的默认z-index为1000。将pac容器的z索引更改为1050将有效!