@tracktor/map 0.1.0
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/LICENSE +15 -0
- package/README.md +104 -0
- package/dist/components/MapBox/MapBox.d.ts +10 -0
- package/dist/components/MarkerMap/MarkerMap.d.ts +3 -0
- package/dist/components/MarkerMap/useMarkerMap.d.ts +11 -0
- package/dist/context/MapProvider.d.ts +11 -0
- package/dist/main.d.ts +6 -0
- package/dist/main.js +973 -0
- package/dist/main.umd.cjs +31 -0
- package/dist/types/MarkerMap.d.ts +89 -0
- package/dist/types/Markers.d.ts +15 -0
- package/dist/types/typeguard.d.ts +19 -0
- package/dist/utils/addPopup.d.ts +15 -0
- package/dist/utils/coordinateConverter.d.ts +7 -0
- package/dist/utils/handleMapClick.d.ts +15 -0
- package/dist/utils/loadMarkers.d.ts +35 -0
- package/dist/utils/mapOptions.d.ts +33 -0
- package/package.json +53 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
The ISC License (ISC)
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2025 Tracktor
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
14
|
+
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
15
|
+
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# 📍 MarkerMap - React Map Library
|
|
2
|
+
|
|
3
|
+
**MarkerMap** is a React library built on top of Mapbox GL JS. It simplifies rendering interactive maps with customizable markers in your React applications.
|
|
4
|
+
|
|
5
|
+
## 🚀 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @tracktor/map
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @tracktor/map
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## 📦 Dependencies
|
|
18
|
+
|
|
19
|
+
This library depends on:
|
|
20
|
+
|
|
21
|
+
- `@tracktor/design-system` for theming and styling
|
|
22
|
+
- `mapbox-gl` for map rendering
|
|
23
|
+
- React 18+
|
|
24
|
+
|
|
25
|
+
## 🔧 Usage
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import MarkerMap from "@tracktor/map";
|
|
29
|
+
|
|
30
|
+
const markers = [
|
|
31
|
+
{
|
|
32
|
+
id: 1,
|
|
33
|
+
lng: 2.3522,
|
|
34
|
+
lat: 48.8566,
|
|
35
|
+
Tooltip: <div>Paris</div>,
|
|
36
|
+
iconImage: "marker-icon.png",
|
|
37
|
+
size: 40,
|
|
38
|
+
onClick: () => alert("Marker clicked!"),
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
<MarkerMap
|
|
43
|
+
markers={markers}
|
|
44
|
+
center={[2.3522, 48.8566]}
|
|
45
|
+
zoom={10}
|
|
46
|
+
fitBounds
|
|
47
|
+
height={400}
|
|
48
|
+
width="100%"
|
|
49
|
+
/>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 🧩 Props
|
|
53
|
+
|
|
54
|
+
### MarkerMap Props
|
|
55
|
+
|
|
56
|
+
| Prop | Type | Description |
|
|
57
|
+
|--------------------|----------------------------------|-------------------------------------------------------------------------|
|
|
58
|
+
| `markers` | `MarkerProps[]` | List of markers to display |
|
|
59
|
+
| `center` | `LngLatLike` or `[number, number]` | Initial map center coordinates |
|
|
60
|
+
| `zoom` | `number` | Initial zoom level |
|
|
61
|
+
| `fitBounds` | `boolean` | Automatically fit the map to the bounds of all markers |
|
|
62
|
+
| `fitBoundsPadding` | `number` | Padding around markers when fitting bounds |
|
|
63
|
+
| `zoomFlyFrom` | `number` | Zoom level to fly in from |
|
|
64
|
+
| `popupMaxWidth` | `string` | Max width for popups |
|
|
65
|
+
| `width` | `number` or `string` | Map width |
|
|
66
|
+
| `height` | `number` or `string` | Map height |
|
|
67
|
+
| `loading` | `boolean` | Whether to show a loading state |
|
|
68
|
+
| `markerImageURL` | `string` | Default marker image URL |
|
|
69
|
+
| `containerStyle` | `SxProps` | Custom styles for the map container |
|
|
70
|
+
| `disableFlyTo` | `boolean` | Disable flyTo animation on marker click |
|
|
71
|
+
| `flyToDuration` | `number` | Duration of the flyTo animation |
|
|
72
|
+
| `fitBoundDuration` | `number` | Duration of the fitBounds animation |
|
|
73
|
+
| `square` | `boolean` | Forces the map to be square-shaped |
|
|
74
|
+
| `openPopup` | `number` or `string` | ID of the marker with an open popup |
|
|
75
|
+
| `openPopupOnHover` | `boolean` | Automatically open popups on marker hover |
|
|
76
|
+
| `onMapClick` | `(lng: number, lat: number) => void` | Callback triggered when clicking on the map |
|
|
77
|
+
|
|
78
|
+
### MarkerProps
|
|
79
|
+
|
|
80
|
+
| Prop | Type | Description |
|
|
81
|
+
|-------------|----------------------|---------------------------------------------------------------|
|
|
82
|
+
| `id` | `number` or `string` | Unique marker identifier |
|
|
83
|
+
| `lng` | `number` | Longitude |
|
|
84
|
+
| `lat` | `number` | Latitude |
|
|
85
|
+
| `Tooltip` | `ReactNode` | Tooltip content displayed in a popup |
|
|
86
|
+
| `iconImage` | `string` | Image URL used as marker icon |
|
|
87
|
+
| `size` | `number` | Marker size in pixels |
|
|
88
|
+
| `zIndex` | `number` | Z-index to control stacking order |
|
|
89
|
+
| `onClick` | `() => void` | Function triggered on marker click |
|
|
90
|
+
| `type` | `string` | Custom marker type (optional, for filtering or styling) |
|
|
91
|
+
| `name` | `string` | Name of the marker |
|
|
92
|
+
| `Icon` | `ReactNode` | Custom React component to render instead of default image |
|
|
93
|
+
|
|
94
|
+
## 🖼 Visual Example
|
|
95
|
+
|
|
96
|
+
<img src="./src/assets/example.png" alt="MarkerMap Example" width="400" />
|
|
97
|
+
|
|
98
|
+
## 🧑💻 Contributing
|
|
99
|
+
|
|
100
|
+
Contributions are welcome! Please follow the coding conventions and include tests when necessary.
|
|
101
|
+
|
|
102
|
+
## 📄 License
|
|
103
|
+
|
|
104
|
+
MIT © [Kevin Graff / Tracktor]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SxProps } from '@tracktor/design-system';
|
|
2
|
+
interface MapBoxProps {
|
|
3
|
+
width?: number | string;
|
|
4
|
+
height?: number | string;
|
|
5
|
+
loading?: boolean;
|
|
6
|
+
containerStyle?: SxProps;
|
|
7
|
+
square?: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: import('react').ForwardRefExoticComponent<MapBoxProps & import('react').RefAttributes<HTMLElement>>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Map } from 'mapbox-gl';
|
|
2
|
+
import { MarkerMapProps } from '../../types/MarkerMap.tsx';
|
|
3
|
+
export declare const DEFAULT_CENTER_LNG = 2.333;
|
|
4
|
+
export declare const DEFAULT_CENTER_LAT = 46.8677;
|
|
5
|
+
declare const useMarkerMap: ({ markers, loading, center, flyToDuration, fitBoundDuration, fitBounds, disableFlyTo, fitBoundsPadding, mapStyle, zoom, zoomFlyFrom, openPopup, onMapClick, }: MarkerMapProps) => {
|
|
6
|
+
loading: boolean | undefined;
|
|
7
|
+
map: import('react').RefObject<Map | null>;
|
|
8
|
+
mapContainer: import('react').RefObject<HTMLDivElement | null>;
|
|
9
|
+
markers: import('../../main').MarkerProps[] | undefined;
|
|
10
|
+
};
|
|
11
|
+
export default useMarkerMap;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
interface MapProviderContextProps {
|
|
3
|
+
licenseMuiX?: string;
|
|
4
|
+
licenceMapbox?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface MapProviderProps extends MapProviderContextProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const MapProviderContext: import('react').Context<MapProviderContextProps>;
|
|
10
|
+
export declare const MapProvider: ({ children, licenseMuiX, licenceMapbox }: MapProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default MapProvider;
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as MarkerMap } from './components/MarkerMap/MarkerMap';
|
|
2
|
+
export * from './components/MarkerMap/MarkerMap';
|
|
3
|
+
export { default as MapProvider } from './context/MapProvider';
|
|
4
|
+
export * from './context/MapProvider';
|
|
5
|
+
export * from './types/Markers';
|
|
6
|
+
export * from './types/MarkerMap';
|