Skip to content

Commit

Permalink
Merge branch 'main' into ALS-1902_political-view
Browse files Browse the repository at this point in the history
  • Loading branch information
its-aazizi committed Nov 21, 2024
2 parents ccd13a6 + 5ecf7ec commit bdfe4fc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/atomicui/molecules/Marker/Marker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const Marker: FC<Props> = ({ latitude, longitude, searchValue, setSearchValue })
if (!info) {
(async () => {
const place: ReverseGeocodeCommandOutput | undefined = await getPlaceDataByCoordinates([longitude, latitude]);
setInfo({ id: uuid.randomUUID(), place: place!.ResultItems![0] });
!!place?.ResultItems?.length && setInfo({ id: uuid.randomUUID(), place: place.ResultItems[0] });
})();
}
}, [info, getPlaceDataByCoordinates, longitude, latitude, marker, selectedMarker, setMarker]);
Expand Down
7 changes: 4 additions & 3 deletions src/hooks/useMapManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { MutableRefObject, useCallback, useEffect, useMemo, useState } from "rea
import { showToast } from "@demo/core/Toast";
import { appConfig, regionsData } from "@demo/core/constants";
import { MapStyleEnum, ToastType } from "@demo/types/Enums";
import { getStyleWithPreferredLanguage } from "@demo/utils";
import { getStyleWithPreferredLanguage, normalizeLng } from "@demo/utils";
import { getCurrentLocation } from "@demo/utils/getCurrentLocation";
import type { GeolocateControl as GeolocateControlRef } from "maplibre-gl";
import { omit } from "ramda";
Expand Down Expand Up @@ -148,9 +148,10 @@ const useMapManager = ({

const handleMapClick = useCallback(
({ lngLat }: MapLayerMouseEvent) => {
if (lngLat && !isUnauthGeofenceBoxOpen && !isUnauthTrackerBoxOpen) {
const { lat: latitude, lng: longitude } = lngLat;
const { lng, lat: latitude } = lngLat;
const longitude = normalizeLng(lng);

if (!isUnauthGeofenceBoxOpen && !isUnauthTrackerBoxOpen) {
if (!isRouteBoxOpen && !isAuthGeofenceBoxOpen && !isSettingsOpen && !isEditingRoute) {
marker && setMarker(undefined);
selectedMarker && setSelectedMarker(undefined);
Expand Down
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ export * from "./distanceUtil";
export * from "./turfUtils";
export * from "./getFlagEmoji";
export * from "./getStyleWithPreferredLanguage";
export * from "./normalizeLng";
1 change: 1 addition & 0 deletions src/utils/normalizeLng.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const normalizeLng = (lng: number) => ((((lng + 180) % 360) + 360) % 360) - 180; // Normalize to [-180, 180];

0 comments on commit bdfe4fc

Please sign in to comment.