homeflowjs 0.11.6 → 0.11.8
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.
@@ -23,6 +23,7 @@ const BranchesMap = ({
|
|
23
23
|
displayPopup,
|
24
24
|
selectedBranch,
|
25
25
|
branches: branchesProp,
|
26
|
+
MapContainerProps,
|
26
27
|
}) => {
|
27
28
|
let branches = !!branchesProp.length
|
28
29
|
? branchesProp
|
@@ -125,6 +126,7 @@ const BranchesMap = ({
|
|
125
126
|
bounds={bounds}
|
126
127
|
scrollWheelZoom={scrollWheelZoom}
|
127
128
|
style={{ height: '100%' }}
|
129
|
+
{...MapContainerProps}
|
128
130
|
>
|
129
131
|
{google ? (
|
130
132
|
<ReactLeafletGoogleLayer apiKey={gmapsKey} type="roadmap" />
|
@@ -149,7 +151,8 @@ BranchesMap.propTypes = {
|
|
149
151
|
markerClickHandler: PropTypes.func,
|
150
152
|
displayPopup : PropTypes.bool,
|
151
153
|
selectedBranch: PropTypes.object,
|
152
|
-
branches: PropTypes.arrayOf(PropTypes.object)
|
154
|
+
branches: PropTypes.arrayOf(PropTypes.object),
|
155
|
+
MapContainerProps: PropTypes.object
|
153
156
|
};
|
154
157
|
|
155
158
|
BranchesMap.defaultProps = {
|
@@ -162,7 +165,8 @@ BranchesMap.defaultProps = {
|
|
162
165
|
markerClickHandler: () => {},
|
163
166
|
displayPopup: true,
|
164
167
|
selectedBranch: {},
|
165
|
-
branches: []
|
168
|
+
branches: [],
|
169
|
+
MapContainerProps: {}
|
166
170
|
};
|
167
171
|
|
168
172
|
const mapStateToProps = (state) => ({
|
package/package.json
CHANGED
@@ -6,11 +6,13 @@ import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet';
|
|
6
6
|
const PropertyLeafletMap = ({ CustomPopup }) => {
|
7
7
|
const property = Homeflow.get('property');
|
8
8
|
const customIcon = Homeflow.get('custom_map_icon');
|
9
|
+
const customIconAnchor = Homeflow.get('custom_map_icon_anchor');
|
9
10
|
|
10
11
|
const defaultIcon = L.icon({
|
11
12
|
iconRetinaUrl: '/assets/marker-icon.png',
|
12
13
|
iconUrl: customIcon || '/assets/marker-icon.png',
|
13
14
|
shadowUrl: '/assets/marker-shadow.png',
|
15
|
+
iconAnchor: customIconAnchor || [12, 41]
|
14
16
|
});
|
15
17
|
|
16
18
|
return (
|
@@ -17,6 +17,7 @@ class LocationInput extends Component {
|
|
17
17
|
this.onLocationChange = this.onLocationChange.bind(this);
|
18
18
|
// wait half a second after typing stops before fetching results
|
19
19
|
this.debouncedLoadSuggestions = debounce(this.loadSuggestions, DEBOUNCE_DELAY);
|
20
|
+
this.abortContRef = React.createRef();
|
20
21
|
}
|
21
22
|
|
22
23
|
onLocationChange(event, { newValue }) {
|
@@ -31,8 +32,14 @@ class LocationInput extends Component {
|
|
31
32
|
}
|
32
33
|
|
33
34
|
getSuggestions(q) {
|
34
|
-
|
35
|
-
|
35
|
+
if (this.abortContRef.current) this.abortContRef.current.abort();
|
36
|
+
this.abortContRef.current = new AbortController();
|
37
|
+
return fetch(`/places?term=${q}`, { signal: this.abortContRef.current.signal })
|
38
|
+
.then(response => response.json())
|
39
|
+
.catch(e => {
|
40
|
+
if (e.code === 20) return;
|
41
|
+
console.error(e);
|
42
|
+
});
|
36
43
|
}
|
37
44
|
|
38
45
|
renderSuggestion(suggestion) {
|
@@ -51,7 +58,7 @@ class LocationInput extends Component {
|
|
51
58
|
this.getSuggestions(value)
|
52
59
|
.then((data) => {
|
53
60
|
const suggestions = data ? (
|
54
|
-
|
61
|
+
data
|
55
62
|
.filter((_item, index) => index < 15 )
|
56
63
|
.map((item) => (
|
57
64
|
{ label: item[0], place: item[1] }
|