0

如何将具有特定投影的简单多边形添加到我的地图?

多边形是有效的,我之前检查过。

coordinatesPolygonInRd = [ [ [173563, 441818], [173063, 441818], [173063, 444318],
      [173563, 444318], [173563, 441818] ] ];

这就是我尝试在将多边形放在地图上之前对其进行转换的方式:

尝试1:

let dutchProjection = new Projection({
  code: 'EPSG:28992',
  extent: [-285401.92, 22598.08, 595402.0, 903402.0],
  worldExtent: [3.2, 50.75, 7.22, 53.7],
  units: 'm'
});
addProjection(dutchProjection);

const geometry = new Polygon( this.coordinatesPolygonInRd).transform( 'EPSG:28992', this.map.getView().getProjection());
this.vectorLayer.getSource().addFeature(new Feature(geometry));

尝试2:

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');
const geometry = new Polygon( this.coordinatesPolygonInRd).transform( 'EPSG:28992', this.map.getView().getProjection());
this.vectorLayer.getSource().addFeature(new Feature(geometry));
4

1 回答 1

1

方法 2 可以,但你的 proj4 语法错误,应该是

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");

您可以在注册 proj4 定义后选择设置投影范围等。

于 2020-11-06T12:07:13.513 回答