diff --git a/web/src/api/api.ts b/web/src/api/api.ts index 36cdf8397..ec3c61702 100644 --- a/web/src/api/api.ts +++ b/web/src/api/api.ts @@ -95,23 +95,19 @@ export type MapMarkerResponseDto = [ string ]; -export class MapMarkerResponseDtoDecorator { +export class MapMarkerResponse { constructor(private lat: number, private lon: number, private assetId: string | null) {} - static from(response: object): MapMarkerResponseDtoDecorator { + static from(response: object): MapMarkerResponse { const responseArray = response as MapMarkerResponseDto; const assetId = responseArray.length === 3 ? responseArray[2] : null; - return new MapMarkerResponseDtoDecorator( - responseArray[0] as number, - responseArray[1] as number, - assetId - ); + return new MapMarkerResponse(responseArray[0] as number, responseArray[1] as number, assetId); } - static fromMany(responses: object[]): MapMarkerResponseDtoDecorator[] { - return responses.map(MapMarkerResponseDtoDecorator.from); + static fromMany(responses: object[]): MapMarkerResponse[] { + return responses.map(MapMarkerResponse.from); } public getAssetId(): string | null { diff --git a/web/src/lib/components/shared-components/leaflet/asset-marker-cluster.svelte b/web/src/lib/components/shared-components/leaflet/asset-marker-cluster.svelte index fc4aa9362..83d3b39bb 100644 --- a/web/src/lib/components/shared-components/leaflet/asset-marker-cluster.svelte +++ b/web/src/lib/components/shared-components/leaflet/asset-marker-cluster.svelte @@ -3,13 +3,13 @@ import { MarkerClusterGroup, Marker, Icon, LeafletEvent } from 'leaflet'; import { onDestroy, onMount } from 'svelte'; import { getMapContext } from './map.svelte'; - import { MapMarkerResponseDtoDecorator, api } from '@api'; + import { MapMarkerResponse, api } from '@api'; import { createEventDispatcher } from 'svelte'; class AssetMarker extends Marker { - marker: MapMarkerResponseDtoDecorator; + marker: MapMarkerResponse; - constructor(marker: MapMarkerResponseDtoDecorator) { + constructor(marker: MapMarkerResponse) { const markerAssetId = marker.getAssetId(); super(marker.getLatLon(), { @@ -40,7 +40,7 @@ const map = getMapContext(); - function setUpCluster(markers: MapMarkerResponseDtoDecorator[]) { + function setUpCluster(markers: MapMarkerResponse[]) { cluster = new MarkerClusterGroup({ showCoverageOnHover: false, zoomToBoundsOnClick: false, @@ -80,7 +80,7 @@ onMount(() => setUpCluster(markers)); - export let markers: MapMarkerResponseDtoDecorator[]; + export let markers: MapMarkerResponse[]; $: { if (cluster) { cluster.remove(); diff --git a/web/src/routes/(user)/map/+page.svelte b/web/src/routes/(user)/map/+page.svelte index 31c1ad18b..274639a61 100644 --- a/web/src/routes/(user)/map/+page.svelte +++ b/web/src/routes/(user)/map/+page.svelte @@ -8,24 +8,24 @@ isViewingAssetStoreState, viewingAssetStoreState } from '$lib/stores/asset-interaction.store'; - import { api, MapMarkerResponseDtoDecorator } from '@api'; + import { api, MapMarkerResponse } from '@api'; import { onMount } from 'svelte'; import { browser } from '$app/environment'; export let data: PageData; - let mapMarkers: MapMarkerResponseDtoDecorator[] = []; + let mapMarkers: MapMarkerResponse[] = []; let initialMapCenter: [number, number] = [48, 11]; onMount(async () => { - mapMarkers = MapMarkerResponseDtoDecorator.fromMany(data.mapMarkers); + mapMarkers = MapMarkerResponse.fromMany(data.mapMarkers); if (mapMarkers.length) { initialMapCenter = mapMarkers[0].getLatLon(); } const markersResponse = (await api.assetApi.getMapMarkers()).data; - mapMarkers = MapMarkerResponseDtoDecorator.fromMany(markersResponse); + mapMarkers = MapMarkerResponse.fromMany(markersResponse); }); let viewingAssets: string[] = [];