mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-27 09:13:14 +10:00
Merge pull request #773 from sharetribe/fix-missing-googlelib-on-maps
Remove throw error when google lib is missing
This commit is contained in:
commit
e604234760
4 changed files with 14 additions and 16 deletions
|
|
@ -1,6 +1,9 @@
|
|||
@import '../../marketplace.css';
|
||||
|
||||
.root {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: var(--matterColorNegative);
|
||||
}
|
||||
|
||||
.mapRoot {
|
||||
|
|
|
|||
|
|
@ -55,13 +55,6 @@ const MapWithGoogleMap = withGoogleMap(props => {
|
|||
});
|
||||
|
||||
export class Map extends Component {
|
||||
componentDidMount() {
|
||||
const mapsLibLoaded = window.google && window.google.maps;
|
||||
if (!mapsLibLoaded) {
|
||||
throw new Error('Google Maps API must be loaded for the Map component');
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
className,
|
||||
|
|
@ -88,7 +81,9 @@ export class Map extends Component {
|
|||
const location = coordinatesConfig.fuzzy ? obfuscatedCenter : center;
|
||||
const centerLocationForGoogleMap = { lat: location.lat, lng: location.lng };
|
||||
|
||||
return (
|
||||
const isMapsLibLoaded = window.google && window.google.maps;
|
||||
|
||||
return isMapsLibLoaded ? (
|
||||
<MapWithGoogleMap
|
||||
containerElement={<div className={classes} onClick={this.onMapClicked} />}
|
||||
mapElement={<div className={mapClasses} />}
|
||||
|
|
@ -97,6 +92,8 @@ export class Map extends Component {
|
|||
address={address}
|
||||
coordinatesConfig={coordinatesConfig}
|
||||
/>
|
||||
) : (
|
||||
<div className={classes} />
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
.root {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: var(--matterColorNegative);
|
||||
}
|
||||
|
||||
.mapRoot {
|
||||
|
|
|
|||
|
|
@ -186,13 +186,6 @@ export class SearchMapComponent extends Component {
|
|||
this.onMapLoadHandler = this.onMapLoadHandler.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const mapsLibLoaded = window.google && window.google.maps;
|
||||
if (!mapsLibLoaded) {
|
||||
throw new Error('Google Maps API must be loaded for the SearchMap component');
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
if (this.googleMap) {
|
||||
const currentBounds = googleBoundsToSDKBounds(this.googleMap.getBounds());
|
||||
|
|
@ -254,9 +247,11 @@ export class SearchMapComponent extends Component {
|
|||
? withCoordinatesObfuscated(listingsWithLocation)
|
||||
: listingsWithLocation;
|
||||
|
||||
const isMapsLibLoaded = window.google && window.google.maps;
|
||||
|
||||
// container element listens clicks so that opened SearchMapInfoCard can be closed
|
||||
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
||||
return (
|
||||
return isMapsLibLoaded ? (
|
||||
<MapWithGoogleMap
|
||||
containerElement={<div className={classes} onClick={this.onMapClicked} />}
|
||||
mapElement={<div className={mapClasses} />}
|
||||
|
|
@ -279,6 +274,8 @@ export class SearchMapComponent extends Component {
|
|||
}}
|
||||
zoom={zoom}
|
||||
/>
|
||||
) : (
|
||||
<div className={classes} />
|
||||
);
|
||||
/* eslint-enable jsx-a11y/no-static-element-interactions */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue