change image layer

This commit is contained in:
baol 2023-10-23 16:52:35 +08:00
parent 5f19682bab
commit f5d34207d5
2 changed files with 47 additions and 3 deletions

View File

@ -4,7 +4,7 @@ import { WebMapServiceImageryProvider } from "cesium";
const url = "http://analysis.tpdc.ac.cn/gs/geoserver/phitrellis/wms"; const url = "http://analysis.tpdc.ac.cn/gs/geoserver/phitrellis/wms";
const name1 = "phitrellis:4_1_sst_JJA_G_dif"; const name1 = "phitrellis:4_1_sst_JJA_L";
const name2 = "phitrellis:4_1_ts_tp_dif_mask"; const name2 = "phitrellis:4_1_ts_tp_dif_mask";
function JJAImageLayer() { function JJAImageLayer() {

View File

@ -1,11 +1,51 @@
import { Entity, PointGraphics, Viewer } from "resium"; import { useMemo } from "react";
import { Cartesian3, Color } from "cesium"; import { Entity, PointGraphics, Viewer, ImageryLayer } from "resium";
import {
Cartesian3,
Color,
UrlTemplateImageryProvider,
WebMercatorTilingScheme,
} from "cesium";
import Picker from "./Picker"; import Picker from "./Picker";
import HeadingPitchRoll from "./HeadingPitchRoll"; import HeadingPitchRoll from "./HeadingPitchRoll";
import CustomToolbar from "@/components/common/CustomToolbar"; import CustomToolbar from "@/components/common/CustomToolbar";
import styles from "./index.module.less"; import styles from "./index.module.less";
const token = "41222ba4e90e51b5c90d08c329a55faa";
const tdtUrl = "https://t{s}.tianditu.gov.cn/";
const subdomains = ["0", "1", "2", "3", "4", "5", "6", "7"];
function MapLayout({ children, className, ...rest }) { function MapLayout({ children, className, ...rest }) {
const imageryProvider = useMemo(
() =>
new UrlTemplateImageryProvider({
url: tdtUrl + "DataServer?T=img_w&x={x}&y={y}&l={z}&tk=" + token,
subdomains: subdomains,
tilingScheme: new WebMercatorTilingScheme(),
maximumLevel: 18,
}),
[]
);
const labelImageryProvider = useMemo(
() =>
new UrlTemplateImageryProvider({
url: tdtUrl + "DataServer?T=cia_w&x={x}&y={y}&l={z}&tk=" + token,
subdomains: subdomains,
maximumLevel: 18,
}),
[]
);
const boundaryImageryProvider = useMemo(
() =>
new UrlTemplateImageryProvider({
url: tdtUrl + "DataServer?T=ibo_w&x={x}&y={y}&l={z}&tk=" + token,
subdomains: subdomains,
maximumLevel: 18,
}),
[]
);
return ( return (
<Viewer <Viewer
className={`${styles.cesiumContainer} ${className}`} className={`${styles.cesiumContainer} ${className}`}
@ -21,7 +61,11 @@ function MapLayout({ children, className, ...rest }) {
baseLayerPicker={false} baseLayerPicker={false}
animation={false} animation={false}
selectionIndicator={false} selectionIndicator={false}
imageryProvider={false}
> >
<ImageryLayer imageryProvider={imageryProvider} />
<ImageryLayer imageryProvider={labelImageryProvider} />
<ImageryLayer imageryProvider={boundaryImageryProvider} />
<Entity position={Cartesian3.fromDegreesArray([0, 90])}> <Entity position={Cartesian3.fromDegreesArray([0, 90])}>
<PointGraphics color={Color.SKYBLUE} pixelSize={10} /> <PointGraphics color={Color.SKYBLUE} pixelSize={10} />
</Entity> </Entity>