Firefox浏览器不支持谷歌自动完成功能

时间:2017-06-22 05:03:33

标签: javascript google-maps firefox google-places-api google-places

最近,当我在不同的浏览器上测试我的网站时,我偶然发现了谷歌位置服务api问题。这实际上是当我开始输入输入时,即在Firefox浏览器上没有任何建议显示,直到我按 spac e或 fullstop“。”请查看并测试样本{{ 3}}

HTML

<input type="text" class="form-control input-lg" placeholder="City" id="autocomplete"  gm-places-autocomplete ng-model="cityName">

的javascript

$scope.lat = undefined;
$scope.lng = undefined;
$scope.$on('gmPlacesAutocomplete::placeChanged', function(){
      var location = $scope.cityName.getPlace().geometry.location;
      $scope.lat = location.lat();
      $scope.lng = location.lng();
      $scope.city = $scope.cityName.getPlace().name;
      $scope.place = $scope.cityName.getPlace();
      $scope.$apply();
      var componentForm = {
            locality: 'long_name',
            administrative_area_level_1: 'long_name',
            country: 'long_name'
        };

        var addCity, addProvince, addCountry;
        for (var i = 0; i < $scope.place.address_components.length; i++) {
            var addressType = $scope.place.address_components[i].types[0];
            if (componentForm[addressType]) {
            var val = $scope.place.address_components[i][componentForm[addressType]];
                if(addressType == 'locality')                    
                    {
                        $scope.newcity = addCity = val;
                    }
                if(addressType == 'administrative_area_level_1') 
                    {
                       $scope.newstate = $scope.stateName = addProvince = val;
                    }
                if(addressType == 'country')                     
                    {
                       $scope.newcountry = addCountry = val;
                    }
            }
        }
});

0 个答案:

没有答案