Google Maps API GeoCoder未返回坐标

时间:2017-09-26 20:55:14

标签: c# asp.net google-maps google-geocoder

在尝试将已发布的示例应用于我的代码时,我收到以下参考错误消息' results&#39 ;: ReferenceError:结果未定义

这是我遇到错误的代码,其中调用了geocoder.geocode的行:

            function GamesCloseBy() {

            var myResult;
            var addressText = $('#<%= UserAddress.ClientID %>').val();
            geocoder = new google.maps.Geocoder();

            geocoder.geocode({ 'address': addressText }, async function (results, status) {
                if (status === 'OK') {
                    alert("coordinates = " + await results[0].geometry.location);
                    myResult = await results[0].geometry.location;
                } else {
                    alert('Geocode was not successful for the following reason: ' + status);
                }
            });
            :
            :
       }

我的值为#34;&#34;用于status,以及addressText的有效地址文本。知道我做错了吗?

谢谢

添加说明:

看来我的回调函数,函数(结果,状态)实际上并未被调用。为了调用该函数,我需要做什么?

我的控制台不断发出:ReferenceError:未定义jQuery但是,在我的.aspx文件中:<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&libraries=geometry"></script>

0 个答案:

没有答案