2017-11-13 1 views
-1

GoogleマップAPIを使用してアプリケーションを作成しようとしています。私はlocalhost上で、次のコードを実行しているものの、それはコンソールに次のメッセージ私が表示されます。Google APIエラーRefererNotAllowedMapError

"Google Maps API error: RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript/error-messages#referer-not-allowed-map-error 
Your site URL to be authorized: http://localhost:8888/fintechjobs.ie/fintechmap.php" 

<!DOCTYPE html> 
<html> 

<body> 

<div id="map" style="width:100%;height:500px"></div> 

<script> 
function myMap() { 
    var myCenter = new google.maps.LatLng(51.508742,-0.120850); 
    var mapCanvas = document.getElementById("map"); 
    var mapOptions = {center: myCenter, zoom: 5}; 
    var map = new google.maps.Map(mapCanvas, mapOptions); 
    var marker = new google.maps.Marker({position:myCenter}); 
    marker.setMap(map); 
} 
</script> 

<script src="https://maps.googleapis.com/maps/api/js?key=xxxxxxxxxxxxxxxx&callback=myMap"></script> 


</body> 
</html> 

を誰かがこのエラーがどこから来ているに導くことはできますか? ありがとうございました!

答えて

0

あなたのAPIのGoogleマップインターフェース内のURLを許可する必要があります:ハンバーガーのhttps://console.cloud.google.com/apis/dashboard

クリックして、「APIとサービス」を選択し、次に左。

次に、左側のパネルの[認証情報]セクションをクリックし、Google Map APIをクリックします。次に、apiセクションのキーの下にurl(localhost)を入力します。 ポートを入力することを忘れないでください。

+0

私はそれが識別子の代わりに**クレデンシャル**だと思います。 –

+0

ディープ3015ありがとうございました。私の答えを訂正しました。 –

+0

お手伝いいただきありがとうございます –

関連する問題