Demo entry 6642827

java

   

Submitted by anonymous on Sep 26, 2017 at 03:19
Language: HTML. Code size: 1.6 kB.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>访问Geoserver发布的地图</title>

<script type='text/javascript' src='./OpenLayers.js'></script>
</head>
<body>
    
	<div style="position: absolute; top: 50px; left: 80px; width: 300px; height: 100px;">  
        <div id='map_element' style='width:1200px;height:500px;'></div>    
    </div> 
	
	<script type="text/javascript">
		var map;

		function init(){
			//定义地图边界  
            var bounds= new OpenLayers.Bounds(109.624691, 20.061808,  
             117.354358, 25.519619);

            var options = {  
                projection: "EPSG:4326",                  
                center: new OpenLayers.LonLat(113.3, 23.2),               
            }; 

            map = new OpenLayers.Map('map_element',options);

            var wms = new OpenLayers.Layer.WMS("OpenLayers WMS",  
                //geoserver所在服务器地址  
                "http://192.168.1.102:8980/geoserver/ltemr_gd/wms",   
                {  
                    layers: "ltemr_gd:shijie_region"  
                });  
            //添加wms图层  
            map.addLayer(wms);

            //添加control空间  
            map.addControl(new OpenLayers.Control.LayerSwitcher());  
            map.addControl(new OpenLayers.Control.MousePosition());  
            map.addControl(new OpenLayers.Control.ScaleLine());  
            map.addControl(new OpenLayers.Control.Scale);             
                                      
            map.zoomToMaxExtent(bounds); 
		}

		init();
	</script>
</body>
</html>

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).