@abcagency/hc-ui-components 1.3.9 → 1.3.11
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.
|
@@ -18,8 +18,9 @@ var Map = function Map(_ref) {
|
|
|
18
18
|
var _useMap = useMap(),
|
|
19
19
|
location = _useMap.location,
|
|
20
20
|
zoom = _useMap.zoom,
|
|
21
|
-
center = _useMap.center
|
|
22
|
-
|
|
21
|
+
center = _useMap.center;
|
|
22
|
+
_useMap.commuteLocation;
|
|
23
|
+
var selectLocationEntity = _useMap.selectLocationEntity,
|
|
23
24
|
setLocation = _useMap.setLocation,
|
|
24
25
|
mapInteracted = _useMap.mapInteracted,
|
|
25
26
|
setMapInteracted = _useMap.setMapInteracted;
|
|
@@ -51,25 +52,24 @@ var Map = function Map(_ref) {
|
|
|
51
52
|
}
|
|
52
53
|
};
|
|
53
54
|
useEffect(function () {
|
|
54
|
-
|
|
55
|
-
if (current) {
|
|
55
|
+
if (mapContainerRef.current) {
|
|
56
56
|
var handleScroll = function handleScroll() {
|
|
57
57
|
setMapInteracted(true);
|
|
58
58
|
};
|
|
59
|
-
current
|
|
59
|
+
var mapContainerRefCurrent = mapContainerRef.current;
|
|
60
|
+
mapContainerRef.current.addEventListener('wheel', handleScroll);
|
|
60
61
|
return function () {
|
|
61
|
-
return
|
|
62
|
+
return mapContainerRefCurrent.removeEventListener('wheel', handleScroll);
|
|
62
63
|
};
|
|
63
64
|
}
|
|
64
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
65
|
}, [mapContainerRef.current]);
|
|
66
66
|
useEffect(function () {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var dragStartListener =
|
|
67
|
+
if (mapRef.current) {
|
|
68
|
+
var mapInstance = mapRef.current;
|
|
69
|
+
var dragStartListener = mapInstance.addListener('dragstart', function () {
|
|
70
70
|
return setMapInteracted(true);
|
|
71
71
|
});
|
|
72
|
-
var mouseDownListener =
|
|
72
|
+
var mouseDownListener = mapInstance.addListener('mousedown', function () {
|
|
73
73
|
return setMapInteracted(true);
|
|
74
74
|
});
|
|
75
75
|
return function () {
|
|
@@ -77,40 +77,32 @@ var Map = function Map(_ref) {
|
|
|
77
77
|
google.maps.event.removeListener(mouseDownListener);
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
}, [mapRef.current]);
|
|
80
|
+
}, [mapRef.current, mapContainerRef.current]);
|
|
82
81
|
useEffect(function () {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
fitBounds(current);
|
|
82
|
+
if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {
|
|
83
|
+
fitBounds(mapRef.current);
|
|
86
84
|
}
|
|
87
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
88
85
|
}, [mapItems, mapRef.current, location]);
|
|
89
86
|
useEffect(function () {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
fitBounds(current, true);
|
|
87
|
+
if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && mapRef.current && mapInteracted) {
|
|
88
|
+
fitBounds(mapRef.current, true);
|
|
93
89
|
}
|
|
94
|
-
if (current) {
|
|
95
|
-
var currZoom = current.zoom;
|
|
90
|
+
if (mapRef.current) {
|
|
91
|
+
var currZoom = mapRef.current.zoom;
|
|
96
92
|
var setZoomVal = currZoom < 13 ? currZoom : 12;
|
|
97
|
-
current.setZoom(setZoomVal);
|
|
93
|
+
mapRef.current.setZoom(setZoomVal);
|
|
98
94
|
}
|
|
99
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
100
95
|
}, [filteredListings]);
|
|
101
96
|
useEffect(function () {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (current) {
|
|
97
|
+
if (!mapRef.current || !location || mapInteracted) return;
|
|
98
|
+
mapRef.current.panTo(new google.maps.LatLng(location.latitude, location.longitude));
|
|
99
|
+
if (mapRef.current) {
|
|
106
100
|
var setZoomVal = zoom < 13 ? zoom : 12;
|
|
107
|
-
current.setZoom(setZoomVal);
|
|
101
|
+
mapRef.current.setZoom(setZoomVal);
|
|
108
102
|
}
|
|
109
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
110
103
|
}, [location, zoom, mapRef.current]);
|
|
111
104
|
var fitBounds = function fitBounds(map) {
|
|
112
105
|
var overload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
113
|
-
var current = mapRef.current;
|
|
114
106
|
if ((mapInteracted === false || overload) && mapItems != null) {
|
|
115
107
|
var bounds = new window.google.maps.LatLngBounds();
|
|
116
108
|
mapItems.forEach(function (item) {
|
|
@@ -119,8 +111,8 @@ var Map = function Map(_ref) {
|
|
|
119
111
|
if (!map) return;
|
|
120
112
|
map.fitBounds(bounds);
|
|
121
113
|
}
|
|
122
|
-
if (current.zoom > 17) {
|
|
123
|
-
current.setZoom(16);
|
|
114
|
+
if (mapRef.current.zoom > 17) {
|
|
115
|
+
mapRef.current.setZoom(16);
|
|
124
116
|
}
|
|
125
117
|
};
|
|
126
118
|
var markerClickHandler = function markerClickHandler(mapLocation) {
|
|
@@ -128,16 +120,15 @@ var Map = function Map(_ref) {
|
|
|
128
120
|
selectLocationEntity(mapLocation);
|
|
129
121
|
};
|
|
130
122
|
var onLoad = function onLoad(map) {
|
|
131
|
-
var current = mapRef.current;
|
|
132
123
|
if (!location || location === null) {
|
|
133
|
-
current = map;
|
|
124
|
+
mapRef.current = map;
|
|
134
125
|
fitBounds(map, true);
|
|
135
126
|
return;
|
|
136
127
|
}
|
|
137
|
-
current = map;
|
|
128
|
+
mapRef.current = map;
|
|
138
129
|
if (mapInteracted === false) {
|
|
139
|
-
current.panTo(new google.maps.LatLng(location.latitude, location.longitude));
|
|
140
|
-
current.setZoom(zoom);
|
|
130
|
+
mapRef.current.panTo(new google.maps.LatLng(location.latitude, location.longitude));
|
|
131
|
+
mapRef.current.setZoom(zoom);
|
|
141
132
|
}
|
|
142
133
|
};
|
|
143
134
|
var pinIconUrl = pinIcon({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.js","sources":["../../../../src/components/modules/maps/map.js"],"sourcesContent":["/* eslint-disable no-undef */\nimport React, { useEffect, useRef } from 'react';\nimport { GoogleMap, MarkerClustererF } from \"@react-google-maps/api\";\n\nimport MapMarker from \"~/components/modules/maps/map-marker\";\nimport PlaceMarker from \"~/components/modules/maps/place-marker\";\nimport ShowAllButton from \"~/components/modules/buttons/show-all-button\";\n\nimport { usePlaces } from \"~/contexts/placesContext\";\nimport { useMap } from \"~/contexts/mapContext\";\nimport { useMapList } from \"~/contexts/mapListContext\";\n\nimport { markerIconSelected, markerIcon, pinIcon } from \"~/util/mapIconUtil\";\nimport { clusterOptions } from \"~/util/mapUtil\";\n\nconst Map = ({\n\tmarkerConfigs,\n\tinfoWindowClasses,\n\tclusterGridSize = 60\n}) => {\n\tconst {\n\t\tlocation,\n\t\tzoom,\n\t\tcenter,\n\t\tselectLocationEntity,\n\t\tsetLocation,\n\t\tmapInteracted,\n\t\tsetMapInteracted\n\t} = useMap();\n\n\tconst {\n\t\tmapItems, filteredListings, setSelectedFilters,\n\t\tsetQuery\n\t} = useMapList();\n\n\tconst mapRef = useRef();\n\tconst markerRefs = useRef({});\n\tconst mapContainerRef = useRef(null);\n\tconst {\n\t\tpoiMarkers,\n\t\tsetCurrentCenter,\n\t\tcurrentCenter,\n\t\tsetCurrentZoom,\n\t\tcurrentZoom,\n\t\tselectedPlaceMarker,\n\t\tsetSelectedPlaceMarker,\n\t\tplacesWindow,\n\t\tsetPlacesWindow } = usePlaces();\n\n\tconst onIdle = () => {\n\t\tif (!currentCenter || !mapRef.current) return;\n\t\tconst newCenter = mapRef.current.getCenter().toJSON();\n\t\tconst newZoom = mapRef.current.zoom;\n\n\t\tsetCurrentCenter(newCenter);\n\n\t\tif (newZoom != currentZoom) {\n\t\t\tsetCurrentZoom(newZoom);\n\t\t}\n\t};\n\n\tuseEffect(() => {\n\t\tconst { current } = mapContainerRef;\n\t\tif (current) {\n\t\t\tconst handleScroll = () => {\n\t\t\t\tsetMapInteracted(true);\n\t\t\t};\n\t\t\tcurrent.addEventListener('wheel', handleScroll);\n\t\t\treturn () => current.removeEventListener('wheel', handleScroll);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapContainerRef.current]);\n\n\tuseEffect(() => {\n\t\tconst { current } = mapRef;\n\t\tif (current) {\n\t\t\tconst dragStartListener = current.addListener('dragstart', () => setMapInteracted(true));\n\t\t\tconst mouseDownListener = current.addListener('mousedown', () => setMapInteracted(true));\n\t\t\treturn () => {\n\t\t\t\tgoogle.maps.event.removeListener(dragStartListener);\n\t\t\t\tgoogle.maps.event.removeListener(mouseDownListener);\n\t\t\t};\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapRef.current]);\n\n\tuseEffect(() => {\n\t\tconst { current } = mapRef;\n\t\tif ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && current) {\n\t\t\tfitBounds(current);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [mapItems, mapRef.current, location]);\n\n\tuseEffect(() => {\n\t\tconst { current } = mapRef;\n\t\tif (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && current && mapInteracted) {\n\t\t\tfitBounds(current, true);\n\t\t}\n\t\tif (current) {\n\t\t\tlet currZoom = current.zoom;\n\t\t\tlet setZoomVal = currZoom < 13 ? currZoom : 12;\n\t\t\tcurrent.setZoom(setZoomVal);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [filteredListings]);\n\n\tuseEffect(() => {\n\t\tconst { current } = mapRef;\n\t\tif (!current || !location || mapInteracted) return;\n\t\tcurrent.panTo(\n\t\t\tnew google.maps.LatLng(location.latitude, location.longitude)\n\t\t);\n\t\tif (current) {\n\t\t\tlet setZoomVal = zoom < 13 ? zoom : 12;\n\t\t\tcurrent.setZoom(setZoomVal);\n\t\t}\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [location, zoom, mapRef.current]);\n\n\tconst fitBounds = (map, overload = false) => {\n\t\tconst { current } = mapRef;\n\t\tif ((mapInteracted === false || overload) && mapItems != null) {\n\t\t\tconst bounds = new window.google.maps.LatLngBounds();\n\t\t\tmapItems.forEach(item => {\n\t\t\t\tbounds.extend(new google.maps.LatLng(item.latitude, item.longitude));\n\t\t\t});\n\t\t\tif (!map) return;\n\t\t\tmap.fitBounds(bounds);\n\t\t}\n\t\tif (current.zoom > 17) {\n\t\t\tcurrent.setZoom(16);\n\t\t}\n\t};\n\n\tconst markerClickHandler = mapLocation => {\n\t\tsetMapInteracted(true);\n\t\tselectLocationEntity(mapLocation);\n\t};\n\n\tconst onLoad = map => {\n\t\tlet { current } = mapRef;\n\t\tif (!location || location === null) {\n\t\t\tcurrent = map;\n\t\t\tfitBounds(map, true);\n\t\t\treturn;\n\t\t}\n\t\tcurrent = map;\n\n\t\tif (mapInteracted === false) {\n\t\t\tcurrent.panTo(\n\t\t\t\tnew google.maps.LatLng(location.latitude, location.longitude)\n\t\t\t);\n\n\t\t\tcurrent.setZoom(zoom);\n\t\t}\n\t};\n\n\tconst pinIconUrl = pinIcon({\n\t\tfillColor: markerConfigs.fillColor,\n\t\tstrokeColor: markerConfigs.strokeColor\n\t});\n\n\treturn (\n\t\t<>\n\t\t\t{zoom && center && <div ref={mapContainerRef} className=\"hc-h-full hc-relative\">\n\t\t\t\t<GoogleMap\n\t\t\t\t\tzoom={zoom}\n\t\t\t\t\tonLoad={onLoad}\n\t\t\t\t\tonIdle={onIdle}\n\t\t\t\t\tcenter={center}\n\t\t\t\t\tmapContainerStyle={{\n\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\theight: \"100%\"\n\t\t\t\t\t}}\n\t\t\t\t\toptions={{\n\t\t\t\t\t\tstyles: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tfeatureType: \"poi\",\n\t\t\t\t\t\t\t\telementType: \"labels\",\n\t\t\t\t\t\t\t\tstylers: [{ visibility: \"off\" }]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>\n\t\t\t\t\t\t{clusterer => (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{mapItems.map(item => (\n\t\t\t\t\t\t\t\t\t<MapMarker\n\t\t\t\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\t\t\t\tselectedLocation={location}\n\t\t\t\t\t\t\t\t\t\tmarkerRefs={markerRefs}\n\t\t\t\t\t\t\t\t\t\tinfoWindowClasses={infoWindowClasses}\n\t\t\t\t\t\t\t\t\t\tsetSelectedLocation={setLocation}\n\t\t\t\t\t\t\t\t\t\tmarkerClickHandler={markerClickHandler}\n\t\t\t\t\t\t\t\t\t\tclusterer={clusterer}\n\t\t\t\t\t\t\t\t\t\tmarkerIcon={markerIcon(markerConfigs)}\n\t\t\t\t\t\t\t\t\t\tmarkerIconSelected={markerIconSelected(markerConfigs)}\n\t\t\t\t\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t{poiMarkers && poiMarkers.markers.map((marker, index) => {\n\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t<PlaceMarker\n\t\t\t\t\t\t\t\t\t\t\tkey={`marker-${marker.title}-${index}`}\n\t\t\t\t\t\t\t\t\t\t\tmarker={marker}\n\t\t\t\t\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\t\t\t\t\tselectedPlaceMarker={selectedPlaceMarker}\n\t\t\t\t\t\t\t\t\t\t\tplacesWindow={placesWindow}\n\t\t\t\t\t\t\t\t\t\t\tsetPlacesWindow={setPlacesWindow}\n\t\t\t\t\t\t\t\t\t\t\tsetSelectedPlaceMarker={setSelectedPlaceMarker}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</MarkerClustererF>\n\t\t\t\t</GoogleMap>\n\t\t\t\t{mapInteracted && markerConfigs && (\n\t\t\t\t\t<ShowAllButton\n\t\t\t\t\t\tmapInteracted={mapInteracted}\n\t\t\t\t\t\tmarkerConfigs={markerConfigs}\n\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\tfitBounds={fitBounds}\n\t\t\t\t\t\tmapRef={mapRef}\n\t\t\t\t\t\tpinIconUrl={pinIconUrl}\n\t\t\t\t\t\tsetQuery={setQuery}\n\t\t\t\t\t\tlistingCount={filteredListings.length}\n\t\t\t\t\t\tsetSelectedFilters={setSelectedFilters}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t\t}\n\t\t</>\n\t);\n};\n\nexport default Map;\n"],"names":["Map","_ref","markerConfigs","infoWindowClasses","_ref$clusterGridSize","clusterGridSize","_useMap","useMap","location","zoom","center","selectLocationEntity","setLocation","mapInteracted","setMapInteracted","_useMapList","useMapList","mapItems","filteredListings","setSelectedFilters","setQuery","mapRef","useRef","markerRefs","mapContainerRef","_usePlaces","usePlaces","poiMarkers","setCurrentCenter","currentCenter","setCurrentZoom","currentZoom","selectedPlaceMarker","setSelectedPlaceMarker","placesWindow","setPlacesWindow","onIdle","current","newCenter","getCenter","toJSON","newZoom","useEffect","handleScroll","addEventListener","removeEventListener","dragStartListener","addListener","mouseDownListener","google","maps","event","removeListener","length","fitBounds","currZoom","setZoomVal","setZoom","panTo","LatLng","latitude","longitude","map","overload","arguments","undefined","bounds","window","LatLngBounds","forEach","item","extend","markerClickHandler","mapLocation","onLoad","pinIconUrl","pinIcon","fillColor","strokeColor","React","createElement","Fragment","ref","className","GoogleMap","mapContainerStyle","width","height","options","styles","featureType","elementType","stylers","visibility","MarkerClustererF","clusterOptions","clusterer","MapMarker","key","id","selectedLocation","setSelectedLocation","markerIcon","markerIconSelected","markers","marker","index","PlaceMarker","concat","title","ShowAllButton","listingCount"],"mappings":";;;;;;;;;;;AAAA;AAeA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAAC,IAAA,EAIH;AAAA,EAAA,IAHLC,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,iBAAiB,GAAAF,IAAA,CAAjBE,iBAAiB;IAAAC,oBAAA,GAAAH,IAAA,CACjBI,eAAe;AAAfA,IAAAA,eAAe,GAAAD,oBAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,oBAAA,CAAA;AAEpB,EAAA,IAAAE,OAAA,GAQIC,MAAM,EAAE;IAPXC,QAAQ,GAAAF,OAAA,CAARE,QAAQ;IACRC,IAAI,GAAAH,OAAA,CAAJG,IAAI;IACJC,MAAM,GAAAJ,OAAA,CAANI,MAAM;IACNC,oBAAoB,GAAAL,OAAA,CAApBK,oBAAoB;IACpBC,WAAW,GAAAN,OAAA,CAAXM,WAAW;IACXC,aAAa,GAAAP,OAAA,CAAbO,aAAa;IACbC,gBAAgB,GAAAR,OAAA,CAAhBQ,gBAAgB,CAAA;AAGjB,EAAA,IAAAC,WAAA,GAGIC,UAAU,EAAE;IAFfC,QAAQ,GAAAF,WAAA,CAARE,QAAQ;IAAEC,gBAAgB,GAAAH,WAAA,CAAhBG,gBAAgB;IAAEC,kBAAkB,GAAAJ,WAAA,CAAlBI,kBAAkB;IAC9CC,QAAQ,GAAAL,WAAA,CAARK,QAAQ,CAAA;AAGT,EAAA,IAAMC,MAAM,GAAGC,MAAM,EAAE,CAAA;AACvB,EAAA,IAAMC,UAAU,GAAGD,MAAM,CAAC,EAAE,CAAC,CAAA;AAC7B,EAAA,IAAME,eAAe,GAAGF,MAAM,CAAC,IAAI,CAAC,CAAA;AAC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O;AACfC,QAAAA,KAAK,EAAEA,KAAM;AACb1E,QAAAA,mBAAmB,EAAEA,mBAAoB;AACzCE,QAAAA,YAAY,EAAEA,YAAa;AAC3BC,QAAAA,eAAe,EAAEA,eAAgB;AACjCF,QAAAA,sBAAsB,EAAEA,sBAAAA;AAAuB,OAC/C,CAAC,CAAA;AAEJ,KAAC,CACA,CAAC,CAAA;GAEa,CACR,CAAC,EACXpB,aAAa,IAAIX,aAAa,iBAC9B6E,KAAA,CAAAC,aAAA,CAAC8B,aAAa,EAAA;AACbjG,IAAAA,aAAa,EAAEA,aAAc;AAC7BX,IAAAA,aAAa,EAAEA,aAAc;AAC7BY,IAAAA,gBAAgB,EAAEA,gBAAiB;AACnCwC,IAAAA,SAAS,EAAEA,SAAU;AACrBjC,IAAAA,MAAM,EAAEA,MAAO;AACfsD,IAAAA,UAAU,EAAEA,UAAW;AACvBvD,IAAAA,QAAQ,EAAEA,QAAS;IACnB2F,YAAY,EAAE7F,gBAAgB,CAACmC,MAAO;AACtClC,IAAAA,kBAAkB,EAAEA,kBAAAA;GACpB,CAEE,CAEJ,CAAC,CAAA;AAEL;;;;"}
|
|
1
|
+
{"version":3,"file":"map.js","sources":["../../../../src/components/modules/maps/map.js"],"sourcesContent":["/* eslint-disable no-undef */\nimport React, { useEffect, useRef } from 'react';\nimport { GoogleMap, MarkerClustererF } from \"@react-google-maps/api\";\n\nimport MapMarker from \"~/components/modules/maps/map-marker\";\nimport PlaceMarker from \"~/components/modules/maps/place-marker\";\nimport ShowAllButton from \"~/components/modules/buttons/show-all-button\";\n\nimport { usePlaces } from \"~/contexts/placesContext\";\nimport { useMap } from \"~/contexts/mapContext\";\nimport { useMapList } from \"~/contexts/mapListContext\";\n\nimport { markerIconSelected, markerIcon, pinIcon } from \"~/util/mapIconUtil\";\nimport { clusterOptions } from \"~/util/mapUtil\";\n\nconst Map = ({\n\tmarkerConfigs,\n\tinfoWindowClasses,\n\tclusterGridSize = 60\n}) => {\n\tconst {\n\t\tlocation,\n\t\tzoom,\n\t\tcenter,\n\t\tcommuteLocation,\n\t\tselectLocationEntity,\n\t\tsetLocation,\n\t\tmapInteracted,\n\t\tsetMapInteracted\n\t} = useMap();\n\n\tconst {\n\t\tmapItems, filteredListings, setSelectedFilters,\n\t\tsetQuery\n\t} = useMapList();\n\n\tconst mapRef = useRef();\n\tconst markerRefs = useRef({});\n\tconst mapContainerRef = useRef(null);\n\tconst {\n\t\tpoiMarkers,\n\t\tsetCurrentCenter,\n\t\tcurrentCenter,\n\t\tsetCurrentZoom,\n\t\tcurrentZoom,\n\t\tselectedPlaceMarker,\n\t\tsetSelectedPlaceMarker,\n\t\tplacesWindow,\n\t\tsetPlacesWindow } = usePlaces();\n\n\tconst onIdle = () => {\n\t\tif (!currentCenter || !mapRef.current) return;\n\t\tconst newCenter = mapRef.current.getCenter().toJSON();\n\t\tconst newZoom = mapRef.current.zoom;\n\n\t\tsetCurrentCenter(newCenter);\n\n\t\tif (newZoom != currentZoom) {\n\t\t\tsetCurrentZoom(newZoom);\n\t\t}\n\t};\n\n\tuseEffect(() => {\n\t\tif (mapContainerRef.current) {\n\t\t\tconst handleScroll = () => {\n\t\t\t\tsetMapInteracted(true);\n\t\t\t};\n\t\t\tvar mapContainerRefCurrent = mapContainerRef.current;\n\t\t\tmapContainerRef.current.addEventListener('wheel', handleScroll);\n\t\t\treturn () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);\n\t\t}\n\t}, [mapContainerRef.current]);\n\n\tuseEffect(() => {\n\t\tif (mapRef.current) {\n\t\t\tconst mapInstance = mapRef.current;\n\t\t\tconst dragStartListener = mapInstance.addListener('dragstart', () => setMapInteracted(true));\n\t\t\tconst mouseDownListener = mapInstance.addListener('mousedown', () => setMapInteracted(true));\n\t\t\treturn () => {\n\t\t\t\tgoogle.maps.event.removeListener(dragStartListener);\n\t\t\t\tgoogle.maps.event.removeListener(mouseDownListener);\n\t\t\t};\n\t\t}\n\t}, [mapRef.current, mapContainerRef.current]);\n\n\tuseEffect(() => {\n\t\tif ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {\n\t\t\tfitBounds(mapRef.current);\n\t\t}\n\t}, [mapItems, mapRef.current, location]);\n\n\tuseEffect(() => {\n\t\tif (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && mapRef.current && mapInteracted) {\n\t\t\tfitBounds(mapRef.current, true);\n\t\t}\n\t\tif (mapRef.current) {\n\t\t\tlet currZoom = mapRef.current.zoom;\n\t\t\tlet setZoomVal = currZoom < 13 ? currZoom : 12;\n\t\t\tmapRef.current.setZoom(setZoomVal);\n\t\t}\n\t}, [filteredListings]);\n\n\tuseEffect(() => {\n\t\tif (!mapRef.current || !location || mapInteracted) return;\n\t\tmapRef.current.panTo(\n\t\t\tnew google.maps.LatLng(location.latitude, location.longitude)\n\t\t);\n\t\tif (mapRef.current) {\n\t\t\tlet setZoomVal = zoom < 13 ? zoom : 12;\n\t\t\tmapRef.current.setZoom(setZoomVal);\n\t\t}\n\t}, [location, zoom, mapRef.current]);\n\n\tconst fitBounds = (map, overload = false) => {\n\t\tif ((mapInteracted === false || overload) && mapItems != null) {\n\t\t\tconst bounds = new window.google.maps.LatLngBounds();\n\t\t\tmapItems.forEach(item => {\n\t\t\t\tbounds.extend(new google.maps.LatLng(item.latitude, item.longitude));\n\t\t\t});\n\t\t\tif (!map) return;\n\t\t\tmap.fitBounds(bounds);\n\t\t}\n\t\tif (mapRef.current.zoom > 17) {\n\t\t\tmapRef.current.setZoom(16);\n\t\t}\n\t};\n\n\tconst markerClickHandler = mapLocation => {\n\t\tsetMapInteracted(true);\n\t\tselectLocationEntity(mapLocation);\n\t};\n\n\tconst onLoad = map => {\n\t\tif (!location || location === null) {\n\t\t\tmapRef.current = map;\n\t\t\tfitBounds(map, true);\n\t\t\treturn;\n\t\t}\n\t\tmapRef.current = map;\n\n\t\tif (mapInteracted === false) {\n\t\t\tmapRef.current.panTo(\n\t\t\t\tnew google.maps.LatLng(location.latitude, location.longitude)\n\t\t\t);\n\n\t\t\tmapRef.current.setZoom(zoom);\n\t\t}\n\t};\n\n\tconst pinIconUrl = pinIcon({\n\t\tfillColor: markerConfigs.fillColor,\n\t\tstrokeColor: markerConfigs.strokeColor\n\t});\n\n\treturn (\n\t\t<>{zoom && center && <div ref={mapContainerRef} className=\"hc-h-full hc-relative\">\n\t\t\t<GoogleMap\n\t\t\t\tzoom={zoom}\n\t\t\t\tonLoad={onLoad}\n\t\t\t\tonIdle={onIdle}\n\t\t\t\tcenter={center}\n\t\t\t\tmapContainerStyle={{\n\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\theight: \"100%\"\n\t\t\t\t}}\n\t\t\t\toptions={{\n\t\t\t\t\tstyles: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfeatureType: \"poi\",\n\t\t\t\t\t\t\telementType: \"labels\",\n\t\t\t\t\t\t\tstylers: [{ visibility: \"off\" }]\n\t\t\t\t\t\t}\n\t\t\t\t\t]\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>\n\t\t\t\t\t{clusterer => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t{mapItems.map(item => (\n\t\t\t\t\t\t\t\t<MapMarker\n\t\t\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\t\t\tselectedLocation={location}\n\t\t\t\t\t\t\t\t\tmarkerRefs={markerRefs}\n\t\t\t\t\t\t\t\t\tinfoWindowClasses={infoWindowClasses}\n\t\t\t\t\t\t\t\t\tsetSelectedLocation={setLocation}\n\t\t\t\t\t\t\t\t\tmarkerClickHandler={markerClickHandler}\n\t\t\t\t\t\t\t\t\tclusterer={clusterer}\n\t\t\t\t\t\t\t\t\tmarkerIcon={markerIcon(markerConfigs)}\n\t\t\t\t\t\t\t\t\tmarkerIconSelected={markerIconSelected(markerConfigs)}\n\t\t\t\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t{poiMarkers && poiMarkers.markers.map((marker, index) => {\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<PlaceMarker\n\t\t\t\t\t\t\t\t\t\tkey={`marker-${marker.title}-${index}`}\n\t\t\t\t\t\t\t\t\t\tmarker={marker}\n\t\t\t\t\t\t\t\t\t\tindex={index}\n\t\t\t\t\t\t\t\t\t\tselectedPlaceMarker={selectedPlaceMarker}\n\t\t\t\t\t\t\t\t\t\tplacesWindow={placesWindow}\n\t\t\t\t\t\t\t\t\t\tsetPlacesWindow={setPlacesWindow}\n\t\t\t\t\t\t\t\t\t\tsetSelectedPlaceMarker={setSelectedPlaceMarker}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t})}\n\t\t\t\t\t\t</>\n\t\t\t\t\t)}\n\t\t\t\t</MarkerClustererF>\n\t\t\t</GoogleMap>\n\t\t\t{mapInteracted && markerConfigs && (\n\t\t\t\t<ShowAllButton\n\t\t\t\t\tmapInteracted={mapInteracted}\n\t\t\t\t\tmarkerConfigs={markerConfigs}\n\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\tfitBounds={fitBounds}\n\t\t\t\t\tmapRef={mapRef}\n\t\t\t\t\tpinIconUrl={pinIconUrl}\n\t\t\t\t\tsetQuery={setQuery}\n\t\t\t\t\tlistingCount={filteredListings.length}\n\t\t\t\t\tsetSelectedFilters={setSelectedFilters}\n\t\t\t\t/>\n\t\t\t)}\n\t\t</div>\n\t\t}\n\t\t</>\n\t);\n};\n\nexport default Map;\n"],"names":["Map","_ref","markerConfigs","infoWindowClasses","_ref$clusterGridSize","clusterGridSize","_useMap","useMap","location","zoom","center","commuteLocation","selectLocationEntity","setLocation","mapInteracted","setMapInteracted","_useMapList","useMapList","mapItems","filteredListings","setSelectedFilters","setQuery","mapRef","useRef","markerRefs","mapContainerRef","_usePlaces","usePlaces","poiMarkers","setCurrentCenter","currentCenter","setCurrentZoom","currentZoom","selectedPlaceMarker","setSelectedPlaceMarker","placesWindow","setPlacesWindow","onIdle","current","newCenter","getCenter","toJSON","newZoom","useEffect","handleScroll","mapContainerRefCurrent","addEventListener","removeEventListener","mapInstance","dragStartListener","addListener","mouseDownListener","google","maps","event","removeListener","length","fitBounds","currZoom","setZoomVal","setZoom","panTo","LatLng","latitude","longitude","map","overload","arguments","undefined","bounds","window","LatLngBounds","forEach","item","extend","markerClickHandler","mapLocation","onLoad","pinIconUrl","pinIcon","fillColor","strokeColor","React","createElement","Fragment","ref","className","GoogleMap","mapContainerStyle","width","height","options","styles","featureType","elementType","stylers","visibility","MarkerClustererF","clusterOptions","clusterer","MapMarker","key","id","selectedLocation","setSelectedLocation","markerIcon","markerIconSelected","markers","marker","index","PlaceMarker","concat","title","ShowAllButton","listingCount"],"mappings":";;;;;;;;;;;AAAA;AAeA,IAAMA,GAAG,GAAG,SAANA,GAAGA,CAAAC,IAAA,EAIH;AAAA,EAAA,IAHLC,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,iBAAiB,GAAAF,IAAA,CAAjBE,iBAAiB;IAAAC,oBAAA,GAAAH,IAAA,CACjBI,eAAe;AAAfA,IAAAA,eAAe,GAAAD,oBAAA,KAAG,KAAA,CAAA,GAAA,EAAE,GAAAA,oBAAA,CAAA;AAEpB,EAAA,IAAAE,OAAA,GASIC,MAAM,EAAE,CAAA;IARXC,QAAQ,GAAAF,OAAA,CAARE,QAAQ,CAAA;IACRC,IAAI,GAAAH,OAAA,CAAJG,IAAI,CAAA;IACJC,MAAM,GAAAJ,OAAA,CAANI,MAAM,CAAA;IACSJ,OAAA,CAAfK,eAAe,CAAA;QACfC,oBAAoB,GAAAN,OAAA,CAApBM,oBAAoB,CAAA;IACpBC,WAAW,GAAAP,OAAA,CAAXO,WAAW,CAAA;IACXC,aAAa,GAAAR,OAAA,CAAbQ,aAAa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ocation,
|
|
27
28
|
mapInteracted,
|
|
@@ -60,66 +61,57 @@ const Map = ({
|
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
useEffect(() => {
|
|
63
|
-
|
|
64
|
-
if (current) {
|
|
64
|
+
if (mapContainerRef.current) {
|
|
65
65
|
const handleScroll = () => {
|
|
66
66
|
setMapInteracted(true);
|
|
67
67
|
};
|
|
68
|
-
current
|
|
69
|
-
|
|
68
|
+
var mapContainerRefCurrent = mapContainerRef.current;
|
|
69
|
+
mapContainerRef.current.addEventListener('wheel', handleScroll);
|
|
70
|
+
return () => mapContainerRefCurrent.removeEventListener('wheel', handleScroll);
|
|
70
71
|
}
|
|
71
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
72
|
}, [mapContainerRef.current]);
|
|
73
73
|
|
|
74
74
|
useEffect(() => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const dragStartListener =
|
|
78
|
-
const mouseDownListener =
|
|
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
79
|
return () => {
|
|
80
80
|
google.maps.event.removeListener(dragStartListener);
|
|
81
81
|
google.maps.event.removeListener(mouseDownListener);
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
}, [mapRef.current]);
|
|
84
|
+
}, [mapRef.current, mapContainerRef.current]);
|
|
86
85
|
|
|
87
86
|
useEffect(() => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
fitBounds(current);
|
|
87
|
+
if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && mapRef.current) {
|
|
88
|
+
fitBounds(mapRef.current);
|
|
91
89
|
}
|
|
92
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
90
|
}, [mapItems, mapRef.current, location]);
|
|
94
91
|
|
|
95
92
|
useEffect(() => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
fitBounds(current, true);
|
|
93
|
+
if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && mapRef.current && mapInteracted) {
|
|
94
|
+
fitBounds(mapRef.current, true);
|
|
99
95
|
}
|
|
100
|
-
if (current) {
|
|
101
|
-
let currZoom = current.zoom;
|
|
96
|
+
if (mapRef.current) {
|
|
97
|
+
let currZoom = mapRef.current.zoom;
|
|
102
98
|
let setZoomVal = currZoom < 13 ? currZoom : 12;
|
|
103
|
-
current.setZoom(setZoomVal);
|
|
99
|
+
mapRef.current.setZoom(setZoomVal);
|
|
104
100
|
}
|
|
105
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
106
101
|
}, [filteredListings]);
|
|
107
102
|
|
|
108
103
|
useEffect(() => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
current.panTo(
|
|
104
|
+
if (!mapRef.current || !location || mapInteracted) return;
|
|
105
|
+
mapRef.current.panTo(
|
|
112
106
|
new google.maps.LatLng(location.latitude, location.longitude)
|
|
113
107
|
);
|
|
114
|
-
if (current) {
|
|
108
|
+
if (mapRef.current) {
|
|
115
109
|
let setZoomVal = zoom < 13 ? zoom : 12;
|
|
116
|
-
current.setZoom(setZoomVal);
|
|
110
|
+
mapRef.current.setZoom(setZoomVal);
|
|
117
111
|
}
|
|
118
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
112
|
}, [location, zoom, mapRef.current]);
|
|
120
113
|
|
|
121
114
|
const fitBounds = (map, overload = false) => {
|
|
122
|
-
const { current } = mapRef;
|
|
123
115
|
if ((mapInteracted === false || overload) && mapItems != null) {
|
|
124
116
|
const bounds = new window.google.maps.LatLngBounds();
|
|
125
117
|
mapItems.forEach(item => {
|
|
@@ -128,8 +120,8 @@ const Map = ({
|
|
|
128
120
|
if (!map) return;
|
|
129
121
|
map.fitBounds(bounds);
|
|
130
122
|
}
|
|
131
|
-
if (current.zoom > 17) {
|
|
132
|
-
current.setZoom(16);
|
|
123
|
+
if (mapRef.current.zoom > 17) {
|
|
124
|
+
mapRef.current.setZoom(16);
|
|
133
125
|
}
|
|
134
126
|
};
|
|
135
127
|
|
|
@@ -139,20 +131,19 @@ const Map = ({
|
|
|
139
131
|
};
|
|
140
132
|
|
|
141
133
|
const onLoad = map => {
|
|
142
|
-
let { current } = mapRef;
|
|
143
134
|
if (!location || location === null) {
|
|
144
|
-
current = map;
|
|
135
|
+
mapRef.current = map;
|
|
145
136
|
fitBounds(map, true);
|
|
146
137
|
return;
|
|
147
138
|
}
|
|
148
|
-
current = map;
|
|
139
|
+
mapRef.current = map;
|
|
149
140
|
|
|
150
141
|
if (mapInteracted === false) {
|
|
151
|
-
current.panTo(
|
|
142
|
+
mapRef.current.panTo(
|
|
152
143
|
new google.maps.LatLng(location.latitude, location.longitude)
|
|
153
144
|
);
|
|
154
145
|
|
|
155
|
-
current.setZoom(zoom);
|
|
146
|
+
mapRef.current.setZoom(zoom);
|
|
156
147
|
}
|
|
157
148
|
};
|
|
158
149
|
|
|
@@ -162,77 +153,76 @@ const Map = ({
|
|
|
162
153
|
});
|
|
163
154
|
|
|
164
155
|
return (
|
|
165
|
-
<>
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
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}
|
|
202
204
|
/>
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
markerConfigs={markerConfigs}
|
|
225
|
-
setMapInteracted={setMapInteracted}
|
|
226
|
-
fitBounds={fitBounds}
|
|
227
|
-
mapRef={mapRef}
|
|
228
|
-
pinIconUrl={pinIconUrl}
|
|
229
|
-
setQuery={setQuery}
|
|
230
|
-
listingCount={filteredListings.length}
|
|
231
|
-
setSelectedFilters={setSelectedFilters}
|
|
232
|
-
/>
|
|
233
|
-
)}
|
|
234
|
-
</div>
|
|
235
|
-
}
|
|
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
|
+
}
|
|
236
226
|
</>
|
|
237
227
|
);
|
|
238
228
|
};
|