【问题标题】:Google Maps not functioning for me谷歌地图对我不起作用
【发布时间】:2009-10-13 23:19:06
【问题描述】:

我的 Google 地图代码全部平方且有效,但无法加载到页面上。这是有问题的页面,我可以完全使用代码,但不确定它为什么会中断:

http://whs.rjuhsd.us/calendar/map

Gmaps JS 在标头中,带有正确的键。传感器设置为 true,并且元素在文档中定义、正确显示、在正确的位置并可供用户使用。

停下来?

【问题讨论】:

  • 是什么让你认为你的代码都是“平方且有效的”?仅加载页面就会出现 10 个 javascript 错误。
  • 您正在编辑实时网站吗?因为,我在任何地方都看不到 Google Maps API 脚本。
  • 非法 - 我的意思是有效,因为它实际上是从 Google API 站点复制/粘贴的,但仍然无法正常工作(由于我现在理解的 jQuery 冲突)

标签: javascript dom google-maps maps


【解决方案1】:

看起来你在 jQuery 和 Prototype 之间有冲突。

使用jQuery的noConflict模式。

PS:你为什么同时使用这两个?

【讨论】:

    【解决方案2】:

    Chetan 是对的,您遇到了 jquery 和 Prototype 之间的冲突。我看到你已经调用了 jquery.noConflict() 一次,但是之后你再次将 jquery 导入到你的文档中,从而撤消了 noConflict:

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js">
    </script>
            ... snip ...
            <!-- following scripts are for the jwPlayer installations oct.09 -->
            <script type="text/javascript" src="/scripts/swfobject.js"></script>
            <script type="text/javascript" src="scripts/jwplaylist/jquery-1.3.2.min.js">
        </script>
    

    您有什么理由不只是更新 swfobject.js 以使用早期版本的 jquery?

    【讨论】:

      【解决方案3】:

      我看到两个指向谷歌地图的链接,但我假设您想在此页面中显示谷歌地图,对吗?

      您的页面上有一个空的 DIV:

      <div id="map_canvas" style="width: 500px; height: 300px;"></div>
      

      也许这是您打算嵌入地图的位置?如果是这样,您可以尝试将其替换为以下内容:

      <div id="map_canvas" style="width: 500px; height: 300px;"><iframe width="500" height="300" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=2551+Woodcreek+Oaks+Blvd.+Roseville,+CA,+95747&amp;sll=37.0625,-95.677068&amp;sspn=41.767874,58.535156&amp;safe=on&amp;ie=UTF8&amp;t=h&amp;hq=&amp;hnear=2551+Woodcreek+Oaks+Blvd,+Roseville,+Placer,+California+95747&amp;ll=38.764056,-121.330884&amp;spn=0.015209,0.020106&amp;z=16&amp;output=embed"></iframe><br /><small><a href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=2551+Woodcreek+Oaks+Blvd.+Roseville,+CA,+95747&amp;sll=37.0625,-95.677068&amp;sspn=41.767874,58.535156&amp;safe=on&amp;ie=UTF8&amp;t=h&amp;hq=&amp;hnear=2551+Woodcreek+Oaks+Blvd,+Roseville,+Placer,+California+95747&amp;ll=38.764056,-121.330884&amp;spn=0.015209,0.020106&amp;z=16" style="color:#0000FF;text-align:left">View Larger Map</a></small></div>
      

      【讨论】:

      • Google Maps API 用地图填充空白 div。包含 IFRAME 反而会失去 API 的许多优势,例如自定义层、标记等。
      • +1 pythonquick,如果提问者只想显示基本地图,嵌入的 iframe 符合要求。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-12
      • 2016-12-17
      • 1970-01-01
      相关资源
      最近更新 更多