使用 openlayers3 创建 EPSG:28992 地图

creating an EPSG:28992 map using openlayers3

我正在尝试使用 eps:28992 设置中的自定义 wmts 图层创建 openlayers3 地图。我以前用过openlayers 2,但是我没有成功。

我试过将 eps 层添加到项目中,但是它似乎没有做任何事情,出现错误:Uncaught TypeError: Cannot read 属性 '0' of null。 并且请求了 none 个图块。

var projection = ol.proj.get('EPSG:28992');
var projectionExtent = projection.getExtent();
var resolutions = [3440.640, 1720.320, 860.160, 430.080, 215.040, 107.520, 53.760, 26.880, 13.440, 6.720, 3.360, 1.680, 0.840, 0.420, 0.210];
var matrixIds = new Array(26);
   for (var i=0; i<26; ++i) {
    matrixIds[i] = "EPSG:28992:" + i;
}

var attribution = new ol.Attribution({
  html: 'Tiles &copy; <a href="http://services.arcgisonline.com/arcgis/rest/' +
      'services/Demographics/USA_Population_Density/MapServer/">ArcGIS</a>'
});

lonlat = result.center.split(',');


var map = new ol.Map({


    view: new ol.View({
        center: [lonlat[0],lonlat[1]],
        zoom: result.zoom
    }),

    layers: [
         new ol.layer.Tile({
          opacity: 0.7,
          source: new ol.source.WMTS({
            attributions: [attribution],
            url: "http://geodata.nationaalgeoregister.nl/wmts/",
            name: "Basis Registratie Topografie",
            layer: "brtachtergrondkaart",
            matrixSet: "EPSG:28992",
            format: 'image/png',
            projection: projection,
            tileGrid: new ol.tilegrid.WMTS({
              origin: ol.extent.getTopLeft(projectionExtent),
              resolutions: resolutions,
              matrixIds: matrixIds
            }),
            style: 'default'
          })
        })
    ],
    target: target
});

分辨率 en matrixIds 在 openlayers2 中有效,所以我直接复制了它们,我想我遗漏了一些非常小的东西,有人知道吗?

p.s。我使用以下行将 epsg:28992 添加到 proj4.js:

proj4.defs("EPSG:28992","+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.417,50.3319,465.552,-0.398957,0.343988,-1.8774,4.0725 +units=m +no_defs");

问候卡斯帕

这里的问题是 ol.proj.Projection#getExtent() 将 return null 用于从 Proj4js 配置的投影。您的地图不需要 Proj4js 即可工作,但您需要瓷砖网格的正确原点。配置 WMTS 层的最简单方法是请求功能 (http://geodata.nationaalgeoregister.nl/wmts/?request=GetCapabilities) 并使用 ol.format.WMTSCapabilitiesol.source.WMTS.optionsFromCapabilitiesol.source.WMTS 实例创建选项。但您也可以手动配置图层。查看 GetCapabilities 响应,我发现正确的来源是 [-285401.92 903402.0].