我按照HTML中的Javascript调用方式,加入到aspx页面中,可是打开后,不显示地图,HTML如下:
<!DOCTYPE HTML>
<html>
<head>
<meta name=”viewport” content=”initial-scale=1.0,user-scalable=no”>
<meta http-equiv=”Content-Type” content=”text/html;charset=utf-8″>
<title>Hello,world</title>
<style type=”text/css”>
html{height:100%}
ody{height:100%;margin:0px;padding:0px}
#container{height:100%}
</style>
<script type=”text/javascript”
src=”http://webapi.amap.com/maps?v=1.3&key=yourkey”>
</script>
<script type=”text/javascript”>
function initialize(){
var position=new AMap.LngLat(116.397428,39.90923);
var mapObj=new AMap.Map(“container”,{
view: new AMap.View2D({//创建地图二维视口
center:position,//创建中心点坐标
zoom:14, //设置地图缩放级别
rotation:0 //设置地图旋转角度
}),
lang:”zh_cn”//设置地图语言类型,默认:中文简体
});//创建地图实例
}
</script>
</head>
<body onload=”initialize()”>
<div id=”container”></div>
</body>
</html>
我的aspx页面如下:
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”HomePage.aspx.cs” Inherits=”HomePage” %>
<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head runat=”server”>
<meta http-equiv=”Content-Type” content=”text/html;charset=utf-8″/>
<title>首页</title>
<style type=”text/css”>
html{height:100%}
body{height:100%;margin:0px;padding:0px}
#map{height:100%}
</style>
<script type=”text/javascript”src=”http://webapi.amap.com/maps?v=1.3&key=yourkey”></script>
<script type=”text/javascript”>
function abc() {
var position = new AMap.LngLat(116.397428, 39.90923);
var mapObj = new AMap.Map(“map”, {
view: new AMap.View2D({//创建地图二维视口
center: position,//创建中心点坐标
zoom: 14, //设置地图缩放级别
rotation: 0 //设置地图旋转角度
}),
lang: “zh_cn”//设置地图语言类型,默认:中文简体
});//创建地图实例
}
</script>
</head>
<body onload=”abc()”>
<form id=”form1″ runat=”server”>
<div>
<div id=”map”></div>
</div>
</form>
</body>
</html>