mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
changing gpx color
This commit is contained in:
parent
871f9bb8a2
commit
c4aede5833
3 changed files with 16 additions and 4 deletions
|
@ -66,6 +66,16 @@ const GpxDialogUnconnected: FC<Props> = ({
|
||||||
[gpx, editorSetGpx]
|
[gpx, editorSetGpx]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onRouteColor = useCallback(
|
||||||
|
index => {
|
||||||
|
if (!gpx.enabled) return;
|
||||||
|
editorSetGpx({
|
||||||
|
list: gpx.list.map((el, i) => (i !== index ? el : { ...el, color: getRandomColor() })),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[gpx, editorSetGpx]
|
||||||
|
);
|
||||||
|
|
||||||
const toggleGpx = useCallback(() => {
|
const toggleGpx = useCallback(() => {
|
||||||
editorSetGpx({ enabled: !gpx.enabled });
|
editorSetGpx({ enabled: !gpx.enabled });
|
||||||
}, [gpx, editorSetGpx]);
|
}, [gpx, editorSetGpx]);
|
||||||
|
@ -83,7 +93,7 @@ const GpxDialogUnconnected: FC<Props> = ({
|
||||||
const addCurrent = useCallback(() => {
|
const addCurrent = useCallback(() => {
|
||||||
if (!route.length) return;
|
if (!route.length) return;
|
||||||
|
|
||||||
const { path } = getUrlData()
|
const { path } = getUrlData();
|
||||||
|
|
||||||
editorSetGpx({
|
editorSetGpx({
|
||||||
list: [
|
list: [
|
||||||
|
@ -115,6 +125,7 @@ const GpxDialogUnconnected: FC<Props> = ({
|
||||||
onRouteDrop={onRouteDrop}
|
onRouteDrop={onRouteDrop}
|
||||||
onFocusRoute={onFocusRoute}
|
onFocusRoute={onFocusRoute}
|
||||||
onRouteToggle={onRouteToggle}
|
onRouteToggle={onRouteToggle}
|
||||||
|
onRouteColor={onRouteColor}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,13 @@ interface IProps {
|
||||||
onFocusRoute: (i: number) => void
|
onFocusRoute: (i: number) => void
|
||||||
onRouteDrop: (i: number) => void
|
onRouteDrop: (i: number) => void
|
||||||
onRouteToggle: (i: number) => void
|
onRouteToggle: (i: number) => void
|
||||||
|
onRouteColor: (i: number) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const GpxDialogRow: FC<IProps> = ({ item, index, enabled, onRouteToggle, onFocusRoute, onRouteDrop }) => {
|
const GpxDialogRow: FC<IProps> = ({ item, index, enabled, onRouteToggle, onFocusRoute, onRouteDrop, onRouteColor }) => {
|
||||||
return (
|
return (
|
||||||
<div className={classnames("gpx-row", { 'gpx-row_disabled': !enabled || !item.enabled })}>
|
<div className={classnames("gpx-row", { 'gpx-row_disabled': !enabled || !item.enabled })}>
|
||||||
<div className="gpx-row__color" style={{ backgroundColor: item.color }}/>
|
<div className="gpx-row__color" style={{ backgroundColor: item.color }} onClick={() => onRouteColor(index)}/>
|
||||||
|
|
||||||
<div className="gpx-row__title" onClick={() => onFocusRoute(index)}>
|
<div className="gpx-row__title" onClick={() => onFocusRoute(index)}>
|
||||||
{item.name}
|
{item.name}
|
||||||
|
|
|
@ -20,7 +20,7 @@ const GpxPolyline: FC<IProps> = ({ latlngs, color }) => {
|
||||||
setLayer(item);
|
setLayer(item);
|
||||||
|
|
||||||
return () => MainMap.removeLayer(item);
|
return () => MainMap.removeLayer(item);
|
||||||
}, [MainMap]);
|
}, [MainMap, color, latlngs]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!layer) return;
|
if (!layer) return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue