读书笔记一,openlayer创建地图

步骤:

1.Including the OpenLayers library files

‹ 2.Creating an HTML element that the map will appear in
3.‹ Creating a map object from the Map class
4.‹ Creating a layer object from a Layer class
5.‹ Adding the layer to the map

6.‹ Defining the map's extent (setting the area the map will initially be displaying)


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>创建电子地图</title>
<!-- 导入OpenLayers.js -->
<script type="text/javascript" src="scripts/OpenLayers.js"></script>
<script type="text/javascript">
	function init(){
		//创建一个map对象
		//参数1 : div  id
		//参数2 : options json类型
		var map = new OpenLayers.Map("map1",{});
		//创建一个Layer(图层)对象
		var wms = new OpenLayers.Layer.WMS(
				//WMS : Web Map Service
			"OpenLayers WMS",
			"http://vmap0.tiles.osgeo.org/wms/vmap0",
			{layers:"basic"},
			{}
		);
		//把Layer添加到map中
		map.addLayer(wms);
		if(!map.getCenter()){
			//定义地图的缩放级别
			map.zoomToMaxExtent();
		}
	}
</script>
</head>
<body οnlοad="init()">
	<!-- 为地图显示创建一个html元素 -->
	<div id="map1" style="width:500px;height:500px;"></div>

</body>
</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值