@abcagency/hc-ui-components 1.3.13 → 1.3.15
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/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/dist/apis/hcApi.js +1 -1
- package/dist/apis/hcApi.js.map +1 -1
- package/dist/clientToken.js.map +1 -1
- package/dist/components/HireControlMap.js.map +1 -1
- package/dist/components/modules/accordions/MapAccordionItem.js.map +1 -1
- package/dist/components/modules/accordions/default.js.map +1 -1
- package/dist/components/modules/accordions/filterItem.js +2 -1
- package/dist/components/modules/accordions/filterItem.js.map +1 -1
- package/dist/components/modules/accordions/filters.js +0 -3
- package/dist/components/modules/accordions/filters.js.map +1 -1
- 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.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.map +1 -1
- package/dist/components/modules/cards/filter.js.map +1 -1
- package/dist/components/modules/dialogs/apply-dialog.js.map +1 -1
- package/dist/components/modules/filter/commute.js.map +1 -1
- package/dist/components/modules/filter/item.js +6 -1
- package/dist/components/modules/filter/item.js.map +1 -1
- package/dist/components/modules/filter/location.js +5 -3
- package/dist/components/modules/filter/location.js.map +1 -1
- package/dist/components/modules/filter/points-of-interest.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.map +1 -1
- package/dist/components/modules/grid.js.map +1 -1
- package/dist/components/modules/icon.js.map +1 -1
- package/dist/components/modules/jobListing/listing-details.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/list/field-mapper.js.map +1 -1
- package/dist/components/modules/maps/list/header-item.js.map +1 -1
- package/dist/components/modules/maps/list/header.js.map +1 -1
- package/dist/components/modules/maps/list/index.js +11 -10
- package/dist/components/modules/maps/list/index.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/index.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-details.js.map +1 -1
- package/dist/components/modules/maps/list/item-expand-card/recruiter-headshot.js.map +1 -1
- package/dist/components/modules/maps/list/list-item/index.js.map +1 -1
- package/dist/components/modules/maps/map-list.js.map +1 -1
- package/dist/components/modules/maps/map-marker.js.map +1 -1
- package/dist/components/modules/maps/map.js.map +1 -1
- package/dist/components/modules/maps/place-marker.js.map +1 -1
- package/dist/components/modules/maps/tabs.js.map +1 -1
- package/dist/constants/placeTypes.js.map +1 -1
- package/dist/contexts/mapContext.js +9 -27
- package/dist/contexts/mapContext.js.map +1 -1
- package/dist/contexts/mapListContext.js +54 -37
- package/dist/contexts/mapListContext.js.map +1 -1
- package/dist/contexts/placesContext.js.map +1 -1
- package/dist/hooks/useList.js +3 -15
- package/dist/hooks/useList.js.map +1 -1
- package/dist/services/apis/hcApi.js +1 -1
- package/dist/services/apis/hcApi.js.map +1 -1
- package/dist/services/clientToken.js.map +1 -1
- package/dist/services/configService.js.map +1 -1
- package/dist/services/googlePlacesNearbyService.js.map +1 -1
- package/dist/services/listingAggregatorService.js +43 -16
- package/dist/services/listingAggregatorService.js.map +1 -1
- package/dist/services/listingEntityService.js.map +1 -1
- package/dist/services/listingService.js.map +1 -1
- package/dist/services/recruiterService.js.map +1 -1
- package/dist/util/filterUtil.js.map +1 -1
- package/dist/util/loading.js.map +1 -1
- 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/jsconfig.json +7 -7
- package/package.json +7 -7
- package/postcss.config.js +13 -13
- package/preset.default.js +15 -15
- package/rollup.config.mjs +88 -87
- package/src/apis/hcApi.js +93 -93
- package/src/clientToken.js +9 -9
- package/src/components/HireControlMap.js +124 -124
- package/src/components/modules/accordions/MapAccordionItem.js +72 -72
- package/src/components/modules/accordions/default.js +171 -171
- package/src/components/modules/accordions/filterItem.js +3 -1
- package/src/components/modules/accordions/filters.js +1 -1
- package/src/components/modules/buttons/button-group-apply.js +116 -116
- 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 +20 -20
- 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 +149 -149
- package/src/components/modules/filter/item.js +5 -0
- package/src/components/modules/filter/location.js +5 -3
- package/src/components/modules/filter/points-of-interest.js +44 -44
- package/src/components/modules/filter/radio-item.js +53 -53
- package/src/components/modules/filter/search.js +92 -92
- 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 +95 -95
- package/src/components/modules/maps/info-window-card.js +17 -17
- package/src/components/modules/maps/info-window-content.js +74 -74
- package/src/components/modules/maps/list/field-mapper.js +112 -112
- package/src/components/modules/maps/list/header-item.js +91 -91
- package/src/components/modules/maps/list/header.js +47 -47
- package/src/components/modules/maps/list/index.js +7 -7
- package/src/components/modules/maps/list/item-expand-card/index.js +22 -22
- package/src/components/modules/maps/list/item-expand-card/recruiter-contact-nav.js +50 -50
- package/src/components/modules/maps/list/item-expand-card/recruiter-details.js +68 -68
- package/src/components/modules/maps/list/item-expand-card/recruiter-headshot.js +22 -22
- package/src/components/modules/maps/list/list-item/index.js +133 -133
- package/src/components/modules/maps/map-list.js +74 -74
- package/src/components/modules/maps/map-marker.js +86 -86
- package/src/components/modules/maps/map.js +230 -230
- package/src/components/modules/maps/place-marker.js +41 -41
- package/src/components/modules/maps/tabs.js +81 -81
- package/src/constants/placeTypes.js +8 -8
- package/src/contexts/mapContext.js +0 -14
- package/src/contexts/mapListContext.js +26 -8
- package/src/contexts/placesContext.js +102 -102
- package/src/hooks/useList.js +4 -16
- package/src/index.js +3 -3
- package/src/services/configService.js +16 -16
- package/src/services/googlePlacesNearbyService.js +33 -33
- package/src/services/listingAggregatorService.js +9 -4
- package/src/services/listingEntityService.js +15 -15
- package/src/services/listingService.js +26 -26
- package/src/services/recruiterService.js +17 -17
- package/src/styles/index.css +23 -23
- package/src/util/arrayUtil.js +3 -3
- package/src/util/fieldMapper.js +22 -22
- package/src/util/filterUtil.js +195 -195
- package/src/util/loading.js +17 -17
- package/src/util/localStorageUtil.js +26 -26
- package/src/util/mapIconUtil.js +180 -180
- package/src/util/mapUtil.js +91 -91
- package/src/util/sortUtil.js +32 -32
- package/src/util/stringUtils.js +6 -6
- package/tailwind.config.js +126 -126
- package/.editorconfig +0 -12
- package/.eslintrc +0 -105
- package/.prettierignore +0 -3
|
@@ -1,230 +1,230 @@
|
|
|
1
|
-
/* eslint-disable no-undef */
|
|
2
|
-
import React, { useEffect, useRef } from 'react';
|
|
3
|
-
import { GoogleMap, MarkerClustererF } from "@react-google-maps/api";
|
|
4
|
-
|
|
5
|
-
import MapMarker from "~/components/modules/maps/map-marker";
|
|
6
|
-
import PlaceMarker from "~/components/modules/maps/place-marker";
|
|
7
|
-
import ShowAllButton from "~/components/modules/buttons/show-all-button";
|
|
8
|
-
|
|
9
|
-
import { usePlaces } from "~/contexts/placesContext";
|
|
10
|
-
import { useMap } from "~/contexts/mapContext";
|
|
11
|
-
import { useMapList } from "~/contexts/mapListContext";
|
|
12
|
-
|
|
13
|
-
import { markerIconSelected, markerIcon, pinIcon } from "~/util/mapIconUtil";
|
|
14
|
-
import { clusterOptions } from "~/util/mapUtil";
|
|
15
|
-
|
|
16
|
-
const Map = ({
|
|
17
|
-
markerConfigs,
|
|
18
|
-
infoWindowClasses,
|
|
19
|
-
clusterGridSize = 60
|
|
20
|
-
}) => {
|
|
21
|
-
const {
|
|
22
|
-
location,
|
|
23
|
-
zoom,
|
|
24
|
-
center,
|
|
25
|
-
commuteLocation,
|
|
26
|
-
selectLocationEntity,
|
|
27
|
-
setLocation,
|
|
28
|
-
mapInteracted,
|
|
29
|
-
setMapInteracted
|
|
30
|
-
} = useMap();
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
mapItems, filteredListings, setSelectedFilters,
|
|
34
|
-
setQuery
|
|
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 (!map) return;
|
|
121
|
-
map.fitBounds(bounds);
|
|
122
|
-
}
|
|
123
|
-
if (mapRef.current.zoom > 17) {
|
|
124
|
-
mapRef.current.setZoom(16);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
const markerClickHandler = mapLocation => {
|
|
129
|
-
setMapInteracted(true);
|
|
130
|
-
selectLocationEntity(mapLocation);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
const onLoad = map => {
|
|
134
|
-
if (!location || location === null) {
|
|
135
|
-
mapRef.current = map;
|
|
136
|
-
fitBounds(map, true);
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
mapRef.current = map;
|
|
140
|
-
|
|
141
|
-
if (mapInteracted === false) {
|
|
142
|
-
mapRef.current.panTo(
|
|
143
|
-
new google.maps.LatLng(location.latitude, location.longitude)
|
|
144
|
-
);
|
|
145
|
-
|
|
146
|
-
mapRef.current.setZoom(zoom);
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
const pinIconUrl = pinIcon({
|
|
151
|
-
fillColor: markerConfigs.fillColor,
|
|
152
|
-
strokeColor: markerConfigs.strokeColor
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<>{zoom && center && <div ref={mapContainerRef} className="hc-h-full hc-relative">
|
|
157
|
-
<GoogleMap
|
|
158
|
-
zoom={zoom}
|
|
159
|
-
onLoad={onLoad}
|
|
160
|
-
onIdle={onIdle}
|
|
161
|
-
center={center}
|
|
162
|
-
mapContainerStyle={{
|
|
163
|
-
width: "100%",
|
|
164
|
-
height: "100%"
|
|
165
|
-
}}
|
|
166
|
-
options={{
|
|
167
|
-
styles: [
|
|
168
|
-
{
|
|
169
|
-
featureType: "poi",
|
|
170
|
-
elementType: "labels",
|
|
171
|
-
stylers: [{ visibility: "off" }]
|
|
172
|
-
}
|
|
173
|
-
]
|
|
174
|
-
}}
|
|
175
|
-
>
|
|
176
|
-
<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>
|
|
177
|
-
{clusterer => (
|
|
178
|
-
<>
|
|
179
|
-
{mapItems.map(item => (
|
|
180
|
-
<MapMarker
|
|
181
|
-
key={item.id}
|
|
182
|
-
item={item}
|
|
183
|
-
selectedLocation={location}
|
|
184
|
-
markerRefs={markerRefs}
|
|
185
|
-
infoWindowClasses={infoWindowClasses}
|
|
186
|
-
setSelectedLocation={setLocation}
|
|
187
|
-
markerClickHandler={markerClickHandler}
|
|
188
|
-
clusterer={clusterer}
|
|
189
|
-
markerIcon={markerIcon(markerConfigs)}
|
|
190
|
-
markerIconSelected={markerIconSelected(markerConfigs)}
|
|
191
|
-
setMapInteracted={setMapInteracted}
|
|
192
|
-
/>
|
|
193
|
-
))}
|
|
194
|
-
{poiMarkers && poiMarkers.markers.map((marker, index) => {
|
|
195
|
-
return (
|
|
196
|
-
<PlaceMarker
|
|
197
|
-
key={`marker-${marker.title}-${index}`}
|
|
198
|
-
marker={marker}
|
|
199
|
-
index={index}
|
|
200
|
-
selectedPlaceMarker={selectedPlaceMarker}
|
|
201
|
-
placesWindow={placesWindow}
|
|
202
|
-
setPlacesWindow={setPlacesWindow}
|
|
203
|
-
setSelectedPlaceMarker={setSelectedPlaceMarker}
|
|
204
|
-
/>
|
|
205
|
-
);
|
|
206
|
-
})}
|
|
207
|
-
</>
|
|
208
|
-
)}
|
|
209
|
-
</MarkerClustererF>
|
|
210
|
-
</GoogleMap>
|
|
211
|
-
{mapInteracted && markerConfigs && (
|
|
212
|
-
<ShowAllButton
|
|
213
|
-
mapInteracted={mapInteracted}
|
|
214
|
-
markerConfigs={markerConfigs}
|
|
215
|
-
setMapInteracted={setMapInteracted}
|
|
216
|
-
fitBounds={fitBounds}
|
|
217
|
-
mapRef={mapRef}
|
|
218
|
-
pinIconUrl={pinIconUrl}
|
|
219
|
-
setQuery={setQuery}
|
|
220
|
-
listingCount={filteredListings.length}
|
|
221
|
-
setSelectedFilters={setSelectedFilters}
|
|
222
|
-
/>
|
|
223
|
-
)}
|
|
224
|
-
</div>
|
|
225
|
-
}
|
|
226
|
-
</>
|
|
227
|
-
);
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export default Map;
|
|
1
|
+
/* eslint-disable no-undef */
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import { GoogleMap, MarkerClustererF } from "@react-google-maps/api";
|
|
4
|
+
|
|
5
|
+
import MapMarker from "~/components/modules/maps/map-marker";
|
|
6
|
+
import PlaceMarker from "~/components/modules/maps/place-marker";
|
|
7
|
+
import ShowAllButton from "~/components/modules/buttons/show-all-button";
|
|
8
|
+
|
|
9
|
+
import { usePlaces } from "~/contexts/placesContext";
|
|
10
|
+
import { useMap } from "~/contexts/mapContext";
|
|
11
|
+
import { useMapList } from "~/contexts/mapListContext";
|
|
12
|
+
|
|
13
|
+
import { markerIconSelected, markerIcon, pinIcon } from "~/util/mapIconUtil";
|
|
14
|
+
import { clusterOptions } from "~/util/mapUtil";
|
|
15
|
+
|
|
16
|
+
const Map = ({
|
|
17
|
+
markerConfigs,
|
|
18
|
+
infoWindowClasses,
|
|
19
|
+
clusterGridSize = 60
|
|
20
|
+
}) => {
|
|
21
|
+
const {
|
|
22
|
+
location,
|
|
23
|
+
zoom,
|
|
24
|
+
center,
|
|
25
|
+
commuteLocation,
|
|
26
|
+
selectLocationEntity,
|
|
27
|
+
setLocation,
|
|
28
|
+
mapInteracted,
|
|
29
|
+
setMapInteracted
|
|
30
|
+
} = useMap();
|
|
31
|
+
|
|
32
|
+
const {
|
|
33
|
+
mapItems, filteredListings, setSelectedFilters,
|
|
34
|
+
setQuery
|
|
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 (!map) return;
|
|
121
|
+
map.fitBounds(bounds);
|
|
122
|
+
}
|
|
123
|
+
if (mapRef.current.zoom > 17) {
|
|
124
|
+
mapRef.current.setZoom(16);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const markerClickHandler = mapLocation => {
|
|
129
|
+
setMapInteracted(true);
|
|
130
|
+
selectLocationEntity(mapLocation);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const onLoad = map => {
|
|
134
|
+
if (!location || location === null) {
|
|
135
|
+
mapRef.current = map;
|
|
136
|
+
fitBounds(map, true);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
mapRef.current = map;
|
|
140
|
+
|
|
141
|
+
if (mapInteracted === false) {
|
|
142
|
+
mapRef.current.panTo(
|
|
143
|
+
new google.maps.LatLng(location.latitude, location.longitude)
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
mapRef.current.setZoom(zoom);
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const pinIconUrl = pinIcon({
|
|
151
|
+
fillColor: markerConfigs.fillColor,
|
|
152
|
+
strokeColor: markerConfigs.strokeColor
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<>{zoom && center && <div ref={mapContainerRef} className="hc-h-full hc-relative">
|
|
157
|
+
<GoogleMap
|
|
158
|
+
zoom={zoom}
|
|
159
|
+
onLoad={onLoad}
|
|
160
|
+
onIdle={onIdle}
|
|
161
|
+
center={center}
|
|
162
|
+
mapContainerStyle={{
|
|
163
|
+
width: "100%",
|
|
164
|
+
height: "100%"
|
|
165
|
+
}}
|
|
166
|
+
options={{
|
|
167
|
+
styles: [
|
|
168
|
+
{
|
|
169
|
+
featureType: "poi",
|
|
170
|
+
elementType: "labels",
|
|
171
|
+
stylers: [{ visibility: "off" }]
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}}
|
|
175
|
+
>
|
|
176
|
+
<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>
|
|
177
|
+
{clusterer => (
|
|
178
|
+
<>
|
|
179
|
+
{mapItems.map(item => (
|
|
180
|
+
<MapMarker
|
|
181
|
+
key={item.id}
|
|
182
|
+
item={item}
|
|
183
|
+
selectedLocation={location}
|
|
184
|
+
markerRefs={markerRefs}
|
|
185
|
+
infoWindowClasses={infoWindowClasses}
|
|
186
|
+
setSelectedLocation={setLocation}
|
|
187
|
+
markerClickHandler={markerClickHandler}
|
|
188
|
+
clusterer={clusterer}
|
|
189
|
+
markerIcon={markerIcon(markerConfigs)}
|
|
190
|
+
markerIconSelected={markerIconSelected(markerConfigs)}
|
|
191
|
+
setMapInteracted={setMapInteracted}
|
|
192
|
+
/>
|
|
193
|
+
))}
|
|
194
|
+
{poiMarkers && poiMarkers.markers.map((marker, index) => {
|
|
195
|
+
return (
|
|
196
|
+
<PlaceMarker
|
|
197
|
+
key={`marker-${marker.title}-${index}`}
|
|
198
|
+
marker={marker}
|
|
199
|
+
index={index}
|
|
200
|
+
selectedPlaceMarker={selectedPlaceMarker}
|
|
201
|
+
placesWindow={placesWindow}
|
|
202
|
+
setPlacesWindow={setPlacesWindow}
|
|
203
|
+
setSelectedPlaceMarker={setSelectedPlaceMarker}
|
|
204
|
+
/>
|
|
205
|
+
);
|
|
206
|
+
})}
|
|
207
|
+
</>
|
|
208
|
+
)}
|
|
209
|
+
</MarkerClustererF>
|
|
210
|
+
</GoogleMap>
|
|
211
|
+
{mapInteracted && markerConfigs && (
|
|
212
|
+
<ShowAllButton
|
|
213
|
+
mapInteracted={mapInteracted}
|
|
214
|
+
markerConfigs={markerConfigs}
|
|
215
|
+
setMapInteracted={setMapInteracted}
|
|
216
|
+
fitBounds={fitBounds}
|
|
217
|
+
mapRef={mapRef}
|
|
218
|
+
pinIconUrl={pinIconUrl}
|
|
219
|
+
setQuery={setQuery}
|
|
220
|
+
listingCount={filteredListings.length}
|
|
221
|
+
setSelectedFilters={setSelectedFilters}
|
|
222
|
+
/>
|
|
223
|
+
)}
|
|
224
|
+
</div>
|
|
225
|
+
}
|
|
226
|
+
</>
|
|
227
|
+
);
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export default Map;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Marker, InfoWindowF } from '@react-google-maps/api';
|
|
3
|
-
|
|
4
|
-
const PlaceMarker = ({
|
|
5
|
-
marker,
|
|
6
|
-
index,
|
|
7
|
-
selectedPlaceMarker,
|
|
8
|
-
setSelectedPlaceMarker,
|
|
9
|
-
placesWindow,
|
|
10
|
-
setPlacesWindow
|
|
11
|
-
}) => {
|
|
12
|
-
const markerKey = `marker-${marker.title}-${index}`;
|
|
13
|
-
|
|
14
|
-
const placeMarkerClickHandler = () => {
|
|
15
|
-
setSelectedPlaceMarker(markerKey);
|
|
16
|
-
setPlacesWindow(true);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<Marker
|
|
21
|
-
key={markerKey}
|
|
22
|
-
position={marker.position}
|
|
23
|
-
title={marker.title}
|
|
24
|
-
icon={marker.icon}
|
|
25
|
-
options={{ optimized: false }}
|
|
26
|
-
onClick={placeMarkerClickHandler}
|
|
27
|
-
>
|
|
28
|
-
{selectedPlaceMarker === markerKey && placesWindow && marker && (
|
|
29
|
-
<InfoWindowF
|
|
30
|
-
position={marker.position}
|
|
31
|
-
onCloseClick={() => setPlacesWindow(false)}
|
|
32
|
-
options={{ maxWidth: 400 }}
|
|
33
|
-
>
|
|
34
|
-
<div>{marker.title}</div>
|
|
35
|
-
</InfoWindowF>
|
|
36
|
-
)}
|
|
37
|
-
</Marker>
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export default PlaceMarker;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Marker, InfoWindowF } from '@react-google-maps/api';
|
|
3
|
+
|
|
4
|
+
const PlaceMarker = ({
|
|
5
|
+
marker,
|
|
6
|
+
index,
|
|
7
|
+
selectedPlaceMarker,
|
|
8
|
+
setSelectedPlaceMarker,
|
|
9
|
+
placesWindow,
|
|
10
|
+
setPlacesWindow
|
|
11
|
+
}) => {
|
|
12
|
+
const markerKey = `marker-${marker.title}-${index}`;
|
|
13
|
+
|
|
14
|
+
const placeMarkerClickHandler = () => {
|
|
15
|
+
setSelectedPlaceMarker(markerKey);
|
|
16
|
+
setPlacesWindow(true);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Marker
|
|
21
|
+
key={markerKey}
|
|
22
|
+
position={marker.position}
|
|
23
|
+
title={marker.title}
|
|
24
|
+
icon={marker.icon}
|
|
25
|
+
options={{ optimized: false }}
|
|
26
|
+
onClick={placeMarkerClickHandler}
|
|
27
|
+
>
|
|
28
|
+
{selectedPlaceMarker === markerKey && placesWindow && marker && (
|
|
29
|
+
<InfoWindowF
|
|
30
|
+
position={marker.position}
|
|
31
|
+
onCloseClick={() => setPlacesWindow(false)}
|
|
32
|
+
options={{ maxWidth: 400 }}
|
|
33
|
+
>
|
|
34
|
+
<div>{marker.title}</div>
|
|
35
|
+
</InfoWindowF>
|
|
36
|
+
)}
|
|
37
|
+
</Marker>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default PlaceMarker;
|