@abcagency/hc-ui-components 1.3.8 → 1.3.10
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useEffect } from 'react';
|
|
1
|
+
import React, { useRef, useCallback, useEffect } from 'react';
|
|
2
2
|
import { GoogleMap, MarkerClustererF } from '@react-google-maps/api';
|
|
3
3
|
import MapMarker from './map-marker.js';
|
|
4
4
|
import PlaceMarker from './place-marker.js';
|
|
@@ -41,15 +41,15 @@ var Map = function Map(_ref) {
|
|
|
41
41
|
setSelectedPlaceMarker = _usePlaces.setSelectedPlaceMarker,
|
|
42
42
|
placesWindow = _usePlaces.placesWindow,
|
|
43
43
|
setPlacesWindow = _usePlaces.setPlacesWindow;
|
|
44
|
-
var onIdle = function
|
|
44
|
+
var onIdle = useCallback(function () {
|
|
45
45
|
if (!currentCenter || !mapRef.current) return;
|
|
46
46
|
var newCenter = mapRef.current.getCenter().toJSON();
|
|
47
47
|
var newZoom = mapRef.current.zoom;
|
|
48
48
|
setCurrentCenter(newCenter);
|
|
49
|
-
if (newZoom
|
|
49
|
+
if (newZoom !== currentZoom) {
|
|
50
50
|
setCurrentZoom(newZoom);
|
|
51
51
|
}
|
|
52
|
-
};
|
|
52
|
+
}, [currentCenter, currentZoom, setCurrentCenter, setCurrentZoom]);
|
|
53
53
|
useEffect(function () {
|
|
54
54
|
var current = mapContainerRef.current;
|
|
55
55
|
if (current) {
|
|
@@ -58,11 +58,10 @@ var Map = function Map(_ref) {
|
|
|
58
58
|
};
|
|
59
59
|
current.addEventListener('wheel', handleScroll);
|
|
60
60
|
return function () {
|
|
61
|
-
return
|
|
61
|
+
return current.removeEventListener('wheel', handleScroll);
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
}, [mapContainerRef.current]);
|
|
64
|
+
}, [mapContainerRef, setMapInteracted]);
|
|
66
65
|
useEffect(function () {
|
|
67
66
|
var current = mapRef.current;
|
|
68
67
|
if (current) {
|
|
@@ -73,19 +72,17 @@ var Map = function Map(_ref) {
|
|
|
73
72
|
return setMapInteracted(true);
|
|
74
73
|
});
|
|
75
74
|
return function () {
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
dragStartListener.remove();
|
|
76
|
+
mouseDownListener.remove();
|
|
78
77
|
};
|
|
79
78
|
}
|
|
80
|
-
|
|
81
|
-
}, [mapRef.current]);
|
|
79
|
+
}, [mapRef, setMapInteracted]);
|
|
82
80
|
useEffect(function () {
|
|
83
81
|
var current = mapRef.current;
|
|
84
82
|
if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && current) {
|
|
85
83
|
fitBounds(current);
|
|
86
84
|
}
|
|
87
|
-
|
|
88
|
-
}, [mapItems, mapRef.current, location]);
|
|
85
|
+
}, [mapItems, poiMarkers, location, fitBounds]);
|
|
89
86
|
useEffect(function () {
|
|
90
87
|
var current = mapRef.current;
|
|
91
88
|
if (mapItems && mapItems.length > 0 || poiMarkers.length > 0 && current && mapInteracted) {
|
|
@@ -96,8 +93,7 @@ var Map = function Map(_ref) {
|
|
|
96
93
|
var setZoomVal = currZoom < 13 ? currZoom : 12;
|
|
97
94
|
current.setZoom(setZoomVal);
|
|
98
95
|
}
|
|
99
|
-
|
|
100
|
-
}, [filteredListings]);
|
|
96
|
+
}, [filteredListings, fitBounds, mapInteracted, mapItems, poiMarkers.length]);
|
|
101
97
|
useEffect(function () {
|
|
102
98
|
var current = mapRef.current;
|
|
103
99
|
if (!current || !location || mapInteracted) return;
|
|
@@ -106,9 +102,8 @@ var Map = function Map(_ref) {
|
|
|
106
102
|
var setZoomVal = zoom < 13 ? zoom : 12;
|
|
107
103
|
current.setZoom(setZoomVal);
|
|
108
104
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
var fitBounds = function fitBounds(map) {
|
|
105
|
+
}, [location, zoom, mapInteracted]);
|
|
106
|
+
var fitBounds = useCallback(function (map) {
|
|
112
107
|
var overload = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
113
108
|
var current = mapRef.current;
|
|
114
109
|
if ((mapInteracted === false || overload) && mapItems != null) {
|
|
@@ -119,27 +114,25 @@ var Map = function Map(_ref) {
|
|
|
119
114
|
if (!map) return;
|
|
120
115
|
map.fitBounds(bounds);
|
|
121
116
|
}
|
|
122
|
-
if (current.zoom > 17) {
|
|
117
|
+
if (current && current.zoom > 17) {
|
|
123
118
|
current.setZoom(16);
|
|
124
119
|
}
|
|
125
|
-
};
|
|
126
|
-
var markerClickHandler = function
|
|
120
|
+
}, [mapInteracted, mapItems]);
|
|
121
|
+
var markerClickHandler = useCallback(function (mapLocation) {
|
|
127
122
|
setMapInteracted(true);
|
|
128
123
|
selectLocationEntity(mapLocation);
|
|
129
|
-
};
|
|
130
|
-
var onLoad = function
|
|
131
|
-
|
|
132
|
-
if (!location
|
|
133
|
-
current = map;
|
|
124
|
+
}, [setMapInteracted, selectLocationEntity]);
|
|
125
|
+
var onLoad = useCallback(function (map) {
|
|
126
|
+
mapRef.current = map;
|
|
127
|
+
if (!location) {
|
|
134
128
|
fitBounds(map, true);
|
|
135
129
|
return;
|
|
136
130
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
current.setZoom(zoom);
|
|
131
|
+
if (!mapInteracted) {
|
|
132
|
+
map.panTo(new google.maps.LatLng(location.latitude, location.longitude));
|
|
133
|
+
map.setZoom(zoom);
|
|
141
134
|
}
|
|
142
|
-
};
|
|
135
|
+
}, [fitBounds, location, mapInteracted, zoom]);
|
|
143
136
|
var pinIconUrl = pinIcon({
|
|
144
137
|
fillColor: markerConfigs.fillColor,
|
|
145
138
|
strokeColor: markerConfigs.strokeColor
|
|
@@ -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 () => mapContainerRefCurrent.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","mapContainerRefCurrent","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","Pla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AA,sBAAsB,EAAEA,sBAAAA;AAAuB,OAC/C,CAAC,CAAA;AAEJ,KAAC,CACA,CAAC,CAAA;GAEa,CACR,CAAC,EACXpB,aAAa,IAAIX,aAAa,iBAC9B8E,KAAA,CAAAC,aAAA,CAAC8B,aAAa,EAAA;AACblG,IAAAA,aAAa,EAAEA,aAAc;AAC7BX,IAAAA,aAAa,EAAEA,aAAc;AAC7BY,IAAAA,gBAAgB,EAAEA,gBAAiB;AACnCyC,IAAAA,SAAS,EAAEA,SAAU;AACrBlC,IAAAA,MAAM,EAAEA,MAAO;AACfuD,IAAAA,UAAU,EAAEA,UAAW;AACvBxD,IAAAA,QAAQ,EAAEA,QAAS;IACnB4F,YAAY,EAAE9F,gBAAgB,CAACoC,MAAO;AACtCnC,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, useCallback } 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\n\t} = usePlaces();\n\n\tconst onIdle = useCallback(() => {\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}, [currentCenter, currentZoom, setCurrentCenter, setCurrentZoom]);\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}, [mapContainerRef, setMapInteracted]);\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\tdragStartListener.remove();\n\t\t\t\tmouseDownListener.remove();\n\t\t\t};\n\t\t}\n\t}, [mapRef, setMapInteracted]);\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}, [mapItems, poiMarkers, location, fitBounds]);\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}, [filteredListings, fitBounds, mapInteracted, mapItems, poiMarkers.length]);\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}, [location, zoom, mapInteracted]);\n\n\tconst fitBounds = useCallback((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 && current.zoom > 17) {\n\t\t\tcurrent.setZoom(16);\n\t\t}\n\t}, [mapInteracted, mapItems]);\n\n\tconst markerClickHandler = useCallback(mapLocation => {\n\t\tsetMapInteracted(true);\n\t\tselectLocationEntity(mapLocation);\n\t}, [setMapInteracted, selectLocationEntity]);\n\n\tconst onLoad = useCallback(map => {\n\t\tmapRef.current = map;\n\t\tif (!location) {\n\t\t\tfitBounds(map, true);\n\t\t\treturn;\n\t\t}\n\n\t\tif (!mapInteracted) {\n\t\t\tmap.panTo(new google.maps.LatLng(location.latitude, location.longitude));\n\t\t\tmap.setZoom(zoom);\n\t\t}\n\t}, [fitBounds, location, mapInteracted, zoom]);\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 && (\n\t\t\t\t<div ref={mapContainerRef} className=\"hc-h-full hc-relative\">\n\t\t\t\t\t<GoogleMap\n\t\t\t\t\t\tzoom={zoom}\n\t\t\t\t\t\tonLoad={onLoad}\n\t\t\t\t\t\tonIdle={onIdle}\n\t\t\t\t\t\tcenter={center}\n\t\t\t\t\t\tmapContainerStyle={{\n\t\t\t\t\t\t\twidth: \"100%\",\n\t\t\t\t\t\t\theight: \"100%\"\n\t\t\t\t\t\t}}\n\t\t\t\t\t\toptions={{\n\t\t\t\t\t\t\tstyles: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tfeatureType: \"poi\",\n\t\t\t\t\t\t\t\t\telementType: \"labels\",\n\t\t\t\t\t\t\t\t\tstylers: [{ visibility: \"off\" }]\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\t\t<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>\n\t\t\t\t\t\t\t{clusterer => (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{mapItems.map(item => (\n\t\t\t\t\t\t\t\t\t\t<MapMarker\n\t\t\t\t\t\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t\t\t\t\t\titem={item}\n\t\t\t\t\t\t\t\t\t\t\tselectedLocation={location}\n\t\t\t\t\t\t\t\t\t\t\tmarkerRefs={markerRefs}\n\t\t\t\t\t\t\t\t\t\t\tinfoWindowClasses={infoWindowClasses}\n\t\t\t\t\t\t\t\t\t\t\tsetSelectedLocation={setLocation}\n\t\t\t\t\t\t\t\t\t\t\tmarkerClickHandler={markerClickHandler}\n\t\t\t\t\t\t\t\t\t\t\tclusterer={clusterer}\n\t\t\t\t\t\t\t\t\t\t\tmarkerIcon={markerIcon(markerConfigs)}\n\t\t\t\t\t\t\t\t\t\t\tmarkerIconSelected={markerIconSelected(markerConfigs)}\n\t\t\t\t\t\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\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\t{poiMarkers && poiMarkers.markers.map((marker, index) => (\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</MarkerClustererF>\n\t\t\t\t\t</GoogleMap>\n\t\t\t\t\t{mapInteracted && markerConfigs && (\n\t\t\t\t\t\t<ShowAllButton\n\t\t\t\t\t\t\tmapInteracted={mapInteracted}\n\t\t\t\t\t\t\tmarkerConfigs={markerConfigs}\n\t\t\t\t\t\t\tsetMapInteracted={setMapInteracted}\n\t\t\t\t\t\t\tfitBounds={fitBounds}\n\t\t\t\t\t\t\tmapRef={mapRef}\n\t\t\t\t\t\t\tpinIconUrl={pinIconUrl}\n\t\t\t\t\t\t\tsetQuery={setQuery}\n\t\t\t\t\t\t\tlistingCount={filteredListings.length}\n\t\t\t\t\t\t\tsetSelectedFilters={setSelectedFilters}\n\t\t\t\t\t\t/>\n\t\t\t\t\t)}\n\t\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","useCallback","current","newCenter","getCenter","toJSON","newZoom","useEffect","handleScroll","addEventListener","removeEventListener","dragStartListener","addListener","mouseDownListener","remove","length","fitBounds","currZoom","setZoomVal","setZoom","panTo","google","maps","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,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ACtChC,IAAAA,kBAAkB,EAAEA,kBAAAA;GACpB,CAEE,CAEL,CAAC,CAAA;AAEL;;;;"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable no-undef */
|
|
2
|
-
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import React, { useEffect, useRef, useCallback } from 'react';
|
|
3
3
|
import { GoogleMap, MarkerClustererF } from "@react-google-maps/api";
|
|
4
4
|
|
|
5
5
|
import MapMarker from "~/components/modules/maps/map-marker";
|
|
@@ -45,19 +45,20 @@ const Map = ({
|
|
|
45
45
|
selectedPlaceMarker,
|
|
46
46
|
setSelectedPlaceMarker,
|
|
47
47
|
placesWindow,
|
|
48
|
-
setPlacesWindow
|
|
48
|
+
setPlacesWindow
|
|
49
|
+
} = usePlaces();
|
|
49
50
|
|
|
50
|
-
const onIdle = () => {
|
|
51
|
+
const onIdle = useCallback(() => {
|
|
51
52
|
if (!currentCenter || !mapRef.current) return;
|
|
52
53
|
const newCenter = mapRef.current.getCenter().toJSON();
|
|
53
54
|
const newZoom = mapRef.current.zoom;
|
|
54
55
|
|
|
55
56
|
setCurrentCenter(newCenter);
|
|
56
57
|
|
|
57
|
-
if (newZoom
|
|
58
|
+
if (newZoom !== currentZoom) {
|
|
58
59
|
setCurrentZoom(newZoom);
|
|
59
60
|
}
|
|
60
|
-
};
|
|
61
|
+
}, [currentCenter, currentZoom, setCurrentCenter, setCurrentZoom]);
|
|
61
62
|
|
|
62
63
|
useEffect(() => {
|
|
63
64
|
const { current } = mapContainerRef;
|
|
@@ -66,10 +67,9 @@ const Map = ({
|
|
|
66
67
|
setMapInteracted(true);
|
|
67
68
|
};
|
|
68
69
|
current.addEventListener('wheel', handleScroll);
|
|
69
|
-
return () =>
|
|
70
|
+
return () => current.removeEventListener('wheel', handleScroll);
|
|
70
71
|
}
|
|
71
|
-
|
|
72
|
-
}, [mapContainerRef.current]);
|
|
72
|
+
}, [mapContainerRef, setMapInteracted]);
|
|
73
73
|
|
|
74
74
|
useEffect(() => {
|
|
75
75
|
const { current } = mapRef;
|
|
@@ -77,20 +77,18 @@ const Map = ({
|
|
|
77
77
|
const dragStartListener = current.addListener('dragstart', () => setMapInteracted(true));
|
|
78
78
|
const mouseDownListener = current.addListener('mousedown', () => setMapInteracted(true));
|
|
79
79
|
return () => {
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
dragStartListener.remove();
|
|
81
|
+
mouseDownListener.remove();
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
|
|
85
|
-
}, [mapRef.current]);
|
|
84
|
+
}, [mapRef, setMapInteracted]);
|
|
86
85
|
|
|
87
86
|
useEffect(() => {
|
|
88
87
|
const { current } = mapRef;
|
|
89
88
|
if ((mapItems && mapItems.length > 0 || poiMarkers.length > 0) && current) {
|
|
90
89
|
fitBounds(current);
|
|
91
90
|
}
|
|
92
|
-
|
|
93
|
-
}, [mapItems, mapRef.current, location]);
|
|
91
|
+
}, [mapItems, poiMarkers, location, fitBounds]);
|
|
94
92
|
|
|
95
93
|
useEffect(() => {
|
|
96
94
|
const { current } = mapRef;
|
|
@@ -102,8 +100,7 @@ const Map = ({
|
|
|
102
100
|
let setZoomVal = currZoom < 13 ? currZoom : 12;
|
|
103
101
|
current.setZoom(setZoomVal);
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
}, [filteredListings]);
|
|
103
|
+
}, [filteredListings, fitBounds, mapInteracted, mapItems, poiMarkers.length]);
|
|
107
104
|
|
|
108
105
|
useEffect(() => {
|
|
109
106
|
const { current } = mapRef;
|
|
@@ -115,10 +112,9 @@ const Map = ({
|
|
|
115
112
|
let setZoomVal = zoom < 13 ? zoom : 12;
|
|
116
113
|
current.setZoom(setZoomVal);
|
|
117
114
|
}
|
|
118
|
-
|
|
119
|
-
}, [location, zoom, mapRef.current]);
|
|
115
|
+
}, [location, zoom, mapInteracted]);
|
|
120
116
|
|
|
121
|
-
const fitBounds = (map, overload = false) => {
|
|
117
|
+
const fitBounds = useCallback((map, overload = false) => {
|
|
122
118
|
const { current } = mapRef;
|
|
123
119
|
if ((mapInteracted === false || overload) && mapItems != null) {
|
|
124
120
|
const bounds = new window.google.maps.LatLngBounds();
|
|
@@ -128,33 +124,28 @@ const Map = ({
|
|
|
128
124
|
if (!map) return;
|
|
129
125
|
map.fitBounds(bounds);
|
|
130
126
|
}
|
|
131
|
-
if (current.zoom > 17) {
|
|
127
|
+
if (current && current.zoom > 17) {
|
|
132
128
|
current.setZoom(16);
|
|
133
129
|
}
|
|
134
|
-
};
|
|
130
|
+
}, [mapInteracted, mapItems]);
|
|
135
131
|
|
|
136
|
-
const markerClickHandler = mapLocation => {
|
|
132
|
+
const markerClickHandler = useCallback(mapLocation => {
|
|
137
133
|
setMapInteracted(true);
|
|
138
134
|
selectLocationEntity(mapLocation);
|
|
139
|
-
};
|
|
135
|
+
}, [setMapInteracted, selectLocationEntity]);
|
|
140
136
|
|
|
141
|
-
const onLoad = map => {
|
|
142
|
-
|
|
143
|
-
if (!location
|
|
144
|
-
current = map;
|
|
137
|
+
const onLoad = useCallback(map => {
|
|
138
|
+
mapRef.current = map;
|
|
139
|
+
if (!location) {
|
|
145
140
|
fitBounds(map, true);
|
|
146
141
|
return;
|
|
147
142
|
}
|
|
148
|
-
current = map;
|
|
149
143
|
|
|
150
|
-
if (mapInteracted
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
current.setZoom(zoom);
|
|
144
|
+
if (!mapInteracted) {
|
|
145
|
+
map.panTo(new google.maps.LatLng(location.latitude, location.longitude));
|
|
146
|
+
map.setZoom(zoom);
|
|
156
147
|
}
|
|
157
|
-
};
|
|
148
|
+
}, [fitBounds, location, mapInteracted, zoom]);
|
|
158
149
|
|
|
159
150
|
const pinIconUrl = pinIcon({
|
|
160
151
|
fillColor: markerConfigs.fillColor,
|
|
@@ -163,46 +154,46 @@ const Map = ({
|
|
|
163
154
|
|
|
164
155
|
return (
|
|
165
156
|
<>
|
|
166
|
-
{zoom && center &&
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
157
|
+
{zoom && center && (
|
|
158
|
+
<div ref={mapContainerRef} className="hc-h-full hc-relative">
|
|
159
|
+
<GoogleMap
|
|
160
|
+
zoom={zoom}
|
|
161
|
+
onLoad={onLoad}
|
|
162
|
+
onIdle={onIdle}
|
|
163
|
+
center={center}
|
|
164
|
+
mapContainerStyle={{
|
|
165
|
+
width: "100%",
|
|
166
|
+
height: "100%"
|
|
167
|
+
}}
|
|
168
|
+
options={{
|
|
169
|
+
styles: [
|
|
170
|
+
{
|
|
171
|
+
featureType: "poi",
|
|
172
|
+
elementType: "labels",
|
|
173
|
+
stylers: [{ visibility: "off" }]
|
|
174
|
+
}
|
|
175
|
+
]
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
<MarkerClustererF options={clusterOptions(clusterGridSize, markerConfigs.fillColor)}>
|
|
179
|
+
{clusterer => (
|
|
180
|
+
<>
|
|
181
|
+
{mapItems.map(item => (
|
|
182
|
+
<MapMarker
|
|
183
|
+
key={item.id}
|
|
184
|
+
item={item}
|
|
185
|
+
selectedLocation={location}
|
|
186
|
+
markerRefs={markerRefs}
|
|
187
|
+
infoWindowClasses={infoWindowClasses}
|
|
188
|
+
setSelectedLocation={setLocation}
|
|
189
|
+
markerClickHandler={markerClickHandler}
|
|
190
|
+
clusterer={clusterer}
|
|
191
|
+
markerIcon={markerIcon(markerConfigs)}
|
|
192
|
+
markerIconSelected={markerIconSelected(markerConfigs)}
|
|
193
|
+
setMapInteracted={setMapInteracted}
|
|
194
|
+
/>
|
|
195
|
+
))}
|
|
196
|
+
{poiMarkers && poiMarkers.markers.map((marker, index) => (
|
|
206
197
|
<PlaceMarker
|
|
207
198
|
key={`marker-${marker.title}-${index}`}
|
|
208
199
|
marker={marker}
|
|
@@ -212,27 +203,26 @@ const Map = ({
|
|
|
212
203
|
setPlacesWindow={setPlacesWindow}
|
|
213
204
|
setSelectedPlaceMarker={setSelectedPlaceMarker}
|
|
214
205
|
/>
|
|
215
|
-
)
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
</
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
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
|
};
|