javascript - 谷歌地图在 aspx 页面上显示未定义的谷歌

标签 javascript html asp.net css

当我在简单的 html 文件(元素外 - 本地)上测试它时,它可以工作,但是当我在我的元素中的 aspx 页面上使用此代码时,它找不到“google”。我该如何解决?这是我使用的代码:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Map</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">    html { height: 100% }    body { height: 100%; margin: 0px; 

padding: 0px }    #map_canvas { height: 100% }  </style>

<script type="text/javascript" src="http:\\maps.google.com/maps/api/js?sensor=false">  

</script>

<script type="text/javascript">
    function initialize() {
        var latlng = new google.maps.LatLng(-34.397, 150.644);
        var myOptions = {
            zoom: 8, center: latlng, mapTypeId:

google.maps.MapTypeId.ROADMAP
        };
        var map = new google.maps.Map(document.getElementById("map_canvas"),

myOptions);
    }
   </script>

</head>
<body onload="initialize()">
<div id="map_canvas" style="width: 100%; height: 100%">
</div>
</body>
</html>

最佳答案

在您的脚本标签中将http:\\ 更改为http://

关于javascript - 谷歌地图在 aspx 页面上显示未定义的谷歌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19166573/

相关文章:

javascript - 我们可以计算两个哈希校验和之间的差异吗?

javascript - For循环创建无限对象树

asp.net - 在 ASP.NET 中从数据库自动生成 ID

c# - 将调试器附加到 IIS 实例

javascript - HTML - 如何生成一个带有百分比的进度条圆圈并使用 JS 或 jQuery 设置值?

javascript - 查找一行的第一个和最后一个引号之间的文本

c# - 如何在下拉列表中向用户显示大量数据?

javascript - 下载属性不建议保存对话框中的文件扩展名

javascript - 在 javascript 上生成带有图像的表格

asp.net - 在 ASP.NET Razor 中格式化字符串