mirror of
https://github.com/SableClient/Sable.git
synced 2026-12-02 06:42:33 -08:00
Fix missing the mark (#937)
<!-- Please read https://github.com/SableClient/Sable/blob/dev/CONTRIBUTING.md before submitting your pull request --> ### Description app.sable.moe seems to not pull the mark on the location map right so i have added it explicitly and added a bodge to fix it doing the marker moving thing Fixes # #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. --> Testing this on an external website made me realize that we have enough deps that now i need to increase my heap for building it locally huh
This commit is contained in:
3 files changed
+43
-5
No files matched your search
@@ -0,0 +1,5 @@
|
||||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
Fix missing the mark icon on Map, and the mark moving around when clicked
|
||||
@@ -41,7 +41,9 @@ import { copyToClipboard } from '$utils/dom';
|
||||
import { MapContainer, Marker, TileLayer } from 'react-leaflet';
|
||||
import type { LatLngExpression } from 'leaflet';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
|
||||
import * as css from './MsgTypeRenderers.css';
|
||||
import { markerIcon } from '$features/room/location-modal/LocationDialog';
|
||||
|
||||
export interface BundleContent extends IPreviewUrlResponse {
|
||||
matched_url: string;
|
||||
@@ -681,6 +683,7 @@ export function MLocation({ content, showMaps }: MLocationProps) {
|
||||
const location = parseGeoUri(geoUri);
|
||||
if (!location) return <BrokenContent />;
|
||||
const coords: LatLngExpression = [Number(location.latitude), Number(location.longitude)];
|
||||
|
||||
return (
|
||||
<Box
|
||||
direction="Column"
|
||||
@@ -730,8 +733,16 @@ export function MLocation({ content, showMaps }: MLocationProps) {
|
||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
/>
|
||||
|
||||
<Marker position={coords}></Marker>
|
||||
<Marker
|
||||
position={coords}
|
||||
eventHandlers={{
|
||||
mousedown: (e) => {
|
||||
e.originalEvent.preventDefault();
|
||||
e.originalEvent.stopPropagation();
|
||||
},
|
||||
}}
|
||||
icon={markerIcon}
|
||||
/>
|
||||
</MapContainer>
|
||||
)}
|
||||
</Box>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// oxlint-disable no-console
|
||||
import FocusTrap from 'focus-trap-react';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -29,7 +28,14 @@ import type { RoomMessageEventContent } from '$types/matrix-sdk';
|
||||
import { settingsAtom } from '$state/settings';
|
||||
import { useSetting } from '$state/hooks/settings';
|
||||
import classNames from 'classnames';
|
||||
import markerIconPng from 'leaflet/dist/images/marker-icon.png';
|
||||
import { Icon } from 'leaflet';
|
||||
|
||||
export const markerIcon = new Icon({
|
||||
iconUrl: markerIconPng,
|
||||
iconSize: [25, 41],
|
||||
iconAnchor: [12, 41],
|
||||
});
|
||||
export function filterLocationString(result: string) {
|
||||
// OSM format
|
||||
if (result.toLowerCase().includes('lat=') && result.toLowerCase().includes('lon=')) {
|
||||
@@ -153,7 +159,14 @@ export function LocationDialog({
|
||||
map.removeLayer(layer);
|
||||
}
|
||||
});
|
||||
L.marker(pos).addTo(map);
|
||||
const marker = L.marker(pos).addTo(map);
|
||||
marker.on({
|
||||
mousedown: (e) => {
|
||||
e.originalEvent.preventDefault();
|
||||
e.originalEvent.stopPropagation();
|
||||
},
|
||||
});
|
||||
marker.setIcon(markerIcon);
|
||||
map.panTo(pos);
|
||||
},
|
||||
[map]
|
||||
@@ -359,7 +372,16 @@ export function LocationDialog({
|
||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
/>
|
||||
<Marker position={initCoords} />
|
||||
<Marker
|
||||
position={initCoords}
|
||||
eventHandlers={{
|
||||
mousedown: (e) => {
|
||||
e.originalEvent.preventDefault();
|
||||
e.originalEvent.stopPropagation();
|
||||
},
|
||||
}}
|
||||
icon={markerIcon}
|
||||
/>
|
||||
|
||||
<MapEvents />
|
||||
</MapContainer>
|
||||
|
||||
Reference in new issue
Block a user