react-native-maplibre-lite 0.2.2 → 0.2.3
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/README.md +12 -0
- package/lib/module/components/MapView.js +23 -3
- package/lib/module/components/MapView.js.map +1 -1
- package/lib/module/components/types.js +2 -0
- package/lib/module/components/types.js.map +1 -1
- package/lib/module/components/webMapBuild.js +1 -1
- package/lib/module/components/webMapBuild.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/MapView.d.ts +9 -0
- package/lib/typescript/src/components/MapView.d.ts.map +1 -1
- package/lib/typescript/src/components/types.d.ts +7 -0
- package/lib/typescript/src/components/types.d.ts.map +1 -1
- package/lib/typescript/src/components/webMapBuild.d.ts +1 -1
- package/lib/typescript/src/components/webMapBuild.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/resources/map.html +43 -43
- package/src/components/MapView.tsx +26 -2
- package/src/components/types.ts +6 -0
- package/src/components/webMapBuild.ts +1 -1
- package/src/index.tsx +1 -0
|
@@ -122,6 +122,13 @@ interface MapViewProps {
|
|
|
122
122
|
* стороне. Без него озвучка и FAB выбора голоса отключены.
|
|
123
123
|
*/
|
|
124
124
|
navigatorVoiceUrl?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Dev-only: автоматически вести маркер по построенному маршруту
|
|
127
|
+
* (симуляция поездки для отладки). Требует `navigator: true`. Пока
|
|
128
|
+
* включено, реальный GPS в WebView не пробрасывается, чтобы не
|
|
129
|
+
* конфликтовать с симуляцией.
|
|
130
|
+
*/
|
|
131
|
+
navigatorSimulate?: boolean;
|
|
125
132
|
onNavigatorRouteSet?: (params: NavigatorRouteSetParams) => void;
|
|
126
133
|
onNavigatorInstruction?: (params: NavigatorInstructionParams) => void;
|
|
127
134
|
onNavigatorPositionSet?: (params: NavigatorPositionSetParams) => void;
|
|
@@ -150,6 +157,8 @@ export type MapViewRef = {
|
|
|
150
157
|
setNavigatorPosition: (latitude: number, longitude: number, accuracy?: number) => void;
|
|
151
158
|
/** Режим «клик по карте = новая позиция» (удобно в dev). */
|
|
152
159
|
pickNavigatorPosition: () => void;
|
|
160
|
+
/** Dev-only: включить/выключить симуляцию поездки по маршруту. */
|
|
161
|
+
setNavigatorSimulation: (enabled: boolean) => void;
|
|
153
162
|
};
|
|
154
163
|
|
|
155
164
|
type MapViewRegistry = {
|
|
@@ -437,6 +446,10 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>((props, ref) => {
|
|
|
437
446
|
sendToWebView({ function: 'recenterNavigatorCamera', params: {} });
|
|
438
447
|
};
|
|
439
448
|
|
|
449
|
+
const setNavigatorSimulation = (enabled: boolean) => {
|
|
450
|
+
sendToWebView({ function: 'setNavigatorSimulation', params: { enabled } });
|
|
451
|
+
};
|
|
452
|
+
|
|
440
453
|
useImperativeHandle(ref, () => ({
|
|
441
454
|
fitBounds,
|
|
442
455
|
flyTo,
|
|
@@ -444,6 +457,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>((props, ref) => {
|
|
|
444
457
|
advanceNavigatorInstruction,
|
|
445
458
|
setNavigatorPosition,
|
|
446
459
|
pickNavigatorPosition,
|
|
460
|
+
setNavigatorSimulation,
|
|
447
461
|
}), [fitBounds]);
|
|
448
462
|
|
|
449
463
|
|
|
@@ -563,7 +577,17 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>((props, ref) => {
|
|
|
563
577
|
};
|
|
564
578
|
|
|
565
579
|
useEffect(() => {
|
|
566
|
-
if (!props.navigator) {
|
|
580
|
+
if (!inited || !props.navigator) {
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
sendToWebViewRef.current({
|
|
584
|
+
function: 'setNavigatorSimulation',
|
|
585
|
+
params: { enabled: !!props.navigatorSimulate },
|
|
586
|
+
});
|
|
587
|
+
}, [inited, props.navigator, props.navigatorSimulate]);
|
|
588
|
+
|
|
589
|
+
useEffect(() => {
|
|
590
|
+
if (!props.navigator || props.navigatorSimulate) {
|
|
567
591
|
return;
|
|
568
592
|
}
|
|
569
593
|
|
|
@@ -615,7 +639,7 @@ export const MapView = forwardRef<MapViewRef, MapViewProps>((props, ref) => {
|
|
|
615
639
|
return () => {
|
|
616
640
|
Geolocation.clearWatch(watchId);
|
|
617
641
|
};
|
|
618
|
-
}, [props.navigator]);
|
|
642
|
+
}, [props.navigator, props.navigatorSimulate]);
|
|
619
643
|
|
|
620
644
|
return (
|
|
621
645
|
<View style={props.style}>
|
package/src/components/types.ts
CHANGED
|
@@ -238,6 +238,11 @@ export type MapLiteSetNavigatorPositionParams = {
|
|
|
238
238
|
accuracy?: number,
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
+
/** RN → Web: `setNavigatorSimulation`. Отладочная симуляция поездки по маршруту. */
|
|
242
|
+
export type MapLiteSetNavigatorSimulationParams = {
|
|
243
|
+
enabled: boolean,
|
|
244
|
+
}
|
|
245
|
+
|
|
241
246
|
/** RN → Web: JSON в `WebView.postMessage` (`webProject/src/map/MapLiteController.receive`). */
|
|
242
247
|
export type NativeToWebCommand =
|
|
243
248
|
| { function: 'init', params: MapLiteInitParams }
|
|
@@ -255,6 +260,7 @@ export type NativeToWebCommand =
|
|
|
255
260
|
| { function: 'setNavigatorPosition', params: MapLiteSetNavigatorPositionParams }
|
|
256
261
|
| { function: 'pickNavigatorPosition', params: Record<string, never> }
|
|
257
262
|
| { function: 'recenterNavigatorCamera', params: Record<string, never> }
|
|
263
|
+
| { function: 'setNavigatorSimulation', params: MapLiteSetNavigatorSimulationParams }
|
|
258
264
|
|
|
259
265
|
/** Web → RN: `postToNative` (`webProject/src/map/types.ts`). */
|
|
260
266
|
export type WebToNativeMessage =
|