Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Mapbox from '@rnmapbox/maps';
import {DirectionProps} from './MapViewTypes';
import styles from '../../styles/styles';
import {DirectionProps} from '../MapViewTypes';
import styles from '../../../styles/styles';

function Direction({coordinates}: DirectionProps) {
if (coordinates.length < 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import React from 'react';
import {View} from 'react-native';
import {Layer, Source} from 'react-map-gl';
import {DirectionProps} from './MapViewTypes';
import {DirectionProps} from '../MapViewTypes';

import styles from '../../styles/styles';
import styles from '../../../styles/styles';

function Direction({coordinates}: DirectionProps) {
const layerLayoutStyle: Record<string, string> = styles.mapDirectionLayer.layout;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from '../../styles/styles';

import responder from './responder';
import utils from './utils';
import Direction from './Direction';
import Direction from './index.native';
import CONST from '../../CONST';

import {MapViewProps, MapViewHandle} from './MapViewTypes';
Expand All @@ -15,12 +15,12 @@ const MapView = forwardRef<MapViewHandle, MapViewProps>(({accessToken, style, ma
const cameraRef = useRef<Mapbox.Camera>(null);
const [isIdle, setIsIdle] = useState(false);

useImperativeHandle(
useImperativeHandle<MapViewHandle, MapViewHandle>(
ref,
() => ({
flyTo: (location: [number, number], zoomLevel: number = CONST.MAPBOX.DEFAULT_ZOOM, animationDuration?: number) =>
cameraRef.current?.setCamera({zoomLevel, centerCoordinate: location, animationDuration}),
fitBounds: (northEast: [number, number], southWest: [number, number], paddingConfig?: number | number[] | undefined, animationDuration?: number | undefined) =>
flyTo: (location, zoomLevel, animationDuration) =>
cameraRef.current?.setCamera({zoomLevel: zoomLevel ?? CONST.MAPBOX.DEFAULT_ZOOM, centerCoordinate: location, animationDuration}),
fitBounds: (northEast, southWest, paddingConfig, animationDuration) =>
cameraRef.current?.fitBounds(northEast, southWest, paddingConfig, animationDuration),
}),
[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ const MapView = forwardRef<MapViewHandle, MapViewProps>(
map.fitBounds([northEast, southWest], {padding: mapPadding});
}, [waypoints, mapRef, mapPadding]);

useImperativeHandle(
useImperativeHandle<MapViewHandle, MapViewHandle>(
ref,
() => ({
flyTo: (location: [number, number], zoomLevel: number = CONST.MAPBOX.DEFAULT_ZOOM, animationDuration?: number) =>
flyTo: (location, zoomLevel, animationDuration) =>
mapRef?.flyTo({
center: location,
zoom: zoomLevel,
zoom: zoomLevel ?? CONST.MAPBOX.DEFAULT_ZOOM,
duration: animationDuration,
}),
fitBounds: (northEast: [number, number], southWest: [number, number]) => mapRef?.fitBounds([northEast, southWest]),
fitBounds: (northEast, southWest) => mapRef?.fitBounds([northEast, southWest]),
}),
[mapRef],
);
Expand Down