@local-logic/maps 0.0.5 → 0.0.7

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.
Files changed (153) hide show
  1. package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
  2. package/dist/index-7D9tjwUD.js +29 -0
  3. package/dist/index-B43MtiHH.js +30 -0
  4. package/dist/index-BZ2605rA.js +39 -0
  5. package/dist/index-C7t1isWh.js +29 -0
  6. package/dist/index-CIUYCbof.js +42 -0
  7. package/dist/index-CPq7k7F4.js +63 -0
  8. package/dist/index-CSXMNubL.js +47 -0
  9. package/dist/index-CTk5bvm9.js +155 -0
  10. package/dist/index-CXjxZmYt.js +144 -0
  11. package/dist/index-CwZ22Kq_.js +676 -0
  12. package/dist/index-D0VvNlqV.js +29 -0
  13. package/dist/index-DVitM43i.js +137 -0
  14. package/dist/index-FSH3b4mt.js +64 -0
  15. package/dist/index-J1MKzGEM.js +31 -0
  16. package/dist/index-qqbvBkdn.js +7 -0
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.es.js +4 -0
  19. package/dist/index.modern-EsUgbhzI.js +908 -0
  20. package/dist/index.umd.js +3181 -0
  21. package/dist/logo-control-NE-LlsRy.js +607 -0
  22. package/dist/mapbox-gl-D58OubwB.js +32266 -0
  23. package/dist/maplibre-gl-CfOZKUDd.js +20722 -0
  24. package/dist/scale-control-CyJd4u6j.js +716 -0
  25. package/dist/src/components/Map/Root/BaseMap/Empty/index.d.ts +3 -0
  26. package/dist/src/components/Map/Root/BaseMap/Empty/index.d.ts.map +1 -0
  27. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts +11 -0
  28. package/dist/src/components/Map/Root/BaseMap/Google/index.d.ts.map +1 -0
  29. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts +4 -0
  30. package/dist/src/components/Map/Root/BaseMap/Mapbox/index.d.ts.map +1 -0
  31. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts +4 -0
  32. package/dist/src/components/Map/Root/BaseMap/Maptiler/index.d.ts.map +1 -0
  33. package/dist/src/components/Map/Root/BaseMap/index.d.ts +4 -0
  34. package/dist/src/components/Map/Root/BaseMap/index.d.ts.map +1 -0
  35. package/dist/src/components/Map/Root/BaseMap/styles.d.ts +2 -0
  36. package/dist/src/components/Map/Root/BaseMap/styles.d.ts.map +1 -0
  37. package/dist/src/components/Map/Root/BaseMap/types.d.ts +3 -0
  38. package/dist/src/components/Map/Root/BaseMap/types.d.ts.map +1 -0
  39. package/dist/src/components/Map/Root/Layers/Google/index.d.ts +4 -0
  40. package/dist/src/components/Map/Root/Layers/Google/index.d.ts.map +1 -0
  41. package/dist/src/components/Map/Root/Layers/Mapbox/index.d.ts +4 -0
  42. package/dist/src/components/Map/Root/Layers/Mapbox/index.d.ts.map +1 -0
  43. package/dist/src/components/Map/Root/Layers/Maptiler/index.d.ts +4 -0
  44. package/dist/src/components/Map/Root/Layers/Maptiler/index.d.ts.map +1 -0
  45. package/dist/src/components/Map/Root/Layers/index.d.ts +4 -0
  46. package/dist/src/components/Map/Root/Layers/index.d.ts.map +1 -0
  47. package/dist/src/components/Map/Root/Layers/types.d.ts +13 -0
  48. package/dist/src/components/Map/Root/Layers/types.d.ts.map +1 -0
  49. package/dist/src/components/Map/Root/Layers/utils.d.ts +6 -0
  50. package/dist/src/components/Map/Root/Layers/utils.d.ts.map +1 -0
  51. package/dist/src/components/Map/Root/Markers/Cluster/index.d.ts +6 -0
  52. package/dist/src/components/Map/Root/Markers/Cluster/index.d.ts.map +1 -0
  53. package/dist/src/components/Map/Root/Markers/Cluster/styles.d.ts +2 -0
  54. package/dist/src/components/Map/Root/Markers/Cluster/styles.d.ts.map +1 -0
  55. package/dist/src/components/Map/Root/Markers/Google/index.d.ts +4 -0
  56. package/dist/src/components/Map/Root/Markers/Google/index.d.ts.map +1 -0
  57. package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts +4 -0
  58. package/dist/src/components/Map/Root/Markers/Mapbox/index.d.ts.map +1 -0
  59. package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts +4 -0
  60. package/dist/src/components/Map/Root/Markers/Maptiler/index.d.ts.map +1 -0
  61. package/dist/src/components/Map/Root/Markers/index.d.ts +4 -0
  62. package/dist/src/components/Map/Root/Markers/index.d.ts.map +1 -0
  63. package/dist/src/components/Map/Root/Markers/styles.d.ts +5 -0
  64. package/dist/src/components/Map/Root/Markers/styles.d.ts.map +1 -0
  65. package/dist/src/components/Map/Root/Markers/types.d.ts +28 -0
  66. package/dist/src/components/Map/Root/Markers/types.d.ts.map +1 -0
  67. package/dist/src/components/Map/Root/Popup/Google/index.d.ts +4 -0
  68. package/dist/src/components/Map/Root/Popup/Google/index.d.ts.map +1 -0
  69. package/dist/src/components/Map/Root/Popup/Mapbox/index.d.ts +4 -0
  70. package/dist/src/components/Map/Root/Popup/Mapbox/index.d.ts.map +1 -0
  71. package/dist/src/components/Map/Root/Popup/Maptiler/index.d.ts +4 -0
  72. package/dist/src/components/Map/Root/Popup/Maptiler/index.d.ts.map +1 -0
  73. package/dist/src/components/Map/Root/Popup/index.d.ts +4 -0
  74. package/dist/src/components/Map/Root/Popup/index.d.ts.map +1 -0
  75. package/dist/src/components/Map/Root/Popup/styles.d.ts +2 -0
  76. package/dist/src/components/Map/Root/Popup/styles.d.ts.map +1 -0
  77. package/dist/src/components/Map/Root/Popup/types.d.ts +10 -0
  78. package/dist/src/components/Map/Root/Popup/types.d.ts.map +1 -0
  79. package/dist/src/components/Map/Root/constants.d.ts +12 -0
  80. package/dist/src/components/Map/Root/constants.d.ts.map +1 -0
  81. package/dist/src/components/Map/Root/context.d.ts +11 -0
  82. package/dist/src/components/Map/Root/context.d.ts.map +1 -0
  83. package/dist/src/components/Map/Root/index.d.ts +8 -0
  84. package/dist/src/components/Map/Root/index.d.ts.map +1 -0
  85. package/dist/src/components/Map/Root/types.d.ts +26 -0
  86. package/dist/src/components/Map/Root/types.d.ts.map +1 -0
  87. package/dist/src/components/Map/index.d.ts +5 -0
  88. package/dist/src/components/Map/index.d.ts.map +1 -0
  89. package/dist/src/components/Map/index.stories.d.ts +8 -0
  90. package/dist/src/components/Map/index.stories.d.ts.map +1 -0
  91. package/dist/src/components/Map/index.test.d.ts +2 -0
  92. package/dist/src/components/Map/index.test.d.ts.map +1 -0
  93. package/dist/src/components/Map/storybook-data.d.ts +4 -0
  94. package/dist/src/components/Map/storybook-data.d.ts.map +1 -0
  95. package/dist/src/index.d.ts +2 -0
  96. package/dist/src/index.d.ts.map +1 -0
  97. package/dist/style.css +1 -0
  98. package/{src/components/Map/Root/Popup/styles.ts → dist/styles-uPzJnzVS.js} +4 -1
  99. package/dist/utils-YqJg0vBb.js +25 -0
  100. package/package.json +15 -3
  101. package/.env.example +0 -3
  102. package/.storybook/defaults.ts +0 -40
  103. package/.storybook/globals.css +0 -40
  104. package/.storybook/main.ts +0 -19
  105. package/.storybook/preview.tsx +0 -27
  106. package/CHANGELOG.md +0 -33
  107. package/eslint.config.mjs +0 -46
  108. package/lint-staged.config.cjs +0 -4
  109. package/postcss.config.cjs +0 -6
  110. package/prettier.config.cjs +0 -1
  111. package/src/components/Map/Root/BaseMap/Empty/index.tsx +0 -7
  112. package/src/components/Map/Root/BaseMap/Google/index.tsx +0 -96
  113. package/src/components/Map/Root/BaseMap/Mapbox/index.tsx +0 -66
  114. package/src/components/Map/Root/BaseMap/Maptiler/index.tsx +0 -59
  115. package/src/components/Map/Root/BaseMap/index.tsx +0 -34
  116. package/src/components/Map/Root/BaseMap/styles.ts +0 -1
  117. package/src/components/Map/Root/BaseMap/types.ts +0 -3
  118. package/src/components/Map/Root/Layers/Google/index.tsx +0 -97
  119. package/src/components/Map/Root/Layers/Mapbox/index.tsx +0 -74
  120. package/src/components/Map/Root/Layers/Maptiler/index.tsx +0 -74
  121. package/src/components/Map/Root/Layers/index.tsx +0 -32
  122. package/src/components/Map/Root/Layers/types.ts +0 -15
  123. package/src/components/Map/Root/Layers/utils.ts +0 -64
  124. package/src/components/Map/Root/Markers/Cluster/index.tsx +0 -27
  125. package/src/components/Map/Root/Markers/Cluster/styles.ts +0 -11
  126. package/src/components/Map/Root/Markers/Google/index.tsx +0 -49
  127. package/src/components/Map/Root/Markers/Mapbox/index.tsx +0 -52
  128. package/src/components/Map/Root/Markers/Maptiler/index.tsx +0 -52
  129. package/src/components/Map/Root/Markers/index.tsx +0 -81
  130. package/src/components/Map/Root/Markers/styles.ts +0 -39
  131. package/src/components/Map/Root/Markers/types.ts +0 -32
  132. package/src/components/Map/Root/Popup/Google/index.tsx +0 -57
  133. package/src/components/Map/Root/Popup/Google/popup.css +0 -15
  134. package/src/components/Map/Root/Popup/Mapbox/index.tsx +0 -36
  135. package/src/components/Map/Root/Popup/Mapbox/popup.css +0 -15
  136. package/src/components/Map/Root/Popup/Maptiler/index.tsx +0 -37
  137. package/src/components/Map/Root/Popup/Maptiler/popup.css +0 -15
  138. package/src/components/Map/Root/Popup/index.tsx +0 -32
  139. package/src/components/Map/Root/Popup/types.ts +0 -20
  140. package/src/components/Map/Root/constants.ts +0 -6
  141. package/src/components/Map/Root/context.tsx +0 -15
  142. package/src/components/Map/Root/index.tsx +0 -30
  143. package/src/components/Map/Root/types.ts +0 -30
  144. package/src/components/Map/index.stories.tsx +0 -134
  145. package/src/components/Map/index.test.tsx +0 -16
  146. package/src/components/Map/index.tsx +0 -1
  147. package/src/components/Map/storybook-data.ts +0 -255
  148. package/src/index.ts +0 -1
  149. package/tailwind.config.cjs +0 -1
  150. package/tsconfig.json +0 -14
  151. package/tsconfig.node.json +0 -8
  152. package/vite-env.d.ts +0 -13
  153. package/vite.config.ts +0 -46
@@ -1,49 +0,0 @@
1
- import React from "react";
2
-
3
- import { MapPin } from "@phosphor-icons/react";
4
- import { AdvancedMarker as GoogleMarker } from "@vis.gl/react-google-maps";
5
-
6
- import type { MapMarkerProps } from "../types";
7
-
8
- import { Cluster } from "../Cluster";
9
-
10
- import * as globalStyles from "../styles";
11
-
12
- export default function GoogleMarkers({ clusters, onClick, children }: MapMarkerProps) {
13
- return clusters?.map((cluster, index) => {
14
- const longitude = cluster.geometry.coordinates[0];
15
- const latitude = cluster.geometry.coordinates[1];
16
-
17
- const handleOnClick = () => {
18
- onClick?.(cluster);
19
- };
20
-
21
- return (
22
- <GoogleMarker
23
- key={`map-marker-${longitude}-${latitude}-${index}`}
24
- position={{
25
- lat: latitude,
26
- lng: longitude,
27
- }}
28
- onClick={handleOnClick}
29
- >
30
- <div className={globalStyles.container} data-is-cluster={!!cluster.properties.cluster}>
31
- {cluster.properties.cluster ? (
32
- <Cluster cluster={cluster} />
33
- ) : (
34
- <>
35
- <div className={globalStyles.iconWrapper}>
36
- {cluster.properties.icon ? (
37
- <cluster.properties.icon className={globalStyles.icon} />
38
- ) : (
39
- <MapPin className={globalStyles.icon} />
40
- )}
41
- </div>
42
- {children}
43
- </>
44
- )}
45
- </div>
46
- </GoogleMarker>
47
- );
48
- });
49
- }
@@ -1,52 +0,0 @@
1
- import React from "react";
2
-
3
- import { MapPin } from "@phosphor-icons/react";
4
- import { Marker as MapboxMarker, type MarkerEvent } from "react-map-gl/mapbox";
5
-
6
- import type { MapMarkerProps } from "../types";
7
-
8
- import { Cluster } from "../Cluster";
9
-
10
- import * as styles from "../styles";
11
-
12
- export default function MapboxMarkers({ clusters, onClick, children }: MapMarkerProps) {
13
- return clusters?.map((cluster, index) => {
14
- const longitude = cluster.geometry.coordinates[0];
15
- const latitude = cluster.geometry.coordinates[1];
16
-
17
- const handleOnClick = (event: MarkerEvent<MouseEvent>) => {
18
- // If we let the click event propagates to the map, it will immediately close the popup
19
- // with `closeOnClick: true`
20
- // https://github.com/visgl/react-map-gl/blob/bdfcfd2d6cfdc641cddb5337d7ed477e5c3c28d5/examples/controls/src/app.tsx#L31-36
21
- event.originalEvent.stopPropagation();
22
- onClick?.(cluster);
23
- };
24
-
25
- return (
26
- <MapboxMarker
27
- key={`map-marker-${longitude}-${latitude}-${index}`}
28
- anchor="bottom"
29
- longitude={longitude}
30
- latitude={latitude}
31
- onClick={handleOnClick}
32
- >
33
- <div className={styles.container} data-is-cluster={!!cluster.properties.cluster}>
34
- {cluster.properties.cluster ? (
35
- <Cluster cluster={cluster} />
36
- ) : (
37
- <>
38
- <div className={styles.iconWrapper}>
39
- {cluster.properties.icon ? (
40
- <cluster.properties.icon className={styles.icon} />
41
- ) : (
42
- <MapPin className={styles.icon} />
43
- )}
44
- </div>
45
- {children}
46
- </>
47
- )}
48
- </div>
49
- </MapboxMarker>
50
- );
51
- });
52
- }
@@ -1,52 +0,0 @@
1
- import React from "react";
2
-
3
- import { MapPin } from "@phosphor-icons/react";
4
- import { Marker as MaplibreMarker, type MarkerEvent } from "react-map-gl/maplibre";
5
-
6
- import type { MapMarkerProps } from "../types";
7
-
8
- import { Cluster } from "../Cluster";
9
-
10
- import * as styles from "../styles";
11
-
12
- export default function MaptilerMarkers({ clusters, onClick, children }: MapMarkerProps) {
13
- return clusters?.map((cluster, index) => {
14
- const longitude = cluster.geometry.coordinates[0];
15
- const latitude = cluster.geometry.coordinates[1];
16
-
17
- const handleOnClick = (event: MarkerEvent<MouseEvent>) => {
18
- // If we let the click event propagates to the map, it will immediately close the popup
19
- // with `closeOnClick: true`
20
- // https://github.com/visgl/react-map-gl/blob/bdfcfd2d6cfdc641cddb5337d7ed477e5c3c28d5/examples/controls/src/app.tsx#L31-36
21
- event.originalEvent.stopPropagation();
22
- onClick?.(cluster);
23
- };
24
-
25
- return (
26
- <MaplibreMarker
27
- key={`map-marker-${longitude}-${latitude}-${index}`}
28
- anchor="bottom"
29
- longitude={longitude}
30
- latitude={latitude}
31
- onClick={handleOnClick}
32
- >
33
- <div className={styles.container} data-is-cluster={!!cluster.properties.cluster}>
34
- {cluster.properties.cluster ? (
35
- <Cluster cluster={cluster} />
36
- ) : (
37
- <>
38
- <div className={styles.iconWrapper}>
39
- {cluster.properties.icon ? (
40
- <cluster.properties.icon className={styles.icon} />
41
- ) : (
42
- <MapPin className={styles.icon} />
43
- )}
44
- </div>
45
- {children}
46
- </>
47
- )}
48
- </div>
49
- </MaplibreMarker>
50
- );
51
- });
52
- }
@@ -1,81 +0,0 @@
1
- import React, { lazy, useMemo } from "react";
2
-
3
- import { point } from "@turf/turf";
4
-
5
- import useSupercluser from "use-supercluster";
6
-
7
- import { useRootElement } from "../context";
8
-
9
- import type { MarkerProps, MapMarkerProps, ClusterPoint, MarkerPoint } from "./types";
10
-
11
- import * as styles from "./styles";
12
-
13
- const MaptilerMarkers = lazy(() => import("./Maptiler"));
14
- const GoogleMarkers = lazy(() => import("./Google"));
15
- const MapboxMarkers = lazy(() => import("./Mapbox"));
16
-
17
- export const Markers = ({ markers, onClick, ...rest }: MarkerProps) => {
18
- const { mapProvider, bounds } = useRootElement();
19
- const { clusters, supercluster } = useSupercluser({
20
- points: markers.map((marker) => point([marker.longitude, marker.latitude], marker)),
21
- bounds,
22
- zoom: 16,
23
- options: { radius: 50, maxZoom: 30 },
24
- });
25
-
26
- const handleOnClick: MapMarkerProps["onClick"] = (cluster) => {
27
- if (!("properties" in cluster)) {
28
- throw new Error("Cluster does not have properties");
29
- }
30
-
31
- if (cluster.properties?.cluster && typeof cluster.properties?.cluster_id === "number") {
32
- onClick?.({
33
- id: `${cluster.properties.cluster_id}`,
34
- latitude: cluster.geometry.coordinates[1],
35
- longitude: cluster.geometry.coordinates[0],
36
- markers: (supercluster
37
- ?.getChildren(cluster.properties.cluster_id)
38
- ?.map((child) => child.properties) ?? []) as MarkerPoint[],
39
- });
40
- return;
41
- }
42
-
43
- onClick?.({
44
- id: cluster.properties.id,
45
- latitude: cluster.properties.latitude,
46
- longitude: cluster.properties.longitude,
47
- markers: [cluster.properties],
48
- });
49
- };
50
-
51
- const BaseMarkers = useMemo(() => {
52
- switch (mapProvider?.name) {
53
- case "maptiler":
54
- return MaptilerMarkers;
55
- case "google":
56
- return GoogleMarkers;
57
- case "mapbox":
58
- return MapboxMarkers;
59
- default:
60
- return null;
61
- }
62
- }, [mapProvider]);
63
-
64
- if (!BaseMarkers) {
65
- return null;
66
- }
67
-
68
- return (
69
- <>
70
- <BaseMarkers clusters={clusters as ClusterPoint[]} onClick={handleOnClick} {...rest}>
71
- {/* POI Pin Background */}
72
- <svg viewBox="0 0 20 28" fill="none" className={styles.background}>
73
- <path
74
- d="M20 10C20 15.5228 12 27.5 10 27.5C8 27.5 0 15.5228 0 10C0 4.47715 4.47715 0 10 0C15.5228 0 20 4.47715 20 10Z"
75
- fill="inherit"
76
- />
77
- </svg>
78
- </BaseMarkers>
79
- </>
80
- );
81
- };
@@ -1,39 +0,0 @@
1
- export const container = `
2
- cursor-pointer
3
- relative
4
- h-7
5
- w-5
6
- text-base-white
7
- group
8
- transition-transform
9
-
10
- data-[is-cluster=true]:w-auto
11
- `;
12
-
13
- export const background = `
14
- cursor-pointer
15
- fill-primary-100
16
- stroke-1
17
- box-border
18
- transition-colors
19
- transition-transform
20
- group-hover:stroke-base-white
21
- group-focus:stroke-base-white
22
- `;
23
-
24
- export const iconWrapper = `
25
- absolute top-1 left-1/2 transform -translate-x-1/2
26
- flex justify-center items-center rounded-full overflow-hidden
27
- transition-all w-3.5 h-3.5
28
-
29
- group-hover:bg-base-white
30
- `;
31
-
32
- export const icon = `
33
- m-auto transition-all w-full h-full
34
- max-w-3.5 max-h-3.5
35
-
36
- group-hover:text-primary-100
37
- group-hover:max-w-2.5
38
- group-hover:max-h-2.5
39
- `;
@@ -1,32 +0,0 @@
1
- import type { ReactNode } from "react";
2
- import type { PointFeature, ClusterProperties } from "supercluster";
3
- import type { Icon } from "@phosphor-icons/react";
4
- import type { Coordinates } from "../types";
5
-
6
- export type ClusterPoint = PointFeature<ClusterProperties & Marker>;
7
-
8
- export type Marker = {
9
- id: string;
10
- latitude: Coordinates["latitude"];
11
- longitude: Coordinates["longitude"];
12
- name?: string;
13
- icon?: Icon;
14
- };
15
-
16
- export type MarkerPoint = {
17
- id: string;
18
- latitude: number;
19
- longitude: number;
20
- markers: Marker[];
21
- };
22
-
23
- export type MarkerProps = {
24
- markers: Marker[];
25
- onClick?: (markers: MarkerPoint) => void;
26
- children?: ReactNode;
27
- };
28
-
29
- export type MapMarkerProps = Omit<MarkerProps, "markers"> & {
30
- clusters: ClusterPoint[];
31
- onClick: (cluster: ClusterPoint) => void;
32
- };
@@ -1,57 +0,0 @@
1
- import React, { useMemo, useEffect } from "react";
2
-
3
- import { useMap, InfoWindow } from "@vis.gl/react-google-maps";
4
-
5
- import { PopupProps } from "../types";
6
-
7
- import "./popup.css";
8
- import * as styles from "../styles";
9
-
10
- export default function GooglePopup({
11
- latitude,
12
- longitude,
13
- offset = [0, -25],
14
- onClose,
15
- children,
16
- }: PopupProps) {
17
- const map = useMap();
18
-
19
- useEffect(() => {
20
- if (!map) return;
21
-
22
- const listener = map.addListener("click", () => {
23
- onClose?.();
24
- });
25
-
26
- // eslint-disable-next-line consistent-return
27
- return () => {
28
- listener.remove();
29
- };
30
- }, [map]);
31
-
32
- const pixelOffset: [number, number] = useMemo(() => {
33
- if (Array.isArray(offset)) {
34
- return [offset[0], offset[1]];
35
- }
36
-
37
- return [offset, offset];
38
- }, [offset]);
39
-
40
- if (typeof latitude === "undefined" || typeof longitude === "undefined") {
41
- return null;
42
- }
43
-
44
- return (
45
- <InfoWindow
46
- shouldFocus
47
- position={{
48
- lat: latitude,
49
- lng: longitude,
50
- }}
51
- pixelOffset={pixelOffset}
52
- onClose={onClose}
53
- >
54
- <div className={styles.container}>{children}</div>
55
- </InfoWindow>
56
- );
57
- }
@@ -1,15 +0,0 @@
1
- .gm-style .gm-style-iw-chr,
2
- .gm-style .gm-style-iw-tc {
3
- display: none;
4
- }
5
-
6
- .gm-style .gm-style-iw-d {
7
- overflow: hidden;
8
- }
9
-
10
- .gm-style .gm-style-iw-c {
11
- border: none;
12
- outline: none;
13
- padding: 0;
14
- border-radius: 8px;
15
- }
@@ -1,36 +0,0 @@
1
- import React from "react";
2
-
3
- import { Popup } from "react-map-gl/mapbox";
4
-
5
- import { PopupProps } from "../types";
6
-
7
- import "./popup.css";
8
- import * as styles from "../styles";
9
-
10
- export default function MapboxPopup({
11
- latitude,
12
- longitude,
13
- anchor,
14
- offset = [0, -35],
15
- onClose,
16
- children,
17
- }: PopupProps) {
18
- if (typeof latitude === "undefined" || typeof longitude === "undefined") {
19
- return null;
20
- }
21
-
22
- return (
23
- <Popup
24
- className="mapbox-popup"
25
- focusAfterOpen
26
- latitude={latitude}
27
- longitude={longitude}
28
- anchor={anchor}
29
- offset={offset}
30
- onClose={onClose}
31
- closeButton={false}
32
- >
33
- <div className={styles.container}>{children}</div>
34
- </Popup>
35
- );
36
- }
@@ -1,15 +0,0 @@
1
- .mapbox-popup {
2
- background: transparent;
3
- }
4
-
5
- .mapbox-popup .mapboxgl-popup-tip {
6
- display: none;
7
- }
8
-
9
- .mapbox-popup .mapboxgl-popup-content {
10
- background: transparent;
11
- border: none;
12
- outline: none;
13
- padding: 0;
14
- border-radius: 8px;
15
- }
@@ -1,37 +0,0 @@
1
- import React from "react";
2
-
3
- import { Popup } from "react-map-gl/maplibre";
4
-
5
- import { PopupProps } from "../types";
6
-
7
- import "./popup.css";
8
- import * as styles from "../styles";
9
-
10
- export default function MaptilerPopup({
11
- latitude,
12
- longitude,
13
- anchor,
14
- offset = [0, -35],
15
- onClose,
16
- children,
17
- }: PopupProps) {
18
- if (typeof latitude === "undefined" || typeof longitude === "undefined") {
19
- return null;
20
- }
21
-
22
- return (
23
- <Popup
24
- key="maplibre-popup"
25
- className="maplibre-popup"
26
- focusAfterOpen
27
- latitude={latitude}
28
- longitude={longitude}
29
- anchor={anchor}
30
- offset={offset}
31
- onClose={onClose}
32
- closeButton={false}
33
- >
34
- <div className={styles.container}>{children}</div>
35
- </Popup>
36
- );
37
- }
@@ -1,15 +0,0 @@
1
- .maplibre-popup {
2
- background: transparent;
3
- }
4
-
5
- .maplibre-popup .maplibregl-popup-tip {
6
- display: none;
7
- }
8
-
9
- .maplibre-popup .maplibregl-popup-content {
10
- background: transparent;
11
- border: none;
12
- outline: none;
13
- padding: 0;
14
- border-radius: 8px;
15
- }
@@ -1,32 +0,0 @@
1
- import React, { lazy, useMemo } from "react";
2
-
3
- import { PopupProps } from "./types";
4
-
5
- import { useRootElement } from "../context";
6
-
7
- const MaptilerPopup = lazy(() => import("./Maptiler"));
8
- const GooglePopup = lazy(() => import("./Google"));
9
- const MapboxPopup = lazy(() => import("./Mapbox"));
10
-
11
- export function Popup({ children, ...rest }: PopupProps) {
12
- const { mapProvider } = useRootElement();
13
-
14
- const BasePopup = useMemo(() => {
15
- switch (mapProvider?.name) {
16
- case "maptiler":
17
- return MaptilerPopup;
18
- case "google":
19
- return GooglePopup;
20
- case "mapbox":
21
- return MapboxPopup;
22
- default:
23
- return null;
24
- }
25
- }, [mapProvider]);
26
-
27
- if (!BasePopup) {
28
- return null;
29
- }
30
-
31
- return <BasePopup {...rest}>{children}</BasePopup>;
32
- }
@@ -1,20 +0,0 @@
1
- import type { ReactNode } from "react";
2
-
3
- export type PopupProps = {
4
- latitude?: number;
5
- longitude?: number;
6
- // Anchor only works for Maplibre and Mapbox
7
- anchor?:
8
- | "center"
9
- | "left"
10
- | "right"
11
- | "top"
12
- | "bottom"
13
- | "top-left"
14
- | "top-right"
15
- | "bottom-left"
16
- | "bottom-right";
17
- offset?: number | [number, number];
18
- onClose?: () => void;
19
- children?: ReactNode;
20
- };
@@ -1,6 +0,0 @@
1
- export const defaultMapValues = {
2
- zoom: 16,
3
- pitch: 0,
4
- bearing: 0,
5
- cooperativeGestures: false,
6
- };
@@ -1,15 +0,0 @@
1
- import React, { useContext } from "react";
2
- import type { BBox } from "geojson";
3
- import type { RootProps } from "./types";
4
-
5
- export type DefaultContext = RootProps & {
6
- bounds?: BBox;
7
- setBounds: (bounds: BBox) => void;
8
- };
9
-
10
- const RootElementContext = React.createContext<DefaultContext>(
11
- {} as DefaultContext,
12
- );
13
- const useRootElement = () => useContext(RootElementContext);
14
-
15
- export { useRootElement, RootElementContext };
@@ -1,30 +0,0 @@
1
- import React, { useState } from "react";
2
- import type { RootProps } from "./types";
3
- import { RootElementContext, type DefaultContext } from "./context";
4
-
5
- export function Root(props: RootProps) {
6
- const [bounds, setBounds] = useState<DefaultContext["bounds"]>();
7
-
8
- return (
9
- <RootElementContext.Provider value={{ ...props, bounds, setBounds }}>
10
- {props.children}
11
- </RootElementContext.Provider>
12
- );
13
- }
14
-
15
- // BASE MAP
16
- export { BaseMap } from "./BaseMap";
17
-
18
- // MARKERS
19
- export { Markers } from "./Markers";
20
- export type { MarkerProps, Marker, MarkerPoint } from "./Markers/types";
21
-
22
- // POPUP
23
- export { Popup } from "./Popup";
24
-
25
- // LAYERS
26
- export { Layers } from "./Layers";
27
- export type { Source, Layer } from "./Layers/types";
28
-
29
- // OTHER
30
- export type { RootProps };
@@ -1,30 +0,0 @@
1
- import type { ReactNode } from "react";
2
-
3
- /**
4
- * We should try to keep the types "agnostic" but if we have to pick a side,
5
- * we should side with the maptiler namings.
6
- */
7
-
8
- export type MapProvider = {
9
- apiKey: string;
10
- name: "maptiler" | "google" | "mapbox";
11
- maptilerTheme?: string;
12
- };
13
-
14
- export type Coordinates = {
15
- latitude: number;
16
- longitude: number;
17
- };
18
-
19
- export type ZoomPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right";
20
-
21
- export type RootProps = {
22
- mapProvider: MapProvider;
23
- center: Coordinates;
24
- zoom?: number;
25
- zoomPosition?: ZoomPosition;
26
- pitch?: number;
27
- bearing?: number;
28
- cooperativeGestures?: boolean;
29
- children?: ReactNode;
30
- };