jsp调用geoserver图层,总结的最精简代码

<script src=”lib/OpenLayers.js”></script>

<script defer=”defer”  type=”text/javascript”>
function init(){
    var map = new OpenLayers.Map(‘map’, {controls:[], ‘projection’: ‘EPSG:4326’,
‘units’:’degrees’}); 
 var bounds = new OpenLayers.Bounds
(123.010546085,41.459407,123.81122292,42.190515);
 var tiled = new OpenLayers.Layer.WMS(
            “基层——边界”, “http://192.168.132.88:8080/geoserver163/wms“,
            {
              height: ‘700’,
              width: ‘800’,

     layers: ‘ topp:railway_polyline  ‘,
    
              styles: ‘line’,
              srs: ‘EPSG:4326’,
              format: ‘image/gif’, tiled: ‘true’, tilesOrigin : “123.010546085,41.459407”
            },
            {maxExtent: bounds, maxResolution: 6.49429687499814E-3, projection: “EPSG:4326”,
buffer: 0}
          );

          map.addLayer(tiled);
          map.zoomToExtent(bounds);//地图坐标范围     
}
</script>
<body bgcolor=”#F0F8FF” onload=”init();”>

<div id=”map”/>

</body>

转载自:https://blog.csdn.net/cyw8998/article/details/3867943

You may also like...