简体   繁体   中英

This page didn't load Google Maps correctly. See the JavaScript console for technical details

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.com/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>

You need generate special api key for google maps

your <script src="http://maps.googleapis.com/maps/api/js"> should looks like this

  <script src="https://maps.googleapis.com/maps/api/js?key=your_key">></script

Go to https://console.developers.google.com to get a free key.

Here's how to fix the error.

Go to https://console.developers.google.com/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.com 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.com/* *.yourname.com/*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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM