From 208c05cdd7acd576d86c1c64c3b9ac0c64fa2bfb Mon Sep 17 00:00:00 2001 From: Vesa Luusua Date: Fri, 20 Jul 2018 14:16:34 +0300 Subject: [PATCH] Change static map to dynamic one on click --- src/components/Map/DynamicMap.js | 22 ++++---- src/containers/ListingPage/ListingPage.css | 3 ++ src/containers/ListingPage/SectionMapMaybe.js | 54 +++++++++++-------- 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/src/components/Map/DynamicMap.js b/src/components/Map/DynamicMap.js index 7dc8bbde..d8515430 100644 --- a/src/components/Map/DynamicMap.js +++ b/src/components/Map/DynamicMap.js @@ -10,17 +10,21 @@ import config from '../../config'; const DynamicMap = withGoogleMap(props => { const { center, zoom, address, coordinatesConfig } = props; - const { markerURI, anchorX, anchorY, width, height } = coordinatesConfig.customMarker; - const markerIcon = { - url: markerURI, + const { markerURI, anchorX, anchorY, width, height } = coordinatesConfig.customMarker || {}; + const markerIcon = coordinatesConfig.customMarker + ? { + icon: { + url: markerURI, - // The origin for this image is (0, 0). - origin: new window.google.maps.Point(0, 0), - size: new window.google.maps.Size(width, height), - anchor: new window.google.maps.Point(anchorX, anchorY), - }; + // The origin for this image is (0, 0). + origin: new window.google.maps.Point(0, 0), + size: new window.google.maps.Size(width, height), + anchor: new window.google.maps.Point(anchorX, anchorY), + }, + } + : {}; - const marker = ; + const marker = ; const circleProps = { options: coordinatesConfig.circleOptions, diff --git a/src/containers/ListingPage/ListingPage.css b/src/containers/ListingPage/ListingPage.css index d28bbc5e..62410f22 100644 --- a/src/containers/ListingPage/ListingPage.css +++ b/src/containers/ListingPage/ListingPage.css @@ -535,6 +535,9 @@ max-width: 640px; max-height: 640px; background-color: #eee; + padding: 0; + border: 0; + cursor: pointer; @media (--viewportMedium) { height: 75vh; diff --git a/src/containers/ListingPage/SectionMapMaybe.js b/src/containers/ListingPage/SectionMapMaybe.js index 9a946305..05782c5b 100644 --- a/src/containers/ListingPage/SectionMapMaybe.js +++ b/src/containers/ListingPage/SectionMapMaybe.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Component } from 'react'; import { string } from 'prop-types'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; @@ -9,31 +9,43 @@ import config from '../../config'; import css from './ListingPage.css'; -const SectionMapMaybe = props => { - const { className, rootClassName, geolocation, publicData, listingId } = props; - - if (!geolocation) { - return null; +class SectionMapMaybe extends Component { + constructor(props) { + super(props); + this.state = { isStatic: true }; } - const address = publicData.location ? publicData.location.address : ''; - const classes = classNames(rootClassName || css.sectionMap, className); + render() { + const { className, rootClassName, geolocation, publicData, listingId } = this.props; - const mapProps = config.coordinates.fuzzy - ? { obfuscatedCenter: obfuscatedCoordinates(geolocation, listingId ? listingId.uuid : null) } - : { address, center: geolocation }; + if (!geolocation) { + return null; + } - return ( -
-

- -

-
- + const address = publicData.location ? publicData.location.address : ''; + const classes = classNames(rootClassName || css.sectionMap, className); + + const mapProps = config.coordinates.fuzzy + ? { obfuscatedCenter: obfuscatedCoordinates(geolocation, listingId ? listingId.uuid : null) } + : { address, center: geolocation }; + + return ( +
+

+ +

+
-
- ); -}; + ); + } +} SectionMapMaybe.defaultProps = { rootClassName: null,