Skip to content

Commit

Permalink
refactor!:NativeUserLocation is deprecated use LocationPuck
Browse files Browse the repository at this point in the history
  • Loading branch information
mfazekas committed Dec 1, 2023
1 parent c0b52cc commit f2aa82d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
3 changes: 2 additions & 1 deletion __tests__/interface.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ describe('Public Interface', () => {
'Callout',
'Camera',
'UserLocation',
'NativeUserLocation',
'NativeUserLocation', // deprecated
'LocationPuck',
'StyleImport',
'Viewport',
'CustomLocationProvider',
Expand Down
6 changes: 5 additions & 1 deletion src/Mapbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export {
default as UserLocation,
UserLocationRenderMode,
} from './components/UserLocation';
export { default as NativeUserLocation } from './components/NativeUserLocation';
export { default as LocationPuck } from './components/LocationPuck';
export { default as VectorSource } from './components/VectorSource';
export { ShapeSource } from './components/ShapeSource';
export { default as RasterSource } from './components/RasterSource';
Expand Down Expand Up @@ -87,6 +87,7 @@ import { deprecatedClass } from './utils/deprecation';
import { AnimatedPoint } from './classes';
import { UserTrackingMode } from './components/Camera';
import MovePointShapeAnimator from './shape_animators/MovePointShapeAnimator';
import LocationPuck from './components/LocationPuck';

/** @deprecated This will be removed in a future release. Use `AnimatedPoint` instead. */

Expand All @@ -95,6 +96,9 @@ export const AnimatedMapPoint = deprecatedClass(
'AnimatedMapPoint is deprecated please use AnimatedPoint',
);

/** @deprecacated NativeUserLocation will be removed in future release. Use `LocationPuck` instead. */
export const NativeUserLocation = LocationPuck;

// types:
export enum StyleURL {
Street = 'mapbox://styles/mapbox/streets-v11',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,16 @@ const defaultProps = {
visible: true,
} as const;

const NativeUserLocation = memo((props: Props) => {
/**
* Renders a puck on the map that shows the device's current location.
*/
const LocationPuck = memo((props: Props) => {
const { iosShowsUserHeadingIndicator, pulsing, ...rest } = props;
const nativePulsing = pulsing ? _pulsingToNative(pulsing) : undefined;
let baseProps: NativeProps = { ...defaultProps, pulsing: nativePulsing };
if (iosShowsUserHeadingIndicator) {
console.warn(
'NativeUserLocation: iosShowsUserHeadingIndicator is deprecated, use puckBearingEnabled={true} puckBearing="heading" instead',
'LocationPuck: iosShowsUserHeadingIndicator is deprecated, use puckBearingEnabled={true} puckBearing="heading" instead',
);

baseProps = {
Expand Down Expand Up @@ -137,4 +140,4 @@ function _pulsingToNative(
};
}

export default NativeUserLocation;
export default LocationPuck;
2 changes: 1 addition & 1 deletion src/components/UserLocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CircleLayerStyle } from '../Mapbox';
import Annotation from './Annotation';
import CircleLayer from './CircleLayer';
import HeadingIndicator from './HeadingIndicator';
import NativeUserLocation from './NativeUserLocation';
import NativeUserLocation from './LocationPuck';

const mapboxBlue = 'rgba(51, 181, 229, 100)';

Expand Down

0 comments on commit f2aa82d

Please sign in to comment.