mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 02:56:41 +07:00
fixed sticker text issues
This commit is contained in:
parent
afc9654200
commit
0314edd550
2 changed files with 14 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { marker, Marker } from 'leaflet';
|
import { marker, Marker } from 'leaflet';
|
||||||
import { IStickerDump } from '~/redux/map/types';
|
import { IStickerDump } from '~/redux/map/types';
|
||||||
import { STICKERS } from '~/constants/stickers';
|
import { STICKERS } from '~/constants/stickers';
|
||||||
|
@ -6,7 +6,7 @@ import { StickerDesc } from '~/components/StickerDesc';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
import { DomMarker } from '~/utils/DomMarker';
|
import { DomMarker } from '~/utils/DomMarker';
|
||||||
import { createPortal } from 'react-dom';
|
import { createPortal } from 'react-dom';
|
||||||
import { MapContainer } from '~/constants/map';
|
import { MapContainer, MainMap } from '~/constants/map';
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
map: MapContainer;
|
map: MapContainer;
|
||||||
|
@ -154,22 +154,27 @@ const Sticker: React.FC<IProps> = ({
|
||||||
|
|
||||||
// Initial leaflet marker creation, when element (dom element div) is ready
|
// Initial leaflet marker creation, when element (dom element div) is ready
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
if (!map) return;
|
|
||||||
|
|
||||||
const icon = new DomMarker({
|
const icon = new DomMarker({
|
||||||
element,
|
element,
|
||||||
className: 'sticker-container',
|
className: 'sticker-container',
|
||||||
});
|
});
|
||||||
|
|
||||||
const item = marker(sticker.latlng, { icon, draggable: true }).addTo(map);
|
const item = marker(sticker.latlng, { icon, draggable: true })
|
||||||
|
|
||||||
setLayer(item);
|
setLayer(item);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
item.removeFrom(map);
|
|
||||||
item.remove();
|
item.remove();
|
||||||
};
|
};
|
||||||
}, [element, map, sticker]);
|
}, [element]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!layer) return;
|
||||||
|
|
||||||
|
layer.addTo(MainMap);
|
||||||
|
|
||||||
|
return () => layer.removeFrom(MainMap)
|
||||||
|
}, [layer]);
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
element.className = is_editing ? 'sticker-container' : 'sticker-container inactive';
|
element.className = is_editing ? 'sticker-container' : 'sticker-container inactive';
|
||||||
|
|
|
@ -30,7 +30,7 @@ const Stickers: React.FC<IProps> = React.memo(
|
||||||
<Sticker
|
<Sticker
|
||||||
map={map}
|
map={map}
|
||||||
sticker={sticker}
|
sticker={sticker}
|
||||||
key={`${index}`}
|
key={`${sticker.set}.${sticker.sticker}.${index}`}
|
||||||
index={index}
|
index={index}
|
||||||
is_editing={is_editing}
|
is_editing={is_editing}
|
||||||
mapSetSticker={mapSetSticker}
|
mapSetSticker={mapSetSticker}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue