@abcagency/hc-ui-components 1.3.59 → 1.3.60
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 +85 -85
- package/dist/apis/hcApi.js.map +1 -1
- package/dist/clientToken.js.map +1 -1
- package/dist/components/HireControlMap.js +11 -1
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/components/containers/accordions/filter-container.js.map +1 -1
- package/dist/components/containers/accordions/filter-item-container.js.map +1 -1
- package/dist/components/containers/accordions/map-accordion-item-container.js.map +1 -1
- package/dist/components/containers/filter/commute-container.js +1 -1
- package/dist/components/containers/filter/commute-container.js.map +1 -1
- package/dist/components/containers/filter/filter-container.js.map +1 -1
- package/dist/components/containers/filter/filter-item-container.js.map +1 -1
- package/dist/components/containers/filter/location-container.js.map +1 -1
- package/dist/components/containers/filter/points-of-interest-container.js.map +1 -1
- package/dist/components/containers/filter/points-of-interest-radio-item-container.js.map +1 -1
- package/dist/components/containers/filter/search-container.js.map +1 -1
- package/dist/components/containers/jobListing/listing-details-container.js +5 -1
- package/dist/components/containers/jobListing/listing-details-container.js.map +1 -1
- package/dist/components/containers/list/item-list-container.js +21 -21
- package/dist/components/containers/list/item-list-container.js.map +1 -1
- package/dist/components/containers/list/list-item/list-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 -1
- package/dist/components/containers/maps/map-container.js.map +1 -1
- package/dist/components/containers/maps/map-list-container.js.map +1 -1
- package/dist/components/containers/maps/map-marker-container.js +1 -1
- package/dist/components/containers/maps/map-marker-container.js.map +1 -1
- package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
- package/dist/components/modules/accordions/default.js +2 -2
- package/dist/components/modules/accordions/default.js.map +1 -1
- package/dist/components/modules/accordions/filterItem.js.map +1 -1
- package/dist/components/modules/accordions/filters.js.map +1 -1
- package/dist/components/modules/buttons/button-group-apply.js +48 -54
- package/dist/components/modules/buttons/button-group-apply.js.map +1 -1
- package/dist/components/modules/buttons/commute-pill.js.map +1 -1
- package/dist/components/modules/buttons/default.js +2 -2
- package/dist/components/modules/buttons/default.js.map +1 -1
- package/dist/components/modules/buttons/items-pill.js.map +1 -1
- package/dist/components/modules/buttons/pill-wrapper.js.map +1 -1
- package/dist/components/modules/buttons/show-all-button.js.map +1 -1
- package/dist/components/modules/cards/default.js +2 -2
- package/dist/components/modules/cards/default.js.map +1 -1
- package/dist/components/modules/cards/filter.js.map +1 -1
- package/dist/components/modules/dialogs/apply-dialog.js +1 -1
- package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
- package/dist/components/modules/filter/commute.js +2 -2
- package/dist/components/modules/filter/commute.js.map +1 -1
- package/dist/components/modules/filter/index.js.map +1 -1
- package/dist/components/modules/filter/item.js.map +1 -1
- package/dist/components/modules/filter/location.js.map +1 -1
- package/dist/components/modules/filter/radio-item.js.map +1 -1
- package/dist/components/modules/filter/search.js.map +1 -1
- package/dist/components/modules/filter/sort.js +2 -2
- package/dist/components/modules/filter/sort.js.map +1 -1
- package/dist/components/modules/grid.js +1 -1
- package/dist/components/modules/grid.js.map +1 -1
- package/dist/components/modules/icon.js +1 -1
- package/dist/components/modules/icon.js.map +1 -1
- package/dist/components/modules/jobListing/listing-details.js +8 -7
- package/dist/components/modules/jobListing/listing-details.js.map +1 -1
- package/dist/components/modules/list/field-mapper.js.map +1 -1
- package/dist/components/modules/list/header-item.js.map +1 -1
- package/dist/components/modules/list/header.js +1 -1
- package/dist/components/modules/list/header.js.map +1 -1
- package/dist/components/modules/list/item-expand-card/index.js +1 -1
- package/dist/components/modules/list/item-expand-card/index.js.map +1 -1
- package/dist/components/modules/list/item-expand-card/recruiter-contact-nav.js +38 -38
- package/dist/components/modules/list/item-expand-card/recruiter-details.js +40 -40
- package/dist/components/modules/list/item-expand-card/recruiter-headshot.js +20 -20
- package/dist/components/modules/list/item-list.js +43 -43
- package/dist/components/modules/list/item-list.js.map +1 -1
- package/dist/components/modules/list/list-item/list-item.js.map +1 -1
- package/dist/components/modules/maps/info-window-card.js.map +1 -1
- package/dist/components/modules/maps/info-window-content.js.map +1 -1
- package/dist/components/modules/maps/map-list.js.map +1 -1
- package/dist/components/modules/maps/map-marker.js +1 -1
- package/dist/components/modules/maps/map-marker.js.map +1 -1
- package/dist/components/modules/maps/map.js +1 -1
- package/dist/components/modules/maps/map.js.map +1 -1
- package/dist/components/modules/maps/place-marker.js +1 -1
- package/dist/components/modules/maps/place-marker.js.map +1 -1
- package/dist/components/modules/maps/tabs.js +1 -1
- package/dist/components/modules/maps/tabs.js.map +1 -1
- package/dist/constants/eventTypes.js +1 -0
- package/dist/constants/eventTypes.js.map +1 -1
- package/dist/constants/placeTypes.js.map +1 -1
- package/dist/contexts/mapContext.js +83 -83
- package/dist/contexts/mapContext.js.map +1 -1
- package/dist/contexts/mapListContext.js +192 -190
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/contexts/placesContext.js.map +1 -1
- package/dist/contexts/themeContext.js.map +1 -1
- package/dist/contexts/trackEventContext.js.map +1 -1
- package/dist/hooks/useList.js.map +1 -1
- package/dist/services/configService.js +9 -9
- package/dist/services/configService.js.map +1 -1
- package/dist/services/googlePlacesNearbyService.js +32 -32
- package/dist/services/googlePlacesNearbyService.js.map +1 -1
- package/dist/services/listingAggregatorService.js +34 -34
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js +9 -9
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js +24 -24
- package/dist/services/listingService.js.map +1 -1
- package/dist/services/recruiterService.js +10 -10
- package/dist/services/recruiterService.js.map +1 -1
- package/dist/types/apis/hcApi.d.ts +5 -5
- package/dist/types/clientToken.d.ts +2 -2
- package/dist/types/components/containers/accordions/map-accordion-item-container.d.ts +12 -12
- package/dist/types/components/containers/jobListing/listing-details-container.d.ts +6 -6
- package/dist/types/components/containers/list/item-list-container.d.ts +9 -9
- package/dist/types/components/containers/list/list-item/list-item-container.d.ts +14 -14
- package/dist/types/components/modules/accordions/MapAccordionItem.d.ts +10 -10
- package/dist/types/components/modules/accordions/default.d.ts +19 -19
- package/dist/types/components/modules/buttons/button-group-apply.d.ts +24 -24
- package/dist/types/components/modules/buttons/commute-pill.d.ts +5 -5
- package/dist/types/components/modules/buttons/default.d.ts +48 -48
- package/dist/types/components/modules/buttons/pill-wrapper.d.ts +3 -3
- package/dist/types/components/modules/dialogs/apply-dialog.d.ts +8 -8
- package/dist/types/components/modules/filter/sort.d.ts +8 -8
- package/dist/types/components/modules/grid.d.ts +8 -8
- package/dist/types/components/modules/icon.d.ts +10 -10
- package/dist/types/components/modules/jobListing/listing-details.d.ts +20 -18
- package/dist/types/components/modules/list/field-mapper.d.ts +10 -10
- package/dist/types/components/modules/list/header-item.d.ts +11 -11
- package/dist/types/components/modules/list/header.d.ts +12 -12
- package/dist/types/components/modules/list/item-expand-card/index.d.ts +7 -7
- package/dist/types/components/modules/list/item-expand-card/recruiter-contact-nav.d.ts +17 -17
- package/dist/types/components/modules/list/item-expand-card/recruiter-details.d.ts +21 -21
- package/dist/types/components/modules/list/item-expand-card/recruiter-headshot.d.ts +8 -8
- package/dist/types/components/modules/list/item-list.d.ts +20 -20
- package/dist/types/components/modules/list/list-item/list-item.d.ts +3 -3
- package/dist/types/constants/eventTypes.d.ts +15 -14
- package/dist/types/contexts/mapContext.d.ts +29 -29
- package/dist/types/contexts/mapListContext.d.ts +65 -61
- package/dist/types/contexts/trackEventContext.d.ts +6 -6
- package/dist/types/enums/SectionType.d.ts +9 -9
- package/dist/types/hooks/useList.d.ts +13 -13
- package/dist/types/services/configService.d.ts +6 -6
- package/dist/types/services/googlePlacesNearbyService.d.ts +5 -5
- package/dist/types/services/listingAggregatorService.d.ts +12 -12
- package/dist/types/services/listingEntityService.d.ts +6 -6
- package/dist/types/services/listingService.d.ts +9 -9
- package/dist/types/services/recruiterService.d.ts +6 -6
- package/dist/types/types/Address.d.ts +7 -7
- package/dist/types/types/ContentSection.d.ts +8 -8
- package/dist/types/types/GetListingParams.d.ts +8 -8
- package/dist/types/types/LatLng.d.ts +4 -4
- package/dist/types/types/ListingEntity.d.ts +10 -10
- package/dist/types/types/ListingFields.d.ts +25 -25
- package/dist/types/types/Listings.d.ts +31 -31
- package/dist/types/types/Recruiter.d.ts +9 -9
- package/dist/types/types/SimilarListing.d.ts +24 -24
- package/dist/types/types/config/Colors.d.ts +8 -8
- package/dist/types/types/config/MapConfig.d.ts +30 -30
- package/dist/types/types/config/PointsOfInterestConfig.d.ts +13 -13
- package/dist/types/types/config/SearchConfig.d.ts +4 -4
- package/dist/types/util/filterUtil.d.ts +28 -28
- package/dist/types/util/loading.d.ts +3 -3
- package/dist/types/util/localStorageUtil.d.ts +3 -3
- package/dist/types/util/mapUtil.d.ts +16 -16
- package/dist/types/util/sortUtil.d.ts +1 -1
- package/dist/types/util/stringUtils.d.ts +1 -1
- package/dist/types/util/urlFilterUtil.d.ts +8 -8
- package/dist/util/filterUtil.js +1 -1
- package/dist/util/filterUtil.js.map +1 -1
- package/dist/util/loading.js.map +1 -1
- package/dist/util/localStorageUtil.js +37 -37
- package/dist/util/localStorageUtil.js.map +1 -1
- package/dist/util/mapIconUtil.js.map +1 -1
- package/dist/util/mapUtil.js.map +1 -1
- package/dist/util/sortUtil.js.map +1 -1
- package/dist/util/stringUtils.js.map +1 -1
- package/dist/util/urlFilterUtil.js.map +1 -1
- package/package.json +90 -90
- package/src/.editorconfig +12 -12
- package/src/apis/hcApi.ts +109 -109
- package/src/bundleIndex.js +14 -14
- package/src/clientToken.js +9 -9
- package/src/components/HireControlMap.js +148 -142
- package/src/components/containers/accordions/filter-container.js +48 -48
- package/src/components/containers/accordions/filter-item-container.js +83 -83
- package/src/components/containers/accordions/map-accordion-item-container.js +70 -70
- package/src/components/containers/filter/commute-container.js +89 -89
- package/src/components/containers/filter/filter-container.js +76 -76
- package/src/components/containers/filter/filter-item-container.js +117 -117
- package/src/components/containers/filter/location-container.js +45 -45
- package/src/components/containers/filter/points-of-interest-container.js +33 -33
- package/src/components/containers/filter/points-of-interest-radio-item-container.js +35 -35
- package/src/components/containers/filter/search-container.js +61 -61
- package/src/components/containers/jobListing/listing-details-container.js +42 -40
- package/src/components/containers/list/item-list-container.tsx +81 -81
- package/src/components/containers/list/list-item/list-item-container.js +43 -43
- package/src/components/containers/maps/info-window-content-container.js +53 -53
- package/src/components/containers/maps/map-container.js +249 -249
- package/src/components/containers/maps/map-list-container.js +50 -50
- package/src/components/containers/maps/map-marker-container.js +78 -78
- package/src/components/modules/accordions/MapAccordionItem.js +30 -30
- package/src/components/modules/accordions/default.js +171 -171
- package/src/components/modules/accordions/filterItem.js +27 -27
- package/src/components/modules/accordions/filters.js +32 -32
- package/src/components/modules/buttons/button-group-apply.js +115 -135
- package/src/components/modules/buttons/commute-pill.js +22 -22
- package/src/components/modules/buttons/default.js +194 -194
- package/src/components/modules/buttons/items-pill.js +35 -35
- package/src/components/modules/buttons/pill-wrapper.js +27 -27
- package/src/components/modules/buttons/show-all-button.js +19 -19
- package/src/components/modules/cards/default.js +167 -167
- package/src/components/modules/cards/filter.js +56 -56
- package/src/components/modules/dialogs/apply-dialog.js +48 -48
- package/src/components/modules/filter/commute.js +108 -108
- package/src/components/modules/filter/index.js +55 -55
- package/src/components/modules/filter/item.js +69 -69
- package/src/components/modules/filter/location.js +51 -51
- package/src/components/modules/filter/radio-item.js +42 -42
- package/src/components/modules/filter/search.js +79 -79
- package/src/components/modules/filter/sort.js +83 -83
- package/src/components/modules/grid.js +54 -54
- package/src/components/modules/icon.js +33 -33
- package/src/components/modules/jobListing/listing-details.js +110 -108
- package/src/components/modules/list/field-mapper.js +130 -130
- package/src/components/modules/list/header-item.js +92 -92
- package/src/components/modules/list/header.js +51 -51
- package/src/components/modules/list/item-expand-card/index.js +22 -22
- package/src/components/modules/list/item-expand-card/recruiter-contact-nav.js +50 -50
- package/src/components/modules/list/item-expand-card/recruiter-details.js +68 -68
- package/src/components/modules/list/item-expand-card/recruiter-headshot.js +22 -22
- package/src/components/modules/list/item-list.tsx +117 -117
- package/src/components/modules/list/list-item/list-item.js +130 -130
- package/src/components/modules/maps/info-window-card.js +17 -17
- package/src/components/modules/maps/info-window-content.js +64 -64
- package/src/components/modules/maps/map-list.js +38 -38
- package/src/components/modules/maps/map-marker.js +29 -29
- package/src/components/modules/maps/map.js +64 -64
- package/src/components/modules/maps/place-marker.js +41 -41
- package/src/components/modules/maps/tabs.js +81 -81
- package/src/constants/eventTypes.js +15 -14
- package/src/constants/placeTypes.js +8 -8
- package/src/contexts/mapContext.tsx +129 -129
- package/src/contexts/mapListContext.tsx +326 -318
- package/src/contexts/placesContext.js +102 -102
- package/src/contexts/themeContext.js +40 -40
- package/src/contexts/trackEventContext.js +14 -14
- package/src/enums/SectionType.ts +9 -9
- package/src/hooks/useList.js +89 -89
- package/src/index.js +3 -3
- package/src/services/configService.ts +16 -16
- package/src/services/googlePlacesNearbyService.ts +42 -42
- package/src/services/listingAggregatorService.ts +76 -76
- package/src/services/listingEntityService.ts +16 -16
- package/src/services/listingService.ts +40 -40
- package/src/services/recruiterService.ts +18 -18
- package/src/styles/bundle.css +268 -268
- package/src/styles/index.css +33 -33
- package/src/types/Address.ts +7 -7
- package/src/types/ContentSection.ts +9 -9
- package/src/types/GetListingParams.ts +8 -8
- package/src/types/LatLng.ts +4 -4
- package/src/types/ListingEntity.ts +11 -11
- package/src/types/ListingFields.ts +25 -25
- package/src/types/Listings.ts +32 -32
- package/src/types/Recruiter.ts +9 -9
- package/src/types/SimilarListing.ts +24 -24
- package/src/types/config/Colors.ts +8 -8
- package/src/types/config/MapConfig.ts +31 -31
- package/src/types/config/PointsOfInterestConfig.ts +13 -13
- package/src/types/config/SearchConfig.ts +4 -4
- package/src/util/arrayUtil.js +3 -3
- package/src/util/fieldMapper.js +22 -22
- package/src/util/filterUtil.js +311 -311
- package/src/util/loading.js +17 -17
- package/src/util/localStorageUtil.ts +34 -34
- package/src/util/mapIconUtil.js +180 -180
- package/src/util/mapUtil.js +92 -92
- package/src/util/sortUtil.js +32 -32
- package/src/util/stringUtils.js +6 -6
- package/src/util/urlFilterUtil.js +85 -85
|
@@ -1,249 +1,249 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import MapMarker from "~/components/containers/maps/map-marker-container";
|
|
4
|
-
import PlaceMarker from "~/components/modules/maps/place-marker";
|
|
5
|
-
|
|
6
|
-
import { usePlaces } from "~/contexts/placesContext";
|
|
7
|
-
import { useMap } from "~/contexts/mapContext";
|
|
8
|
-
import { useMapList } from "~/contexts/mapListContext";
|
|
9
|
-
|
|
10
|
-
import { markerIconSelected, markerIcon, pinIcon } from "~/util/mapIconUtil";
|
|
11
|
-
|
|
12
|
-
import Map from "~/components/modules/maps/map";
|
|
13
|
-
import { MarkerClustererF } from "@react-google-maps/api";
|
|
14
|
-
import { clusterOptions } from "~/util/mapUtil";
|
|
15
|
-
|
|
16
|
-
const MapContainer = ({
|
|
17
|
-
markerConfigs,
|
|
18
|
-
infoWindowClasses,
|
|
19
|
-
clusterGridSize = 60
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
location,
|
|
23
|
-
zoom,
|
|
24
|
-
center,
|
|
25
|
-
selectLocationEntity,
|
|
26
|
-
setLocation,
|
|
27
|
-
mapInteracted,
|
|
28
|
-
setMapInteracted
|
|
29
|
-
} = useMap();
|
|
30
|
-
|
|
31
|
-
const {
|
|
32
|
-
mapItems, filteredListings, setSelectedFilters,
|
|
33
|
-
setQuery,
|
|
34
|
-
siteConfig
|
|
35
|
-
} = useMapList();
|
|
36
|
-
|
|
37
|
-
const mapRef = useRef();
|
|
38
|
-
const markerRefs = useRef({});
|
|
39
|
-
const mapContainerRef = useRef(null);
|
|
40
|
-
const {
|
|
41
|
-
poiMarkers,
|
|
42
|
-
setCurrentCenter,
|
|
43
|
-
currentCenter,
|
|
44
|
-
setCurrentZoom,
|
|
45
|
-
currentZoom,
|
|
46
|
-
selectedPlaceMarker,
|
|
47
|
-
setSelectedPlaceMarker,
|
|
48
|
-
placesWindow,
|
|
49
|
-
setPlacesWindow } = usePlaces();
|
|
50
|
-
|
|
51
|
-
const onIdle = () => {
|
|
52
|
-
if (!currentCenter || !mapRef.current) return;
|
|
53
|
-
const newCenter = mapRef.current.getCenter().toJSON();
|
|
54
|
-
const newZoom = mapRef.current.zoom;
|
|
55
|
-
|
|
56
|
-
setCurrentCenter(newCenter);
|
|
57
|
-
|
|
58
|
-
if (newZoom !== currentZoom) {
|
|
59
|
-
setCurrentZoom(newZoom);
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (mapContainerRef.current) {
|
|
65
|
-
const handleScroll = () => {
|
|
66
|
-
setMapInteracted(true);
|
|
67
|
-
};
|
|
68
|
-
var mapContainerRefCurrent = mapContainerRef.current;
|
|
69
|
-
mapContainerRef.current.addEventListener('wheel', handleScroll);
|
|
70
|
-
return () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);
|
|
71
|
-
}
|
|
72
|
-
}, [mapContainerRef.current]);
|
|
73
|
-
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (mapRef.current) {
|
|
76
|
-
const mapInstance = mapRef.current;
|
|
77
|
-
const dragStartListener = mapInstance.addListener('dragstart', () => setMapInteracted(true));
|
|
78
|
-
const mouseDownListener = mapInstance.addListener('mousedown', () => setMapInteracted(true));
|
|
79
|
-
return () => {
|
|
80
|
-
google.maps.event.removeListener(dragStartListener);
|
|
81
|
-
google.maps.event.removeListener(mouseDownListener);
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}, [mapRef.current, mapContainerRef.current]);
|
|
85
|
-
|
|
86
|
-
useEffect(() => {
|
|
87
|
-
if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {
|
|
88
|
-
fitBounds(mapRef.current);
|
|
89
|
-
}
|
|
90
|
-
}, [mapItems, mapRef.current, location]);
|
|
91
|
-
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current && mapInteracted) {
|
|
94
|
-
fitBounds(mapRef.current, true);
|
|
95
|
-
}
|
|
96
|
-
if (mapRef.current) {
|
|
97
|
-
let currZoom = mapRef.current.zoom;
|
|
98
|
-
let setZoomVal = currZoom < 13 ? currZoom : 12;
|
|
99
|
-
mapRef.current.setZoom(setZoomVal);
|
|
100
|
-
}
|
|
101
|
-
}, [filteredListings]);
|
|
102
|
-
|
|
103
|
-
useEffect(() => {
|
|
104
|
-
if (!mapRef.current || !location || mapInteracted) return;
|
|
105
|
-
mapRef.current.panTo(
|
|
106
|
-
new google.maps.LatLng(location.latitude, location.longitude)
|
|
107
|
-
);
|
|
108
|
-
if (mapRef.current) {
|
|
109
|
-
let setZoomVal = zoom < 13 ? zoom : 12;
|
|
110
|
-
mapRef.current.setZoom(setZoomVal);
|
|
111
|
-
}
|
|
112
|
-
}, [location, zoom, mapRef.current]);
|
|
113
|
-
|
|
114
|
-
const fitBounds = (map, overload = false) => {
|
|
115
|
-
if ((mapInteracted === false || overload) && mapItems != null) {
|
|
116
|
-
const bounds = new window.google.maps.LatLngBounds();
|
|
117
|
-
mapItems.forEach(item => {
|
|
118
|
-
bounds.extend(new google.maps.LatLng(item.latitude, item.longitude));
|
|
119
|
-
});
|
|
120
|
-
if(siteConfig.optionalShowLocationClusterConfig){
|
|
121
|
-
let configLocation = new google.maps.LatLng(siteConfig.optionalShowLocationClusterConfig.latitude, siteConfig.optionalShowLocationClusterConfig.longitude);
|
|
122
|
-
map.panTo(configLocation);
|
|
123
|
-
bounds.extend(new google.maps.LatLng(siteConfig.optionalShowLocationClusterConfig.latitude, siteConfig.optionalShowLocationClusterConfig.longitude));
|
|
124
|
-
}
|
|
125
|
-
if (!map) return;
|
|
126
|
-
const currentCenter = map.getCenter();
|
|
127
|
-
map.fitBounds(bounds);
|
|
128
|
-
const newCenter = bounds.getCenter();
|
|
129
|
-
if (currentCenter && newCenter) {
|
|
130
|
-
map.panTo(newCenter);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
if (mapRef.current.zoom > 17) {
|
|
134
|
-
mapRef.current.setZoom(16);
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
const markerClickHandler = mapLocation => {
|
|
139
|
-
setMapInteracted(true);
|
|
140
|
-
selectLocationEntity(mapLocation);
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const onLoad = map => {
|
|
144
|
-
if (!location || location === null) {
|
|
145
|
-
mapRef.current = map;
|
|
146
|
-
fitBounds(map, true);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
mapRef.current = map;
|
|
150
|
-
|
|
151
|
-
if (mapInteracted === false) {
|
|
152
|
-
mapRef.current.panTo(
|
|
153
|
-
new google.maps.LatLng(location.latitude, location.longitude)
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
mapRef.current.setZoom(zoom);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
const pinIconUrl = pinIcon({
|
|
161
|
-
fillColor: markerConfigs.fillColor,
|
|
162
|
-
strokeColor: markerConfigs.strokeColor
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
const onClusterClick = cluster => {
|
|
166
|
-
if(!siteConfig.optionalShowLocationClusterConfig || (mapRef.current.zoom > siteConfig.optionalShowLocationClusterConfig.showForZoomLevelLessThan)) {
|
|
167
|
-
console.log("should return");
|
|
168
|
-
return;
|
|
169
|
-
}
|
|
170
|
-
if (!cluster || typeof cluster.getMarkers !== 'function') {
|
|
171
|
-
console.error('Cluster object or getMarkers method not available.');
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const markers = cluster.getMarkers();
|
|
176
|
-
|
|
177
|
-
if (!markers || markers.length === 0) {
|
|
178
|
-
console.error('No markers found in the cluster.');
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
setTimeout(() => {
|
|
183
|
-
const bounds = new window.google.maps.LatLngBounds();
|
|
184
|
-
|
|
185
|
-
markers.forEach(marker => {
|
|
186
|
-
bounds.extend(marker.getPosition());
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
bounds.extend(new google.maps.LatLng(siteConfig.optionalShowLocationClusterConfig.latitude, siteConfig.optionalShowLocationClusterConfig.longitude));
|
|
190
|
-
|
|
191
|
-
if (mapRef.current) {
|
|
192
|
-
mapRef.current.fitBounds(bounds);
|
|
193
|
-
}
|
|
194
|
-
}, 500);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
return (
|
|
198
|
-
<Map
|
|
199
|
-
zoom={zoom}
|
|
200
|
-
center={center}
|
|
201
|
-
mapContainerRef={mapContainerRef}
|
|
202
|
-
onLoad={onLoad}
|
|
203
|
-
onIdle={onIdle}
|
|
204
|
-
mapInteracted={mapInteracted}
|
|
205
|
-
pinIconUrl={pinIconUrl}
|
|
206
|
-
setMapInteracted={setMapInteracted}
|
|
207
|
-
fitBounds={fitBounds}
|
|
208
|
-
mapRef={mapRef}
|
|
209
|
-
setQuery={setQuery}
|
|
210
|
-
filteredListingsLength={filteredListings.length}
|
|
211
|
-
setSelectedFilters={setSelectedFilters}
|
|
212
|
-
>
|
|
213
|
-
<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)} onClick={onClusterClick}>
|
|
214
|
-
{clusterer => (
|
|
215
|
-
<>
|
|
216
|
-
{mapItems.map(item => (
|
|
217
|
-
<MapMarker
|
|
218
|
-
key={item.id}
|
|
219
|
-
item={item}
|
|
220
|
-
selectedLocation={location}
|
|
221
|
-
markerRefs={markerRefs}
|
|
222
|
-
infoWindowClasses={infoWindowClasses}
|
|
223
|
-
setSelectedLocation={setLocation}
|
|
224
|
-
markerClickHandler={markerClickHandler}
|
|
225
|
-
clusterer={clusterer}
|
|
226
|
-
markerIcon={markerIcon(markerConfigs)}
|
|
227
|
-
markerIconSelected={markerIconSelected(markerConfigs)}
|
|
228
|
-
setMapInteracted={setMapInteracted}
|
|
229
|
-
/>
|
|
230
|
-
))}
|
|
231
|
-
{poiMarkers && poiMarkers.markers.map((marker, index) => (
|
|
232
|
-
<PlaceMarker
|
|
233
|
-
key={`marker-${marker.title}-${index}`}
|
|
234
|
-
marker={marker}
|
|
235
|
-
index={index}
|
|
236
|
-
selectedPlaceMarker={selectedPlaceMarker}
|
|
237
|
-
placesWindow={placesWindow}
|
|
238
|
-
setPlacesWindow={setPlacesWindow}
|
|
239
|
-
setSelectedPlaceMarker={setSelectedPlaceMarker}
|
|
240
|
-
/>
|
|
241
|
-
))}
|
|
242
|
-
</>
|
|
243
|
-
)}
|
|
244
|
-
</MarkerClustererF>
|
|
245
|
-
</Map>
|
|
246
|
-
);
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
export default MapContainer;
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import MapMarker from "~/components/containers/maps/map-marker-container";
|
|
4
|
+
import PlaceMarker from "~/components/modules/maps/place-marker";
|
|
5
|
+
|
|
6
|
+
import { usePlaces } from "~/contexts/placesContext";
|
|
7
|
+
import { useMap } from "~/contexts/mapContext";
|
|
8
|
+
import { useMapList } from "~/contexts/mapListContext";
|
|
9
|
+
|
|
10
|
+
import { markerIconSelected, markerIcon, pinIcon } from "~/util/mapIconUtil";
|
|
11
|
+
|
|
12
|
+
import Map from "~/components/modules/maps/map";
|
|
13
|
+
import { MarkerClustererF } from "@react-google-maps/api";
|
|
14
|
+
import { clusterOptions } from "~/util/mapUtil";
|
|
15
|
+
|
|
16
|
+
const MapContainer = ({
|
|
17
|
+
markerConfigs,
|
|
18
|
+
infoWindowClasses,
|
|
19
|
+
clusterGridSize = 60
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
location,
|
|
23
|
+
zoom,
|
|
24
|
+
center,
|
|
25
|
+
selectLocationEntity,
|
|
26
|
+
setLocation,
|
|
27
|
+
mapInteracted,
|
|
28
|
+
setMapInteracted
|
|
29
|
+
} = useMap();
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
mapItems, filteredListings, setSelectedFilters,
|
|
33
|
+
setQuery,
|
|
34
|
+
siteConfig
|
|
35
|
+
} = useMapList();
|
|
36
|
+
|
|
37
|
+
const mapRef = useRef();
|
|
38
|
+
const markerRefs = useRef({});
|
|
39
|
+
const mapContainerRef = useRef(null);
|
|
40
|
+
const {
|
|
41
|
+
poiMarkers,
|
|
42
|
+
setCurrentCenter,
|
|
43
|
+
currentCenter,
|
|
44
|
+
setCurrentZoom,
|
|
45
|
+
currentZoom,
|
|
46
|
+
selectedPlaceMarker,
|
|
47
|
+
setSelectedPlaceMarker,
|
|
48
|
+
placesWindow,
|
|
49
|
+
setPlacesWindow } = usePlaces();
|
|
50
|
+
|
|
51
|
+
const onIdle = () => {
|
|
52
|
+
if (!currentCenter || !mapRef.current) return;
|
|
53
|
+
const newCenter = mapRef.current.getCenter().toJSON();
|
|
54
|
+
const newZoom = mapRef.current.zoom;
|
|
55
|
+
|
|
56
|
+
setCurrentCenter(newCenter);
|
|
57
|
+
|
|
58
|
+
if (newZoom !== currentZoom) {
|
|
59
|
+
setCurrentZoom(newZoom);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (mapContainerRef.current) {
|
|
65
|
+
const handleScroll = () => {
|
|
66
|
+
setMapInteracted(true);
|
|
67
|
+
};
|
|
68
|
+
var mapContainerRefCurrent = mapContainerRef.current;
|
|
69
|
+
mapContainerRef.current.addEventListener('wheel', handleScroll);
|
|
70
|
+
return () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);
|
|
71
|
+
}
|
|
72
|
+
}, [mapContainerRef.current]);
|
|
73
|
+
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (mapRef.current) {
|
|
76
|
+
const mapInstance = mapRef.current;
|
|
77
|
+
const dragStartListener = mapInstance.addListener('dragstart', () => setMapInteracted(true));
|
|
78
|
+
const mouseDownListener = mapInstance.addListener('mousedown', () => setMapInteracted(true));
|
|
79
|
+
return () => {
|
|
80
|
+
google.maps.event.removeListener(dragStartListener);
|
|
81
|
+
google.maps.event.removeListener(mouseDownListener);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
}, [mapRef.current, mapContainerRef.current]);
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {
|
|
88
|
+
fitBounds(mapRef.current);
|
|
89
|
+
}
|
|
90
|
+
}, [mapItems, mapRef.current, location]);
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current && mapInteracted) {
|
|
94
|
+
fitBounds(mapRef.current, true);
|
|
95
|
+
}
|
|
96
|
+
if (mapRef.current) {
|
|
97
|
+
let currZoom = mapRef.current.zoom;
|
|
98
|
+
let setZoomVal = currZoom < 13 ? currZoom : 12;
|
|
99
|
+
mapRef.current.setZoom(setZoomVal);
|
|
100
|
+
}
|
|
101
|
+
}, [filteredListings]);
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (!mapRef.current || !location || mapInteracted) return;
|
|
105
|
+
mapRef.current.panTo(
|
|
106
|
+
new google.maps.LatLng(location.latitude, location.longitude)
|
|
107
|
+
);
|
|
108
|
+
if (mapRef.current) {
|
|
109
|
+
let setZoomVal = zoom < 13 ? zoom : 12;
|
|
110
|
+
mapRef.current.setZoom(setZoomVal);
|
|
111
|
+
}
|
|
112
|
+
}, [location, zoom, mapRef.current]);
|
|
113
|
+
|
|
114
|
+
const fitBounds = (map, overload = false) => {
|
|
115
|
+
if ((mapInteracted === false || overload) && mapItems != null) {
|
|
116
|
+
const bounds = new window.google.maps.LatLngBounds();
|
|
117
|
+
mapItems.forEach(item => {
|
|
118
|
+
bounds.extend(new google.maps.LatLng(item.latitude, item.longitude));
|
|
119
|
+
});
|
|
120
|
+
if(siteConfig.optionalShowLocationClusterConfig){
|
|
121
|
+
let configLocation = new google.maps.LatLng(siteConfig.optionalShowLocationClusterConfig.latitude, siteConfig.optionalShowLocationClusterConfig.longitude);
|
|
122
|
+
map.panTo(configLocation);
|
|
123
|
+
bounds.extend(new google.maps.LatLng(siteConfig.optionalShowLocationClusterConfig.latitude, siteConfig.optionalShowLocationClusterConfig.longitude));
|
|
124
|
+
}
|
|
125
|
+
if (!map) return;
|
|
126
|
+
const currentCenter = map.getCenter();
|
|
127
|
+
map.fitBounds(bounds);
|
|
128
|
+
const newCenter = bounds.getCenter();
|
|
129
|
+
if (currentCenter && newCenter) {
|
|
130
|
+
map.panTo(newCenter);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (mapRef.current.zoom > 17) {
|
|
134
|
+
mapRef.current.setZoom(16);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const markerClickHandler = mapLocation => {
|
|
139
|
+
setMapInteracted(true);
|
|
140
|
+
selectLocationEntity(mapLocation);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const onLoad = map => {
|
|
144
|
+
if (!location || location === null) {
|
|
145
|
+
mapRef.current = map;
|
|
146
|
+
fitBounds(map, true);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
mapRef.current = map;
|
|
150
|
+
|
|
151
|
+
if (mapInteracted === false) {
|
|
152
|
+
mapRef.current.panTo(
|
|
153
|
+
new google.maps.LatLng(location.latitude, location.longitude)
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
mapRef.current.setZoom(zoom);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
const pinIconUrl = pinIcon({
|
|
161
|
+
fillColor: markerConfigs.fillColor,
|
|
162
|
+
strokeColor: markerConfigs.strokeColor
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
const onClusterClick = cluster => {
|
|
166
|
+
if(!siteConfig.optionalShowLocationClusterConfig || (mapRef.current.zoom > siteConfig.optionalShowLocationClusterConfig.showForZoomLevelLessThan)) {
|
|
167
|
+
console.log("should return");
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (!cluster || typeof cluster.getMarkers !== 'function') {
|
|
171
|
+
console.error('Cluster object or getMarkers method not available.');
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const markers = cluster.getMarkers();
|
|
176
|
+
|
|
177
|
+
if (!markers || markers.length === 0) {
|
|
178
|
+
console.error('No markers found in the cluster.');
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
setTimeout(() => {
|
|
183
|
+
const bounds = new window.google.maps.LatLngBounds();
|
|
184
|
+
|
|
185
|
+
markers.forEach(marker => {
|
|
186
|
+
bounds.extend(marker.getPosition());
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
bounds.extend(new google.maps.LatLng(siteConfig.optionalShowLocationClusterConfig.latitude, siteConfig.optionalShowLocationClusterConfig.longitude));
|
|
190
|
+
|
|
191
|
+
if (mapRef.current) {
|
|
192
|
+
mapRef.current.fitBounds(bounds);
|
|
193
|
+
}
|
|
194
|
+
}, 500);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
return (
|
|
198
|
+
<Map
|
|
199
|
+
zoom={zoom}
|
|
200
|
+
center={center}
|
|
201
|
+
mapContainerRef={mapContainerRef}
|
|
202
|
+
onLoad={onLoad}
|
|
203
|
+
onIdle={onIdle}
|
|
204
|
+
mapInteracted={mapInteracted}
|
|
205
|
+
pinIconUrl={pinIconUrl}
|
|
206
|
+
setMapInteracted={setMapInteracted}
|
|
207
|
+
fitBounds={fitBounds}
|
|
208
|
+
mapRef={mapRef}
|
|
209
|
+
setQuery={setQuery}
|
|
210
|
+
filteredListingsLength={filteredListings.length}
|
|
211
|
+
setSelectedFilters={setSelectedFilters}
|
|
212
|
+
>
|
|
213
|
+
<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)} onClick={onClusterClick}>
|
|
214
|
+
{clusterer => (
|
|
215
|
+
<>
|
|
216
|
+
{mapItems.map(item => (
|
|
217
|
+
<MapMarker
|
|
218
|
+
key={item.id}
|
|
219
|
+
item={item}
|
|
220
|
+
selectedLocation={location}
|
|
221
|
+
markerRefs={markerRefs}
|
|
222
|
+
infoWindowClasses={infoWindowClasses}
|
|
223
|
+
setSelectedLocation={setLocation}
|
|
224
|
+
markerClickHandler={markerClickHandler}
|
|
225
|
+
clusterer={clusterer}
|
|
226
|
+
markerIcon={markerIcon(markerConfigs)}
|
|
227
|
+
markerIconSelected={markerIconSelected(markerConfigs)}
|
|
228
|
+
setMapInteracted={setMapInteracted}
|
|
229
|
+
/>
|
|
230
|
+
))}
|
|
231
|
+
{poiMarkers && poiMarkers.markers.map((marker, index) => (
|
|
232
|
+
<PlaceMarker
|
|
233
|
+
key={`marker-${marker.title}-${index}`}
|
|
234
|
+
marker={marker}
|
|
235
|
+
index={index}
|
|
236
|
+
selectedPlaceMarker={selectedPlaceMarker}
|
|
237
|
+
placesWindow={placesWindow}
|
|
238
|
+
setPlacesWindow={setPlacesWindow}
|
|
239
|
+
setSelectedPlaceMarker={setSelectedPlaceMarker}
|
|
240
|
+
/>
|
|
241
|
+
))}
|
|
242
|
+
</>
|
|
243
|
+
)}
|
|
244
|
+
</MarkerClustererF>
|
|
245
|
+
</Map>
|
|
246
|
+
);
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
export default MapContainer;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import List from '~/components/containers/list/item-list-container';
|
|
4
|
-
import Map from '~/components/containers/maps/map-container';
|
|
5
|
-
import Filter from '~/components/containers/filter/filter-container';
|
|
6
|
-
import MapList from '~/components/modules/maps/map-list';
|
|
7
|
-
|
|
8
|
-
const MapListContainer = ({
|
|
9
|
-
loading = false,
|
|
10
|
-
mapDetails,
|
|
11
|
-
markerConfigs,
|
|
12
|
-
itemExpandedContent,
|
|
13
|
-
fieldsShown,
|
|
14
|
-
specialFeatures,
|
|
15
|
-
fieldNames,
|
|
16
|
-
showMap,
|
|
17
|
-
placeMappings,
|
|
18
|
-
mapPosition
|
|
19
|
-
}) => {
|
|
20
|
-
|
|
21
|
-
const listProps = {
|
|
22
|
-
fieldsShown,
|
|
23
|
-
fieldNames,
|
|
24
|
-
itemExpandedContent,
|
|
25
|
-
loading,
|
|
26
|
-
showMap,
|
|
27
|
-
specialFeatures
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const mapProps = {
|
|
31
|
-
mapDetails,
|
|
32
|
-
markerConfigs,
|
|
33
|
-
placeMappings,
|
|
34
|
-
clusterGridSize: 60,
|
|
35
|
-
showMap
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<MapList
|
|
40
|
-
showMap={showMap}
|
|
41
|
-
loading={loading}
|
|
42
|
-
list={<List {...listProps} />}
|
|
43
|
-
map={<Map {...mapProps} />}
|
|
44
|
-
filter={<Filter showMap={showMap} className="md:hc-hidden" />}
|
|
45
|
-
mapPosition={mapPosition}
|
|
46
|
-
/>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default MapListContainer;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import List from '~/components/containers/list/item-list-container';
|
|
4
|
+
import Map from '~/components/containers/maps/map-container';
|
|
5
|
+
import Filter from '~/components/containers/filter/filter-container';
|
|
6
|
+
import MapList from '~/components/modules/maps/map-list';
|
|
7
|
+
|
|
8
|
+
const MapListContainer = ({
|
|
9
|
+
loading = false,
|
|
10
|
+
mapDetails,
|
|
11
|
+
markerConfigs,
|
|
12
|
+
itemExpandedContent,
|
|
13
|
+
fieldsShown,
|
|
14
|
+
specialFeatures,
|
|
15
|
+
fieldNames,
|
|
16
|
+
showMap,
|
|
17
|
+
placeMappings,
|
|
18
|
+
mapPosition
|
|
19
|
+
}) => {
|
|
20
|
+
|
|
21
|
+
const listProps = {
|
|
22
|
+
fieldsShown,
|
|
23
|
+
fieldNames,
|
|
24
|
+
itemExpandedContent,
|
|
25
|
+
loading,
|
|
26
|
+
showMap,
|
|
27
|
+
specialFeatures
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const mapProps = {
|
|
31
|
+
mapDetails,
|
|
32
|
+
markerConfigs,
|
|
33
|
+
placeMappings,
|
|
34
|
+
clusterGridSize: 60,
|
|
35
|
+
showMap
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<MapList
|
|
40
|
+
showMap={showMap}
|
|
41
|
+
loading={loading}
|
|
42
|
+
list={<List {...listProps} />}
|
|
43
|
+
map={<Map {...mapProps} />}
|
|
44
|
+
filter={<Filter showMap={showMap} className="md:hc-hidden" />}
|
|
45
|
+
mapPosition={mapPosition}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default MapListContainer;
|