diff --git a/app/components/map/topbar.tsx b/app/components/map/topbar.tsx index dc29d1ab..c65e7618 100644 --- a/app/components/map/topbar.tsx +++ b/app/components/map/topbar.tsx @@ -6,7 +6,6 @@ import LanguageSelector from '../landing/header/language-selector' import { TooltipProvider } from '../ui/tooltip' interface MapHeaderProps { - user: any devices: any measurementCount: number | undefined onHomeClick?: () => void diff --git a/app/routes/explore.tsx b/app/routes/explore.tsx index fa28a51a..801c42fb 100644 --- a/app/routes/explore.tsx +++ b/app/routes/explore.tsx @@ -33,6 +33,8 @@ import maplibregl, { LngLatLike, MapLayerMouseEvent, MapLibreEvent, + MapLibreMap, + StyleImageMetadata, type FilterSpecification, } from 'maplibre-gl' import BoxMarker from '~/components/map/layers/cluster/box-marker' @@ -471,48 +473,59 @@ export default function Explore() { } const loadImageIfNotExists = async ( - map: MapInstance, + map: MapLibreMap, id: string, url: string, + options?: Partial, ) => { - 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 ), ]) } @@ -521,7 +534,6 @@ export default function Explore() {