0

Создаю ключ API:

введите сюда описание изображения

В .html подключаю карту:

...
<div id="map"></div>
...
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDxRDQAmC7mMPkkP0S9mlbbbYZEhKTZpF0&callback=initMap"
        async defer></script>
...

В js инициализирую:

   var map;
    function initMap() {
      map = new google.maps.Map(document.getElementById('map'), {
        center: {lat: -34.397, lng: 150.644},
        zoom: 8
      });
    }

Но карта не отображается и выдает то такую ошибку:

Google Maps API error: ApiNotActivatedMapError ...

То такую:

Uncaught

Gc {message: "initMap is not a function", name: "InvalidValueError", stack: "Error↵ at new Gc (https://maps.googleapis.com/m…AIzaSyDxRDQAmC7mMPkkP0S9mlbbbYZEhKTZpF0&callback=initMap:137:73"}

Вопрос: Как правильно подключать google карту (то ли ключ не правильно создаю)?

Есть ли способ подключения google карты без ключа?

1 ответ 1

1

Помогла вставка libraries=places :

<script src="https://maps.googleapis.com/maps/api/js?libraries=places&key=MyKey"></script>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.