@woosmap/ui 3.46.0 → 3.50.0
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.
package/package.json
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
import React, { Component } from 'react';
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import cl from 'classnames';
|
|
5
|
-
import GoogleMapReact from 'google-map-react';
|
|
6
5
|
import Demo from './SkeletonDemo';
|
|
7
|
-
import AddressAutocomplete from '../Woosmap/AddressAutocomplete';
|
|
8
|
-
import Marker from '../Map/Marker';
|
|
9
6
|
import Constants from '../../Constants';
|
|
10
|
-
import {
|
|
7
|
+
import { createWoosmapMap, WoosmapMapBoundingBox } from '../Map/drawOnMap';
|
|
11
8
|
import Button from '../Button/Button';
|
|
12
9
|
import ButtonGroup from '../Button/ButtonGroup';
|
|
13
10
|
import CountrySelect from '../Select/CountrySelect';
|
|
14
11
|
import { tr } from '../utils/locale';
|
|
15
12
|
import Input from '../Input/Input';
|
|
13
|
+
import Script from '../utils/Script';
|
|
14
|
+
import markerIcon from '../../images/marker.png';
|
|
15
|
+
import AddressAutocomplete from '../Woosmap/AddressAutocomplete';
|
|
16
16
|
|
|
17
17
|
const languages = [
|
|
18
18
|
{ value: 'fr', label: 'French' },
|
|
@@ -49,6 +49,11 @@ export default class AddressDemo extends Component {
|
|
|
49
49
|
this.requestGeocodeUrl = 'https://api.woosmap.com/address/geocode/json';
|
|
50
50
|
this.inputRef = React.createRef();
|
|
51
51
|
this.addressAutocompleteRef = React.createRef();
|
|
52
|
+
this.demoRef = React.createRef();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
componentDidMount() {
|
|
56
|
+
this.displayMap();
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
componentWillUnmount() {
|
|
@@ -80,9 +85,9 @@ export default class AddressDemo extends Component {
|
|
|
80
85
|
};
|
|
81
86
|
if (usecase === 'geocode') {
|
|
82
87
|
// eslint-disable-next-line prefer-destructuring
|
|
83
|
-
state.
|
|
88
|
+
state.selectedAddress = response.data.results[0];
|
|
84
89
|
}
|
|
85
|
-
this.setState(state);
|
|
90
|
+
this.setState(state, this.displayOnMap);
|
|
86
91
|
}
|
|
87
92
|
})
|
|
88
93
|
.catch((error) => {
|
|
@@ -107,12 +112,15 @@ export default class AddressDemo extends Component {
|
|
|
107
112
|
})
|
|
108
113
|
.then((response) => {
|
|
109
114
|
if (this.mounted) {
|
|
110
|
-
this.setState(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
this.setState(
|
|
116
|
+
{
|
|
117
|
+
error: null,
|
|
118
|
+
showDetails: true,
|
|
119
|
+
response: response.data.result,
|
|
120
|
+
selectedAddress: response.data.result,
|
|
121
|
+
},
|
|
122
|
+
this.displayOnMap
|
|
123
|
+
);
|
|
116
124
|
}
|
|
117
125
|
})
|
|
118
126
|
.catch((error) => {
|
|
@@ -122,12 +130,10 @@ export default class AddressDemo extends Component {
|
|
|
122
130
|
};
|
|
123
131
|
|
|
124
132
|
getRequestparams = () => {
|
|
125
|
-
const { input, geocodeInput,
|
|
126
|
-
this.state;
|
|
133
|
+
const { input, geocodeInput, language, countries, showDetails, usecase, geometry } = this.state;
|
|
127
134
|
if (showDetails) {
|
|
128
135
|
const detailsParam = {
|
|
129
136
|
key: Constants.woosmapKey,
|
|
130
|
-
public_id: selectedLocality.public_id,
|
|
131
137
|
};
|
|
132
138
|
if (geometry) {
|
|
133
139
|
detailsParam.fields = 'geometry';
|
|
@@ -154,14 +160,37 @@ export default class AddressDemo extends Component {
|
|
|
154
160
|
|
|
155
161
|
displayOnMap = () => {
|
|
156
162
|
const { selectedAddress } = this.state;
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
|
|
164
|
+
if (this.map && selectedAddress?.geometry.location) {
|
|
165
|
+
if (this.marker) {
|
|
166
|
+
this.marker.setMap(null);
|
|
167
|
+
this.marker = null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (this.overlay) {
|
|
171
|
+
this.overlay.setMap(null);
|
|
172
|
+
this.overlay = null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
this.marker = new window.woosmap.map.Marker({
|
|
176
|
+
icon: { url: markerIcon, scaledSize: { height: 46, width: 30 } },
|
|
177
|
+
position: selectedAddress.geometry.location,
|
|
178
|
+
map: this.map,
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
if (selectedAddress.geometry.viewport) {
|
|
182
|
+
const { northeast, southwest } = selectedAddress.geometry.viewport;
|
|
183
|
+
const bounds = {
|
|
184
|
+
north: northeast.lat,
|
|
185
|
+
east: northeast.lng,
|
|
186
|
+
south: southwest.lat,
|
|
187
|
+
west: southwest.lng,
|
|
188
|
+
};
|
|
189
|
+
this.overlay = new WoosmapMapBoundingBox(bounds);
|
|
190
|
+
this.overlay.setMap(this.map);
|
|
191
|
+
this.map.fitBounds(bounds, { top: 70, bottom: 70, left: 70, right: 70 });
|
|
164
192
|
} else {
|
|
193
|
+
this.map.setCenter(selectedAddress.geometry.location);
|
|
165
194
|
this.map.setZoom(10);
|
|
166
195
|
}
|
|
167
196
|
}
|
|
@@ -171,7 +200,7 @@ export default class AddressDemo extends Component {
|
|
|
171
200
|
this.setState(
|
|
172
201
|
{
|
|
173
202
|
error: null,
|
|
174
|
-
|
|
203
|
+
selectedAddress: address,
|
|
175
204
|
},
|
|
176
205
|
this.requestAddress
|
|
177
206
|
);
|
|
@@ -194,7 +223,7 @@ export default class AddressDemo extends Component {
|
|
|
194
223
|
key="autocomplete"
|
|
195
224
|
active={usecase === 'autocomplete'}
|
|
196
225
|
onClick={() => {
|
|
197
|
-
this.setState({ usecase: 'autocomplete',
|
|
226
|
+
this.setState({ usecase: 'autocomplete', selectedAddress: null, showDetails: false });
|
|
198
227
|
}}
|
|
199
228
|
label={tr('Autocomplete')}
|
|
200
229
|
/>
|
|
@@ -203,7 +232,7 @@ export default class AddressDemo extends Component {
|
|
|
203
232
|
key="geocode"
|
|
204
233
|
active={usecase === 'geocode'}
|
|
205
234
|
onClick={() => {
|
|
206
|
-
this.setState({ usecase: 'geocode',
|
|
235
|
+
this.setState({ usecase: 'geocode', selectedAddress: null, showDetails: false });
|
|
207
236
|
}}
|
|
208
237
|
label={tr('Geocode')}
|
|
209
238
|
/>
|
|
@@ -296,14 +325,14 @@ export default class AddressDemo extends Component {
|
|
|
296
325
|
};
|
|
297
326
|
|
|
298
327
|
renderAddress = () => {
|
|
299
|
-
const {
|
|
328
|
+
const { selectedAddress, geometry } = this.state;
|
|
300
329
|
if (geometry) {
|
|
301
330
|
return null;
|
|
302
331
|
}
|
|
303
332
|
let addressComponents = [];
|
|
304
|
-
const hasComponents =
|
|
333
|
+
const hasComponents = selectedAddress && selectedAddress.address_components;
|
|
305
334
|
if (hasComponents) {
|
|
306
|
-
addressComponents =
|
|
335
|
+
addressComponents = selectedAddress.address_components;
|
|
307
336
|
}
|
|
308
337
|
let shippingAddress = '';
|
|
309
338
|
let shippingAddress2 = '';
|
|
@@ -393,29 +422,17 @@ export default class AddressDemo extends Component {
|
|
|
393
422
|
);
|
|
394
423
|
};
|
|
395
424
|
|
|
396
|
-
|
|
397
|
-
|
|
425
|
+
displayMap = () => {
|
|
426
|
+
if (this.timeoutMap) {
|
|
427
|
+
clearTimeout(this.timeoutMap);
|
|
428
|
+
}
|
|
398
429
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
return (
|
|
406
|
-
<GoogleMapReact
|
|
407
|
-
defaultZoom={10}
|
|
408
|
-
center={[location.lat, location.lng]}
|
|
409
|
-
bootstrapURLKeys={{ key: Constants.gmapKey, libraries: ['geometry', 'places'] }}
|
|
410
|
-
yesIWantToUseGoogleMapApiInternals
|
|
411
|
-
onGoogleApiLoaded={({ map }) => {
|
|
412
|
-
this.map = map;
|
|
413
|
-
this.displayOnMap();
|
|
414
|
-
}}
|
|
415
|
-
>
|
|
416
|
-
{marker}
|
|
417
|
-
</GoogleMapReact>
|
|
418
|
-
);
|
|
430
|
+
if (window.woosmap && window.woosmap.map && this.demoRef.current) {
|
|
431
|
+
window.woosmap.map.config.setApiKey(Constants.woosmapKey);
|
|
432
|
+
this.map = createWoosmapMap(this.demoRef.current.getMap());
|
|
433
|
+
} else {
|
|
434
|
+
this.timeoutMap = setTimeout(this.displayMap, 300);
|
|
435
|
+
}
|
|
419
436
|
};
|
|
420
437
|
|
|
421
438
|
render() {
|
|
@@ -429,19 +446,23 @@ export default class AddressDemo extends Component {
|
|
|
429
446
|
}
|
|
430
447
|
}
|
|
431
448
|
return (
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
449
|
+
<>
|
|
450
|
+
<Script url="https://sdk.woosmap.com/map/map.js" />
|
|
451
|
+
<Demo
|
|
452
|
+
noheader
|
|
453
|
+
id="address-demo"
|
|
454
|
+
className="demo--address"
|
|
455
|
+
footerFilters={this.renderFooterFilters()}
|
|
456
|
+
headerFilters={this.renderHeaderFilters()}
|
|
457
|
+
request={request}
|
|
458
|
+
params={this.getRequestparams()}
|
|
459
|
+
referer="http://localhost/"
|
|
460
|
+
response={error || response}
|
|
461
|
+
result={this.renderAddress()}
|
|
462
|
+
ref={this.demoRef}
|
|
463
|
+
withMap
|
|
464
|
+
/>
|
|
465
|
+
</>
|
|
445
466
|
);
|
|
446
467
|
}
|
|
447
468
|
}
|
|
@@ -145,6 +145,7 @@ import { ReactComponent as MultiSearch } from '../../icons/multisearch.svg';
|
|
|
145
145
|
import { ReactComponent as Mapping } from '../../icons/mapping.svg';
|
|
146
146
|
import { ReactComponent as Connectors } from '../../icons/connectors.svg';
|
|
147
147
|
import { ReactComponent as Showcases } from '../../icons/showcases.svg';
|
|
148
|
+
import { ReactComponent as Indoor } from '../../icons/indoor.svg';
|
|
148
149
|
|
|
149
150
|
import { ReactComponent as SocialFacebook } from '../../icons/social-facebook.svg';
|
|
150
151
|
import { ReactComponent as SocialLinkedin } from '../../icons/social-linkedin.svg';
|
|
@@ -295,6 +296,7 @@ const Icons = {
|
|
|
295
296
|
mapping: Mapping,
|
|
296
297
|
connectors: Connectors,
|
|
297
298
|
showcases: Showcases,
|
|
299
|
+
indoor: Indoor,
|
|
298
300
|
'social-facebook': SocialFacebook,
|
|
299
301
|
'social-linkedin': SocialLinkedin,
|
|
300
302
|
'social-twitter': SocialTwitter,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 70 70"><path d="M56.094 6.994H13.906A6.919 6.919 0 0 0 7 13.905V56.1a6.919 6.919 0 0 0 6.911 6.911h42.183a6.919 6.919 0 0 0 6.911-6.911V13.905a6.919 6.919 0 0 0-6.911-6.911Zm-1.146 22.317c0 .019-.011.036-.011.056v6.609H42.9v-6.665Zm1.978 0h4.079v6.665h-4.068v-6.609c0-.02-.01-.037-.011-.056Zm4.079-15.406v13.406h-9.619V14.9a1 1 0 0 0-2 0v12.411H41.9a1 1 0 0 0-1 1v8.665a1 1 0 0 0 1 1H61v7.363H41.9a1 1 0 0 0-1 1v14.667H29.235V40.938a1 1 0 0 0-1-1H8.995V28.794h14.913a1 1 0 0 0 1-1v-18.8H34v8.9a1 1 0 0 0 1 1h6.33a1 1 0 0 0 1-1v-8.9h13.764a4.916 4.916 0 0 1 4.911 4.911ZM42.9 55.172h6.485v5.834H42.9Zm6.485-2H42.9v-5.833h6.485ZM18.817 41.938h8.418v9.57h-8.418ZM8.995 20.031h13.913v6.763H8.995Zm31.335-11V16.9H36V9.026Zm-26.424-.037h9v9.037H8.995v-4.126a4.916 4.916 0 0 1 4.911-4.911ZM8.995 56.1V41.938h7.822v10.57a1 1 0 0 0 1 1h9.418v7.5H13.906A4.916 4.916 0 0 1 8.995 56.1Zm47.1 4.911h-4.709V47.339h9.619V56.1a4.916 4.916 0 0 1-4.911 4.906Z"/></svg>
|