mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
Abstract away map provider
This commit is contained in:
parent
afe9cad777
commit
ac093bf89e
2 changed files with 10 additions and 8 deletions
6
src/components/Map/GoogleMap.js
Normal file
6
src/components/Map/GoogleMap.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export { default as DynamicMap } from './DynamicGoogleMap';
|
||||
export { default as StaticMap } from './StaticGoogleMap';
|
||||
|
||||
export const isMapsLibLoaded = () => {
|
||||
return typeof window !== 'undefined' && window.google && window.google.maps;
|
||||
};
|
||||
|
|
@ -3,9 +3,8 @@ import { bool, number, object, string } from 'prop-types';
|
|||
import classNames from 'classnames';
|
||||
import { propTypes } from '../../util/types';
|
||||
import config from '../../config';
|
||||
import { StaticMap, DynamicMap, isMapsLibLoaded } from './GoogleMap';
|
||||
|
||||
import DynamicMap from './DynamicGoogleMap';
|
||||
import StaticMap from './StaticGoogleMap';
|
||||
import css from './Map.css';
|
||||
|
||||
export class Map extends Component {
|
||||
|
|
@ -34,15 +33,12 @@ export class Map extends Component {
|
|||
}
|
||||
|
||||
const location = coordinatesConfig.fuzzy ? obfuscatedCenter : center;
|
||||
const centerLocationForGoogleMap = { lat: location.lat, lng: location.lng };
|
||||
|
||||
const isMapsLibLoaded = typeof window !== 'undefined' && window.google && window.google.maps;
|
||||
|
||||
return !isMapsLibLoaded ? (
|
||||
return !isMapsLibLoaded() ? (
|
||||
<div className={classes} />
|
||||
) : useStaticMap ? (
|
||||
<StaticMap
|
||||
center={centerLocationForGoogleMap}
|
||||
center={location}
|
||||
zoom={zoom}
|
||||
address={address}
|
||||
coordinatesConfig={coordinatesConfig}
|
||||
|
|
@ -51,7 +47,7 @@ export class Map extends Component {
|
|||
<DynamicMap
|
||||
containerElement={<div className={classes} onClick={this.onMapClicked} />}
|
||||
mapElement={<div className={mapClasses} />}
|
||||
center={centerLocationForGoogleMap}
|
||||
center={location}
|
||||
zoom={zoom}
|
||||
address={address}
|
||||
coordinatesConfig={coordinatesConfig}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue