加入以下代码拓展一下Cesium.GeoJsonDataSource.crsNames即可
来源:https://github.com/hslayers/hslayers-ng/blob/efa5df4ddaf0860cef106b8383cd7f18d8ec5c30/components/hscesium/hscesium-layers.service.ts
// 解决"RuntimeError", message: "Unknown crs name: urn:ogc:def:crs:EPSG::3857"
import {default as proj4} from 'proj4';
Cesium.GeoJsonDataSource.crsNames[
"urn:ogc:def:crs:EPSG::3857"
] = Cesium.GeoJsonDataSource.crsNames["EPSG:3857"] = function(
coordinates
) {
const firstProjection =
'PROJCS["WGS 84 / Pseudo-Mercator",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Mercator_1SP"],PARAMETER["central_meridian",0],PARAMETER["scale_factor",1],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["X",EAST],AXIS["Y",NORTH],EXTENSION["PROJ4","+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"],AUTHORITY["EPSG","3857"]]';
const secondProjection =
'GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]]';
const xa = coordinates[0];
const ya = coordinates[1];
const newCoordinates = proj4(
firstProjection,
secondProjection,
[xa, ya]
);
return Cesium.Cartesian3.fromDegrees(
newCoordinates[0],
newCoordinates[1],
0
);
};