Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions app/routes/explore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
LngLatLike,
MapLayerMouseEvent,
MapLibreEvent,
MapLibreMap,
StyleImageMetadata,
type FilterSpecification,
} from 'maplibre-gl'
import BoxMarker from '~/components/map/layers/cluster/box-marker'
Expand Down Expand Up @@ -471,48 +473,59 @@
}

const loadImageIfNotExists = async (
map: MapInstance,
map: MapLibreMap,
id: string,
url: string,
options?: Partial<StyleImageMetadata>,
) => {
if (!map.getImage(id)) {
const imgResponse = await map.loadImage(url)
map.addImage(id, imgResponse.data)
if (map.hasImage(id)) return;

const image = await map.loadImage(url);

if (!map.hasImage(id)) {
map.addImage(id, image.data, options);
}
}
};

const handleMapLoad = async (e: MapLibreEvent) => {
const map = e.target
const retinaImageOptions = { pixelRatio: 2 };
await Promise.allSettled([
loadImageIfNotExists(
map,
'osem-device-active',
'/img/device_marker_active.png',
retinaImageOptions
),
loadImageIfNotExists(
map,
'osem-device-inactive',
'/img/device_marker_inactive.png',
retinaImageOptions
),
loadImageIfNotExists(
map,
'osem-device-old',
'/img/device_marker_old.png',
retinaImageOptions
),
loadImageIfNotExists(
map,
'osem-mobile-active',
'/img/mobile_marker_active.png',
retinaImageOptions
),
loadImageIfNotExists(
map,
'osem-mobile-inactive',
'/img/mobile_marker_inactive.png',
retinaImageOptions
),
loadImageIfNotExists(
map,
'osem-mobile-old',
'/img/mobile_marker_old.png',
retinaImageOptions
),
])
}
Expand All @@ -520,8 +533,7 @@
return (
<div className="h-full w-full">
<MapProvider>
<MapHeader

Check failure on line 536 in app/routes/explore.tsx

View workflow job for this annotation

GitHub Actions / ʦ TypeScript

Property 'user' is missing in type '{ devices: FeatureCollection<Point, any>; measurementCount: number; onHomeClick: () => void; }' but required in type 'MapHeaderProps'.
user={user}
devices={devices}
measurementCount={measurementCount}
onHomeClick={handleHomeClick}
Expand Down
Binary file modified public/img/device_marker_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/device_marker_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/device_marker_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/mobile_marker_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/mobile_marker_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/img/mobile_marker_old.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading