forked from marsprj/Map5
-
Notifications
You must be signed in to change notification settings - Fork 0
/
map_close.html
53 lines (46 loc) · 1.69 KB
/
map_close.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="../lib/css/Map5.min.css">
<script type="text/javascript" src="../lib/Map5.min.js"></script>
<style type="text/css">
body{
margin: 0px;
}
</style>
<script type="text/javascript">
// 地图变量
var mapObj = null;
function init(){
// 1、设置地图的范围
var extent = new GeoBeans.Envelope(-180,-90,180,90);
// 2、初始化地图变量,参数分别为:
// 地图的容器为"mapDiv",地图名称"map",地图范围,地图的空间参考,4326为经纬度
mapObj = new GeoBeans.Map("mapDiv","map",extent,4326);
if(mapObj == null){
return;
}
// 3、添加一个图层
// 定义一个QuadServer图层,作为底图,第一个参数为图层名称,第二个参数为QuadServer地址
var layer = new GeoBeans.Layer.QSLayer("base","/QuadServer/maprequest?services=world_vector");
// 4、添加图层
mapObj.addLayer(layer);
// 5、设置中心点和显示级别
var zoom = 2;
var center = new GeoBeans.Geometry.Point(0,0);
var viewer = mapObj.getViewer();
viewer.setZoomCenter(zoom,center);
}
function closeMap(){
// 关闭地图
mapObj.close();
}
</script>
<title>Map5 -- 关闭地图</title>
<body onload="init()">
<div id="mapDiv" style="height:800px;width:100%;position:absolute;top:30px;">
</div>
<button onclick="closeMap()">关闭地图</button>
<button onclick="init()">初始化地图</button>
</body>