Openlayers - 为视图设置特定投影
Openlayers - set specific projection for View
如何为地图设置特定的投影?我在 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"
});
尝试 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");
如何为地图设置特定的投影?我在 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"
});
尝试 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");