uni-leaflet 1.0.4 → 1.0.5
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/app-render.js +13 -1
- package/engine/h5-map-adapter.ts +14 -2
- package/package.json +1 -1
package/app-render.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import * as LModule from 'leaflet';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
function resolveLeaflet(raw) {
|
|
4
|
+
if (raw && typeof raw.map === 'function') return raw;
|
|
5
|
+
if (raw && raw.default && typeof raw.default.map === 'function') return raw.default;
|
|
6
|
+
if (typeof window !== 'undefined' && window.L && typeof window.L.map === 'function') {
|
|
7
|
+
return window.L;
|
|
8
|
+
}
|
|
9
|
+
if (typeof globalThis !== 'undefined' && globalThis.L && typeof globalThis.L.map === 'function') {
|
|
10
|
+
return globalThis.L;
|
|
11
|
+
}
|
|
12
|
+
return (raw && raw.default) ? raw.default : raw;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const L = resolveLeaflet(LModule);
|
|
4
16
|
|
|
5
17
|
// Inject essential Leaflet layout CSS into Webview document
|
|
6
18
|
function ensureLeafletStyles() {
|
package/engine/h5-map-adapter.ts
CHANGED
|
@@ -32,13 +32,25 @@ export interface H5AdapterOptions {
|
|
|
32
32
|
import * as LModule from 'leaflet';
|
|
33
33
|
import 'leaflet/dist/leaflet.css';
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
function resolveLeaflet(raw: any): any {
|
|
36
|
+
if (raw && typeof raw.map === 'function') return raw;
|
|
37
|
+
if (raw && raw.default && typeof raw.default.map === 'function') return raw.default;
|
|
38
|
+
if (typeof window !== 'undefined' && (window as any).L && typeof (window as any).L.map === 'function') {
|
|
39
|
+
return (window as any).L;
|
|
40
|
+
}
|
|
41
|
+
if (typeof globalThis !== 'undefined' && (globalThis as any).L && typeof (globalThis as any).L.map === 'function') {
|
|
42
|
+
return (globalThis as any).L;
|
|
43
|
+
}
|
|
44
|
+
return raw?.default || raw;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const L: any = resolveLeaflet(LModule);
|
|
36
48
|
|
|
37
49
|
export class H5MapAdapter implements IMapEngine {
|
|
38
50
|
private map: any = null;
|
|
39
51
|
private tileLayers: any[] = [];
|
|
40
52
|
private overlayGroup: any = null;
|
|
41
|
-
private L: any = L;
|
|
53
|
+
private L: any = resolveLeaflet(L || LModule);
|
|
42
54
|
private pendingLayers?: Array<string | TileLayerConfig>;
|
|
43
55
|
private pendingOverlays?: MapOverlays;
|
|
44
56
|
|
package/package.json
CHANGED