diff --git a/package.json b/package.json
index 828868030..3ec7f3f2d 100644
--- a/package.json
+++ b/package.json
@@ -71,6 +71,7 @@
"is-hotkey": "^0.2.0",
"jotai": "^2.18.0",
"katex": "^0.16.45",
+ "leaflet": "1.9.4",
"linkify-react": "^4.3.2",
"linkifyjs": "^4.3.2",
"marked": "^18.0.2",
@@ -84,6 +85,7 @@
"react-dom": "^18.3.1",
"react-google-recaptcha": "^2.1.0",
"react-i18next": "^16.5.4",
+ "react-leaflet": "^4.2.1",
"react-range": "^1.10.0",
"react-router-dom": "^6.30.3",
"slate": "^0.123.0",
@@ -107,6 +109,7 @@
"@types/chroma-js": "^3.1.2",
"@types/file-saver": "^2.0.7",
"@types/is-hotkey": "^0.1.10",
+ "@types/leaflet": "^1.9.21",
"@types/node": "24.10.13",
"@types/react": "^18.3.28",
"@types/react-dom": "^18.3.7",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index ee7836185..48cf88586 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -138,6 +138,9 @@ importers:
katex:
specifier: ^0.16.45
version: 0.16.45
+ leaflet:
+ specifier: 1.9.4
+ version: 1.9.4
linkify-react:
specifier: ^4.3.2
version: 4.3.2(linkifyjs@4.3.2)(react@18.3.1)
@@ -177,6 +180,9 @@ importers:
react-i18next:
specifier: ^16.5.4
version: 16.5.7(i18next@25.8.17(typescript@5.9.3))(react-dom@18.3.1(react@18.3.1))(react@18.3.1)(typescript@5.9.3)
+ react-leaflet:
+ specifier: ^4.2.1
+ version: 4.2.1(leaflet@1.9.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
react-range:
specifier: ^1.10.0
version: 1.10.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
@@ -241,6 +247,9 @@ importers:
'@types/is-hotkey':
specifier: ^0.1.10
version: 0.1.10
+ '@types/leaflet':
+ specifier: ^1.9.21
+ version: 1.9.21
'@types/node':
specifier: 24.10.13
version: 24.10.13
@@ -2137,6 +2146,13 @@ packages:
react: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
react-dom: ^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1
+ '@react-leaflet/core@2.1.0':
+ resolution: {integrity: sha512-Qk7Pfu8BSarKGqILj4x7bCSZ1pjuAPZ+qmRwH5S7mDS91VSbVVsJSrW4qA+GPrro8t69gFYVMWb1Zc4yFmPiVg==}
+ peerDependencies:
+ leaflet: ^1.9.0
+ react: ^18.0.0
+ react-dom: ^18.0.0
+
'@react-stately/calendar@3.9.3':
resolution: {integrity: sha512-uw7fCZXoypSBBUsVkbNvJMQWTihZReRbyLIGG3o/ZM630N3OCZhb/h4Uxke4pNu7n527H0V1bAnZgAldIzOYqg==}
peerDependencies:
@@ -2984,9 +3000,15 @@ packages:
'@types/file-saver@2.0.7':
resolution: {integrity: sha512-dNKVfHd/jk0SkR/exKGj2ggkB45MAkzvWCaqLUUgkyjITkGNzH8H+yUwr+BLJUBjZOe9w8X3wgmXhZDRg1ED6A==}
+ '@types/geojson@7946.0.16':
+ resolution: {integrity: sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==}
+
'@types/is-hotkey@0.1.10':
resolution: {integrity: sha512-RvC8KMw5BCac1NvRRyaHgMMEtBaZ6wh0pyPTBu7izn4Sj/AX9Y4aXU5c7rX8PnM/knsuUpC1IeoBkANtxBypsQ==}
+ '@types/leaflet@1.9.21':
+ resolution: {integrity: sha512-TbAd9DaPGSnzp6QvtYngntMZgcRk+igFELwR2N99XZn7RXUdKgsXMR+28bUO0rPsWp8MIu/f47luLIQuSLYv/w==}
+
'@types/node@24.10.13':
resolution: {integrity: sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg==}
@@ -4092,6 +4114,9 @@ packages:
'@types/node': '>=18'
typescript: '>=5.0.4 <7'
+ leaflet@1.9.4:
+ resolution: {integrity: sha512-nxS1ynzJOmOlHp+iL3FyWqK89GtNL8U8rvlMOsQdTTssxZwCXh8N2NB3GDQOL+YR3XnWyZAxwQixURb+FA74PA==}
+
leven@3.1.0:
resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==}
engines: {node: '>=6'}
@@ -4493,6 +4518,13 @@ packages:
react-is@17.0.2:
resolution: {integrity: sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==}
+ react-leaflet@4.2.1:
+ resolution: {integrity: sha512-p9chkvhcKrWn/H/1FFeVSqLdReGwn2qmiobOQGO3BifX+/vV/39qhY8dGqbdcPh1e6jxh/QHriLXr7a4eLFK4Q==}
+ peerDependencies:
+ leaflet: ^1.9.0
+ react: ^18.0.0
+ react-dom: ^18.0.0
+
react-property@2.0.2:
resolution: {integrity: sha512-+PbtI3VuDV0l6CleQMsx2gtK0JZbZKbpdu5ynr+lbsuvtmgbNcS3VM0tuY2QjFNOcWxvXeHjDpy42RO+4U2rug==}
@@ -7212,6 +7244,12 @@ snapshots:
react: 18.3.1
react-dom: 18.3.1(react@18.3.1)
+ '@react-leaflet/core@2.1.0(leaflet@1.9.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)':
+ dependencies:
+ leaflet: 1.9.4
+ react: 18.3.1
+ react-dom: 18.3.1(react@18.3.1)
+
'@react-stately/calendar@3.9.3(react@18.3.1)':
dependencies:
'@internationalized/date': 3.12.0
@@ -8083,8 +8121,14 @@ snapshots:
'@types/file-saver@2.0.7': {}
+ '@types/geojson@7946.0.16': {}
+
'@types/is-hotkey@0.1.10': {}
+ '@types/leaflet@1.9.21':
+ dependencies:
+ '@types/geojson': 7946.0.16
+
'@types/node@24.10.13':
dependencies:
undici-types: 7.16.0
@@ -9332,6 +9376,8 @@ snapshots:
typescript: 5.9.3
zod: 4.3.6
+ leaflet@1.9.4: {}
+
leven@3.1.0: {}
lines-and-columns@1.2.4: {}
@@ -9798,6 +9844,13 @@ snapshots:
react-is@17.0.2: {}
+ react-leaflet@4.2.1(leaflet@1.9.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
+ dependencies:
+ '@react-leaflet/core': 2.1.0(leaflet@1.9.4)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
+ leaflet: 1.9.4
+ react: 18.3.1
+ react-dom: 18.3.1(react@18.3.1)
+
react-property@2.0.2: {}
react-range@1.10.0(react-dom@18.3.1(react@18.3.1))(react@18.3.1):
diff --git a/src/app/components/RenderMessageContent.tsx b/src/app/components/RenderMessageContent.tsx
index 8f87a2891..936b21f79 100644
--- a/src/app/components/RenderMessageContent.tsx
+++ b/src/app/components/RenderMessageContent.tsx
@@ -59,6 +59,7 @@ type RenderMessageContentProps = {
bundledPreview?: boolean;
urlPreview?: boolean;
clientUrlPreview?: boolean;
+ showMaps?: boolean;
highlightRegex?: RegExp;
htmlReactParserOptions: HTMLReactParserOptions;
linkifyOpts: Opts;
@@ -94,6 +95,7 @@ function RenderMessageContentInternal({
bundledPreview,
urlPreview,
clientUrlPreview,
+ showMaps,
highlightRegex,
htmlReactParserOptions,
linkifyOpts,
@@ -429,7 +431,7 @@ function RenderMessageContentInternal({
}
if (msgType === (MsgType.File as string)) return renderFile();
- if (msgType === (MsgType.Location as string)) return ;
+ if (msgType === (MsgType.Location as string)) return ;
if (msgType === 'm.bad.encrypted') return ;
// cute events
diff --git a/src/app/components/message/MsgTypeRenderers.tsx b/src/app/components/message/MsgTypeRenderers.tsx
index 9ef884a43..de102dcad 100644
--- a/src/app/components/message/MsgTypeRenderers.tsx
+++ b/src/app/components/message/MsgTypeRenderers.tsx
@@ -1,6 +1,6 @@
import type { CSSProperties, ReactNode } from 'react';
import { useMemo } from 'react';
-import { Box, Chip, Icon, Icons, Text, toRem } from 'folds';
+import { Box, Chip, color, Icon, Icons, Text, toRem, config } from 'folds';
import type { IContent, IPreviewUrlResponse } from '$types/matrix-sdk';
import { JUMBO_EMOJI_REG } from '$utils/regex';
import { trimReplyFromBody } from '$utils/room';
@@ -35,6 +35,10 @@ import { MessageTextBody } from './layout';
import { unwrapForwardedContent } from './modals/MessageForward';
import { LINKINPUTREGEX } from '$components/editor';
import { MATRIX_TO_BASE } from '$plugins/matrix-to';
+import { MapContainer, Marker, TileLayer } from 'react-leaflet';
+import type { LatLngExpression } from 'leaflet';
+import 'leaflet/dist/leaflet.css';
+import { copyToClipboard } from '$utils/dom';
export interface BundleContent extends IPreviewUrlResponse {
matched_url: string;
@@ -636,30 +640,71 @@ export function MFile({ content, renderFileContent, outlined }: MFileProps) {
type MLocationProps = {
content: IContent;
+ showMaps?: boolean;
};
-export function MLocation({ content }: MLocationProps) {
+export function MLocation({ content, showMaps }: MLocationProps) {
const geoUri = content.geo_uri;
if (typeof geoUri !== 'string') {
return ;
}
const location = parseGeoUri(geoUri);
if (!location) return ;
-
+ const coords: LatLngExpression = [Number(location.latitude), Number(location.longitude)];
return (
-
- {geoUri}
- }
+ evt.stopPropagation()}
+ >
+
- Open Location
-
+ copyToClipboard(`${location.latitude}, ${location.longitude}`)}
+ before={}
+ >
+ {`${location.latitude}, ${location.longitude}`}
+
+
+ }
+ >
+ Open Location
+
+
+ {showMaps && (
+
+
+
+
+ )}
);
}
diff --git a/src/app/features/room/RoomTimeline.tsx b/src/app/features/room/RoomTimeline.tsx
index 56bf1cca5..08bd19c53 100644
--- a/src/app/features/room/RoomTimeline.tsx
+++ b/src/app/features/room/RoomTimeline.tsx
@@ -162,6 +162,10 @@ export function RoomTimeline({
const [incomingInlineImagesMaxHeight] = useSetting(settingsAtom, 'incomingInlineImagesMaxHeight');
const [hideMemberInReadOnly] = useSetting(settingsAtom, 'hideMembershipInReadOnly');
+ const [showInteractiveMap] = useSetting(settingsAtom, 'showInteractiveMap');
+ const [showEncInteractiveMap] = useSetting(settingsAtom, 'showEncInteractiveMap');
+ const showMaps = room.hasEncryptionStateEvent() ? showEncInteractiveMap : showInteractiveMap;
+
const showUrlPreview = room.hasEncryptionStateEvent() ? encUrlPreview : urlPreview;
const showClientUrlPreview = room.hasEncryptionStateEvent()
? clientUrlPreview && encClientUrlPreview
@@ -609,6 +613,7 @@ export function RoomTimeline({
showBundledPreview,
showUrlPreview,
showClientUrlPreview,
+ showMaps,
autoplayStickers,
hideMemberInReadOnly,
isReadOnly,
diff --git a/src/app/features/room/ThreadDrawer.tsx b/src/app/features/room/ThreadDrawer.tsx
index 070cdaf58..2b0a61cc2 100644
--- a/src/app/features/room/ThreadDrawer.tsx
+++ b/src/app/features/room/ThreadDrawer.tsx
@@ -153,6 +153,9 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra
const showClientUrlPreview = room.hasEncryptionStateEvent()
? clientUrlPreview && encClientUrlPreview
: clientUrlPreview;
+ const [showInteractiveMap] = useSetting(settingsAtom, 'showInteractiveMap');
+ const [showEncInteractiveMap] = useSetting(settingsAtom, 'showEncInteractiveMap');
+ const showMaps = room.hasEncryptionStateEvent() ? showEncInteractiveMap : showInteractiveMap;
// Memoized parsing options
const linkifyOpts = useMemo(
@@ -703,6 +706,7 @@ export function ThreadDrawer({ room, threadRootId, onClose, overlay }: ThreadDra
showUrlPreview,
showClientUrlPreview,
showBundledPreview,
+ showMaps,
autoplayStickers,
hideMemberInReadOnly,
isReadOnly,
diff --git a/src/app/features/settings/general/General.tsx b/src/app/features/settings/general/General.tsx
index 9333858e7..50cbd4bd5 100644
--- a/src/app/features/settings/general/General.tsx
+++ b/src/app/features/settings/general/General.tsx
@@ -1052,6 +1052,14 @@ function Embeds() {
const [urlPreview, setUrlPreview] = useSetting(settingsAtom, 'urlPreview');
const [encUrlPreview, setEncUrlPreview] = useSetting(settingsAtom, 'encUrlPreview');
const [clientUrlPreview, setClientUrlPreview] = useSetting(settingsAtom, 'clientUrlPreview');
+ const [showInteractiveMap, setShowInteractiveMap] = useSetting(
+ settingsAtom,
+ 'showInteractiveMap'
+ );
+ const [showEncInteractiveMap, setEncShowInteractiveMap] = useSetting(
+ settingsAtom,
+ 'showEncInteractiveMap'
+ );
const [encClientUrlPreview, setEncClientUrlPreview] = useSetting(
settingsAtom,
'encClientUrlPreview'
@@ -1112,48 +1120,72 @@ function Embeds() {
}
/>
-
+ {clientUrlPreview && (
+ <>
+
+
+ }
+ />
+
+
+
+ }
+ />
+
+ >
+ )}
+
}
/>
-
+
}
/>
diff --git a/src/app/features/settings/settingsLink.ts b/src/app/features/settings/settingsLink.ts
index d2ae99a1d..787b6310b 100644
--- a/src/app/features/settings/settingsLink.ts
+++ b/src/app/features/settings/settingsLink.ts
@@ -17,6 +17,8 @@ const settingsSectionLabel = Object.fromEntries(
const settingsLinkFocusIdsBySection: Record = {
general: [
+ 'show-interactive-map',
+ 'show-interactive-map-enc',
'client-side-embeds',
'composer-formatting-toolbar',
'hide-add-menu',
diff --git a/src/app/hooks/timeline/useTimelineEventRenderer.tsx b/src/app/hooks/timeline/useTimelineEventRenderer.tsx
index 750f4c281..110b6e120 100644
--- a/src/app/hooks/timeline/useTimelineEventRenderer.tsx
+++ b/src/app/hooks/timeline/useTimelineEventRenderer.tsx
@@ -273,6 +273,7 @@ export interface TimelineEventRendererOptions {
showUrlPreview: boolean;
showBundledPreview: boolean;
showClientUrlPreview: boolean;
+ showMaps?: boolean;
autoplayStickers: boolean;
hideMemberInReadOnly: boolean;
isReadOnly: boolean;
@@ -329,6 +330,7 @@ export function useTimelineEventRenderer({
showBundledPreview,
showUrlPreview,
showClientUrlPreview,
+ showMaps,
autoplayStickers,
hideMemberInReadOnly,
isReadOnly,
@@ -511,6 +513,7 @@ export function useTimelineEventRenderer({
urlPreview={showUrlPreview}
bundledPreview={showBundledPreview}
clientUrlPreview={showClientUrlPreview}
+ showMaps={showMaps}
htmlReactParserOptions={htmlReactParserOptions}
linkifyOpts={linkifyOpts}
outlineAttachment={messageLayout === MessageLayout.Bubble}
diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts
index 63f466bf8..9c236d5aa 100644
--- a/src/app/state/settings.ts
+++ b/src/app/state/settings.ts
@@ -115,6 +115,8 @@ export interface Settings {
clientUrlPreview: boolean;
encClientUrlPreview: boolean;
clientPreviewYoutube: boolean;
+ showInteractiveMap: boolean;
+ showEncInteractiveMap: boolean;
usePushNotifications: boolean;
useInAppNotifications: boolean;
@@ -248,6 +250,8 @@ export const defaultSettings: Settings = {
clientUrlPreview: false,
encClientUrlPreview: false,
clientPreviewYoutube: false,
+ showInteractiveMap: true,
+ showEncInteractiveMap: false,
showHiddenEvents: false,
showTombstoneEvents: false,
legacyUsernameColor: false,