Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用Google Places Autocomplete API检索邮政编码和地址_Php_Reactjs_Codeigniter_Google Maps Api 3_Googleplacesautocomplete - Fatal编程技术网

Php 使用Google Places Autocomplete API检索邮政编码和地址

Php 使用Google Places Autocomplete API检索邮政编码和地址,php,reactjs,codeigniter,google-maps-api-3,googleplacesautocomplete,Php,Reactjs,Codeigniter,Google Maps Api 3,Googleplacesautocomplete,我正在使用PlacesAutoCompleteGoogleAPI传递-输入和键。我键入一个地址搜索文本,该文本被发送到API,并返回该文本的所有匹配地址,我从中选择一个。返回的地址没有邮政编码。我怎样才能得到它?我做错了什么请通过添加api密钥来尝试下面的代码它对我来说工作正常 $(document).on('click', "#autocomplete", function () { var currentInp = $(this).attr("id"); va

我正在使用PlacesAutoCompleteGoogleAPI传递-输入和键。我键入一个地址搜索文本,该文本被发送到API,并返回该文本的所有匹配地址,我从中选择一个。返回的地址没有邮政编码。我怎样才能得到它?我做错了什么

请通过添加api密钥来尝试下面的代码它对我来说工作正常

$(document).on('click', "#autocomplete", function () {
        var currentInp = $(this).attr("id");
        var $tabletextbox = $(this);
        var autocomplete = new google.maps.places.Autocomplete(document.getElementById(currentInp));
        autocomplete.addListener('place_changed', function () {
            var place = autocomplete.getPlace();
            if (!place.geometry) {
                // User entered the name of a Place that was not suggested and
                // pressed the Enter key, or the Place Details request failed.
                window.alert("No details available for input: '" + place.name + "'");
                return;
            }
            for (var i = 0; i < place.address_components.length; i++) {
              if(place.address_components[i].types[0] == 'postal_code'){
                alert(place.address_components[i].long_name);
              }
            }
            $('#lat').val(place.geometry.location.lat().toFixed(8));
            $('#lng').val(place.geometry.location.lng().toFixed(8));

        });
    });
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=Your API Key&libraries=places"></script>

你能发布你的代码吗?公共功能建议可能重复{$search=$this->post'search';$arrContextOptions=arrayssl=>array-verify\u-peer=>false,verify\u-peer\u-name=>false,;$url=;$json=file\u-get\u-contents$url,false,stream\u-context\u-create$arrContextOptions;$results=json\u-decode$json;$this->-response['predictions'>$results->]}]谢谢@Ryankozak。我之前检查了该链接,但它与我的代码不兼容。在url中使用types=regions可以解决问题。感谢您的帮助。如果问题重复,请道歉