homeflowjs 1.0.4 → 1.0.6

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.
@@ -38,7 +38,7 @@ export const initGoogleMaps = () => (dispatch, getState) => {
38
38
  // Load the Google Maps API
39
39
  const script = document.createElement('script');
40
40
  const { app: { themePreferences: { google_maps_api_key: gmapKey } } } = getState();
41
- script.src = `https://maps.googleapis.com/maps/api/js?key=${gmapKey}&callback=resolveGoogleMapsPromise`;
41
+ script.src = `https://maps.googleapis.com/maps/api/js?key=${gmapKey}&libraries=marker&loading=async&callback=resolveGoogleMapsPromise`;
42
42
  script.async = true;
43
43
  script.id = 'hfjs-google-maps-script';
44
44
  document.body.appendChild(script);
@@ -127,7 +127,8 @@ export const postPropertyView = (payload) => () => {
127
127
  });
128
128
  };
129
129
 
130
- export const postBulkPropertyExposureCreation = (payload, { sendAsFormData } = {}) => () => {
130
+ export const postBulkPropertyExposureCreation = (payload) => () => {
131
+ const { sendAsFormData } = Homeflow.get('createManyOptions') ?? {};
131
132
  const domain = location.hostname;
132
133
  const exposuresPublicUrl = Homeflow.get('exposures_public_url');
133
134
 
@@ -116,7 +116,7 @@ const hfInitialize = () => {
116
116
  postBulkPropertyExposureCreation({
117
117
  eventType: 'SearchResult',
118
118
  propertyIds,
119
- }, Homeflow.get('createManyOptions')),
119
+ }),
120
120
  );
121
121
  }
122
122
 
@@ -6,10 +6,10 @@ import PropTypes from 'prop-types';
6
6
  import { initGoogleMaps } from '../../actions/app.actions';
7
7
  import { simpleBW } from '../../shared/custom-gmap-styles';
8
8
 
9
- const BranchLeafletMap = React.lazy(() => import('./branch-leaflet-map.component'));
10
-
11
9
  import 'leaflet/dist/leaflet.css';
12
10
 
11
+ const BranchLeafletMap = React.lazy(() => import('./branch-leaflet-map.component'));
12
+
13
13
  const LazyLeafletMap = (props) => (
14
14
  <Suspense fallback={<div>Loading</div>}>
15
15
  <BranchLeafletMap {...props} />
@@ -34,7 +34,6 @@ class BranchMap extends React.Component {
34
34
  disableStreetview,
35
35
  custom,
36
36
  iconConfig,
37
- fullscreenControl,
38
37
  zoomControl,
39
38
  googleMapsBranchZoomLevel,
40
39
  } = this.props;
@@ -42,7 +41,7 @@ class BranchMap extends React.Component {
42
41
  // Should this be added to Redux?
43
42
  const branch = Homeflow.get('branch');
44
43
  const usedZoom = parseInt(googleMapsBranchZoomLevel || defaultZoom, 10);
45
-
44
+ const imgElement = document.createElement('img');
46
45
  const options = {
47
46
  center: new google.maps.LatLng(branch.lat, branch.lng),
48
47
  mapTypeControl,
@@ -51,18 +50,25 @@ class BranchMap extends React.Component {
51
50
  streetViewControl: !disableStreetview,
52
51
  fullscreenControl: false,
53
52
  zoomControl,
53
+ mapId: 'HF_BRANCH_MAP',
54
54
  };
55
55
 
56
56
  if (custom === 'simple_bw') {
57
57
  options.styles = simpleBW;
58
58
  }
59
59
 
60
- const map = new google.maps.Map(document.getElementById('hfjs-branch-map'), options);
60
+ if (iconConfig && iconConfig?.iconUrl) {
61
+ imgElement.src = iconConfig?.iconUrl;
62
+ }
61
63
 
62
- const marker = new google.maps.Marker({
64
+ const map = new google.maps.Map(document.getElementById('hfjs-branch-map'), options);
65
+ const marker = new google.maps.marker.AdvancedMarkerElement({
63
66
  position: { lat: branch.lat, lng: branch.lng },
64
67
  map,
65
- ...(iconConfig && { icon: iconConfig.iconUrl }),
68
+ ...(
69
+ (iconConfig && iconConfig?.iconUrl) && {
70
+ content: imgElement,
71
+ }),
66
72
  });
67
73
 
68
74
  const branchPopupContent = document.getElementById('branch-map-popup-template')?.innerHTML;
@@ -100,6 +106,7 @@ BranchMap.propTypes = {
100
106
  scrollWheel: PropTypes.bool,
101
107
  custom: PropTypes.oneOf(['simple_bw', null]),
102
108
  zoom: PropTypes.number,
109
+ defaultZoom: PropTypes.number,
103
110
  disableStreetview: PropTypes.bool,
104
111
  initGoogleMaps: PropTypes.func.isRequired,
105
112
  google: PropTypes.bool,
@@ -21,7 +21,7 @@ const BranchesMap = ({
21
21
  scrollWheelZoom,
22
22
  markerClickHandler,
23
23
  displayPopup,
24
- selectedBranch,
24
+ selectedBranch,
25
25
  branches: branchesProp,
26
26
  MapContainerProps,
27
27
  }) => {
@@ -42,8 +42,6 @@ const BranchesMap = ({
42
42
  shadowUrl: '/assets/marker-shadow.png',
43
43
  };
44
44
 
45
-
46
-
47
45
  const bounds = latLngBounds([branches[0].lat, branches[0].lng]);
48
46
 
49
47
  const markers = branches.map((branch) => {
@@ -149,10 +147,10 @@ BranchesMap.propTypes = {
149
147
  fallbackLatLng: PropTypes.object,
150
148
  scrollWheelZoom: PropTypes.bool,
151
149
  markerClickHandler: PropTypes.func,
152
- displayPopup : PropTypes.bool,
150
+ displayPopup: PropTypes.bool,
153
151
  selectedBranch: PropTypes.object,
154
152
  branches: PropTypes.arrayOf(PropTypes.object),
155
- MapContainerProps: PropTypes.object
153
+ MapContainerProps: PropTypes.object,
156
154
  };
157
155
 
158
156
  BranchesMap.defaultProps = {
@@ -166,7 +164,7 @@ BranchesMap.defaultProps = {
166
164
  displayPopup: true,
167
165
  selectedBranch: {},
168
166
  branches: [],
169
- MapContainerProps: {}
167
+ MapContainerProps: {},
170
168
  };
171
169
 
172
170
  const mapStateToProps = (state) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -277,7 +277,7 @@ export default class DraggableMap {
277
277
  console.warn('Tried to render a Google map layer without a google maps API key being set in admin.');
278
278
  }
279
279
  layer = new L.TileLayer(
280
- 'http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}', {
280
+ 'http://{s}.google.com/vt/lyrs=m&x={x}&y={y}&z={z}&loading=async', {
281
281
  subdomains: ['mt0','mt1','mt2','mt3'],
282
282
  attribution: `<img src="${Homeflow.get('root_url')}assets/leaflet/google-logo.png" alt="Powered by Google" />`
283
283
  });
@@ -73,7 +73,7 @@ const PropertiesMap = ({ leaflet, gmapKey, googleLayer, legacyMapOptions }) => {
73
73
 
74
74
  if (needsGoogle && !document.getElementById('hfjs-gmaps') && gmapKey) {
75
75
  const gmapScript = document.createElement('script');
76
- gmapScript.setAttribute('src', `https://maps.google.com/maps/api/js?key=${gmapKey}`);
76
+ gmapScript.setAttribute('src', `https://maps.google.com/maps/api/js?key=${gmapKey}&loading=async`);
77
77
  gmapScript.setAttribute('id', 'hfjs-gmaps');
78
78
  document.head.appendChild(gmapScript);
79
79
  }
@@ -10,6 +10,7 @@ import '../properties-map/leaflet.css';
10
10
 
11
11
  const PropertyLeafletMap = React.lazy(() => import('./property-leaflet-map.component'));
12
12
 
13
+ // eslint-disable-next-line react/prop-types
13
14
  const LazyLeafletMap = ({ placeholder, ...props }) => (
14
15
  <Suspense fallback={placeholder}>
15
16
  <PropertyLeafletMap {...props} />
@@ -38,24 +39,32 @@ class PropertyMap extends React.Component {
38
39
 
39
40
  // Should this be added to Redux?
40
41
  const property = Homeflow.get('property');
41
-
42
+ const imgElement = document.createElement('img');
42
43
  const options = {
43
44
  center: new google.maps.LatLng(property.lat, property.lng),
44
45
  mapTypeControl,
45
46
  scrollWheel,
46
47
  zoom,
47
48
  streetViewControl: !disableStreetview,
49
+ mapId: 'HF_PROPERTY_MAP',
48
50
  };
49
51
 
50
52
  if (custom === 'simple_bw') {
51
53
  options.styles = simpleBW;
52
54
  }
53
55
 
56
+ if (iconConfig && iconConfig?.iconUrl) {
57
+ imgElement.src = iconConfig?.iconUrl;
58
+ }
59
+
54
60
  const map = new google.maps.Map(document.getElementById('hfjs-property-map'), options);
55
- const marker = new google.maps.Marker({
61
+ const marker = new google.maps.marker.AdvancedMarkerElement({
56
62
  position: { lat: property.lat, lng: property.lng },
57
63
  map,
58
- ...(iconConfig && { icon: iconConfig.iconUrl }),
64
+ ...(
65
+ (iconConfig && iconConfig?.iconUrl) && {
66
+ content: imgElement,
67
+ }),
59
68
  });
60
69
 
61
70
  const propertyPopupContent = document.getElementById('property-show-map-popup-template')?.innerHTML;
@@ -76,7 +85,9 @@ class PropertyMap extends React.Component {
76
85
  }
77
86
 
78
87
  render() {
79
- const { google, iconConfig, CustomPopup, placeholder, leafletWhenReady } = this.props;
88
+ const {
89
+ google, iconConfig, CustomPopup, placeholder, leafletWhenReady,
90
+ } = this.props;
80
91
 
81
92
  if (!google) {
82
93
  return (
@@ -85,7 +96,8 @@ class PropertyMap extends React.Component {
85
96
  CustomPopup={CustomPopup}
86
97
  placeholder={placeholder}
87
98
  leafletWhenReady={leafletWhenReady}
88
- />);
99
+ />
100
+ );
89
101
  }
90
102
 
91
103
  return (