homeflowjs 0.10.24 → 0.10.25
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.
@@ -13,9 +13,20 @@ import ReactLeafletGoogleLayer from 'react-leaflet-google-layer';
|
|
13
13
|
import 'leaflet/dist/leaflet.css';
|
14
14
|
|
15
15
|
const BranchesMap = ({
|
16
|
-
CustomPopup,
|
16
|
+
CustomPopup,
|
17
|
+
google,
|
18
|
+
gmapsKey,
|
19
|
+
iconConfig,
|
20
|
+
fallbackLatLng,
|
21
|
+
scrollWheelZoom,
|
22
|
+
markerClickHandler,
|
23
|
+
displayPopup,
|
24
|
+
selectedBranch,
|
25
|
+
branches: branchesProp,
|
17
26
|
}) => {
|
18
|
-
let branches =
|
27
|
+
let branches = !!branchesProp.length
|
28
|
+
? branchesProp
|
29
|
+
: Homeflow.get('branches');
|
19
30
|
let showMarkers = true;
|
20
31
|
|
21
32
|
// If no branches found use fallback lat, long and set showMarkers to false
|
@@ -30,17 +41,20 @@ const BranchesMap = ({
|
|
30
41
|
shadowUrl: '/assets/marker-shadow.png',
|
31
42
|
};
|
32
43
|
|
33
|
-
|
44
|
+
|
34
45
|
|
35
46
|
const bounds = latLngBounds([branches[0].lat, branches[0].lng]);
|
36
47
|
|
37
48
|
const markers = branches.map((branch) => {
|
38
49
|
bounds.extend([branch.lat, branch.lng]);
|
50
|
+
let icon = L.icon(iconConfig || defaultIconConfig);
|
39
51
|
// check if branch object have mapIcon payload, example:
|
40
52
|
// mapIcon: {
|
41
53
|
// iconUrl: 'specific-path.png' || 'data:image/svg+xml;utf8,<svg></svg>',
|
42
54
|
// iconSize: [149, 66],
|
43
55
|
// }
|
56
|
+
if (branch.branchID === selectedBranch.branchID && 'mapIcon' in selectedBranch) icon = L.icon(selectedBranch.mapIcon);
|
57
|
+
|
44
58
|
if ('mapIcon' in branch) icon = L.icon(branch.mapIcon);
|
45
59
|
// check if branch object have mapDivIcon payload, example:
|
46
60
|
// mapDivIcon: {
|
@@ -49,35 +63,55 @@ const BranchesMap = ({
|
|
49
63
|
// }
|
50
64
|
if ('mapDivIcon' in branch) icon = L.divIcon(branch.mapDivIcon);
|
51
65
|
|
66
|
+
if (displayPopup) {
|
67
|
+
return (
|
68
|
+
<Marker
|
69
|
+
position={[branch.lat, branch.lng]}
|
70
|
+
icon={icon}
|
71
|
+
key={branch?.branch_id || branch?.branchID}
|
72
|
+
eventHandlers={{
|
73
|
+
click: () => markerClickHandler(branch),
|
74
|
+
}}
|
75
|
+
>
|
76
|
+
{CustomPopup ? (
|
77
|
+
<Popup>
|
78
|
+
<CustomPopup branch={branch} />
|
79
|
+
</Popup>
|
80
|
+
) : (
|
81
|
+
<Popup>
|
82
|
+
<div className="hfjs-branch-marker-popup">
|
83
|
+
<h2>{branch.name}</h2>
|
84
|
+
<p>{branch.address}</p>
|
85
|
+
|
86
|
+
{branch.sales_enabled && (
|
87
|
+
<a href={`${branch.branch_url}/sales`}>
|
88
|
+
View all properties for sale >
|
89
|
+
</a>
|
90
|
+
)}
|
91
|
+
|
92
|
+
<br />
|
93
|
+
|
94
|
+
{branch.lettings_enabled && (
|
95
|
+
<a href={`${branch.branch_url}/lettings`}>
|
96
|
+
View all properties to let >
|
97
|
+
</a>
|
98
|
+
)}
|
99
|
+
</div>
|
100
|
+
</Popup>
|
101
|
+
)}
|
102
|
+
</Marker>
|
103
|
+
);
|
104
|
+
}
|
105
|
+
|
52
106
|
return (
|
53
107
|
<Marker
|
54
108
|
position={[branch.lat, branch.lng]}
|
55
109
|
icon={icon}
|
56
|
-
key={branch
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
</Popup>
|
62
|
-
) : (
|
63
|
-
<Popup>
|
64
|
-
<div className="hfjs-branch-marker-popup">
|
65
|
-
<h2>{branch.name}</h2>
|
66
|
-
<p>{branch.address}</p>
|
67
|
-
|
68
|
-
{branch.sales_enabled && (
|
69
|
-
<a href={`${branch.branch_url}/sales`}>View all properties for sale ></a>
|
70
|
-
)}
|
71
|
-
|
72
|
-
<br />
|
73
|
-
|
74
|
-
{branch.lettings_enabled && (
|
75
|
-
<a href={`${branch.branch_url}/lettings`}>View all properties to let ></a>
|
76
|
-
)}
|
77
|
-
</div>
|
78
|
-
</Popup>
|
79
|
-
)}
|
80
|
-
</Marker>
|
110
|
+
key={branch?.branch_id || branch?.branchID}
|
111
|
+
eventHandlers={{
|
112
|
+
click: () => markerClickHandler(branch),
|
113
|
+
}}
|
114
|
+
/>
|
81
115
|
);
|
82
116
|
});
|
83
117
|
|
@@ -112,6 +146,10 @@ BranchesMap.propTypes = {
|
|
112
146
|
iconConfig: PropTypes.object,
|
113
147
|
fallbackLatLng: PropTypes.object,
|
114
148
|
scrollWheelZoom: PropTypes.bool,
|
149
|
+
markerClickHandler: PropTypes.func,
|
150
|
+
displayPopup : PropTypes.bool,
|
151
|
+
selectedBranch: PropTypes.object,
|
152
|
+
branches: PropTypes.arrayOf(PropTypes.object)
|
115
153
|
};
|
116
154
|
|
117
155
|
BranchesMap.defaultProps = {
|
@@ -121,6 +159,10 @@ BranchesMap.defaultProps = {
|
|
121
159
|
iconConfig: null,
|
122
160
|
fallbackLatLng: { lat: 51.509865, lng: -0.118092 },
|
123
161
|
scrollWheelZoom: false,
|
162
|
+
markerClickHandler: () => {},
|
163
|
+
displayPopup: true,
|
164
|
+
selectedBranch: {},
|
165
|
+
branches: []
|
124
166
|
};
|
125
167
|
|
126
168
|
const mapStateToProps = (state) => ({
|