Openlayers 如何显示WMS图层。如果服务器不是地理服务器

Openlayers 如何显示WMS图层。如果服务器不是地理服务器,openlayers,arcgis,geoserver,Openlayers,Arcgis,Geoserver,如果服务器不是Geoserver,如何显示WMS图层 示例此WMS URL来自。**您可以使用ARCGIS URL显示该URL的平铺层** Openlayers 4.5 根据您的问题,这是您的WMS链接@antochoy: 对于地图部分,请尝试此操作。我仅包括名为2的图层: var layers = [ new ol.layer.Tile({ source: new ol.source.OSM() }), new ol.layer.Tile({ extent: [94

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


示例此WMS URL来自。

**您可以使用ARCGIS URL显示该URL的平铺层**

Openlayers 4.5


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

对于地图部分,请尝试此操作。我仅包括名为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'
  })
});

您好@antochoy这里有关于使用MapServer将OpenLayers连接到MapServer的信息。GeoServer更易于处理。MapServer提供了更多的可能性,但需要您编写一些代码。
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'
  })
});