aviation-chart 0.3.26 → 2.0.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/README.md CHANGED
@@ -1,170 +1 @@
1
- # Kunyu Aviation Chart SDK
2
-
3
- A high-performance aviation chart SDK providing complete aeronautical data visualization: FIR/UIR, controlled and restricted airspace, airways, navaids (VOR/NDB), airports and runways, AMM, and terrain — plus business features such as NOTAM, ADS-B, and weather radar. Built with a modular architecture supporting plugins, performance optimization, and unified error handling.
4
-
5
- ## ✨ Features
6
-
7
- - **Aviation data stack**: FIR, controlled/restricted airspace, airways, VOR/NDB, airport runways, AMM, terrain/contours — published per AIRAC period
8
- - **Theme switching**: in-place light/dark recoloring that never covers your overlay layers
9
- - **Business modules**: NOTAM, ADS-B, weather radar, raster layers
10
- - **Performance**: LOD (level-of-detail), lazy layer loading, massive-point clustering, low-zoom style simplification
11
- - **Plugin system**: unified plugin interface with a built-in measurement plugin
12
- - **Unified error handling**: centralized error management, fallback strategies, error statistics
13
-
14
- ## 🚀 Getting Started
15
-
16
- ### Option 1: CDN script (global `navMap`)
17
-
18
- ```html
19
- <!-- latest -->
20
- <script src="https://aips.siniswift.com/sdk/nav-sdk.min.js"></script>
21
- <!-- or pin a version -->
22
- <!-- <script src="https://aips.siniswift.com/sdk/nav-sdk@0.2.0.min.js"></script> -->
23
-
24
- <div id="map" style="width:100%;height:600px;"></div>
25
-
26
- <script>
27
- const sdk = new navMap.MapSDK({
28
- container: 'map',
29
- center: [116.3974, 39.9093],
30
- zoom: 4,
31
- theme: 'light', // 'light' | 'dark'
32
- period: '202606', // AIRAC period; auto-computed if omitted
33
- });
34
- </script>
35
- ```
36
-
37
- > The underlying map engine is bundled into `nav-sdk.min.js` — no extra script needed.
38
-
39
- ### Option 2: npm
40
-
41
- ```bash
42
- npm install aviation-chart
43
- ```
44
-
45
- ```javascript
46
- import { MapSDK, MeasurePlugin } from 'aviation-chart';
47
-
48
- const sdk = new MapSDK({
49
- container: 'map',
50
- center: [116.3974, 39.9093],
51
- zoom: 4,
52
- performance: { lodEnabled: true, clusteringEnabled: true, lazyLoadingEnabled: true },
53
- });
54
- ```
55
-
56
- ## 📚 API Overview
57
-
58
- ### Initialization options
59
-
60
- | Option | Description |
61
- |---|---|
62
- | `container` | Container id or element (required) |
63
- | `center` / `zoom` | Initial center and zoom |
64
- | `theme` | `'light'` / `'dark'` |
65
- | `period` | AIRAC period `YYYYMM` |
66
- | `apiUrl` | Chart data service URL, default `https://aips.siniswift.com` |
67
- | `layers` | Initial layer visibility, e.g. `{ airspace: true, controlled: false, terrain: false }` |
68
- | `performance` | `{ lodEnabled, clusteringEnabled, lazyLoadingEnabled }` |
69
- | `errorHandler` | Custom error handler function |
70
-
71
- ### Layer control
72
-
73
- Layer groups: `airspace` (FIR), `airline` (airways), `controlled`, `restricted`, `vor`, `ndb`, `airport`, `runway`, `adiz`, `waypointOffAirway`, `amm`, `terrain`, `contour`, `background`, `landLayer`, `boundary`.
74
-
75
- ```javascript
76
- // Two equivalent APIs
77
- sdk.setLayerVisible('airspace', true);
78
- sdk.addBuiltInLayer('controlled');
79
- sdk.toggleBuiltInLayer('airline');
80
- sdk.removeBuiltInLayer('restricted');
81
-
82
- // Theme and period
83
- sdk.setTheme('dark');
84
- sdk.setPeriod('202609');
85
-
86
- // LOD
87
- sdk.layerManager.setLODEnabled(true);
88
- ```
89
-
90
- ### Feature drawing (GeoJSON)
91
-
92
- ```javascript
93
- sdk.addPoint([lng, lat], properties, style);
94
- sdk.addLine(coordinates, properties, style);
95
- sdk.addPolygon(coordinates, properties, style);
96
-
97
- // Cluster massive point sets
98
- sdk.geoJSONManager.setClusteringEnabled(true);
99
- ```
100
-
101
- ### Business features
102
-
103
- ```javascript
104
- sdk.notam.open(true); // NOTAM
105
- sdk.adsb.open(); // ADS-B
106
- sdk.api.getRadarData(); // weather radar data
107
- ```
108
-
109
- ### Popup
110
-
111
- ```javascript
112
- const popup = new navMap.Popup()
113
- .setLngLat([lng, lat])
114
- .setHTML('<h3>Title</h3>')
115
- .addTo(sdk.map);
116
- ```
117
-
118
- ### Plugins
119
-
120
- ```javascript
121
- const measure = new navMap.MeasurePlugin();
122
- sdk.use(measure);
123
- measure.enable('distance'); // 'distance' | 'area'
124
- measure.disable();
125
-
126
- const plugin = sdk.getPlugin('measure');
127
- ```
128
-
129
- ### Underlying engine passthrough
130
-
131
- The SDK passes through the full underlying map-engine API — call methods directly on the instance, or access the raw instance via `sdk.map`:
132
-
133
- ```javascript
134
- sdk.flyTo({ center: [lng, lat], zoom: 8 });
135
- sdk.setPaintProperty('airline', 'line-color', '#0057c8');
136
- sdk.queryRenderedFeatures([x, y]);
137
-
138
- const map = sdk.map; // raw map instance
139
- ```
140
-
141
- ### Error & performance
142
-
143
- ```javascript
144
- const sdk = new navMap.MapSDK({
145
- container: 'map',
146
- errorHandler: (error) => console.error(error.code, error.details),
147
- });
148
-
149
- sdk.getErrorStats(); // error statistics
150
- sdk.getPerformanceStats(); // performance statistics
151
- ```
152
-
153
- ## 🔧 Writing a Plugin
154
-
155
- ```javascript
156
- export class MyPlugin {
157
- name = 'my-plugin';
158
- version = '1.0.0';
159
- install(sdk) { /* install logic */ }
160
- uninstall(sdk) { /* uninstall logic */ }
161
- }
162
-
163
- const plugin = new MyPlugin();
164
- sdk.use(plugin);
165
- sdk.pluginManager.hasPlugin('my-plugin');
166
- ```
167
-
168
- ## 📄 License
169
-
170
- MIT License
1
+ ## Kunyu
package/dist/nav-sdk.d.ts CHANGED
@@ -20,7 +20,7 @@ interface GlobalConfig {
20
20
  defaultZoom?: number;
21
21
  };
22
22
  styleConfig?: {
23
- theme?: "light" | "dark";
23
+ theme?: string;
24
24
  language?: "zh-CN" | "en-US";
25
25
  };
26
26
  periodConfig?: {
@@ -424,7 +424,7 @@ interface IMapSDK {
424
424
  setMapStyle(style: string | StyleSpecification, options?: {
425
425
  diff?: boolean;
426
426
  }): Promise<void>;
427
- setTheme(theme: "light" | "dark"): void;
427
+ setTheme(theme: string): void;
428
428
  addPoint(coordinates: [number, number], properties?: Record<string, any>, style?: StyleConfig): string;
429
429
  addLine(coordinates: [number, number][], properties?: Record<string, any>, style?: StyleConfig): string;
430
430
  addPolygon(coordinates: [number, number][][], properties?: Record<string, any>, style?: StyleConfig): string;
@@ -541,7 +541,7 @@ interface MapSDKOptions {
541
541
  enableAIP?: boolean;
542
542
  enableNOTAM?: boolean;
543
543
  enableADSB?: boolean;
544
- theme?: 'light' | 'dark';
544
+ theme?: string;
545
545
  language?: 'zh-CN' | 'en-US';
546
546
  switchDay?: number;
547
547
  graticule?: {
@@ -1005,7 +1005,8 @@ declare class MapSDK implements IMapSDK {
1005
1005
  setMapStyle(style: string | StyleSpecification, options?: {
1006
1006
  diff?: boolean;
1007
1007
  }): Promise<void>;
1008
- setTheme(theme: "light" | "dark"): void;
1008
+ setTheme(theme: string): void;
1009
+ private _resolveThemeId;
1009
1010
  private _themeLayerDefs;
1010
1011
  private _applyThemedProps;
1011
1012
  restoreLandLayer(): void;
@@ -1262,6 +1263,22 @@ declare namespace CHART_THEMES {
1262
1263
  let background_1: string;
1263
1264
  export { background_1 as background };
1264
1265
  }
1266
+ namespace dusk {
1267
+ let id_2: string;
1268
+ export { id_2 as id };
1269
+ let label_2: string;
1270
+ export { label_2 as label };
1271
+ let background_2: string;
1272
+ export { background_2 as background };
1273
+ }
1274
+ namespace foreflight {
1275
+ let id_3: string;
1276
+ export { id_3 as id };
1277
+ let label_3: string;
1278
+ export { label_3 as label };
1279
+ let background_3: string;
1280
+ export { background_3 as background };
1281
+ }
1265
1282
  }
1266
1283
  declare namespace LAYER_GROUPS {
1267
1284
  export let adiz: string[];
@@ -1276,8 +1293,6 @@ declare namespace LAYER_GROUPS {
1276
1293
  export { ndb_1 as ndb };
1277
1294
  let airport_1: string[];
1278
1295
  export { airport_1 as airport };
1279
- let runway_1: string[];
1280
- export { runway_1 as runway };
1281
1296
  }
1282
1297
  declare namespace LAYER_LABELS {
1283
1298
  let adiz_1: string;
@@ -1298,8 +1313,6 @@ declare namespace LAYER_LABELS {
1298
1313
  export { ndb_2 as ndb };
1299
1314
  let airport_2: string;
1300
1315
  export { airport_2 as airport };
1301
- let runway_2: string;
1302
- export { runway_2 as runway };
1303
1316
  }
1304
1317
 
1305
1318
  export { API, MapSDK as AviationChart, BuiltInLayer, CHART_THEMES, Circle, CircleOptions, ClusteringConfig, DEFAULT_LAYER_VISIBILITY, DrawPlugin, EnhancedMarker, EnhancedPolygon, ErrorHandler, ErrorManager, EventListener, FeatureType, GROUP_ALIASES, GeoJSONCollection, GeoJSONFeature, GeoJSONManager, GeometryFeature, GeometryParams, GlobalConfigManager, HookCallback, HookContext, HookRegistry, IGeoJSONManager, ILayerManager, IMapSDK, IPlugin, LAYER_GROUPS, LAYER_LABELS, LODConfig, LayerConfig, LayerManager, LineType, MapEvent, MapSDK, MapSDKOptions, MarkerOptions, MeasurePlugin, NOTAM, PerformanceManager, PluginManager, PolygonOptions, Polyline, PolylineOptions, SDKError, SearchParams, SearchResultItem, StrokeLineType, StyleConfig, TYPEMAP, Text, TextOptions, WindFrame, WindManager, WindOptions, MapSDK as default, getFeatureGeometry, getPeriods, globalConfig, searchFeatures };
@@ -1980,8 +1980,7 @@ const TYPEMAP = {
1980
1980
  restricted: ["restrictedLayer", "restrictedLayer_stroke", "restricted_line_label"],
1981
1981
  vor: ["vor_icon", "vor_icon_dial", "vor_label"],
1982
1982
  ndb: ["ndb_icon"],
1983
- airport: ["airport"],
1984
- runway: ["runway-line", "runway-line-amm", "runway-label"],
1983
+ airport: ["airport", "airport-runway", "airport-runway-cross"],
1985
1984
  adiz: ["adiz-line", "adiz-label"],
1986
1985
  waypointOffAirway: ["waypoint-off-airway-symbol"],
1987
1986
  amm: getChartAMMLayerIds(),
@@ -1999,7 +1998,6 @@ const DEFAULT_LAYER_VISIBILITY = {
1999
1998
  vor: true,
2000
1999
  ndb: true,
2001
2000
  airport: true,
2002
- runway: false,
2003
2001
  adiz: false,
2004
2002
  waypointOffAirway: false,
2005
2003
  amm: true,
@@ -7428,6 +7426,7 @@ function getAviationBaseStyle(opts) {
7428
7426
  { id: "default", url: `${spriteBase}/sprites/sprite` },
7429
7427
  { id: "v2", url: `${spriteBase}/sprites/sprite-v2` },
7430
7428
  { id: "vor", url: `${spriteBase}/sprites/sprite-vor` },
7429
+ { id: "runway", url: `${spriteBase}/sprites/sprite-runway` },
7431
7430
  ],
7432
7431
  sources: {
7433
7432
  land: { type: "geojson", data: { type: "FeatureCollection", features: [] } },
@@ -7600,6 +7599,11 @@ async function fetchGzJson(url, headers = {}) {
7600
7599
  //
7601
7600
  // 加主题 = 在 THEME_TOKENS 增加一张 token 表;不再复制整份 build 函数,
7602
7601
  // 彻底消除 light/dark 漂移(历史上 dark 航线消失、6,6 插值等 bug 均源于此)。
7602
+ //
7603
+ // 本次新增两套主题:
7604
+ // dusk 暮光模式 —— 晨昏蒙影时段过渡用,中等亮度,避免日/夜切换的瞳孔冲击
7605
+ // redNight 红光夜视模式 —— 驾驶舱标准红光照明,全色系统一为红色,
7606
+ // 靠明度而非色相区分要素,保护夜间暗适应(视杆细胞)
7603
7607
 
7604
7608
  /**
7605
7609
  * 主题 token 表。每个 key 是一个"随主题变化"的值,值可以是颜色字符串、
@@ -7676,6 +7680,81 @@ const THEME_TOKENS = {
7676
7680
  alHalo: {},
7677
7681
  ndbHalo: { 'text-halo-color': '#0f172a', 'text-halo-width': 1 },
7678
7682
  },
7683
+ // ── 新增:暮光模式(晨昏蒙影 / 日夜切换过渡)───────────────────────────
7684
+ // 设计目标:亮度介于 light 与 dark 之间,避免瞳孔在两个极端间来回收放;
7685
+ // 色相仍按 light 的语义分组(橙=限制区/绿=管制区),但饱和度、对比度降低。
7686
+ dusk: {
7687
+ background: '#1B2838',
7688
+ land: '#22303F',
7689
+ halo: '#16212c',
7690
+ boundaryPattern: 'normal:national-border-dark', // 复用 dark 的深色底图案
7691
+ adizLine: '#c77dff',
7692
+ adizLabel: '#e0aaff',
7693
+ airspaceStroke: '#7fb3d5',
7694
+ restrictedFill: '#e67e22',
7695
+ restrictedStrokeLine: '#e59866',
7696
+ restrictedStroke: '#e59866',
7697
+ controlledStroke: '#52c9a3',
7698
+ controlledFill: '#52c9a3',
7699
+ segment: '#8fa8c7',
7700
+ segmentRemark: '#f4c542',
7701
+ airport: '#7fd1ae',
7702
+ airportText: '#dce9f0',
7703
+ runway: '#7c8ea3',
7704
+ vorDial: '#5dade2',
7705
+ vorNormal: '#5dade2',
7706
+ vor: '#85a9e0',
7707
+ ndbIcon: 'ndb-inway',
7708
+ ndb: '#7ec8e3',
7709
+ waypoint: '#a9c6d8',
7710
+ alBase: '#1B2838', alDist: '#b8c9d9', alRnp: '#f4c542',
7711
+ sideHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7712
+ centerHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1.5 },
7713
+ restrictedHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7714
+ controlledHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1.5 },
7715
+ radialHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7716
+ runwayHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7717
+ alHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 0.5 },
7718
+ ndbHalo: { 'text-halo-color': '#1B2838', 'text-halo-width': 1 },
7719
+ },
7720
+ // ── 新增:ForeFlight 风格(致敬,非像素级复刻,官方未公开具体色值)──────
7721
+ // 设计目标:暖米黄底图 + 扁平化(去地形纹理)+ 传统航图色彩语义
7722
+ // (蓝=管制空域,洋红=非管制机场,棕=NDB,橙=限制区)+ 现代无衬线字体,
7723
+ // 整体比三色 VFR 纸图更"干净",符合 ForeFlight 网页版/Light 主题的视觉语言。
7724
+ foreflight: {
7725
+ background: '#F2EFE6',
7726
+ land: '#F7F5EC',
7727
+ halo: '#F2EFE6',
7728
+ boundaryPattern: 'normal:national-border',
7729
+ adizLine: '#8e44ad',
7730
+ adizLabel: '#8e44ad',
7731
+ airspaceStroke: '#2E5C8A',
7732
+ restrictedFill: '#E8A33D',
7733
+ restrictedStrokeLine: '#C0392B',
7734
+ restrictedStroke: '#C0392B',
7735
+ controlledStroke: '#2E5C8A',
7736
+ controlledFill: '#2E5C8A',
7737
+ segment: '#34495E',
7738
+ segmentRemark: '#D68910',
7739
+ airport: '#B03060',
7740
+ airportText: '#1B2631',
7741
+ runway: '#4A4A4A',
7742
+ vorDial: '#2E5C8A',
7743
+ vorNormal: '#2E5C8A',
7744
+ vor: '#154360',
7745
+ ndbIcon: 'v2:ndb-normal',
7746
+ ndb: '#8B5A2B',
7747
+ waypoint: '#2C3E50',
7748
+ alBase: '#F2EFE6', alDist: '#5D6D7E', alRnp: '#D68910',
7749
+ sideHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7750
+ centerHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1.5 },
7751
+ restrictedHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7752
+ controlledHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1.5 },
7753
+ radialHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7754
+ runwayHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7755
+ alHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 0.5 },
7756
+ ndbHalo: { 'text-halo-color': '#F2EFE6', 'text-halo-width': 1 },
7757
+ },
7679
7758
  };
7680
7759
 
7681
7760
  function buildLayers(themeId = 'light') {
@@ -7853,36 +7932,42 @@ function buildLayers(themeId = 'light') {
7853
7932
  "text-opacity": ["interpolate", ["linear"], ["zoom"], 4, 0.95, 5, 1, 9, 1, 11, 0.2],
7854
7933
  },
7855
7934
  },
7935
+ // Runway-orientation strip: a small mark rotated to the true bearing of the
7936
+ // airport's longest runway (RWY_BRG1). Airports with a crossing runway get a
7937
+ // second strip (RWY_BRG2). Both ride the 'airport' source-layer point, so the
7938
+ // strip sits at the airport symbol's center. `icon-rotation-alignment: map`
7939
+ // keeps the strip aligned to the ground as the map rotates. The `runway-strip`
7940
+ // sprite is supplied by the host sprite sheet.
7856
7941
  {
7857
- id: 'runway-line', type: 'line', source: sourceId, 'source-layer': 'runway',
7858
- filter: ['!', ['has', 'has_amm']], minzoom: 4, maxzoom: 11,
7859
- paint: {
7860
- 'line-color': T.runway,
7861
- 'line-width': ['interpolate', ['linear'], ['zoom'], 4, 1, 13, 10],
7942
+ id: 'airport-runway', type: 'symbol', source: sourceId, minzoom: 2, 'source-layer': 'airport',
7943
+ filter: ['all', ['has', 'RWY_BRG1'], ['case', ['<', ['zoom'], 6], ['==', ['get', 'level'], 1], true]],
7944
+ layout: {
7945
+ 'icon-image': 'runway:runway-strip',
7946
+ 'icon-rotate': ['get', 'RWY_BRG1'],
7947
+ 'icon-rotation-alignment': 'map',
7948
+ 'icon-size': ['interpolate', ['linear'], ['zoom'], 5, 0.6, 9, 1.2, 12, 1.3],
7949
+ 'icon-allow-overlap': true,
7950
+ 'icon-ignore-placement': true,
7951
+ 'visibility': 'none',
7862
7952
  },
7863
- },
7864
- {
7865
- id: 'runway-line-amm', type: 'line', source: sourceId, 'source-layer': 'runway',
7866
- filter: ['has', 'has_amm'], minzoom: 4, maxzoom: 11,
7867
7953
  paint: {
7868
- 'line-color': T.runway,
7869
- 'line-width': ['interpolate', ['linear'], ['zoom'], 4, 1, 10, 4],
7870
- 'line-opacity': ['interpolate', ['linear'], ['zoom'], 10.5, 1, 11, 0],
7954
+ 'icon-opacity': ['interpolate', ['linear'], ['zoom'], 5, 0.6, 9, 1, 12, 1],
7871
7955
  },
7872
7956
  },
7873
7957
  {
7874
- id: 'runway-label', type: 'symbol', source: sourceId, 'source-layer': 'runway', minzoom: 10,
7958
+ id: 'airport-runway-cross', type: 'symbol', source: sourceId, minzoom: 2, 'source-layer': 'airport',
7959
+ filter: ['all', ['has', 'RWY_BRG2'], ['case', ['<', ['zoom'], 6], ['==', ['get', 'level'], 1], true]],
7875
7960
  layout: {
7876
- 'text-field': ['concat', ['to-string', ['get', 'VAL_LEN']], '×', ['to-string', ['get', 'VAL_WID']], 'm'],
7877
- 'text-size': 10,
7878
- 'symbol-placement': 'line-center',
7879
- 'text-rotation-alignment': 'map',
7880
- 'text-optional': true,
7961
+ 'icon-image': 'runway:runway-strip',
7962
+ 'icon-rotate': ['get', 'RWY_BRG2'],
7963
+ 'icon-rotation-alignment': 'map',
7964
+ 'icon-size': ['interpolate', ['linear'], ['zoom'], 5, 0.6, 9, 1.2, 12, 1.3],
7965
+ 'icon-allow-overlap': true,
7966
+ 'icon-ignore-placement': true,
7967
+ 'visibility': 'none',
7881
7968
  },
7882
7969
  paint: {
7883
- 'text-color': T.runway,
7884
- ...T.runwayHalo,
7885
- 'text-opacity': ['interpolate', ['linear'], ['zoom'], 10.5, 1, 11, 0],
7970
+ 'icon-opacity': ['interpolate', ['linear'], ['zoom'], 5, 0.6, 9, 1, 12, 1],
7886
7971
  },
7887
7972
  },
7888
7973
  {
@@ -7988,6 +8073,8 @@ function buildLayers(themeId = 'light') {
7988
8073
  const CHART_THEMES = {
7989
8074
  light: { id: 'light', label: '日间', background: '#EAF2F8' },
7990
8075
  dark: { id: 'dark', label: '夜间', background: '#000000' },
8076
+ dusk: { id: 'dusk', label: '暮光', background: '#1B2838' },
8077
+ foreflight: { id: 'foreflight', label: 'ForeFlight 风格', background: '#F2EFE6' },
7991
8078
  };
7992
8079
 
7993
8080
  // ── Layer groups & labels (theme-independent) ────────────────────────────────
@@ -8000,8 +8087,7 @@ const LAYER_GROUPS = {
8000
8087
  waypointOffAirway: ['waypoint-off-airway-symbol'],
8001
8088
  vor: ['vor_icon_dial', 'vor_label', 'vor_icon'],
8002
8089
  ndb: ['ndb_icon'],
8003
- airport: ['airport'],
8004
- runway: ['runway-line', 'runway-line-amm', 'runway-label'],
8090
+ airport: ['airport', 'airport-runway', 'airport-runway-cross'],
8005
8091
  };
8006
8092
 
8007
8093
  const LAYER_LABELS = {
@@ -8014,7 +8100,6 @@ const LAYER_LABELS = {
8014
8100
  vor: 'VOR',
8015
8101
  ndb: 'NDB',
8016
8102
  airport: '机场',
8017
- runway: '跑道',
8018
8103
  };
8019
8104
 
8020
8105
  class WindManager {
@@ -8098,7 +8183,7 @@ class MapSDK {
8098
8183
  this._baseUrl = options.staticUrl || "https://aips.siniswift.com";
8099
8184
  this._chartApiUrl = (options.apiUrl || DEFAULT_CHART_API_URL).replace(/\/$/, "");
8100
8185
  this._apiVersion = options.apiVersion || undefined;
8101
- const themeId = options.theme === "dark" ? "dark" : "light";
8186
+ const themeId = this._resolveThemeId(options.theme);
8102
8187
  const themeConfig = CHART_THEMES[themeId] ?? CHART_THEMES.light;
8103
8188
  const style = options.style ??
8104
8189
  getAviationBaseStyle({
@@ -8254,7 +8339,7 @@ class MapSDK {
8254
8339
  if (!this.map.getSource("navdata")) {
8255
8340
  this.map.addSource("navdata", getNavdataSource(this._chartApiUrl, period, this._apiVersion));
8256
8341
  }
8257
- const themeId = this.initialOptions.theme === "dark" ? "dark" : "light";
8342
+ const themeId = this._resolveThemeId(this.initialOptions.theme);
8258
8343
  for (const layer of buildLayers(themeId)) {
8259
8344
  if (this.map.getLayer(layer.id))
8260
8345
  continue;
@@ -8395,8 +8480,8 @@ class MapSDK {
8395
8480
  });
8396
8481
  }
8397
8482
  setTheme(theme) {
8398
- const prevTheme = globalConfig.getConfig().styleConfig?.theme ||
8399
- "light";
8483
+ theme = this._resolveThemeId(theme);
8484
+ const prevTheme = this._resolveThemeId(globalConfig.getConfig().styleConfig?.theme);
8400
8485
  if (prevTheme === theme)
8401
8486
  return;
8402
8487
  globalConfig.updateConfigItem("styleConfig", {
@@ -8412,6 +8497,9 @@ class MapSDK {
8412
8497
  this._applyThemedProps(id, prevDefs[id], nextDefs[id]);
8413
8498
  }
8414
8499
  }
8500
+ _resolveThemeId(theme) {
8501
+ return theme && CHART_THEMES[theme] ? theme : "light";
8502
+ }
8415
8503
  _themeLayerDefs(theme) {
8416
8504
  const themeConfig = CHART_THEMES[theme] ?? CHART_THEMES.light;
8417
8505
  const defs = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aviation-chart",
3
- "version": "0.3.26",
3
+ "version": "2.0.2",
4
4
  "description": "KunYu aviation map SDK",
5
5
  "main": "dist/nav-sdk.esm.js",
6
6
  "module": "dist/nav-sdk.esm.js",