@summeruse/ol 0.3.1 → 0.3.2
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.
- package/CHANGELOG.md +7 -0
- package/dist/index.js +21 -5
- package/es/components/ol-map/index.vue_vue_type_script_setup_true_lang.mjs +1 -0
- package/es/index.mjs +2 -2
- package/es/utils/index.mjs +1 -1
- package/es/utils/layer/index.d.ts +19 -4
- package/es/utils/layer/index.mjs +34 -19
- package/lib/components/ol-map/index.vue_vue_type_script_setup_true_lang.js +1 -1
- package/lib/index.js +1 -1
- package/lib/utils/layer/index.d.ts +19 -4
- package/lib/utils/layer/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import VectorLayer from "ol/layer/Vector";
|
|
|
8
8
|
import VectorSource from "ol/source/Vector";
|
|
9
9
|
import { Circle as Circle$1, Fill, Icon, Stroke, Style, Text } from "ol/style";
|
|
10
10
|
import { Graticule, Tile } from "ol/layer";
|
|
11
|
+
import WebGLVectorLayer from "ol/layer/WebGLVector";
|
|
11
12
|
import { BingMaps, OSM, XYZ } from "ol/source";
|
|
12
13
|
import { transform, transformExtent } from "ol/proj";
|
|
13
14
|
const olMapInjectionKey = Symbol("olMapInjectionKey");
|
|
@@ -15,6 +16,7 @@ function useOlMap() {
|
|
|
15
16
|
return inject(olMapInjectionKey);
|
|
16
17
|
}
|
|
17
18
|
var ol_map_default = /* @__PURE__ */ defineComponent({
|
|
19
|
+
name: "OlMap",
|
|
18
20
|
__name: "index",
|
|
19
21
|
props: {
|
|
20
22
|
olMap: { default: () => new Map() },
|
|
@@ -382,14 +384,28 @@ function createOpenStreetMapLayer(r) {
|
|
|
382
384
|
...l
|
|
383
385
|
});
|
|
384
386
|
}
|
|
387
|
+
function createVectorSource(r) {
|
|
388
|
+
return new VectorSource({ ...r });
|
|
389
|
+
}
|
|
385
390
|
function createVectorLayer(r) {
|
|
386
|
-
let { styleOptions: l,...
|
|
391
|
+
let { styleOptions: l, sourceOptions: u,...d } = r || {}, f = l ? createStyle(l) : void 0, p = createVectorSource(u);
|
|
387
392
|
return {
|
|
388
|
-
source:
|
|
393
|
+
source: p,
|
|
389
394
|
layer: new VectorLayer({
|
|
395
|
+
source: p,
|
|
396
|
+
...d,
|
|
397
|
+
style: f || d.style
|
|
398
|
+
})
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function createWebGLVectorLayer(r) {
|
|
402
|
+
let { style: l, sourceOptions: u,...d } = r, f = createVectorSource(u);
|
|
403
|
+
return {
|
|
404
|
+
source: f,
|
|
405
|
+
layer: new WebGLVectorLayer({
|
|
390
406
|
source: f,
|
|
391
|
-
...
|
|
392
|
-
style:
|
|
407
|
+
...d,
|
|
408
|
+
style: l
|
|
393
409
|
})
|
|
394
410
|
};
|
|
395
411
|
}
|
|
@@ -722,4 +738,4 @@ function useSwitchBaseLayer(r) {
|
|
|
722
738
|
});
|
|
723
739
|
}, { immediate: !0 }), { visibleLayerName: l };
|
|
724
740
|
}
|
|
725
|
-
export { EPSG_3857, EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, ONE_NM, ol_map_default as OlMap, WGS84Projection, WebMercatorProjection, createBingLayer, createCircle, createCircleFeature, createCircleStyle, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createOpenStreetMapLayer, createPoint, createPointFeature, createPolygon, createPolygonFeature, createStyle, createTextStyle, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, formatAngle, formatRotation, kmToNauticalMiles, mercatorExtentToWgs84, mercatorToWgs84, nauticalMilesToKm, olMapInjectionKey, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useOlMap, usePointermove, useSwitchBaseLayer, wgs84ExtentToMercator, wgs84ToMercator };
|
|
741
|
+
export { EPSG_3857, EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, ONE_NM, ol_map_default as OlMap, WGS84Projection, WebMercatorProjection, createBingLayer, createCircle, createCircleFeature, createCircleStyle, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createOpenStreetMapLayer, createPoint, createPointFeature, createPolygon, createPolygonFeature, createStyle, createTextStyle, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, createVectorSource, createWebGLVectorLayer, formatAngle, formatRotation, kmToNauticalMiles, mercatorExtentToWgs84, mercatorToWgs84, nauticalMilesToKm, olMapInjectionKey, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useOlMap, usePointermove, useSwitchBaseLayer, wgs84ExtentToMercator, wgs84ToMercator };
|
|
@@ -4,6 +4,7 @@ import { Map, View } from "ol";
|
|
|
4
4
|
import { Attribution, FullScreen, OverviewMap, Rotate, ScaleLine, Zoom } from "ol/control";
|
|
5
5
|
import { DoubleClickZoom, DragPan, DragRotate, KeyboardPan, KeyboardZoom, MouseWheelZoom, PinchRotate, PinchZoom } from "ol/interaction";
|
|
6
6
|
var index_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
7
|
+
name: "OlMap",
|
|
7
8
|
__name: "index",
|
|
8
9
|
props: {
|
|
9
10
|
olMap: { default: () => new Map() },
|
package/es/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { EPSG_3857, EPSG_4326, WGS84Projection, WebMercatorProjection } from "./
|
|
|
7
7
|
import { formatAngle, formatRotation, kmToNauticalMiles, nauticalMilesToKm } from "./utils/distance/index.mjs";
|
|
8
8
|
import { createCircleStyle, createStyle, createTextStyle } from "./utils/style/index.mjs";
|
|
9
9
|
import { createCircle, createCircleFeature, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createPoint, createPointFeature, createPolygon, createPolygonFeature } from "./utils/feature/index.mjs";
|
|
10
|
-
import { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer } from "./utils/layer/index.mjs";
|
|
10
|
+
import { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, createVectorSource, createWebGLVectorLayer } from "./utils/layer/index.mjs";
|
|
11
11
|
import { EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, mercatorExtentToWgs84, mercatorToWgs84, wgs84ExtentToMercator, wgs84ToMercator } from "./utils/projection/index.mjs";
|
|
12
12
|
import "./utils/index.mjs";
|
|
13
13
|
import { useDrawLineString } from "./composables/useDrawLineString/index.mjs";
|
|
@@ -16,4 +16,4 @@ import { useGraticule } from "./composables/useGraticule/index.mjs";
|
|
|
16
16
|
import { usePointermove } from "./composables/usePointermove/index.mjs";
|
|
17
17
|
import { useSwitchBaseLayer } from "./composables/useSwitchBaseLayer/index.mjs";
|
|
18
18
|
import "./composables/index.mjs";
|
|
19
|
-
export { EPSG_3857, EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, ONE_NM, ol_map_default as OlMap, WGS84Projection, WebMercatorProjection, createBingLayer, createCircle, createCircleFeature, createCircleStyle, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createOpenStreetMapLayer, createPoint, createPointFeature, createPolygon, createPolygonFeature, createStyle, createTextStyle, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, formatAngle, formatRotation, kmToNauticalMiles, mercatorExtentToWgs84, mercatorToWgs84, nauticalMilesToKm, olMapInjectionKey, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useOlMap, usePointermove, useSwitchBaseLayer, wgs84ExtentToMercator, wgs84ToMercator };
|
|
19
|
+
export { EPSG_3857, EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, ONE_NM, ol_map_default as OlMap, WGS84Projection, WebMercatorProjection, createBingLayer, createCircle, createCircleFeature, createCircleStyle, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createOpenStreetMapLayer, createPoint, createPointFeature, createPolygon, createPolygonFeature, createStyle, createTextStyle, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, createVectorSource, createWebGLVectorLayer, formatAngle, formatRotation, kmToNauticalMiles, mercatorExtentToWgs84, mercatorToWgs84, nauticalMilesToKm, olMapInjectionKey, useContextmenu, useDrawLineString, useDrawPolygon, useGraticule, useOlMap, usePointermove, useSwitchBaseLayer, wgs84ExtentToMercator, wgs84ToMercator };
|
package/es/utils/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatAngle, formatRotation, kmToNauticalMiles, nauticalMilesToKm } from "./distance/index.mjs";
|
|
2
2
|
import { createCircleStyle, createStyle, createTextStyle } from "./style/index.mjs";
|
|
3
3
|
import { createCircle, createCircleFeature, createFeature, createLineString, createLineStringFeature, createMultiLineString, createMultiLineStringFeature, createMultiPoint, createMultiPointFeature, createMultiPolygon, createMultiPolygonFeature, createPoint, createPointFeature, createPolygon, createPolygonFeature } from "./feature/index.mjs";
|
|
4
|
-
import { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer } from "./layer/index.mjs";
|
|
4
|
+
import { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, createVectorSource, createWebGLVectorLayer } from "./layer/index.mjs";
|
|
5
5
|
import { EPSG_3857ExtentToEPSG_4326, EPSG_3857ToEPSG_4326, EPSG_4326ExtentToEPSG_3857, EPSG_4326ToEPSG_3857, mercatorExtentToWgs84, mercatorToWgs84, wgs84ExtentToMercator, wgs84ToMercator } from "./projection/index.mjs";
|
|
@@ -2,8 +2,10 @@ import { StyleOptions } from '../style';
|
|
|
2
2
|
import { Feature } from 'ol';
|
|
3
3
|
import { Geometry } from 'ol/geom';
|
|
4
4
|
import { ProjectionLike } from 'ol/proj';
|
|
5
|
+
import { FlatStyleLike } from 'ol/style/flat';
|
|
5
6
|
import { Tile as TileLayer } from 'ol/layer';
|
|
6
7
|
import { default as VectorLayer } from 'ol/layer/Vector';
|
|
8
|
+
import { default as WebGLVectorLayer } from 'ol/layer/WebGLVector';
|
|
7
9
|
import { BingMaps, OSM, XYZ } from 'ol/source';
|
|
8
10
|
import { default as VectorSource } from 'ol/source/Vector';
|
|
9
11
|
export type T_MAP_TYPE = 'vec' | 'cva' | 'img' | 'cia' | 'ter' | 'cta' | 'ibo';
|
|
@@ -35,11 +37,24 @@ export interface CreateOpenStreetMapLayerOptions {
|
|
|
35
37
|
sourceOptions?: BingMapsSourceOptions;
|
|
36
38
|
}
|
|
37
39
|
export declare function createOpenStreetMapLayer(data?: CreateOpenStreetMapLayerOptions): TileLayer<import('ol/source').Tile<import('ol').Tile>>;
|
|
38
|
-
export type
|
|
39
|
-
export type
|
|
40
|
+
export type _VectorSourceOptions<T extends Geometry = Geometry> = ConstructorParameters<typeof VectorSource<Feature<T>>>[0];
|
|
41
|
+
export type VectorSourceOptions<T extends Geometry = Geometry> = _VectorSourceOptions<T>;
|
|
42
|
+
export declare function createVectorSource<T extends Geometry = Geometry>(options?: VectorSourceOptions<T>): VectorSource<Feature<T>>;
|
|
43
|
+
export type _VectorLayerOptions<T extends Geometry = Geometry> = ConstructorParameters<typeof VectorLayer<VectorSource<Feature<T>>>>[0];
|
|
44
|
+
export type VectorLayerOptions<T extends Geometry = Geometry> = _VectorLayerOptions<T> & {
|
|
40
45
|
styleOptions?: StyleOptions;
|
|
46
|
+
sourceOptions?: VectorSourceOptions<T>;
|
|
41
47
|
};
|
|
42
|
-
export declare function createVectorLayer<T extends Geometry = Geometry>(options?: VectorLayerOptions): {
|
|
48
|
+
export declare function createVectorLayer<T extends Geometry = Geometry>(options?: VectorLayerOptions<T>): {
|
|
43
49
|
source: VectorSource<Feature<T>>;
|
|
44
|
-
layer: VectorLayer<VectorSource<
|
|
50
|
+
layer: VectorLayer<VectorSource<Feature<T>>, Feature<T>>;
|
|
51
|
+
};
|
|
52
|
+
export type _WebGLVectorLayerOptions<T extends Geometry = Geometry> = ConstructorParameters<typeof WebGLVectorLayer<VectorSource<Feature<T>>>>[0];
|
|
53
|
+
export type WebGLVectorLayerOptions<T extends Geometry = Geometry> = _WebGLVectorLayerOptions<T> & {
|
|
54
|
+
style: FlatStyleLike;
|
|
55
|
+
sourceOptions?: VectorSourceOptions<T>;
|
|
56
|
+
};
|
|
57
|
+
export declare function createWebGLVectorLayer<T extends Geometry = Geometry>(options: WebGLVectorLayerOptions<T>): {
|
|
58
|
+
source: VectorSource<Feature<T>>;
|
|
59
|
+
layer: WebGLVectorLayer<VectorSource<Feature<T>>, Feature<T>>;
|
|
45
60
|
};
|
package/es/utils/layer/index.mjs
CHANGED
|
@@ -3,53 +3,68 @@ import { createStyle } from "../style/index.mjs";
|
|
|
3
3
|
import VectorLayer from "ol/layer/Vector";
|
|
4
4
|
import VectorSource from "ol/source/Vector";
|
|
5
5
|
import { Tile } from "ol/layer";
|
|
6
|
+
import WebGLVectorLayer from "ol/layer/WebGLVector";
|
|
6
7
|
import { BingMaps, OSM, XYZ } from "ol/source";
|
|
7
8
|
function createTianDiTuUrl(e) {
|
|
8
|
-
let { type:
|
|
9
|
-
return `${
|
|
9
|
+
let { type: d = "img", projection: f = WebMercatorProjection, key: p } = e, m = e.url || "https://t{0-4}.tianditu.gov.cn", h = `&tk=${p}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;
|
|
10
|
+
return `${m}/${d}_${f === "EPSG:4326" ? "c" : f === "EPSG:3857" ? "w" : "c"}/wmts?LAYER=${d}${h}`;
|
|
10
11
|
}
|
|
11
12
|
function createTianDiTuLayer(e) {
|
|
12
|
-
let { layerOptions:
|
|
13
|
+
let { layerOptions: u, sourceOptions: d,...f } = e;
|
|
13
14
|
return new Tile({
|
|
14
15
|
source: new XYZ({
|
|
15
|
-
url: createTianDiTuUrl(
|
|
16
|
-
projection:
|
|
16
|
+
url: createTianDiTuUrl(f),
|
|
17
|
+
projection: f.projection,
|
|
17
18
|
crossOrigin: "Anonymous",
|
|
18
|
-
...
|
|
19
|
+
...d
|
|
19
20
|
}),
|
|
20
|
-
...
|
|
21
|
+
...u
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
function createBingLayer({ name: e, key:
|
|
24
|
+
function createBingLayer({ name: e, key: u, layerOptions: d, sourceOptions: f }) {
|
|
24
25
|
return new Tile({
|
|
25
26
|
source: new BingMaps({
|
|
26
|
-
key:
|
|
27
|
+
key: u,
|
|
27
28
|
imagerySet: e,
|
|
28
29
|
placeholderTiles: !1,
|
|
29
|
-
...
|
|
30
|
+
...f
|
|
30
31
|
}),
|
|
31
|
-
...
|
|
32
|
+
...d
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
function createOpenStreetMapLayer(e) {
|
|
35
|
-
let { layerOptions:
|
|
36
|
+
let { layerOptions: u, sourceOptions: d } = e || {};
|
|
36
37
|
return new Tile({
|
|
37
38
|
source: new OSM({
|
|
38
39
|
crossOrigin: "Anonymous",
|
|
39
|
-
...
|
|
40
|
+
...d
|
|
40
41
|
}),
|
|
41
|
-
...
|
|
42
|
+
...u
|
|
42
43
|
});
|
|
43
44
|
}
|
|
45
|
+
function createVectorSource(e) {
|
|
46
|
+
return new VectorSource({ ...e });
|
|
47
|
+
}
|
|
44
48
|
function createVectorLayer(e) {
|
|
45
|
-
let { styleOptions:
|
|
49
|
+
let { styleOptions: u, sourceOptions: p,...m } = e || {}, h = u ? createStyle(u) : void 0, g = createVectorSource(p);
|
|
46
50
|
return {
|
|
47
|
-
source:
|
|
51
|
+
source: g,
|
|
48
52
|
layer: new VectorLayer({
|
|
53
|
+
source: g,
|
|
54
|
+
...m,
|
|
55
|
+
style: h || m.style
|
|
56
|
+
})
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function createWebGLVectorLayer(e) {
|
|
60
|
+
let { style: u, sourceOptions: d,...f } = e, p = createVectorSource(d);
|
|
61
|
+
return {
|
|
62
|
+
source: p,
|
|
63
|
+
layer: new WebGLVectorLayer({
|
|
49
64
|
source: p,
|
|
50
|
-
...
|
|
51
|
-
style:
|
|
65
|
+
...f,
|
|
66
|
+
style: u
|
|
52
67
|
})
|
|
53
68
|
};
|
|
54
69
|
}
|
|
55
|
-
export { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer };
|
|
70
|
+
export { createBingLayer, createOpenStreetMapLayer, createTianDiTuLayer, createTianDiTuUrl, createVectorLayer, createVectorSource, createWebGLVectorLayer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../_virtual/rolldown_runtime.js`),t=require(`./props.js`);let n=require(`vue`);n=e.__toESM(n);let r=require(`ol`);r=e.__toESM(r);let i=require(`ol/control`);i=e.__toESM(i);let a=require(`ol/interaction`);a=e.__toESM(a);var o=(0,n.defineComponent)({__name:`index`,props:{olMap:{default:()=>new r.Map},center:{default:()=>[0,0]},zoom:{default:2},minZoom:{default:2},maxZoom:{default:18},constrainResolution:{type:Boolean,default:!0},projection:{},extent:{},showZoom:{type:Boolean,default:!1},showAttribution:{type:Boolean,default:!1},showRotate:{type:Boolean,default:!1},showFullScreen:{type:Boolean,default:!1},showOverview:{type:Boolean,default:!1},showScale:{type:Boolean,default:!1},dragPan:{type:Boolean,default:!0},mouseWheelZoom:{type:Boolean,default:!0},doubleClickZoom:{type:Boolean,default:!1},pinchRotate:{type:Boolean},pinchZoom:{type:Boolean},altShiftDragRotate:{type:Boolean}},emits:[`update:zoom`,`update:center`,`changeResolution`,`changeCenter`,`moveend`,`movestart`],setup(e,{expose:o,emit:s}){let c=e,l=s,u=(0,n.ref)(),d=c.olMap,f=new r.View({projection:c.projection,extent:c.extent});d.setView(f),f.setZoom(c.zoom),f.setCenter(c.center),(0,n.watch)(()=>c.constrainResolution,e=>{f.setConstrainResolution(e)},{immediate:!0}),(0,n.watch)(()=>c.minZoom,e=>{e&&f.setMinZoom(e)},{immediate:!0}),(0,n.watch)(()=>c.maxZoom,e=>{e&&f.setMaxZoom(e)},{immediate:!0}),(0,n.watch)(u,e=>{e&&d.setTarget(e)}),o({olMap:d}),(0,n.provide)(t.olMapInjectionKey,d);let p=d.getControls().getArray(),m=p.find(e=>e instanceof i.Zoom)||new i.Zoom,h=p.find(e=>e instanceof i.Attribution)||new i.Attribution,g=p.find(e=>e instanceof i.Rotate)||new i.Rotate,_=p.find(e=>e instanceof i.FullScreen)||new i.FullScreen,v=p.find(e=>e instanceof i.OverviewMap)||new i.OverviewMap,y=p.find(e=>e instanceof i.ScaleLine)||new i.ScaleLine;(0,n.watch)(()=>c.showZoom,e=>{m.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showAttribution,e=>{h.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showRotate,e=>{g.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showFullScreen,e=>{_.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showOverview,e=>{v.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showScale,e=>{y.setMap(e?d:null)},{immediate:!0});let b=d.getInteractions().getArray(),x=b.find(e=>e instanceof a.DragPan)||new a.DragPan,S=b.find(e=>e instanceof a.MouseWheelZoom)||new a.MouseWheelZoom,C=b.find(e=>e instanceof a.DoubleClickZoom)||new a.DoubleClickZoom,w=b.find(e=>e instanceof a.PinchRotate)||new a.PinchRotate,T=b.find(e=>e instanceof a.PinchZoom)||new a.PinchZoom,E=b.find(e=>e instanceof a.DragRotate)||new a.DragRotate,D=b.find(e=>e instanceof a.KeyboardPan)||new a.KeyboardPan,O=b.find(e=>e instanceof a.KeyboardZoom)||new a.KeyboardZoom;d.removeInteraction(x),d.addInteraction(x),d.removeInteraction(S),d.addInteraction(S),d.removeInteraction(C),d.addInteraction(C),d.removeInteraction(w),d.addInteraction(w),d.removeInteraction(T),d.addInteraction(T),d.removeInteraction(E),d.addInteraction(E),d.removeInteraction(D),d.removeInteraction(O),(0,n.watch)(()=>c.dragPan,e=>{x.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.mouseWheelZoom,e=>{S.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.doubleClickZoom,e=>{C.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.pinchRotate,e=>{w.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.pinchZoom,e=>{T.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.altShiftDragRotate,e=>{E.setActive(e)},{immediate:!0});function k(e){l(`update:zoom`,Math.floor(f.getZoom()||0)),l(`changeResolution`,e)}(0,n.onMounted)(()=>{f.on(`change:resolution`,k)}),(0,n.onUnmounted)(()=>{f.un(`change:resolution`,k)});function A(e){l(`update:center`,f.getCenter()||[0,0]),l(`changeCenter`,e)}(0,n.onMounted)(()=>{f.on(`change:center`,A)}),(0,n.onUnmounted)(()=>{f.un(`change:center`,A)});function j(e){l(`movestart`,e)}(0,n.onMounted)(()=>{d.on(`movestart`,j)}),(0,n.onUnmounted)(()=>{d.un(`movestart`,j)});function M(e){l(`moveend`,e)}return(0,n.onMounted)(()=>{d.on(`moveend`,M)}),(0,n.onUnmounted)(()=>{d.un(`moveend`,M)}),(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{ref_key:`mapRef`,ref:u},[(0,n.renderSlot)(e.$slots,`default`,{olMap:(0,n.unref)(d),mapRef:u.value})],512))}});exports.default=o;
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.js`),t=require(`./props.js`);let n=require(`vue`);n=e.__toESM(n);let r=require(`ol`);r=e.__toESM(r);let i=require(`ol/control`);i=e.__toESM(i);let a=require(`ol/interaction`);a=e.__toESM(a);var o=(0,n.defineComponent)({name:`OlMap`,__name:`index`,props:{olMap:{default:()=>new r.Map},center:{default:()=>[0,0]},zoom:{default:2},minZoom:{default:2},maxZoom:{default:18},constrainResolution:{type:Boolean,default:!0},projection:{},extent:{},showZoom:{type:Boolean,default:!1},showAttribution:{type:Boolean,default:!1},showRotate:{type:Boolean,default:!1},showFullScreen:{type:Boolean,default:!1},showOverview:{type:Boolean,default:!1},showScale:{type:Boolean,default:!1},dragPan:{type:Boolean,default:!0},mouseWheelZoom:{type:Boolean,default:!0},doubleClickZoom:{type:Boolean,default:!1},pinchRotate:{type:Boolean},pinchZoom:{type:Boolean},altShiftDragRotate:{type:Boolean}},emits:[`update:zoom`,`update:center`,`changeResolution`,`changeCenter`,`moveend`,`movestart`],setup(e,{expose:o,emit:s}){let c=e,l=s,u=(0,n.ref)(),d=c.olMap,f=new r.View({projection:c.projection,extent:c.extent});d.setView(f),f.setZoom(c.zoom),f.setCenter(c.center),(0,n.watch)(()=>c.constrainResolution,e=>{f.setConstrainResolution(e)},{immediate:!0}),(0,n.watch)(()=>c.minZoom,e=>{e&&f.setMinZoom(e)},{immediate:!0}),(0,n.watch)(()=>c.maxZoom,e=>{e&&f.setMaxZoom(e)},{immediate:!0}),(0,n.watch)(u,e=>{e&&d.setTarget(e)}),o({olMap:d}),(0,n.provide)(t.olMapInjectionKey,d);let p=d.getControls().getArray(),m=p.find(e=>e instanceof i.Zoom)||new i.Zoom,h=p.find(e=>e instanceof i.Attribution)||new i.Attribution,g=p.find(e=>e instanceof i.Rotate)||new i.Rotate,_=p.find(e=>e instanceof i.FullScreen)||new i.FullScreen,v=p.find(e=>e instanceof i.OverviewMap)||new i.OverviewMap,y=p.find(e=>e instanceof i.ScaleLine)||new i.ScaleLine;(0,n.watch)(()=>c.showZoom,e=>{m.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showAttribution,e=>{h.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showRotate,e=>{g.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showFullScreen,e=>{_.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showOverview,e=>{v.setMap(e?d:null)},{immediate:!0}),(0,n.watch)(()=>c.showScale,e=>{y.setMap(e?d:null)},{immediate:!0});let b=d.getInteractions().getArray(),x=b.find(e=>e instanceof a.DragPan)||new a.DragPan,S=b.find(e=>e instanceof a.MouseWheelZoom)||new a.MouseWheelZoom,C=b.find(e=>e instanceof a.DoubleClickZoom)||new a.DoubleClickZoom,w=b.find(e=>e instanceof a.PinchRotate)||new a.PinchRotate,T=b.find(e=>e instanceof a.PinchZoom)||new a.PinchZoom,E=b.find(e=>e instanceof a.DragRotate)||new a.DragRotate,D=b.find(e=>e instanceof a.KeyboardPan)||new a.KeyboardPan,O=b.find(e=>e instanceof a.KeyboardZoom)||new a.KeyboardZoom;d.removeInteraction(x),d.addInteraction(x),d.removeInteraction(S),d.addInteraction(S),d.removeInteraction(C),d.addInteraction(C),d.removeInteraction(w),d.addInteraction(w),d.removeInteraction(T),d.addInteraction(T),d.removeInteraction(E),d.addInteraction(E),d.removeInteraction(D),d.removeInteraction(O),(0,n.watch)(()=>c.dragPan,e=>{x.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.mouseWheelZoom,e=>{S.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.doubleClickZoom,e=>{C.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.pinchRotate,e=>{w.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.pinchZoom,e=>{T.setActive(e)},{immediate:!0}),(0,n.watch)(()=>c.altShiftDragRotate,e=>{E.setActive(e)},{immediate:!0});function k(e){l(`update:zoom`,Math.floor(f.getZoom()||0)),l(`changeResolution`,e)}(0,n.onMounted)(()=>{f.on(`change:resolution`,k)}),(0,n.onUnmounted)(()=>{f.un(`change:resolution`,k)});function A(e){l(`update:center`,f.getCenter()||[0,0]),l(`changeCenter`,e)}(0,n.onMounted)(()=>{f.on(`change:center`,A)}),(0,n.onUnmounted)(()=>{f.un(`change:center`,A)});function j(e){l(`movestart`,e)}(0,n.onMounted)(()=>{d.on(`movestart`,j)}),(0,n.onUnmounted)(()=>{d.un(`movestart`,j)});function M(e){l(`moveend`,e)}return(0,n.onMounted)(()=>{d.on(`moveend`,M)}),(0,n.onUnmounted)(()=>{d.un(`moveend`,M)}),(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,{ref_key:`mapRef`,ref:u},[(0,n.renderSlot)(e.$slots,`default`,{olMap:(0,n.unref)(d),mapRef:u.value})],512))}});exports.default=o;
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./components/ol-map/props.js`),t=require(`./components/ol-map/index.js`);require(`./components/index.js`);const n=require(`./composables/useContextmenu/index.js`),r=require(`./constants/distance.js`),i=require(`./constants/projection.js`),a=require(`./utils/distance/index.js`),o=require(`./utils/style/index.js`),s=require(`./utils/feature/index.js`),c=require(`./utils/layer/index.js`),l=require(`./utils/projection/index.js`);require(`./utils/index.js`);const u=require(`./composables/useDrawLineString/index.js`),d=require(`./composables/useDrawPolygon/index.js`),f=require(`./composables/useGraticule/index.js`),p=require(`./composables/usePointermove/index.js`),m=require(`./composables/useSwitchBaseLayer/index.js`);require(`./composables/index.js`),exports.EPSG_3857=i.EPSG_3857,exports.EPSG_3857ExtentToEPSG_4326=l.EPSG_3857ExtentToEPSG_4326,exports.EPSG_3857ToEPSG_4326=l.EPSG_3857ToEPSG_4326,exports.EPSG_4326=i.EPSG_4326,exports.EPSG_4326ExtentToEPSG_3857=l.EPSG_4326ExtentToEPSG_3857,exports.EPSG_4326ToEPSG_3857=l.EPSG_4326ToEPSG_3857,exports.ONE_NM=r.ONE_NM,exports.OlMap=t.default,exports.WGS84Projection=i.WGS84Projection,exports.WebMercatorProjection=i.WebMercatorProjection,exports.createBingLayer=c.createBingLayer,exports.createCircle=s.createCircle,exports.createCircleFeature=s.createCircleFeature,exports.createCircleStyle=o.createCircleStyle,exports.createFeature=s.createFeature,exports.createLineString=s.createLineString,exports.createLineStringFeature=s.createLineStringFeature,exports.createMultiLineString=s.createMultiLineString,exports.createMultiLineStringFeature=s.createMultiLineStringFeature,exports.createMultiPoint=s.createMultiPoint,exports.createMultiPointFeature=s.createMultiPointFeature,exports.createMultiPolygon=s.createMultiPolygon,exports.createMultiPolygonFeature=s.createMultiPolygonFeature,exports.createOpenStreetMapLayer=c.createOpenStreetMapLayer,exports.createPoint=s.createPoint,exports.createPointFeature=s.createPointFeature,exports.createPolygon=s.createPolygon,exports.createPolygonFeature=s.createPolygonFeature,exports.createStyle=o.createStyle,exports.createTextStyle=o.createTextStyle,exports.createTianDiTuLayer=c.createTianDiTuLayer,exports.createTianDiTuUrl=c.createTianDiTuUrl,exports.createVectorLayer=c.createVectorLayer,exports.formatAngle=a.formatAngle,exports.formatRotation=a.formatRotation,exports.kmToNauticalMiles=a.kmToNauticalMiles,exports.mercatorExtentToWgs84=l.mercatorExtentToWgs84,exports.mercatorToWgs84=l.mercatorToWgs84,exports.nauticalMilesToKm=a.nauticalMilesToKm,exports.olMapInjectionKey=e.olMapInjectionKey,exports.useContextmenu=n.useContextmenu,exports.useDrawLineString=u.useDrawLineString,exports.useDrawPolygon=d.useDrawPolygon,exports.useGraticule=f.useGraticule,exports.useOlMap=e.useOlMap,exports.usePointermove=p.usePointermove,exports.useSwitchBaseLayer=m.useSwitchBaseLayer,exports.wgs84ExtentToMercator=l.wgs84ExtentToMercator,exports.wgs84ToMercator=l.wgs84ToMercator;
|
|
1
|
+
const e=require(`./components/ol-map/props.js`),t=require(`./components/ol-map/index.js`);require(`./components/index.js`);const n=require(`./composables/useContextmenu/index.js`),r=require(`./constants/distance.js`),i=require(`./constants/projection.js`),a=require(`./utils/distance/index.js`),o=require(`./utils/style/index.js`),s=require(`./utils/feature/index.js`),c=require(`./utils/layer/index.js`),l=require(`./utils/projection/index.js`);require(`./utils/index.js`);const u=require(`./composables/useDrawLineString/index.js`),d=require(`./composables/useDrawPolygon/index.js`),f=require(`./composables/useGraticule/index.js`),p=require(`./composables/usePointermove/index.js`),m=require(`./composables/useSwitchBaseLayer/index.js`);require(`./composables/index.js`),exports.EPSG_3857=i.EPSG_3857,exports.EPSG_3857ExtentToEPSG_4326=l.EPSG_3857ExtentToEPSG_4326,exports.EPSG_3857ToEPSG_4326=l.EPSG_3857ToEPSG_4326,exports.EPSG_4326=i.EPSG_4326,exports.EPSG_4326ExtentToEPSG_3857=l.EPSG_4326ExtentToEPSG_3857,exports.EPSG_4326ToEPSG_3857=l.EPSG_4326ToEPSG_3857,exports.ONE_NM=r.ONE_NM,exports.OlMap=t.default,exports.WGS84Projection=i.WGS84Projection,exports.WebMercatorProjection=i.WebMercatorProjection,exports.createBingLayer=c.createBingLayer,exports.createCircle=s.createCircle,exports.createCircleFeature=s.createCircleFeature,exports.createCircleStyle=o.createCircleStyle,exports.createFeature=s.createFeature,exports.createLineString=s.createLineString,exports.createLineStringFeature=s.createLineStringFeature,exports.createMultiLineString=s.createMultiLineString,exports.createMultiLineStringFeature=s.createMultiLineStringFeature,exports.createMultiPoint=s.createMultiPoint,exports.createMultiPointFeature=s.createMultiPointFeature,exports.createMultiPolygon=s.createMultiPolygon,exports.createMultiPolygonFeature=s.createMultiPolygonFeature,exports.createOpenStreetMapLayer=c.createOpenStreetMapLayer,exports.createPoint=s.createPoint,exports.createPointFeature=s.createPointFeature,exports.createPolygon=s.createPolygon,exports.createPolygonFeature=s.createPolygonFeature,exports.createStyle=o.createStyle,exports.createTextStyle=o.createTextStyle,exports.createTianDiTuLayer=c.createTianDiTuLayer,exports.createTianDiTuUrl=c.createTianDiTuUrl,exports.createVectorLayer=c.createVectorLayer,exports.createVectorSource=c.createVectorSource,exports.createWebGLVectorLayer=c.createWebGLVectorLayer,exports.formatAngle=a.formatAngle,exports.formatRotation=a.formatRotation,exports.kmToNauticalMiles=a.kmToNauticalMiles,exports.mercatorExtentToWgs84=l.mercatorExtentToWgs84,exports.mercatorToWgs84=l.mercatorToWgs84,exports.nauticalMilesToKm=a.nauticalMilesToKm,exports.olMapInjectionKey=e.olMapInjectionKey,exports.useContextmenu=n.useContextmenu,exports.useDrawLineString=u.useDrawLineString,exports.useDrawPolygon=d.useDrawPolygon,exports.useGraticule=f.useGraticule,exports.useOlMap=e.useOlMap,exports.usePointermove=p.usePointermove,exports.useSwitchBaseLayer=m.useSwitchBaseLayer,exports.wgs84ExtentToMercator=l.wgs84ExtentToMercator,exports.wgs84ToMercator=l.wgs84ToMercator;
|
|
@@ -2,8 +2,10 @@ import { StyleOptions } from '../style';
|
|
|
2
2
|
import { Feature } from 'ol';
|
|
3
3
|
import { Geometry } from 'ol/geom';
|
|
4
4
|
import { ProjectionLike } from 'ol/proj';
|
|
5
|
+
import { FlatStyleLike } from 'ol/style/flat';
|
|
5
6
|
import { Tile as TileLayer } from 'ol/layer';
|
|
6
7
|
import { default as VectorLayer } from 'ol/layer/Vector';
|
|
8
|
+
import { default as WebGLVectorLayer } from 'ol/layer/WebGLVector';
|
|
7
9
|
import { BingMaps, OSM, XYZ } from 'ol/source';
|
|
8
10
|
import { default as VectorSource } from 'ol/source/Vector';
|
|
9
11
|
export type T_MAP_TYPE = 'vec' | 'cva' | 'img' | 'cia' | 'ter' | 'cta' | 'ibo';
|
|
@@ -35,11 +37,24 @@ export interface CreateOpenStreetMapLayerOptions {
|
|
|
35
37
|
sourceOptions?: BingMapsSourceOptions;
|
|
36
38
|
}
|
|
37
39
|
export declare function createOpenStreetMapLayer(data?: CreateOpenStreetMapLayerOptions): TileLayer<import('ol/source').Tile<import('ol').Tile>>;
|
|
38
|
-
export type
|
|
39
|
-
export type
|
|
40
|
+
export type _VectorSourceOptions<T extends Geometry = Geometry> = ConstructorParameters<typeof VectorSource<Feature<T>>>[0];
|
|
41
|
+
export type VectorSourceOptions<T extends Geometry = Geometry> = _VectorSourceOptions<T>;
|
|
42
|
+
export declare function createVectorSource<T extends Geometry = Geometry>(options?: VectorSourceOptions<T>): VectorSource<Feature<T>>;
|
|
43
|
+
export type _VectorLayerOptions<T extends Geometry = Geometry> = ConstructorParameters<typeof VectorLayer<VectorSource<Feature<T>>>>[0];
|
|
44
|
+
export type VectorLayerOptions<T extends Geometry = Geometry> = _VectorLayerOptions<T> & {
|
|
40
45
|
styleOptions?: StyleOptions;
|
|
46
|
+
sourceOptions?: VectorSourceOptions<T>;
|
|
41
47
|
};
|
|
42
|
-
export declare function createVectorLayer<T extends Geometry = Geometry>(options?: VectorLayerOptions): {
|
|
48
|
+
export declare function createVectorLayer<T extends Geometry = Geometry>(options?: VectorLayerOptions<T>): {
|
|
43
49
|
source: VectorSource<Feature<T>>;
|
|
44
|
-
layer: VectorLayer<VectorSource<
|
|
50
|
+
layer: VectorLayer<VectorSource<Feature<T>>, Feature<T>>;
|
|
51
|
+
};
|
|
52
|
+
export type _WebGLVectorLayerOptions<T extends Geometry = Geometry> = ConstructorParameters<typeof WebGLVectorLayer<VectorSource<Feature<T>>>>[0];
|
|
53
|
+
export type WebGLVectorLayerOptions<T extends Geometry = Geometry> = _WebGLVectorLayerOptions<T> & {
|
|
54
|
+
style: FlatStyleLike;
|
|
55
|
+
sourceOptions?: VectorSourceOptions<T>;
|
|
56
|
+
};
|
|
57
|
+
export declare function createWebGLVectorLayer<T extends Geometry = Geometry>(options: WebGLVectorLayerOptions<T>): {
|
|
58
|
+
source: VectorSource<Feature<T>>;
|
|
59
|
+
layer: WebGLVectorLayer<VectorSource<Feature<T>>, Feature<T>>;
|
|
45
60
|
};
|
package/lib/utils/layer/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`../../_virtual/rolldown_runtime.js`),t=require(`../../constants/projection.js`),n=require(`../style/index.js`);let r=require(`ol/layer/Vector`);r=e.__toESM(r);let i=require(`ol/source/Vector`);i=e.__toESM(i);let a=require(`ol/layer`);a=e.__toESM(a);let o=require(`ol/
|
|
1
|
+
const e=require(`../../_virtual/rolldown_runtime.js`),t=require(`../../constants/projection.js`),n=require(`../style/index.js`);let r=require(`ol/layer/Vector`);r=e.__toESM(r);let i=require(`ol/source/Vector`);i=e.__toESM(i);let a=require(`ol/layer`);a=e.__toESM(a);let o=require(`ol/layer/WebGLVector`);o=e.__toESM(o);let s=require(`ol/source`);s=e.__toESM(s);function c(e){let{type:n=`img`,projection:r=t.WebMercatorProjection,key:i}=e,a=e.url||`https://t{0-4}.tianditu.gov.cn`,o=`&tk=${i}&SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}`;return`${a}/${n}_${r===`EPSG:4326`?`c`:r===`EPSG:3857`?`w`:`c`}/wmts?LAYER=${n}${o}`}function l(e){let{layerOptions:t,sourceOptions:n,...r}=e;return new a.Tile({source:new s.XYZ({url:c(r),projection:r.projection,crossOrigin:`Anonymous`,...n}),...t})}function u({name:e,key:t,layerOptions:n,sourceOptions:r}){return new a.Tile({source:new s.BingMaps({key:t,imagerySet:e,placeholderTiles:!1,...r}),...n})}function d(e){let{layerOptions:t,sourceOptions:n}=e||{};return new a.Tile({source:new s.OSM({crossOrigin:`Anonymous`,...n}),...t})}function f(e){return new i.default({...e})}function p(e){let{styleOptions:t,sourceOptions:i,...a}=e||{},o=t?n.createStyle(t):void 0,s=f(i);return{source:s,layer:new r.default({source:s,...a,style:o||a.style})}}function m(e){let{style:t,sourceOptions:n,...r}=e,i=f(n);return{source:i,layer:new o.default({source:i,...r,style:t})}}exports.createBingLayer=u,exports.createOpenStreetMapLayer=d,exports.createTianDiTuLayer=l,exports.createTianDiTuUrl=c,exports.createVectorLayer=p,exports.createVectorSource=f,exports.createWebGLVectorLayer=m;
|