首页/GIS/列表

openlayer3加载Arcgis WMS服务与Supermap WMS服务加载参数设置不同地方

来源:  2018-04-19 09:44:54    评论:0点击:

var layer = new ol.layer.Tile({  
      name:"sd",  
      source: new ol.source.TileWMS({  
          url: baseWMS,  
          params: {'layers': '0','CRS':'CRS:84','STYLES':'',  
              'BBOX':'84.5,18.16,144.77 ,53.56',  
              'EXCEPTIONS':'XML','FORMAT':'image/png'  
          }  
      })  
  });   
 layers与styles要一一对应。当layers有多个参数需要用“,”隔开,例如:'layers': '0,1,2' 对应的'STYLES':',,'。  
 
 不同之处当:在使用Arcgis wms服务layers只有一个图层时候styles引号中间需要空格:
 
 layers': '0','STYLES':' ',SuperMap可以不需要中间的逗号隔开

以下是超图实际加载的例子:

<!doctype html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="https://openlayers.org/en/v4.6.5/css/ol.css" type="text/css">
    <style>
      .map {
        height: 400px;
        width: 100%;
      }
    </style>
    <script src="https://openlayers.org/en/v4.6.5/build/ol.js" type="text/javascript"></script>
    <title>OpenLayers example</title>
  </head>
  <body>
    <h2>My Map</h2>
    <div id="map" class="map"></div>
    <script type="text/javascript">
    var layers = [  
          
          new ol.layer.Tile({  
              //extent: [117.909832, 24.427347, 118.346327, 24.792678],  
              source: new ol.source.TileWMS({  
 
                  url: 'http://172.19.36.119:8090/iserver/services/map-china400/wms111/China_4326',  
                  params: { 'LAYERS': '0', 'singleTile': true }  
                   
              })  
          })  
        ];  
        var map = new ol.Map({  
            layers: layers,  
            target: 'map',  
            view: new ol.View({  
                center: [118, 24.5],  
                zoom: 12,  
                projection: "EPSG:4326"  
            })  
        });     
    </script>
  </body>
</html>
为您推荐

友情链接 |九搜汽车网 |手机ok生活信息网|ok生活信息网|ok微生活
 Powered by www.360SDN.COM   京ICP备11022651号-4 © 2012-2016 版权