• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

terrestris / react-geo / 12950341541

24 Jan 2025 01:12PM UTC coverage: 58.073%. First build
12950341541

Pull #4070

github

web-flow
Merge 6ce69a17c into de3b56555
Pull Request #4070: chore(eslint): upgrade to v9 and fix resulting lint errors / issues

494 of 962 branches covered (51.35%)

Branch coverage included in aggregate %.

13 of 18 new or added lines in 14 files covered. (72.22%)

995 of 1602 relevant lines covered (62.11%)

11.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

80.0
/src/Button/GeoLocationButton/GeoLocationButton.tsx
1
import React, {
2
  FC
3
} from 'react';
4

5
import {
6
  type GeoLocation,
7
  useGeoLocation
8
} from '@terrestris/react-util/dist/Hooks/useGeoLocation/useGeoLocation';
9

10
import { CSS_PREFIX } from '../../constants';
11
import ToggleButton, { ToggleButtonProps } from '../ToggleButton/ToggleButton';
12

13
interface OwnProps {
14
  trackingOptions?: PositionOptions;
15
  /**
16
   * Will be called if geolocation fails.
17
   */
18
  onError?: () => void;
19
  /**
20
   * Will be called when position changes. Receives an object with the properties
21
   * position, accuracy, heading and speed
22
   */
23
  onGeoLocationChange?: (geolocation: GeoLocation) => void;
24
  /**
25
   * Whether to show a map marker at the current position.
26
   */
27
  showMarker?: boolean;
28
  /**
29
   * Whether to follow the current position.
30
   */
31
  follow?: boolean;
32
  /**
33
   * Enable tracking of GeoLocations
34
   */
35
  enableTracking?: boolean;
36
}
37

38
export type GeoLocationButtonProps = OwnProps & Partial<ToggleButtonProps>;
39

40
export const GeoLocationButton: FC<GeoLocationButtonProps> = ({
1✔
41
  className,
42
  enableTracking = false,
2✔
43
  follow = false,
14✔
44
  onError = () => undefined,
✔
NEW
45
  onGeoLocationChange = () => undefined,
✔
46
  pressed,
47
  showMarker = true,
1✔
48
  trackingOptions,
49
  ...passThroughProps
50
}) => {
51

52
  useGeoLocation({
14✔
53
    active: !!pressed,
54
    enableTracking: pressed && enableTracking,
20✔
55
    follow,
56
    onError,
57
    onGeoLocationChange,
58
    showMarker,
59
    trackingOptions
60
  });
61

62
  const finalClassName = className
14!
63
    ? `${className} ${CSS_PREFIX}geolocationbutton`
64
    : `${CSS_PREFIX}geolocationbutton`;
65

66
  return (
14✔
67
    <ToggleButton
68
      pressed={pressed}
69
      className={finalClassName}
70
      {...passThroughProps}
71
    />
72
  );
73
};
74

75
export default GeoLocationButton;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc