@dxos/react-ui-geo 0.7.5-main.ff8607b → 0.7.5-staging.2ff1350
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/lib/browser/index.mjs +87 -35
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +91 -39
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +87 -35
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Globe/Globe.d.ts +5 -5
- package/dist/types/src/components/Globe/Globe.d.ts.map +1 -1
- package/dist/types/src/components/Globe/Globe.stories.d.ts +9 -10
- package/dist/types/src/components/Globe/Globe.stories.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.d.ts +4 -4
- package/dist/types/src/components/Map/Map.d.ts.map +1 -1
- package/dist/types/src/components/Map/Map.stories.d.ts +6 -2
- package/dist/types/src/components/Map/Map.stories.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Controls.d.ts +2 -3
- package/dist/types/src/components/Toolbar/Controls.d.ts.map +1 -1
- package/dist/types/src/hooks/context.d.ts +2 -2
- package/dist/types/src/hooks/context.d.ts.map +1 -1
- package/dist/types/src/util/debug.d.ts.map +1 -1
- package/dist/types/src/util/render.d.ts +2 -2
- package/dist/types/src/util/render.d.ts.map +1 -1
- package/package.json +15 -14
- package/src/components/Globe/Globe.stories.tsx +5 -5
- package/src/components/Globe/Globe.tsx +56 -32
- package/src/components/Map/Map.stories.tsx +28 -6
- package/src/components/Map/Map.tsx +17 -3
- package/src/hooks/context.tsx +5 -5
- package/src/util/debug.ts +1 -0
- package/src/util/render.ts +18 -4
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// eslint-disable-next-line no-restricted-imports
|
|
6
6
|
import 'leaflet/dist/leaflet.css';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import L from 'leaflet';
|
|
9
9
|
import { type ControlPosition, Control, DomEvent, DomUtil, type LatLngExpression, latLngBounds } from 'leaflet';
|
|
10
10
|
import React, { forwardRef, type PropsWithChildren, useEffect, useImperativeHandle } from 'react';
|
|
11
11
|
import { createRoot } from 'react-dom/client';
|
|
@@ -127,10 +127,24 @@ const MapCanvas = forwardRef<MapController, MapCanvasProps>(
|
|
|
127
127
|
/>
|
|
128
128
|
|
|
129
129
|
{/* Markers. */}
|
|
130
|
-
{/* TODO(burdon): Marker icon doesn't load on mobile? */}
|
|
131
130
|
{markers.map(({ id, title, location: { lat, lng } }) => {
|
|
132
131
|
return (
|
|
133
|
-
<Marker
|
|
132
|
+
<Marker
|
|
133
|
+
key={id}
|
|
134
|
+
position={{ lat, lng }}
|
|
135
|
+
icon={
|
|
136
|
+
// TODO(burdon): Create custom icon from bundled assets.
|
|
137
|
+
new L.Icon({
|
|
138
|
+
iconUrl: 'https://dxos.network/marker-icon.png',
|
|
139
|
+
iconRetinaUrl: 'https://dxos.network/marker-icon-2x.png',
|
|
140
|
+
shadowUrl: 'https://dxos.network/marker-shadow.png',
|
|
141
|
+
iconSize: [25, 41],
|
|
142
|
+
iconAnchor: [12, 41],
|
|
143
|
+
popupAnchor: [1, -34],
|
|
144
|
+
shadowSize: [41, 41],
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
>
|
|
134
148
|
{title && <Popup>{title}</Popup>}
|
|
135
149
|
</Marker>
|
|
136
150
|
);
|
package/src/hooks/context.tsx
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React, { createContext, type Dispatch, type PropsWithChildren, type SetStateAction, useContext } from 'react';
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
|
-
import {
|
|
8
|
+
import { useControlledState } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
10
|
import { type LatLng } from '../util';
|
|
11
11
|
|
|
@@ -40,10 +40,10 @@ export const GlobeContextProvider = ({
|
|
|
40
40
|
translation: _translation,
|
|
41
41
|
rotation: _rotation,
|
|
42
42
|
}: GlobeContextProviderProps) => {
|
|
43
|
-
const [center, setCenter] =
|
|
44
|
-
const [scale, setScale] =
|
|
45
|
-
const [translation, setTranslation] =
|
|
46
|
-
const [rotation, setRotation] =
|
|
43
|
+
const [center, setCenter] = useControlledState(_center);
|
|
44
|
+
const [scale, setScale] = useControlledState(_scale);
|
|
45
|
+
const [translation, setTranslation] = useControlledState<Point>(_translation);
|
|
46
|
+
const [rotation, setRotation] = useControlledState<Vector>(_rotation);
|
|
47
47
|
|
|
48
48
|
return (
|
|
49
49
|
<GlobeContext.Provider
|
package/src/util/debug.ts
CHANGED
package/src/util/render.ts
CHANGED
|
@@ -11,7 +11,17 @@ import { type LatLng, geoLine, geoPoint } from './path';
|
|
|
11
11
|
|
|
12
12
|
export type Styles = Record<string, any>;
|
|
13
13
|
|
|
14
|
-
export type Style =
|
|
14
|
+
export type Style =
|
|
15
|
+
| 'background'
|
|
16
|
+
| 'water'
|
|
17
|
+
| 'graticule'
|
|
18
|
+
| 'land'
|
|
19
|
+
| 'border'
|
|
20
|
+
| 'dots'
|
|
21
|
+
| 'point'
|
|
22
|
+
| 'line'
|
|
23
|
+
| 'cursor'
|
|
24
|
+
| 'arc';
|
|
15
25
|
|
|
16
26
|
export type StyleSet = Partial<Record<Style, Styles>>;
|
|
17
27
|
|
|
@@ -108,16 +118,20 @@ export const createLayers = (topology: Topology, features: Features, styles: Sty
|
|
|
108
118
|
/**
|
|
109
119
|
* Render layers created above.
|
|
110
120
|
*/
|
|
111
|
-
export const renderLayers = (generator: GeoPath, layers: Layer[] = [], scale: number) => {
|
|
121
|
+
export const renderLayers = (generator: GeoPath, layers: Layer[] = [], scale: number, styles: StyleSet) => {
|
|
112
122
|
const context: CanvasRenderingContext2D = generator.context();
|
|
113
123
|
const {
|
|
114
124
|
canvas: { width, height },
|
|
115
125
|
} = context;
|
|
116
126
|
context.reset();
|
|
117
127
|
|
|
118
|
-
// TODO(burdon): Option.
|
|
119
128
|
// Clear background.
|
|
120
|
-
|
|
129
|
+
if (styles.background) {
|
|
130
|
+
context.fillStyle = styles.background.fillStyle;
|
|
131
|
+
context.fillRect(0, 0, width, height);
|
|
132
|
+
} else {
|
|
133
|
+
context.clearRect(0, 0, width, height);
|
|
134
|
+
}
|
|
121
135
|
|
|
122
136
|
// Render features.
|
|
123
137
|
// https://github.com/d3/d3-geo#_path
|