Google Maps won't work when API key is provided

szymond

I am getting alert saying:

Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#api_key

when using Google Maps with API key.

What I did:

1.Created new API key with setting "Any referer allowed".

2.Deployed on my local webserver Hello World example from documentation:

<!DOCTYPE html>
<html>
  <head>
    <style type="text/css">
      html, body, #map-canvas { height: 100%; margin: 0; padding: 0;}
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=API_KEY">
    </script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions = {
          center: { lat: -34.397, lng: 150.644},
          zoom: 8
        };
        var map = new google.maps.Map(document.getElementById('map-canvas'),
            mapOptions);
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
<div id="map-canvas"></div>
  </body>
</html>

3.Replaced API_KEY with newly generated key.

When I access such page, I am getting the alert. How do I fix it?

szymond

As Dr.Molle said: the problem was with not enabling maps-javascript-API in the console.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Google maps won't load - Android

분류에서Dev

Google Maps doesn't work if device is restarted

분류에서Dev

Google Maps API for Work 고객-API 요청

분류에서Dev

RequestContext won't work

분류에서Dev

Lightbox won't work when my site css page is linked

분류에서Dev

UISwitch doesn't work on Google Maps SDK for iOS?

분류에서Dev

Google Maps REST API

분류에서Dev

Google Maps Directions API

분류에서Dev

Google Maps Autocompletion API

분류에서Dev

AJAXify won't work on phpBB?

분류에서Dev

Program won't work in FireFox

분류에서Dev

Fade in Function Won't Work

분류에서Dev

Getting message on AVD "This app won't work unless you update Google play services"

분류에서Dev

Apigee Edge에서 Google Maps at Work API 용 HMAC 서명 생성

분류에서Dev

Blazor : Google Maps JS API

분류에서Dev

Google Maps API access release

분류에서Dev

Dynamically load Google Maps API

분류에서Dev

Printing and lots of google maps (api)

분류에서Dev

Meteor Google Maps JavaScript API

분류에서Dev

Google Maps API 요청

분류에서Dev

Google Maps stuck on top-left corner - solution for Desktop doesn't work for mobile design

분류에서Dev

Why won't this regexp in htaccess work properly?

분류에서Dev

Alsamixer won't work with bluetooth device

분류에서Dev

Post variables with ajax won't work

분류에서Dev

Simple class won't work in C++

분류에서Dev

Laravel named routes won't work on wampserver

분류에서Dev

Why won't the routing work in this code?

분류에서Dev

Now visudo won't work at all

분류에서Dev

Why won't this MySQL stored procedure work?