Skip to content

Commit

Permalink
ShareDialog: Add support for Open Location Codes
Browse files Browse the repository at this point in the history
Related to #834

via #834

Written with the new Copilot Workspace AI tool. :-)

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/zbycz/osmapp/issues/834?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
zbycz committed Jan 10, 2025
1 parent c41f739 commit f6da3a9
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ActionButtons } from './ActionButtons';
import styled from '@emotion/styled';
import { t } from '../../../../services/intl';
import { useMobileMode } from '../../../helpers';
import { encode } from 'open-location-code';

const useCoords = () => {
const { feature } = useFeatureContext();
Expand All @@ -14,6 +15,7 @@ const useCoords = () => {
return {
deg: positionToDeg(center),
dm: positionToDM(center),
olc: encode(center[1], center[0]),
};
};

Expand All @@ -23,7 +25,7 @@ const StyledSelect = styled(Select<string>)`
`;

export const CoordinateSection = () => {
const { deg, dm } = useCoords();
const { deg, dm, olc } = useCoords();
const [selected, setSelected] = React.useState(deg);

const onChange = ({ target }) => {
Expand All @@ -48,6 +50,7 @@ export const CoordinateSection = () => {
>
<MenuItem value={deg}>{deg}</MenuItem>
<MenuItem value={dm}>{dm}</MenuItem>
<MenuItem value={olc}>{olc}</MenuItem>
</StyledSelect>
<ActionButtons payload={selected} type="text" />
</Stack>
Expand Down

0 comments on commit f6da3a9

Please sign in to comment.