my-openlayer 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -17,6 +17,10 @@ export default class MapBaseLayers {
|
|
|
17
17
|
static addAnnotationLayer(map: Map, options: AnnotationLayerOptions): TileLayer<XYZ>;
|
|
18
18
|
addMapLayer(): void;
|
|
19
19
|
createLayer(layer: any): any;
|
|
20
|
+
addGeoServerLayer(url: string, layer: string, options: {
|
|
21
|
+
zIndex?: number;
|
|
22
|
+
visible?: boolean;
|
|
23
|
+
}): string;
|
|
20
24
|
static getTiandiTuLayer(options: {
|
|
21
25
|
type: TiandituType;
|
|
22
26
|
token: string;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Tile as TileLayer } from "ol/layer";
|
|
5
5
|
import { get as getProjection } from "ol/proj";
|
|
6
6
|
import { getTopLeft, getWidth } from "ol/extent";
|
|
7
|
-
|
|
7
|
+
import { TileWMS } from "ol/source";
|
|
8
8
|
import WMTSTileGrid from "ol/tilegrid/WMTS";
|
|
9
9
|
import XYZ from "ol/source/XYZ";
|
|
10
10
|
import MapTools from "./MapTools";
|
|
@@ -108,6 +108,24 @@ export default class MapBaseLayers {
|
|
|
108
108
|
}
|
|
109
109
|
return layer;
|
|
110
110
|
}
|
|
111
|
+
addGeoServerLayer(url, layer, options) {
|
|
112
|
+
const wmsLayer = new TileLayer({
|
|
113
|
+
source: new TileWMS({
|
|
114
|
+
url: url,
|
|
115
|
+
params: {
|
|
116
|
+
'LAYERS': layer,
|
|
117
|
+
'TILED': true,
|
|
118
|
+
'VERSION': '1.1.1' // 或 '1.3.0'
|
|
119
|
+
},
|
|
120
|
+
serverType: 'geoserver',
|
|
121
|
+
crossOrigin: 'anonymous', // 允许跨域
|
|
122
|
+
}),
|
|
123
|
+
zIndex: options.zIndex ?? 10,
|
|
124
|
+
visible: options.visible ?? true,
|
|
125
|
+
});
|
|
126
|
+
this.map.addLayer(wmsLayer);
|
|
127
|
+
return layer;
|
|
128
|
+
}
|
|
111
129
|
//img_c 影像底图 ter_c 地形底图
|
|
112
130
|
static getTiandiTuLayer(options) {
|
|
113
131
|
return new TileLayer({
|