Tests for getGeoUri (#7400)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
f389324571
commit
bd226cd062
2 changed files with 96 additions and 10 deletions
|
@ -185,21 +185,12 @@ class LocationPicker extends React.Component<IProps, IState> {
|
|||
this.setState({ description: ev.target.value });
|
||||
};
|
||||
|
||||
private getGeoUri = (position) => {
|
||||
return (`geo:${ position.coords.latitude },` +
|
||||
position.coords.longitude +
|
||||
( position.coords.altitude !== undefined ?
|
||||
`,${ position.coords.altitude }` : '' ) +
|
||||
( position.coords.accuracy !== undefined ?
|
||||
`;u=${ position.coords.accuracy }` : '' ));
|
||||
};
|
||||
|
||||
private onOk = () => {
|
||||
const position = (this.state.type == LocationShareType.Custom) ?
|
||||
this.state.manualPosition : this.state.position;
|
||||
|
||||
this.props.onChoose(
|
||||
position ? this.getGeoUri(position) : undefined,
|
||||
position ? getGeoUri(position) : undefined,
|
||||
position ? position.timestamp : undefined,
|
||||
this.state.type,
|
||||
this.state.description,
|
||||
|
@ -263,4 +254,13 @@ class LocationPicker extends React.Component<IProps, IState> {
|
|||
}
|
||||
}
|
||||
|
||||
export function getGeoUri(position: GeolocationPosition): string {
|
||||
return (`geo:${ position.coords.latitude },` +
|
||||
position.coords.longitude +
|
||||
( position.coords.altitude !== undefined ?
|
||||
`,${ position.coords.altitude }` : '' ) +
|
||||
( position.coords.accuracy !== undefined ?
|
||||
`;u=${ position.coords.accuracy }` : '' ));
|
||||
}
|
||||
|
||||
export default LocationPicker;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue