Geocode失败的原因如下:Google Map Integration中的REQUEST_DENIED

时间:2019-01-18 10:17:22

标签: wordpress google-maps google-api geolocation

我们已经在wordpress网站中集成了google位置地图,但是现在当我加载该页面时,它会显示错误

  

Geocode失败的原因如下:REQUEST_DENIED

当贴图显示褪色的彩色贴图时,仅用于开发目的。 我的代码如下所示。

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"></script>
    <script type="text/javascript">         var geocoder, map;      function mapInit(address) {             geocoder = new google.maps.Geocoder();          var latlng = new google.maps.LatLng(-34.397, 150.644);          var mapOptions = {
                zoom: 8,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP            }           map = new google.maps.Map(document.getElementById('map'), mapOptions);          codeAddress(address);       }       function codeAddress(address) {             geocoder.geocode( { 'address': address}, function(results, status) {
                if (status == google.maps.GeocoderStatus.OK) {
                    map.setCenter(results[0].geometry.location);
                    var marker = new google.maps.Marker({
                        map: map,
                        position: results[0].geometry.location
                    });
                } else {
                    alert("Geocode was not successful for the following reason: " + status);
                }           });         }       $(function(){           mapInit($('.current-contact .address b').html());
                        $('.location').click(function() {
                var $this = $(this),
                    currentAddr = $('.current-contact').html(),
                    nextAddr = $this.html(),
                    address = $this.find('.address b').html();

                codeAddress(address);
                $('.current-contact').html(nextAddr);
                //$this.html(currentAddr);          });         });
    </script>

获得api代码后,需要在此脚本中进行哪些更改?

0 个答案:

没有答案
相关问题