Reputation: 31
I need your help please. I want to integrate a Google Map with javascript-api.
I do not know what I'm doing wrong. Google JavaScript API is enabled. My Domain is confirmed. In key=YOUR_API_KEY
, i have entered my API-KEY.
The Google code example below of the "Simple Map" creates a blank page. No error message is displayed console screenshot
It seems like the script is loaded, but the map will not be displayed.
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#map {
height: 100%;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
async defer></script>
</body>
</html>
View this example page on my site map.html
Maybe someone can help me.
Thank You, Chris
Upvotes: 1
Views: 8314
Reputation: 148
In my case, just need to give the height attribute and value (exactly value: like 200px) on the
<div id="map"></div>
Like above @NeuTronas said, it solve my problem.
I also find out the official document instruction
Hope this can help you.
Upvotes: 0
Reputation: 16
First of all sorry for my maybe bad English.
I've had the same problem and found the following answers (In my case the first answer was the correct one):
Source: developers.google.com
If you have the same answer, you can signup with a credit card here: console.cloud.google.com
Upvotes: 0
Reputation: 273
You are getting "RefererNotAllowedMapError" error from Google script. This means your URL was not successfully added to refferers list. Check if you added. At least on your example page. Try clearing cache or use Incognito window to make sure you are not getting any errors.
EDIT: Also make sure you set height to your map div! (it is set to 0 by default!)
Upvotes: 2
Reputation: 109
Log in to https://console.developers.google.com using your account that consist of google maps api then
Upvotes: 2