• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

keplergl / kepler.gl / 12650563989

07 Jan 2025 11:20AM UTC coverage: 66.757% (-0.06%) from 66.819%
12650563989

push

github

web-flow
[feat] mapbox and maplibre simultaneous support (#2897)

- switch between basemap style libraries
- add back mapbox styles in Basemap Style tab

Signed-off-by: Ihor Dykhta <dikhta.igor@gmail.com>

5967 of 10394 branches covered (57.41%)

Branch coverage included in aggregate %.

26 of 46 new or added lines in 6 files covered. (56.52%)

1 existing line in 1 file now uncovered.

12243 of 16884 relevant lines covered (72.51%)

89.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

62.5
/src/utils/src/application-config.ts
1
// SPDX-License-Identifier: MIT
2
// Copyright contributors to the kepler.gl project
3

4
import {MapLib, MapRef} from 'react-map-gl';
5

6
import type {BaseMapLibraryType} from '@kepler.gl/constants';
7

8
export type MapLibInstance = MapLib<any>;
9
export type GetMapRef = ReturnType<MapRef['getMap']>;
10

11
export type BaseMapLibraryConfig = {
12
  getMapLib: () => Promise<MapLibInstance>;
13
  mapLibAttributionCssClass: string;
14
  mapLibCssClass: string;
15
  mapLibName: string;
16
  mapLibUrl: string;
17
};
18

19
/**
20
 * A mechanism to override default Kepler values/settings so that we
21
 * without having to make application-specific changes to the kepler repo.
22
 */
23
export type KeplerApplicationConfig<Map> = {
24
  /** Default name of export HTML file, can be overridden by user */
25
  defaultHtmlName?: string;
26
  defaultImageName?: string;
27
  defaultJsonName?: string;
28
  defaultDataName?: string;
29
  defaultExportJsonSettings?: {
30
    hasData?: boolean;
31
  };
32
  baseMapLibraryConfig?: Record<BaseMapLibraryType, BaseMapLibraryConfig>;
33
  plugins?: any[];
34
  // KeplerTable alternative
35
  // TODO improve typing by exporting KeplerTable interface to @kepler.gl/types
36
  table?: any;
37
};
38

39
const DEFAULT_APPLICATION_CONFIG: Required<KeplerApplicationConfig<mapboxgl.Map>> = {
15✔
40
  defaultHtmlName: 'kepler.gl.html',
41
  defaultImageName: 'kepler.gl.png',
42
  defaultJsonName: 'kepler.gl.json',
43
  defaultDataName: 'kepler.gl',
44
  defaultExportJsonSettings: {
45
    hasData: true
46
  },
47

48
  baseMapLibraryConfig: {
49
    maplibre: {
50
      getMapLib: () => import('maplibre-gl'),
29✔
51
      mapLibCssClass: 'maplibregl',
52
      mapLibAttributionCssClass: 'maplibre-attribution-container',
53
      mapLibName: 'MapLibre',
54
      mapLibUrl: 'https://www.maplibre.org/'
55
    },
56
    mapbox: {
NEW
57
      getMapLib: () => import('mapbox-gl'),
×
58
      mapLibCssClass: 'mapboxgl',
59
      mapLibAttributionCssClass: 'mapbox-attribution-container',
60
      mapLibName: 'Mapbox',
61
      mapLibUrl: 'https://www.mapbox.com/'
62
    }
63
  },
64

65
  plugins: [],
66
  // The default table class is KeplerTable.
67
  // TODO include KeplerTable here when the circular dependency with @kepler.gl/table and @kepler.gl/utils are resolved.
68
  table: null
69
};
70

71
const applicationConfig: Required<KeplerApplicationConfig<mapboxgl.Map>> =
72
  DEFAULT_APPLICATION_CONFIG;
15✔
73

74
export const getApplicationConfig = (): Required<KeplerApplicationConfig<mapboxgl.Map>> =>
15✔
75
  applicationConfig;
92✔
76

77
export function initApplicationConfig<M>(appConfig: KeplerApplicationConfig<M> = {}) {
×
78
  Object.assign(applicationConfig, appConfig);
×
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc