本文介绍了谷歌地图API示例不起作用,给我空白屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Maps API教程()给我一个空白屏幕。我一直在为此工作3个小时,但无法弄清楚。

我甚至完全复制/粘贴了代码,它保存为.html文件。

 <!DOCTYPE html> 
< html>
< head>
< style>
#map_canvas {
height:500px;
width:400px;
}
< / style>
< script src =http://maps.googleapis.com/maps/api/js?sensor=false>< / script>
< script>
函数initialize(){
var map_canvas = document.getElementById('map_canvas');
var map_options = {
center:new google.maps.LatLng(44.5403,-78.5463),
zoom:8,
mapTypeId:google.maps.MapTypeId.ROADMAP

var map = new google.maps.Map(map_canvas,map_options)
}
google.maps.event.addDomListener(window,'load',initialize);
< / script>
< / head>

< body>
< div id =map_canvas>< / div>
< / body>
< / html>


解决方案

您的代码中包含非法字符:

 时间戳:08/12/2013 02:08:39 PM 
错误:非法字符
行:21,列:48
源代码:
google.maps.event.addDomListener(window,$(B!F(Bload $(B!G(B,initialize);
 $ b 

更改:

  google.maps .event.addDomListener(window,'load',initialize); 

收件人:

  google.maps.event.addDomListener(window,load,initialize); 


The Google Maps API tutorial (https://developers.google.com/maps/tutorials/fundamentals/adding-a-google-map) is giving me a blank screen. I have been working on this for 3 hours and cannot figure it out.

I even copied/pasted the code exactly, it is saved as an .html file.

<!DOCTYPE html>
<html>
  <head>
    <style>
      #map_canvas{
        height: 500px;
        width: 400px;
      }
    </style>
    <script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
    <script>
      function initialize() {
        var map_canvas = document.getElementById('map_canvas');
        var map_options = {
          center: new google.maps.LatLng(44.5403, -78.5463),
          zoom: 8,
          mapTypeId: google.maps.MapTypeId.ROADMAP
        }
        var map = new google.maps.Map(map_canvas, map_options)
      }
       google.maps.event.addDomListener(window, ‘load’, initialize);
    </script>
  </head>

  <body>
    <div id="map_canvas"></div>
  </body>
</html>
解决方案

You have illegal characters in your code:

Timestamp: 08/12/2013 02:08:39 PM
Error: illegal character
Line: 21, Column: 48
Source Code:
   google.maps.event.addDomListener(window, $(B!F(Bload$(B!G(B, initialize);

Change:

 google.maps.event.addDomListener(window, ‘load’, initialize);

To:

 google.maps.event.addDomListener(window, "load", initialize);

这篇关于谷歌地图API示例不起作用,给我空白屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 20:52