Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 4x 4x | import React, { FC, useMemo, useState } from 'react';
import { Map } from '../Map';
import { Loading } from 'ag-ems-ui-library';
const styles = require('./ProductMap.module.css')
export const ProductMap: FC<{
product: any;
onClick?: () => void;
}> = ({
product,
onClick
}) => {
const [preloader, setPreloader] = useState(true);
const onInit = () => setPreloader(false);
const map = useMemo(() => {
return <Map
products={[product]}
onInit={onInit}
attributionControl={false}
zoomControl={false}
center={product.coordinates
? [product.coordinates.lat, product.coordinates.lon]
: [product.location.coordinates.lat, product.location.coordinates.lon]
}
zoom={15}
/>
}, [product]);
return <>
{preloader && <Loading color="#007c00" />}
<div className={styles.ProductMap} role="button" onClick={onClick}>
<div className={styles.ProductMapContainer}>{map}</div>
</div>
</>;
} |