-1

如果服务器不是 Geoserver,如何显示 WMS 图层。

此链接中的此 WMS URL 示例。

4

2 回答 2

3

**您可以使用 ARCGIS Url 显示该 Url 的 Tile 图层 **

开放层 4.5

  var layers = [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    }),
    new ol.layer.Tile({
      extent: [-13884991, 2870341, -7455066, 6338219],
      source: new ol.source.TileArcGISRest({
        url: https://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StateCityHighway_USA/MapServer
      })
    })
  ];
于 2019-01-29T10:59:23.497 回答
0

根据您的问题,这是您的 WMS 链接@antochoy:

http://portal.ina-sdi.or.id/arcgis/services/IGD/RupabumiIndonesia/MapServer/WMSServer?request=GetCapabilities&service=WMS

对于地图部分,试试这个(它有效,我只包含了你的名为“2”的图层):

var layers = [
  new ol.layer.Tile({
    source: new ol.source.OSM()
  }),
  new ol.layer.Tile({
    extent: [94.972663,-11.007615,141.029973,6.076940],
    source: new ol.source.TileWMS({
      url: 'http://portal.ina-sdi.or.id/arcgis/services/IGD/RupabumiIndonesia/MapServer/WMSServer',
      params: {'LAYERS': '2', 'TILED': true},
      projection: 'EPSG:4326'
    })
  })
];
var map = new ol.Map({
  layers: layers,
  target: 'map',
  view: new ol.View({
    center: [106,0],
    zoom: 6,
    projection: 'EPSG:4326'
  })
});
于 2019-01-30T19:45:45.677 回答