@tracktor/map 1.1.2 → 1.2.1
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/dist/Features/Bounds/FitsBounds.d.ts +13 -0
- package/dist/Features/MarkerMap/MarkerMap.d.ts +4 -0
- package/dist/Features/MarkerMap/useMarkerMap.d.ts +22 -0
- package/dist/Features/Markers/DefaultMarkers.d.ts +14 -0
- package/dist/Features/RenderFeature/RenderFeature.d.ts +6 -0
- package/dist/constants/baseMap.d.ts +9 -0
- package/dist/constants/globalStyle.d.ts +18 -0
- package/dist/context/MapContext.d.ts +5 -0
- package/dist/context/MapProvider.d.ts +2 -6
- package/dist/main.d.ts +2 -2
- package/dist/main.js +552 -27926
- package/dist/main.umd.cjs +4 -257
- package/dist/services/getRoute.d.ts +3 -0
- package/dist/types/MarkerMapProps.d.ts +72 -25
- package/dist/types/MarkerProps.d.ts +22 -1
- package/dist/utils/getCoreMapOptions.d.ts +32 -24
- package/package.json +21 -4
- package/dist/components/MarkerMap/MarkerMap.d.ts +0 -4
- package/dist/components/MarkerMap/useMarkerMap.d.ts +0 -23
- package/dist/hooks/useFitBounds.d.ts +0 -15
- package/dist/hooks/useMarkers.d.ts +0 -14
- package/dist/hooks/useOnMapClick.d.ts +0 -9
- package/dist/hooks/usePopups.d.ts +0 -11
- package/dist/utils/addPopup.d.ts +0 -43
- package/dist/utils/coordinateConverter.d.ts +0 -16
- package/dist/utils/getFeature.d.ts +0 -18
- package/dist/utils/loadMarkers.d.ts +0 -73
- package/dist/utils/typeguard.d.ts +0 -25
|
@@ -1,73 +1,84 @@
|
|
|
1
1
|
import { SxProps } from '@tracktor/design-system';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Feature, FeatureCollection } from 'geojson';
|
|
3
|
+
import { LngLatLike } from 'mapbox-gl';
|
|
4
|
+
import { ProjectionSpecification as ReactMapProjection } from 'react-map-gl';
|
|
5
|
+
import { MarkerProps } from './MarkerProps';
|
|
4
6
|
export interface MarkerMapProps {
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Automatically adjusts the map's zoom and center
|
|
9
|
+
* to ensure all markers are visible within the viewport.
|
|
7
10
|
*/
|
|
8
11
|
fitBounds?: boolean;
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
13
|
+
* Additional padding (in pixels) around the bounds
|
|
14
|
+
* when using `fitBounds`.
|
|
11
15
|
*/
|
|
12
16
|
fitBoundsPadding?: number;
|
|
13
17
|
/**
|
|
14
|
-
* Coordinates for the center of the map
|
|
18
|
+
* Coordinates for the initial center of the map.
|
|
19
|
+
* Format: [longitude, latitude].
|
|
15
20
|
*/
|
|
16
21
|
center?: LngLatLike | number[];
|
|
17
22
|
/**
|
|
18
|
-
*
|
|
23
|
+
* Mapbox style URL or predefined style ID
|
|
24
|
+
* (e.g., "mapbox://styles/mapbox/streets-v11").
|
|
19
25
|
*/
|
|
20
26
|
mapStyle?: string;
|
|
21
27
|
/**
|
|
22
28
|
* Initial zoom level of the map.
|
|
29
|
+
* A higher number means a closer zoom.
|
|
23
30
|
*/
|
|
24
31
|
zoom?: number;
|
|
25
32
|
/**
|
|
26
|
-
* Maximum width of popups in pixels or
|
|
33
|
+
* Maximum width of popups in pixels or any valid CSS unit.
|
|
27
34
|
*/
|
|
28
35
|
popupMaxWidth?: string;
|
|
29
36
|
/**
|
|
30
37
|
* Width of the map container.
|
|
38
|
+
* Can be a number (px) or any CSS unit (e.g. "100%").
|
|
31
39
|
*/
|
|
32
40
|
width?: number | string;
|
|
33
41
|
/**
|
|
34
42
|
* Height of the map container.
|
|
43
|
+
* Can be a number (px) or any CSS unit (e.g. "100vh").
|
|
35
44
|
*/
|
|
36
45
|
height?: number | string;
|
|
37
46
|
/**
|
|
38
|
-
* Indicates
|
|
47
|
+
* Indicates whether the map is currently in a loading state.
|
|
48
|
+
* Displays a skeleton overlay when true.
|
|
39
49
|
*/
|
|
40
50
|
loading?: boolean;
|
|
41
51
|
/**
|
|
42
|
-
* URL of
|
|
52
|
+
* URL of a custom image used as the default marker icon.
|
|
43
53
|
*/
|
|
44
54
|
markerImageURL?: string;
|
|
45
55
|
/**
|
|
46
|
-
*
|
|
56
|
+
* Custom styles applied to the map container.
|
|
57
|
+
* Uses MUI's `SxProps` system.
|
|
47
58
|
*/
|
|
48
59
|
containerStyle?: SxProps;
|
|
49
60
|
/**
|
|
50
|
-
* Disables the animation
|
|
61
|
+
* Disables the map's fitBounds animation.
|
|
51
62
|
*/
|
|
52
63
|
disableAnimation?: boolean;
|
|
53
64
|
/**
|
|
54
|
-
* Duration of the
|
|
65
|
+
* Duration (in ms) of the fitBounds animation.
|
|
55
66
|
*/
|
|
56
67
|
fitBoundDuration?: number;
|
|
57
68
|
/**
|
|
58
|
-
* Optional key to trigger fitBounds animation.
|
|
69
|
+
* Optional key that can be updated to re-trigger the fitBounds animation.
|
|
59
70
|
*/
|
|
60
71
|
fitBoundsAnimationKey?: unknown;
|
|
61
72
|
/**
|
|
62
|
-
* Forces the map container to
|
|
73
|
+
* Forces the map container to have a square shape.
|
|
63
74
|
*/
|
|
64
75
|
square?: boolean;
|
|
65
76
|
/**
|
|
66
|
-
* ID of the marker whose popup should be open
|
|
77
|
+
* ID of the marker whose popup should be open when the map loads.
|
|
67
78
|
*/
|
|
68
79
|
openPopup?: number | string;
|
|
69
80
|
/**
|
|
70
|
-
*
|
|
81
|
+
* Opens marker popups automatically when hovering over them.
|
|
71
82
|
*/
|
|
72
83
|
openPopupOnHover?: boolean;
|
|
73
84
|
/**
|
|
@@ -75,29 +86,65 @@ export interface MarkerMapProps {
|
|
|
75
86
|
*/
|
|
76
87
|
markers?: MarkerProps[];
|
|
77
88
|
/**
|
|
78
|
-
*
|
|
89
|
+
* Callback triggered when the map is clicked.
|
|
90
|
+
* Returns the longitude and latitude of the clicked point.
|
|
79
91
|
*/
|
|
80
92
|
onMapClick?: (lng: number, lat: number) => void;
|
|
81
93
|
/**
|
|
82
|
-
* The theme of
|
|
94
|
+
* The color theme of the map UI.
|
|
83
95
|
* @default "light"
|
|
84
96
|
*/
|
|
85
97
|
theme?: "dark" | "light";
|
|
86
98
|
/**
|
|
87
|
-
*
|
|
99
|
+
* Map projection type to use.
|
|
100
|
+
* @default "mercator"
|
|
88
101
|
*/
|
|
89
|
-
projection?:
|
|
102
|
+
projection?: ReactMapProjection;
|
|
90
103
|
/**
|
|
91
|
-
*
|
|
92
|
-
* @default "
|
|
104
|
+
* Base map view mode.
|
|
105
|
+
* @default "street"
|
|
93
106
|
*/
|
|
94
|
-
baseMapView?: "
|
|
107
|
+
baseMapView?: "satellite" | "street";
|
|
95
108
|
/**
|
|
96
|
-
*
|
|
109
|
+
* Enables or disables cooperative gestures
|
|
110
|
+
* (e.g. requiring two-finger pan on touch devices).
|
|
111
|
+
* @default true
|
|
97
112
|
*/
|
|
98
113
|
cooperativeGestures?: boolean;
|
|
99
114
|
/**
|
|
100
|
-
*
|
|
115
|
+
* Enables or disables double-click zoom.
|
|
116
|
+
* @default true
|
|
101
117
|
*/
|
|
102
118
|
doubleClickZoom?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* One or multiple GeoJSON line features to display on the map.
|
|
121
|
+
*/
|
|
122
|
+
features?: Feature | Feature[] | FeatureCollection;
|
|
123
|
+
/**
|
|
124
|
+
* Starting point of the route.
|
|
125
|
+
* Format: [longitude, latitude].
|
|
126
|
+
* If both `from` and `to` are provided, a route will be calculated.
|
|
127
|
+
*/
|
|
128
|
+
from?: [number, number];
|
|
129
|
+
/**
|
|
130
|
+
* Ending point of the route.
|
|
131
|
+
* Format: [longitude, latitude].
|
|
132
|
+
* If both `from` and `to` are provided, a route will be calculated.
|
|
133
|
+
*/
|
|
134
|
+
to?: [number, number];
|
|
135
|
+
/**
|
|
136
|
+
* Transportation profile used for route calculation.
|
|
137
|
+
* @default "driving"
|
|
138
|
+
*/
|
|
139
|
+
profile?: "driving" | "walking" | "cycling";
|
|
140
|
+
/**
|
|
141
|
+
* Custom styles for the itinerary line displayed on the map.
|
|
142
|
+
* If not provided, default styles will be used.
|
|
143
|
+
* @default { color: "#3b82f6", width: 4, opacity: 0.8 }
|
|
144
|
+
*/
|
|
145
|
+
itineraryLineStyle?: Partial<{
|
|
146
|
+
color: string;
|
|
147
|
+
width: number;
|
|
148
|
+
opacity: number;
|
|
149
|
+
}>;
|
|
103
150
|
}
|
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { VariantMarker } from '../Features/Markers/DefaultMarkers.tsx';
|
|
3
|
+
interface CustomMarkerMapProps {
|
|
4
|
+
geometry: {
|
|
5
|
+
coordinates: number[];
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
properties: {
|
|
9
|
+
description?: string;
|
|
10
|
+
id?: string | number;
|
|
11
|
+
size: number;
|
|
12
|
+
zIndex: number;
|
|
13
|
+
pointerEvents?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
iconProps?: Record<string, unknown>;
|
|
16
|
+
onClick?: (markerData?: CustomMarkerMapProps) => void;
|
|
17
|
+
IconComponent?: ComponentType<unknown>;
|
|
18
|
+
};
|
|
19
|
+
type: string;
|
|
20
|
+
}
|
|
3
21
|
export interface MarkerProps<T = Record<string, unknown>> {
|
|
4
22
|
/**
|
|
5
23
|
* Optional unique identifier for the marker.
|
|
@@ -58,4 +76,7 @@ export interface MarkerProps<T = Record<string, unknown>> {
|
|
|
58
76
|
* Overrides iconImage if provided.
|
|
59
77
|
*/
|
|
60
78
|
IconComponent?: ComponentType<any>;
|
|
79
|
+
color?: string;
|
|
80
|
+
variant?: string | VariantMarker;
|
|
61
81
|
}
|
|
82
|
+
export {};
|
|
@@ -1,42 +1,50 @@
|
|
|
1
1
|
import { MapOptions } from 'mapbox-gl';
|
|
2
|
+
import { BaseMapView } from '../constants/baseMap.ts';
|
|
2
3
|
interface MapOptionsProps {
|
|
3
4
|
mapStyle?: string;
|
|
4
5
|
projection?: MapOptions["projection"];
|
|
5
|
-
baseMapView?:
|
|
6
|
+
baseMapView?: BaseMapView;
|
|
6
7
|
cooperativeGestures?: boolean;
|
|
7
8
|
doubleClickZoom?: boolean;
|
|
8
9
|
theme?: "light" | "dark";
|
|
9
10
|
}
|
|
11
|
+
export declare const getBaseMapStyle: (baseMapView?: BaseMapView, theme?: "dark" | "light") => string;
|
|
10
12
|
/**
|
|
11
|
-
* Generates configuration options for initializing a Mapbox map
|
|
13
|
+
* Generates standardized configuration options for initializing a Mapbox map.
|
|
12
14
|
*
|
|
13
|
-
* This utility function
|
|
14
|
-
*
|
|
15
|
-
* - Center point calculation (with fallback to marker positions or default)
|
|
16
|
-
* - Style application
|
|
17
|
-
* - Initial zoom level
|
|
15
|
+
* This utility function returns a base configuration object compatible with **Mapbox GL JS**.
|
|
16
|
+
* It applies a default style based on the selected **base map view** and **theme** if no explicit style is provided.
|
|
18
17
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @param {string} [params.baseMapView] - Optional base map view type (default, satellite, streets, dark, 3d)
|
|
25
|
-
* @param {boolean} [params.cooperativeGestures=true] - Enable cooperative gestures (default: true)
|
|
26
|
-
* @param {boolean} [params.doubleClickZoom=true] - Enable double-click zoom (default: true)
|
|
18
|
+
* ### Features
|
|
19
|
+
* - Supports both **light** and **dark** themes.
|
|
20
|
+
* - Supports multiple base map types (e.g., streets, satellite).
|
|
21
|
+
* - Enables optional Mapbox interaction settings (e.g., cooperative gestures, double-click zoom).
|
|
22
|
+
* - Disables `failIfMajorPerformanceCaveat` by default for broader compatibility.
|
|
27
23
|
*
|
|
28
|
-
* @
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
24
|
+
* @param {Object} params - Configuration parameters.
|
|
25
|
+
* @param {string} [params.mapStyle] - Custom Mapbox style URL or specification.
|
|
26
|
+
* If not provided, a default style is derived from `baseMapView` and `theme`.
|
|
27
|
+
* @param {"light" | "dark"} [params.theme] - Theme mode that determines which default style to use.
|
|
28
|
+
* @param {BaseMapView} [params.baseMapView] - Base map view type (`"satellite"`, `"street"`, etc.).
|
|
29
|
+
* @param {boolean} [params.doubleClickZoom] - Enable or disable double-click zoom.
|
|
30
|
+
* @param {boolean} [params.cooperativeGestures] - Enable or disable cooperative gestures.
|
|
31
|
+
*
|
|
32
|
+
* @returns {Omit<MapOptions, "container"> & { style: string }} - A configuration object ready to be passed to the Mapbox constructor.
|
|
34
33
|
*
|
|
35
34
|
* @example
|
|
36
35
|
* const options = getCoreMapOptions({
|
|
37
|
-
*
|
|
38
|
-
*
|
|
36
|
+
* theme: "dark",
|
|
37
|
+
* baseMapView: "satellite",
|
|
38
|
+
* cooperativeGestures: true,
|
|
39
|
+
* doubleClickZoom: false,
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* new mapboxgl.Map({
|
|
43
|
+
* container: "map",
|
|
44
|
+
* ...options,
|
|
39
45
|
* });
|
|
40
46
|
*/
|
|
41
|
-
declare const getCoreMapOptions: ({ mapStyle, theme, baseMapView, doubleClickZoom, cooperativeGestures, }: MapOptionsProps) => Omit<MapOptions, "container"
|
|
47
|
+
declare const getCoreMapOptions: ({ mapStyle, theme, baseMapView, doubleClickZoom, cooperativeGestures, }: MapOptionsProps) => Omit<MapOptions, "container"> & {
|
|
48
|
+
style: string;
|
|
49
|
+
};
|
|
42
50
|
export default getCoreMapOptions;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "A React library to easily display map with multiple tools",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
|
-
"version": "1.1
|
|
6
|
+
"version": "1.2.1",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "dist/main.umd.cjs",
|
|
9
9
|
"module": "dist/main.js",
|
|
@@ -22,8 +22,14 @@
|
|
|
22
22
|
"lint:fix": "bunx biome check . --write",
|
|
23
23
|
"prepublishOnly": "bun run build",
|
|
24
24
|
"preview": "bunx vite preview",
|
|
25
|
-
"release": "bun run build && bun publish --access public",
|
|
26
|
-
"version": "bunx standard-version"
|
|
25
|
+
"release": "bun run build && bun publish --access example/public",
|
|
26
|
+
"version": "bunx standard-version",
|
|
27
|
+
"prepare": "husky",
|
|
28
|
+
"test": "bun test --preload ./test/setup.ts",
|
|
29
|
+
"test:watch": "bun test --watch --preload ./test/setup.ts",
|
|
30
|
+
"dev:example": "vite --config vite.config.example.ts",
|
|
31
|
+
"build:example": "vite build --config vite.config.example.ts",
|
|
32
|
+
"deploy:example": "bun run build:example && cp dist-example/index.html dist-example/404.html && gh-pages -d dist-example"
|
|
27
33
|
},
|
|
28
34
|
"files": [
|
|
29
35
|
"dist"
|
|
@@ -36,17 +42,28 @@
|
|
|
36
42
|
"@mui/x-license": "^8.6.0",
|
|
37
43
|
"@tracktor/design-system": "^4.3.1",
|
|
38
44
|
"@tracktor/react-utils": "^1.24.0",
|
|
39
|
-
"
|
|
45
|
+
"@types/react-map-gl": "^6.1.7",
|
|
46
|
+
"mapbox-gl": "^3.16.0",
|
|
47
|
+
"react-map-gl": "7.0.20"
|
|
40
48
|
},
|
|
41
49
|
"devDependencies": {
|
|
50
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
51
|
+
"@testing-library/react": "^16.3.0",
|
|
42
52
|
"@tracktor/biome-config-react": "^1.3.0",
|
|
53
|
+
"@types/jsdom": "^27.0.0",
|
|
43
54
|
"@types/mapbox-gl": "^3.4.1",
|
|
44
55
|
"@types/node": "^22.14.0",
|
|
45
56
|
"@types/react": "^19.0.0",
|
|
46
57
|
"@types/react-dom": "^19.0.0",
|
|
47
58
|
"@vitejs/plugin-react": "^4.6.0",
|
|
59
|
+
"bun-types": "^1.3.1",
|
|
60
|
+
"gh-pages": "^6.3.0",
|
|
61
|
+
"husky": "^9.1.7",
|
|
62
|
+
"jsdom": "^27.0.1",
|
|
63
|
+
"prism-react-renderer": "^2.4.1",
|
|
48
64
|
"react": "^19.0.0",
|
|
49
65
|
"react-dom": "^19.0.0",
|
|
66
|
+
"react-router-dom": "^7.9.4",
|
|
50
67
|
"standard-version": "^9.5.0",
|
|
51
68
|
"typescript": "~5.8.3",
|
|
52
69
|
"vite": "^7.0.0",
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
2
|
-
import { MarkerMapProps } from '../../types/MarkerMapProps.ts';
|
|
3
|
-
declare const _default: import('react').MemoExoticComponent<({ containerStyle, square, loading, height, width, ...props }: MarkerMapProps) => ReactElement>;
|
|
4
|
-
export default _default;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Map as MapboxMap } from 'mapbox-gl';
|
|
2
|
-
import { MarkerMapProps } from '../../types/MarkerMapProps';
|
|
3
|
-
export declare const DEFAULT_CENTER_LNG = 2.333;
|
|
4
|
-
export declare const DEFAULT_CENTER_LAT = 46.8677;
|
|
5
|
-
/**
|
|
6
|
-
* Custom React hook to integrate and manage a Mapbox map instance with dynamic markers,
|
|
7
|
-
* popups, zooming, centering, and click handling.
|
|
8
|
-
*
|
|
9
|
-
* This hook:
|
|
10
|
-
* - Initializes a Mapbox map inside a container
|
|
11
|
-
* - Loads and displays markers on the map
|
|
12
|
-
* - Adds popups to specific markers when requested
|
|
13
|
-
* - Adjusts the map center or fits bounds based on markers
|
|
14
|
-
* - Handles map click events with a provided callback
|
|
15
|
-
*/
|
|
16
|
-
declare const useMarkerMap: ({ markers, center, disableAnimation, openPopup, onMapClick, projection, theme, mapStyle, fitBoundsAnimationKey, baseMapView, zoom, fitBoundsPadding, fitBoundDuration, fitBounds, cooperativeGestures, doubleClickZoom, }: MarkerMapProps) => {
|
|
17
|
-
containerRef: import('react').RefObject<string | HTMLDivElement>;
|
|
18
|
-
currentTheme: import('@tracktor/design-system').PaletteMode;
|
|
19
|
-
isMapInitialized: boolean;
|
|
20
|
-
map: import('react').RefObject<MapboxMap | null>;
|
|
21
|
-
markers: import('../../main').MarkerProps<Record<string, unknown>>[];
|
|
22
|
-
};
|
|
23
|
-
export default useMarkerMap;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Map as MapboxMap } from 'mapbox-gl';
|
|
2
|
-
import { RefObject } from 'react';
|
|
3
|
-
import { MarkerProps } from '../types/MarkerProps.ts';
|
|
4
|
-
type useFitBoundsProps = {
|
|
5
|
-
map: RefObject<MapboxMap | null>;
|
|
6
|
-
disableAnimation: boolean | undefined;
|
|
7
|
-
fitBounds?: boolean;
|
|
8
|
-
fitBoundDuration?: number;
|
|
9
|
-
fitBoundsPadding?: number;
|
|
10
|
-
isMapInitialized: boolean;
|
|
11
|
-
markers?: MarkerProps[];
|
|
12
|
-
fitBoundsAnimationKey?: unknown;
|
|
13
|
-
};
|
|
14
|
-
declare const useFitBounds: ({ map, disableAnimation, fitBounds, markers, fitBoundDuration, fitBoundsPadding, isMapInitialized, fitBoundsAnimationKey, }: useFitBoundsProps) => void;
|
|
15
|
-
export default useFitBounds;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Palette } from '@tracktor/design-system';
|
|
2
|
-
import { LngLatLike, Map as MapboxMap } from 'mapbox-gl';
|
|
3
|
-
import { RefObject } from 'react';
|
|
4
|
-
import { MarkerProps } from '../types/MarkerProps.ts';
|
|
5
|
-
type UseInitializeMapProps = {
|
|
6
|
-
map: RefObject<MapboxMap | null>;
|
|
7
|
-
markers?: MarkerProps[];
|
|
8
|
-
palette: Palette;
|
|
9
|
-
isMapInitialized: boolean;
|
|
10
|
-
fitBounds?: boolean;
|
|
11
|
-
center?: LngLatLike | number[];
|
|
12
|
-
};
|
|
13
|
-
declare const useMarkers: ({ map, markers, palette, isMapInitialized, fitBounds, center }: UseInitializeMapProps) => void;
|
|
14
|
-
export default useMarkers;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { Map as MapboxMap } from 'mapbox-gl';
|
|
2
|
-
import { RefObject } from 'react';
|
|
3
|
-
type UseCorrectedMapClickProps = {
|
|
4
|
-
map: RefObject<MapboxMap | null>;
|
|
5
|
-
onMapClick?: (lng: number, lat: number) => void;
|
|
6
|
-
isMapInitialized?: boolean;
|
|
7
|
-
};
|
|
8
|
-
declare const useCorrectedMapClick: ({ map, onMapClick, isMapInitialized }: UseCorrectedMapClickProps) => void;
|
|
9
|
-
export default useCorrectedMapClick;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Map as MapboxMap } from 'mapbox-gl';
|
|
2
|
-
import { RefObject } from 'react';
|
|
3
|
-
import { MarkerProps } from '../types/MarkerProps';
|
|
4
|
-
type UsePopupsProps = {
|
|
5
|
-
map: RefObject<MapboxMap | null>;
|
|
6
|
-
markers?: MarkerProps[];
|
|
7
|
-
openPopup: string | number | undefined;
|
|
8
|
-
isMapInitialized: boolean;
|
|
9
|
-
};
|
|
10
|
-
declare const usePopups: ({ openPopup, map, markers, isMapInitialized }: UsePopupsProps) => void;
|
|
11
|
-
export default usePopups;
|
package/dist/utils/addPopup.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { Map as MapboxMap, Popup } from 'mapbox-gl';
|
|
2
|
-
import { ReactNode, RefObject } from 'react';
|
|
3
|
-
interface AddPopupProps {
|
|
4
|
-
coordinates?: [number, number];
|
|
5
|
-
tooltip?: ReactNode;
|
|
6
|
-
map: RefObject<MapboxMap | null>;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Adds a React-based popup to a Mapbox map
|
|
10
|
-
*
|
|
11
|
-
* This function creates and displays a popup on a Mapbox map with custom content rendered
|
|
12
|
-
* using React. The popup includes a styled close button and properly handles React component
|
|
13
|
-
* lifecycle to prevent memory leaks.
|
|
14
|
-
*
|
|
15
|
-
* @param {Object} options - The configuration options
|
|
16
|
-
* @param {MutableRefObject<Map | null>} options.map - Reference to the Mapbox map instance
|
|
17
|
-
* @param {ReactNode} [options.tooltip] - React node to render inside the popup
|
|
18
|
-
* @param {[number, number]} [options.coordinates] - [longitude, latitude] where the popup should appear
|
|
19
|
-
* @returns {void}
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* // Basic usage
|
|
23
|
-
* addPopup({
|
|
24
|
-
* map: mapRef,
|
|
25
|
-
* coordinates: [-73.985, 40.748],
|
|
26
|
-
* tooltip: <div>Empire State Building</div>
|
|
27
|
-
* });
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* // With complex React content
|
|
31
|
-
* addPopup({
|
|
32
|
-
* map: mapRef,
|
|
33
|
-
* coordinates: marker.position,
|
|
34
|
-
* tooltip: (
|
|
35
|
-
* <InfoWindow title={marker.title}>
|
|
36
|
-
* <p>{marker.description}</p>
|
|
37
|
-
* <button onClick={handleAction}>More Info</button>
|
|
38
|
-
* </InfoWindow>
|
|
39
|
-
* )
|
|
40
|
-
* });
|
|
41
|
-
*/
|
|
42
|
-
declare const addPopup: ({ map, tooltip, coordinates }: AddPopupProps) => Popup | null;
|
|
43
|
-
export default addPopup;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { LngLatLike } from 'mapbox-gl';
|
|
2
|
-
/**
|
|
3
|
-
* Converts coordinates to a format compatible with Mapbox's LngLatLike type
|
|
4
|
-
*
|
|
5
|
-
* This utility function ensures coordinates are properly formatted for Mapbox operations.
|
|
6
|
-
* It handles different input formats and converts them to the expected LngLatLike format,
|
|
7
|
-
* which requires longitude and latitude values in the form [lng, lat].
|
|
8
|
-
*
|
|
9
|
-
* @param {LngLatLike | number[] | undefined} center - Coordinates to convert, which can be:
|
|
10
|
-
* - LngLatLike object (already in Mapbox format)
|
|
11
|
-
* - number array in [longitude, latitude] format
|
|
12
|
-
* - undefined (no coordinates provided)
|
|
13
|
-
* @returns {LngLatLike | undefined} - Properly formatted coordinates or undefined if invalid
|
|
14
|
-
*/
|
|
15
|
-
declare const coordinateConverter: (center: LngLatLike | number[] | undefined) => LngLatLike | undefined;
|
|
16
|
-
export default coordinateConverter;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Map as MapboxMap, PointLike } from 'mapbox-gl';
|
|
2
|
-
import { RefObject } from 'react';
|
|
3
|
-
interface GetFeatureProps {
|
|
4
|
-
map: RefObject<MapboxMap | null>;
|
|
5
|
-
point: PointLike;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Handles map click events to display popups
|
|
9
|
-
*
|
|
10
|
-
* This function:
|
|
11
|
-
* 1. Detects if a GeoJSON marker was clicked
|
|
12
|
-
* 2. If a marker was clicked, displays its popup
|
|
13
|
-
* 3. If no marker was clicked, displays a popup at clicked location
|
|
14
|
-
*
|
|
15
|
-
* @param {GetFeatureProps} options - Configuration params
|
|
16
|
-
*/
|
|
17
|
-
declare const getFeature: ({ map, point }: GetFeatureProps) => (import('mapbox-gl').GeoJSONFeature & import('./typeguard').ClickedFeature) | null | undefined;
|
|
18
|
-
export default getFeature;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { Palette } from '@tracktor/design-system';
|
|
2
|
-
import { Map as MapboxMap } from 'mapbox-gl';
|
|
3
|
-
import { ComponentType, RefObject } from 'react';
|
|
4
|
-
import { MarkerProps } from '../types/MarkerProps.ts';
|
|
5
|
-
export interface CustomMarkerMapProps {
|
|
6
|
-
geometry: {
|
|
7
|
-
coordinates: number[];
|
|
8
|
-
type: string;
|
|
9
|
-
};
|
|
10
|
-
properties: {
|
|
11
|
-
description?: string;
|
|
12
|
-
id?: string | number;
|
|
13
|
-
size: number;
|
|
14
|
-
zIndex: number;
|
|
15
|
-
pointerEvents?: string;
|
|
16
|
-
name?: string;
|
|
17
|
-
iconProps?: Record<string, unknown>;
|
|
18
|
-
onClick?: (markerData?: CustomMarkerMapProps) => void;
|
|
19
|
-
IconComponent?: ComponentType<unknown>;
|
|
20
|
-
};
|
|
21
|
-
type: string;
|
|
22
|
-
}
|
|
23
|
-
interface GenerateMarkersProps {
|
|
24
|
-
palette: Palette;
|
|
25
|
-
type?: string;
|
|
26
|
-
}
|
|
27
|
-
interface LoadMarkersProps {
|
|
28
|
-
map: RefObject<MapboxMap | null>;
|
|
29
|
-
palette: Palette;
|
|
30
|
-
markers: MarkerProps[];
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Generates visual styles for map markers based on theme palette and marker type
|
|
34
|
-
*
|
|
35
|
-
* Creates consistent styling for different marker types with:
|
|
36
|
-
* - Dynamic color theming (light/dark mode support)
|
|
37
|
-
* - Type-specific visual differentiation
|
|
38
|
-
* - Responsive sizing
|
|
39
|
-
*
|
|
40
|
-
* @param {Object} params - Configuration parameters
|
|
41
|
-
* @param {Palette} params.palette - Design system color palette
|
|
42
|
-
* @param {string} [params.type] - Optional marker type identifier (e.g. "dropOff")
|
|
43
|
-
*
|
|
44
|
-
* @returns {Object} Mapbox GL paint properties object containing:
|
|
45
|
-
* - circle-color: Center fill color
|
|
46
|
-
* - circle-radius: Size of marker
|
|
47
|
-
* - circle-stroke-color: Border color
|
|
48
|
-
* - circle-stroke-width: Border thickness
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
* const markerStyle = generateMarkers({
|
|
52
|
-
* palette: theme.palette,
|
|
53
|
-
* type: "dropOff"
|
|
54
|
-
* });
|
|
55
|
-
*/
|
|
56
|
-
export declare const generateMarkers: ({ palette, type }: GenerateMarkersProps) => object;
|
|
57
|
-
/**
|
|
58
|
-
* Main entry point for loading markers onto a Mapbox GL map
|
|
59
|
-
*
|
|
60
|
-
* Orchestrates:
|
|
61
|
-
* - Data conversion to GeoJSON
|
|
62
|
-
* - Marker type classification
|
|
63
|
-
* - Parallel loading of different marker types
|
|
64
|
-
* - Loading state management
|
|
65
|
-
* - zIndex-based ordering
|
|
66
|
-
*
|
|
67
|
-
* @param {Object} params - Configuration parameters
|
|
68
|
-
* @param {MutableRefObject<Map|null>} params.map - React ref to Mapbox GL instance
|
|
69
|
-
* @param {Palette} params.palette - Design system color palette
|
|
70
|
-
* @param {MarkerProps[]} params.markers - Array of marker definitions
|
|
71
|
-
*/
|
|
72
|
-
export declare const loadMarkers: ({ map, palette, markers }: LoadMarkersProps) => void;
|
|
73
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
type Coordinates = [number, number];
|
|
2
|
-
interface GeometryPoint {
|
|
3
|
-
type: string;
|
|
4
|
-
coordinates: Coordinates;
|
|
5
|
-
}
|
|
6
|
-
interface FeatureProperties {
|
|
7
|
-
id: string | number;
|
|
8
|
-
[key: string]: unknown;
|
|
9
|
-
}
|
|
10
|
-
export interface ClickedFeature {
|
|
11
|
-
geometry: GeometryPoint;
|
|
12
|
-
properties: FeatureProperties;
|
|
13
|
-
[key: string]: unknown;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Type guard to check if the given geometry is a valid GeoJSON Point geometry
|
|
17
|
-
* @param geometry
|
|
18
|
-
*/
|
|
19
|
-
export declare const isFeatureGeometry: (geometry: unknown) => geometry is GeometryPoint;
|
|
20
|
-
/**
|
|
21
|
-
* Type guard to check if the given feature is a ClickedFeature
|
|
22
|
-
* @param feature
|
|
23
|
-
*/
|
|
24
|
-
export declare const isClickedFeature: (feature: unknown) => feature is ClickedFeature;
|
|
25
|
-
export {};
|