diff --git a/src/mocks/maps.mock.tsx b/src/mocks/maps.mock.tsx index 51139ac6e8..ccb6d31def 100644 --- a/src/mocks/maps.mock.tsx +++ b/src/mocks/maps.mock.tsx @@ -36,6 +36,6 @@ export const generatePinDetails = (pin: IMapPin): IMapPinDetail => { lastActive, profilePicUrl: 'https://picsum.photos/50/50', profileUrl: '/testing', - heroImageUrl: 'https://picsum.photos/285/175', + heroImageUrl: `https://picsum.photos/seed/${lastActive}/285/175`, } } diff --git a/src/pages/Maps/Content/Controls/index.tsx b/src/pages/Maps/Content/Controls/index.tsx index c7be7a82a1..ff3a3c45b8 100644 --- a/src/pages/Maps/Content/Controls/index.tsx +++ b/src/pages/Maps/Content/Controls/index.tsx @@ -12,6 +12,8 @@ import { HashLink } from 'react-router-hash-link' import { AuthWrapper } from 'src/components/Auth/AuthWrapper' import { Map } from 'react-leaflet' import { ILocation } from 'src/models/common.models' +import { inject } from 'mobx-react' +import { MapsStore } from 'src/stores/Maps/maps.store' interface IProps { mapRef: React.RefObject @@ -19,6 +21,9 @@ interface IProps { onFilterChange: (grouping: IPinGrouping, filters: Array) => void onLocationChange: (selectedLocation: ILocation) => void } +interface IInjectedProps extends IProps { + mapsStore: MapsStore +} const SearchWrapper = styled.div` width: 300px; @@ -30,7 +35,7 @@ const MapFlexBar = styled(Flex)` position: absolute; top: 25px; width: 100%; - z-index: 99999; + z-index: 3; left: 50%; transform: translateX(-50%); ` @@ -38,11 +43,14 @@ const MapFlexBar = styled(Flex)` const FlexSpacer = styled.div` flex: 1; ` - +@inject('mapsStore') class Controls extends React.Component { constructor(props) { super(props) } + get injected() { + return this.props as IInjectedProps + } public render() { const { availableFilters } = this.props @@ -60,10 +68,12 @@ class Controls extends React.Component { return ( { - // this.props.map.current.leafletElement.closePopup() + // close any active popup on click + this.injected.mapsStore.setActivePin(undefined) }} > @@ -80,7 +90,6 @@ class Controls extends React.Component { items={groupedFilters[grouping]} onChange={options => { this.props.onFilterChange(grouping as IPinGrouping, options) - this.props.mapRef.current!.leafletElement.closePopup() }} /> ))} diff --git a/src/pages/Maps/Content/View/index.tsx b/src/pages/Maps/Content/View/index.tsx index fe51d200cc..bcb0c135dc 100644 --- a/src/pages/Maps/Content/View/index.tsx +++ b/src/pages/Maps/Content/View/index.tsx @@ -72,9 +72,8 @@ class MapView extends React.Component { center={[center.lat, center.lng]} zoom={zoom} maxZoom={18} - style={{ height: '100%' }} + style={{ height: '100%', zIndex: 0 }} onmove={this.handleMove} - onresize={() => console.log('resize called')} > ({ @@ -66,7 +70,6 @@ export class MapsStore extends ModuleStore { workspaceType, }), ) - this.filteredPins = this.mapPins } @@ -127,7 +130,9 @@ export class MapsStore extends ModuleStore { public async setActivePin(pin?: IMapPin) { this.activePin = pin if (pin) { - const pinDetail = await this.getUserProfilePin(pin._id) + const pinDetail = IS_MOCK + ? generatePinDetails(pin) + : await this.getUserProfilePin(pin._id) this.activePin = { ...pin, ...pinDetail } } } @@ -144,7 +149,6 @@ export class MapsStore extends ModuleStore { // add new pin or update existing public async setPin(pin: IMapPin) { // generate standard doc meta - console.debug('setting pin', pin) return this.db .collection('v2_mappins') .doc(pin._id)