@tpzdsp/next-toolkit 1.2.8 → 1.2.9
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/package.json +1 -1
- package/src/map/MapComponent.tsx +2 -35
- package/src/utils/http.ts +1 -0
- package/src/utils/index.ts +0 -1
package/package.json
CHANGED
package/src/map/MapComponent.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import { LayerSwitcherControl } from './LayerSwitcherControl';
|
|
|
12
12
|
import { useMap } from './MapContext';
|
|
13
13
|
import { Popup } from './Popup';
|
|
14
14
|
import { getPopupPositionClass } from './utils';
|
|
15
|
-
import type {
|
|
15
|
+
import type { PopupDirection } from '../types/map';
|
|
16
16
|
|
|
17
17
|
export type MapComponentProps = {
|
|
18
18
|
osMapsApiKey?: string;
|
|
@@ -63,8 +63,6 @@ export const MapComponent = ({
|
|
|
63
63
|
mapRef,
|
|
64
64
|
mapConfig: { center, zoom },
|
|
65
65
|
setMap,
|
|
66
|
-
setMapConfig,
|
|
67
|
-
map,
|
|
68
66
|
isDrawing,
|
|
69
67
|
} = useMap();
|
|
70
68
|
|
|
@@ -159,42 +157,11 @@ export const MapComponent = ({
|
|
|
159
157
|
});
|
|
160
158
|
});
|
|
161
159
|
|
|
162
|
-
|
|
163
|
-
setMap(newMap);
|
|
164
|
-
}
|
|
160
|
+
setMap(newMap);
|
|
165
161
|
|
|
166
|
-
return () => {
|
|
167
|
-
newMap?.setTarget();
|
|
168
|
-
};
|
|
169
162
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
170
163
|
}, []); // This is a rare case where we want to run this only once.
|
|
171
164
|
|
|
172
|
-
// Update map config when map is moved
|
|
173
|
-
useEffect(() => {
|
|
174
|
-
if (!map) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
const view = map.getView();
|
|
179
|
-
const moveHandler = () => {
|
|
180
|
-
const center = view.getCenter();
|
|
181
|
-
|
|
182
|
-
if (center) {
|
|
183
|
-
setMapConfig((prev: MapConfig) => ({
|
|
184
|
-
...prev,
|
|
185
|
-
center,
|
|
186
|
-
zoom: view.getZoom()!,
|
|
187
|
-
}));
|
|
188
|
-
}
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
map.on('moveend', moveHandler);
|
|
192
|
-
|
|
193
|
-
return () => {
|
|
194
|
-
map.un('moveend', moveHandler);
|
|
195
|
-
};
|
|
196
|
-
}, [map, setMapConfig]);
|
|
197
|
-
|
|
198
165
|
const closePopup = () => {
|
|
199
166
|
setPopupFeatures([]);
|
|
200
167
|
setPopupCoordinate(null);
|
package/src/utils/http.ts
CHANGED
package/src/utils/index.ts
CHANGED