geoserver发布图片(2)

1.新建工作区

2.添加数据源——WorldImage

3.发布图层

4.gridset设置

5.图层中添加gridset设置

6.重点在调用的时候

function initMap() {
	initLayout();
	var mapresolutions = [0.703125, 0.3515625, 0.17578125, 0.087890625, 0.0439453125, 0.02197265625, 
	  					0.010986328125, 0.0054931640625, 0.00274658203125, 0.001373291015625, 6.866455078125E-4, 
	  					3.4332275390625E-4, 1.71661376953125E-4, 8.58306884765625E-5, 4.291534423828125E-5, 
	  					2.1457672119140625E-5, 1.0728836059570312E-5, 5.364418029785156E-6, 2.682209014892578E-6, 
	  					1.341104507446289E-6, 6.705522537231445E-7, 3.3527612686157227E-7
	  				];
	var mapOptions = {
//		resolutions:mapresolutions,
		resolutions :  [4.291534423828125E-5,2.1457672119140625E-5, 1.0728836059570312E-5, 5.364418029785156E-6],
		projection : new OpenLayers.Projection('EPSG:4326'),
		maxExtent : new OpenLayers.Bounds(-180.0, -90.0, 180.0, 90.0),
		units : "degrees",// 单位度
//		numZoomLevels : 15,
		controls : []
	// 清空控件
	};
	map = new OpenLayers.Map('map', mapOptions);
	// 地图控制-导航工具
//	map.addControl(new OpenLayers.Control.PanZoomBar({
//		position : new OpenLayers.Pixel(2, 10)
//	// 导航偏移
//	}));
	// 地图控制-导航控件
	map.addControl(new OpenLayers.Control.Navigation());
	// 地图控制-显示比例尺
	map.addControl(new OpenLayers.Control.Scale($('scale')));
	// 地图控制-鼠标坐标拾取
	map.addControl(new OpenLayers.Control.MousePosition({
		element : $('location')
	}));
	// 开启瓦片缓存服务地址必须加上 /gwc/service
//	weihaiLayer = new OpenLayers.Layer.WMS("test:weihai",
//			"http://172.31.170.98:8088/geoserver/gwc/service/wms", {
//				layers : 'test:weihai',
//				format : 'image/png'
//			}, {
//				tileSize : new OpenLayers.Size(256, 256)
//			});
	weihaiLayer = new OpenLayers.Layer.WMS("test:weihai",
	"http://172.31.170.98:8088/geoserver/gwc/service/wms", {
		layers : 'weidong:weidong',
		format : 'image/png'
	}, {
		tileSize : new OpenLayers.Size(256, 256)
	});
	map.addLayer(weihaiLayer);
//	map.zoomToExtent(new OpenLayers.Bounds(121.95669802850942,
//			37.302124678674154, 122.48995650645256, 37.63463806886632));
	map.zoomToExtent(new OpenLayers.Bounds(121.90369802850942,37.388124678674154,122.48995650645256,37.63463806886632));
	map.zoomTo(1);
}

转载自:https://blog.csdn.net/wd4java/article/details/46550455

You may also like...