Геокод не был успешным по следующей причине: REQUEST_DENIED в Google Map Integration - PullRequest
0 голосов
/ 18 января 2019

Мы интегрировали карту местоположения Google в наш веб-сайт WordPress, но теперь, когда я загружаю эту страницу, она показывает ошибку

Геокод не был успешным по следующей причине: 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, какие изменения мне нужно внести в этот скрипт?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...