@abcagency/hc-ui-components 1.4.4 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apis/hcApi.js +1 -1
- package/dist/apis/hcApi.js.map +1 -1
- package/dist/components/containers/accordions/map-accordion-item-container.js +1 -3
- package/dist/components/containers/accordions/map-accordion-item-container.js.map +1 -1
- package/dist/components/containers/maps/info-window-content-container.js.map +1 -1
- package/dist/components/containers/maps/map-container.js +1 -0
- package/dist/components/containers/maps/map-container.js.map +1 -1
- package/dist/components/modules/buttons/button-group-apply.js +4 -4
- package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
- package/dist/contexts/mapListContext.js +13 -17
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/services/listingAggregatorService.js +10 -11
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js +2 -3
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js +16 -10
- package/dist/services/listingService.js.map +1 -1
- package/dist/types/contexts/mapListContext.d.ts +1 -0
- package/dist/types/services/listingAggregatorService.d.ts +1 -1
- package/dist/types/services/listingEntityService.d.ts +3 -2
- package/dist/types/types/ListingEntity.d.ts +1 -2
- package/dist/types/types/ListingFields.d.ts +2 -4
- package/dist/types/types/Listings.d.ts +1 -0
- package/dist/types/util/mapUtil.d.ts +3 -3
- package/dist/util/mapUtil.js +25 -33
- package/dist/util/mapUtil.js.map +1 -1
- package/package.json +1 -1
- package/src/components/containers/accordions/map-accordion-item-container.js +1 -3
- package/src/components/containers/maps/info-window-content-container.js +1 -1
- package/src/components/containers/maps/map-container.js +1 -2
- package/src/components/modules/buttons/button-group-apply.js +4 -4
- package/src/contexts/mapListContext.tsx +17 -17
- package/src/services/listingAggregatorService.ts +12 -13
- package/src/services/listingEntityService.ts +3 -3
- package/src/services/listingService.ts +10 -11
- package/src/types/ListingEntity.ts +1 -2
- package/src/types/ListingFields.ts +2 -4
- package/src/types/Listings.ts +1 -0
- package/src/util/mapUtil.js +41 -48
package/src/util/mapUtil.js
CHANGED
|
@@ -1,55 +1,54 @@
|
|
|
1
|
-
export const getDistinctItemsByProximity = (items,
|
|
1
|
+
export const getDistinctItemsByProximity = (items, listingEntitiesDetails) => {
|
|
2
2
|
const clusters = {};
|
|
3
3
|
|
|
4
|
-
if (!
|
|
5
|
-
|
|
6
|
-
const listingEntitiesDetails = Array.isArray(listingEntitiesDetailsInput)
|
|
7
|
-
? listingEntitiesDetailsInput.reduce((acc, entity) => {
|
|
8
|
-
if (entity?.entityKey) acc[entity.entityKey] = entity;
|
|
9
|
-
return acc;
|
|
10
|
-
}, {})
|
|
11
|
-
: listingEntitiesDetailsInput;
|
|
4
|
+
if (!listingEntitiesDetails) return [];
|
|
12
5
|
|
|
13
6
|
const closeItemPairs = findCloseItems(listingEntitiesDetails);
|
|
14
7
|
if (closeItemPairs.length > 0) {
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
listingEntitiesDetails = adjustItemPositions(
|
|
9
|
+
listingEntitiesDetails,
|
|
10
|
+
closeItemPairs
|
|
11
|
+
);
|
|
17
12
|
}
|
|
18
13
|
|
|
19
14
|
items?.forEach(item => {
|
|
20
|
-
|
|
21
|
-
if (!entityKey || entityKey === '-1') return;
|
|
22
|
-
const entityDetails = listingEntitiesDetails[entityKey];
|
|
23
|
-
if (!entityDetails) {
|
|
24
|
-
console.error(`Details not found for entityKey: ${entityKey}`);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
15
|
+
if(item.entityId !== -1){
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
const entityDetails = listingEntitiesDetails[item.entityId];
|
|
29
18
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
if (!entityDetails) {
|
|
20
|
+
console.error(`Details not found for entityId: ${item.entityId}`);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
item.mapDetails = entityDetails;
|
|
25
|
+
|
|
26
|
+
if (!clusters[item.entityId]) {
|
|
27
|
+
clusters[item.entityId] = {
|
|
28
|
+
...item.mapDetails,
|
|
29
|
+
items: { [item.id]: item }
|
|
30
|
+
};
|
|
31
|
+
} else {
|
|
32
|
+
clusters[item.entityId].items[item.id] = item;
|
|
33
|
+
}}
|
|
38
34
|
});
|
|
39
35
|
|
|
40
36
|
return Object.values(clusters);
|
|
41
37
|
};
|
|
42
38
|
|
|
43
|
-
export const findCloseItems =
|
|
39
|
+
export const findCloseItems = itemsObj => {
|
|
44
40
|
const closeItems = [];
|
|
45
|
-
const items = Object.values(
|
|
41
|
+
const items = Object.values(itemsObj); // Convert object to array for iteration
|
|
46
42
|
const proximityThreshold = 0.0001;
|
|
47
43
|
|
|
48
44
|
for (let i = 0; i < items.length; i++) {
|
|
49
45
|
for (let j = i + 1; j < items.length; j++) {
|
|
50
46
|
const distanceLat = Math.abs(items[i].latitude - items[j].latitude);
|
|
51
47
|
const distanceLng = Math.abs(items[i].longitude - items[j].longitude);
|
|
52
|
-
if (
|
|
48
|
+
if (
|
|
49
|
+
distanceLat < proximityThreshold &&
|
|
50
|
+
distanceLng < proximityThreshold
|
|
51
|
+
) {
|
|
53
52
|
closeItems.push({ item1: items[i], item2: items[j] });
|
|
54
53
|
}
|
|
55
54
|
}
|
|
@@ -58,18 +57,14 @@ export const findCloseItems = entitiesByKey => {
|
|
|
58
57
|
return closeItems;
|
|
59
58
|
};
|
|
60
59
|
|
|
61
|
-
export const adjustItemPositions = (
|
|
60
|
+
export const adjustItemPositions = (itemsObj, closeItemPairs) => {
|
|
62
61
|
const adjustmentValue = 0.0001;
|
|
63
|
-
const adjustedItems = { ...
|
|
62
|
+
const adjustedItems = { ...itemsObj }; // Create a shallow copy of the object
|
|
64
63
|
|
|
65
64
|
closeItemPairs.forEach(pair => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
adjustedItems[
|
|
69
|
-
...adjustedItems[key2],
|
|
70
|
-
latitude: adjustedItems[key2].latitude + adjustmentValue,
|
|
71
|
-
longitude: adjustedItems[key2].longitude + adjustmentValue
|
|
72
|
-
};
|
|
65
|
+
if (adjustedItems[pair.item1.id] && adjustedItems[pair.item2.id]) {
|
|
66
|
+
adjustedItems[pair.item2.id].latitude += adjustmentValue;
|
|
67
|
+
adjustedItems[pair.item2.id].longitude += adjustmentValue;
|
|
73
68
|
}
|
|
74
69
|
});
|
|
75
70
|
|
|
@@ -79,15 +74,13 @@ export const adjustItemPositions = (entitiesByKey, closeItemPairs) => {
|
|
|
79
74
|
export const clusterOptions = (clusterGridSize, fillColor) => {
|
|
80
75
|
return {
|
|
81
76
|
gridSize: clusterGridSize,
|
|
82
|
-
maxZoom:
|
|
83
|
-
styles:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
]
|
|
77
|
+
maxZoom:15,
|
|
78
|
+
styles:[{
|
|
79
|
+
url: createSvgDataUri(fillColor),
|
|
80
|
+
textColor:'white',
|
|
81
|
+
height: 40,
|
|
82
|
+
width: 40
|
|
83
|
+
}]
|
|
91
84
|
};
|
|
92
85
|
};
|
|
93
86
|
|