Google Places Autocomplete plugin isnt working in Firefox android

╄→尐↘猪︶ㄣ 提交于 2019-12-04 10:28:42

A work around for the second issue is to give the first autocomplete suggestion a top margin so the user can click it. Its not pretty but its functional.

css

.FirefoxAndroid .pac-container .pac-item:first-child { 
    margin-top: 20px;
}

js

<script> 
    var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;     
    var is_android = navigator.userAgent.toLowerCase().indexOf('android') > -1; 

    if(is_firefox && is_android){ 
        $('html').addClass('FirefoxAndroid');
    }
</script>
Marcel Powolny

I encountered the same issue today - the website I am working on is working perfectly on every web browser, the auto-complete as well except on FF mobile.

After trying 3-4 solutions the one that worked for me was to declare the var place at the top of my code.

I have something like that

var autocomplete;
var place;
var input = document.getElementById('location');
var options = {
    componentRestrictions: {'country':'be'},
    types: ['(regions)'] // (cities)
};

autocomplete = new google.maps.places.Autocomplete(input,options);
google.maps.event.addListener(autocomplete, 'place_changed', function () {
    place = autocomplete.getPlace();
    ...
}

It was not working only on FF mobile because I wasn't declaring place at the top.

Maybe it will help someone in the future who knows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!