Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Openlayers-为视图设置特定投影_Openlayers_Openlayers 6_Angular Openlayers - Fatal编程技术网

Openlayers-为视图设置特定投影

Openlayers-为视图设置特定投影,openlayers,openlayers-6,angular-openlayers,Openlayers,Openlayers 6,Angular Openlayers,如何设置地图的特定投影?我在Angular 10上下文中使用Openlayers 6 地图加载在EPSG:3857中,我想通过投影EPSG:28992使用它 尝试1: 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

如何设置地图的特定投影?我在Angular 10上下文中使用Openlayers 6

地图加载在EPSG:3857中,我想通过投影EPSG:28992使用它

尝试1:

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.040,49.910,465.840,-0.40939,0.35971,-1.86849,4.0772 +units=m +no_defs";
register(proj4)
let dutchProjection = GetProjection('EPSG:28992');

this.map = new Map({
  layers: [
    new Tile({
      source: new XYZ({
        url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/brtachtergrondkaart/EPSG:3857/{z}/{x}/{y}.png',
      })
    }), this.vectorLayer
  ],
  view: new View({
    projection: dutchProjection,
    center: [173563, 441818],
    zoom: 10
  }),
  target: "map"
});
Try-2:

let dutchProjection = new Projection({
  code: "EPSG:28992",
  units: "m",
  extent: [-285401.92, 22598.08, 595401.9199999999, 903401.9199999999]
});

this.map = new Map({
  layers: [
    new Tile({
      source: new XYZ({
        url: 'https://geodata.nationaalgeoregister.nl/tiles/service/wmts/brtachtergrondkaart/EPSG:3857/{z}/{x}/{y}.png',
      })
    }), this.vectorLayer
  ],
  view: new View({
    projection: dutchProjection,
    center: [173563, 441818],
    zoom: 10
  }),
  target: "map"
});

受@Mike答案的启发,此解决方案有效!选项1是正确的,但有一个错误

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.040,49.910,465.840,-0.40939,0.35971,-1.86849,4.0772 +units=m +no_defs");

您是如何使用proj4j的,请出示您的导入内容好吗?另外,您安装了哪些npm软件包?安装了哪些软件包?npm安装项目4;npm安装@types/proj4。使用?看看下面的答案,这就是你所需要的。使用起来很简单,请参见