Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details.
i don't know why .
<!DOCTYPE html>
<html>
<head>
<script src="">
</script>
<script>
var myCenter = new google.maps.LatLng(30.023354, 31.477439);
function initialize() {
var mapProp = {
center: myCenter,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
var marker = new google.maps.Marker({
position: myCenter,
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details.
i don't know why .
<!DOCTYPE html>
<html>
<head>
<script src="http://maps.googleapis./maps/api/js">
</script>
<script>
var myCenter = new google.maps.LatLng(30.023354, 31.477439);
function initialize() {
var mapProp = {
center: myCenter,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("googleMap"), mapProp);
var marker = new google.maps.Marker({
position: myCenter,
});
marker.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="googleMap" style="width:500px;height:380px;"></div>
</body>
</html>
Share
Improve this question
asked Aug 16, 2016 at 10:07
hashimhashim
691 silver badge14 bronze badges
3
- So... "something" went wrong, what's "something"? what's the expected behaviour, what's actually happening, what does your console say? – Jeremy Thille Commented Aug 16, 2016 at 10:12
- Did you see the JavaScript console for technical details? – JJJ Commented Aug 16, 2016 at 10:13
- Possible duplicate of ERROR: Google Maps API error: MissingKeyMapError – Joyson Commented Aug 16, 2016 at 11:17
2 Answers
Reset to default 4You need generate special api key for google maps
your
<script src="http://maps.googleapis./maps/api/js">
should looks like this
<script src="https://maps.googleapis./maps/api/js?key=your_key">></script
Go to https://console.developers.google. to get a free key.
Here’s how to fix the error.
Go to https://console.developers.google./apis/credentials Click your API key’s name to edit its settings. Under Application restrictions, choose “HTTP referrers (web sites)” then add the two entries below (replacing yourname. with your own domain).
Type the first entry then hit enter on your keyboard to add it. Repeat to add the second entry.
Having both entries (with asterisks) will help ensure your maps work on any URL of your website. yourname./* *.yourname./*Google Maps API Restrictions
Click the Save button then wait a few minutes for the change to take effect (Google says it can take up to 5 minutes).
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745142946a4613512.html
评论列表(0条)