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

时间:2013-10-03 18:31:11

标签: 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>

1 个答案:

答案 0 :(得分:1)

将脚本代码中的http:\\更改为http://