Skip to content

Commit

Permalink
prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
OlliV committed Oct 29, 2023
1 parent ed32f35 commit da307bd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
14 changes: 9 additions & 5 deletions components/map/Edit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ export default function MapEditCourse({
// @ts-ignore
if (layer._latlngs && layer._latlngs.length > 0) {
// @ts-ignore
updateTrackSegment(newCourse, seg++, layer._latlngs.map((v) => ({ lat: v.lat, lon: v.lng })));
updateTrackSegment(
newCourse,
seg++,
layer._latlngs.map((v) => ({ lat: v.lat, lon: v.lng }))
);
}
} else if (layer instanceof L.Marker) {
// @ts-ignore
Expand All @@ -81,10 +85,10 @@ export default function MapEditCourse({
position="topleft"
draw={{
polygon: false,
rectangle: false,
circle: false,
circlemarker: false,
marker: { icon: createMarkerIcon() },
rectangle: false,
circle: false,
circlemarker: false,
marker: { icon: createMarkerIcon() },
}}
onCreated={editEvent}
onEdited={editEvent}
Expand Down
12 changes: 10 additions & 2 deletions components/map/Marker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { renderToString } from 'react-dom/server';
import MarkerIcon from '../../node_modules/leaflet/dist/images/marker-icon.png';
import MarkerShadow from '../../node_modules/leaflet/dist/images/marker-shadow.png';

export function createMarkerIcon(icon?: ReactNode ) {
export function createMarkerIcon(icon?: ReactNode) {
if (icon) {
return L.divIcon({
html: renderToString(icon),
Expand All @@ -25,7 +25,15 @@ export function createMarkerIcon(icon?: ReactNode ) {
}
}

export default function MapMarker({ icon, position, children }: { icon?: ReturnType<typeof createMarkerIcon>; position: [number, number]; children?: ReactNode; }) {
export default function MapMarker({
icon,
position,
children,
}: {
icon?: ReturnType<typeof createMarkerIcon>;
position: [number, number];
children?: ReactNode;
}) {
return (
<Marker
position={position}
Expand Down
11 changes: 8 additions & 3 deletions pages/ride/map/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ export default function RideMap() {
const bounds = useMemo(() => course && getMapBounds(course), [course]);

useEffect(() => {
if (map && bounds &&
[bounds.minlat, bounds.minlon, bounds.maxlat, bounds.maxlon].some((v) => Number.isFinite(v))) {
if (
map &&
bounds &&
[bounds.minlat, bounds.minlon, bounds.maxlat, bounds.maxlon].some((v) => Number.isFinite(v))
) {
map.fitBounds([
[bounds.minlat, bounds.minlon],
[bounds.maxlat, bounds.maxlon],
Expand Down Expand Up @@ -115,7 +118,9 @@ export default function RideMap() {
</Stack>

<DynamicMap center={coord} setMap={setMap}>
<DynamicMapMarker icon={<IconHome/>} position={coord}>You are here.</DynamicMapMarker>
<DynamicMapMarker icon={<IconHome />} position={coord}>
You are here.
</DynamicMapMarker>
{editMode ? <DynamicMapEditCourse initialCourse={course} setCourse={setCourse} /> : null}
{course && !editMode ? <DynamicCourse course={course} /> : null}
</DynamicMap>
Expand Down

0 comments on commit da307bd

Please sign in to comment.