diff --git a/src/components/Map/GoogleMap.js b/src/components/Map/GoogleMap.js new file mode 100644 index 00000000..65db93bd --- /dev/null +++ b/src/components/Map/GoogleMap.js @@ -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; +}; diff --git a/src/components/Map/Map.js b/src/components/Map/Map.js index db6207ed..bb1f98c8 100644 --- a/src/components/Map/Map.js +++ b/src/components/Map/Map.js @@ -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() ? (
) : useStaticMap ? (