import React, { useRef, useMemo } from 'react'; import { Polygon, Tooltip, PolygonProps } from 'react-leaflet'; import { coordsToLatLngs, circleToPolygon } from 'utils/geo'; import { AnnotationShapes, AddedProperties } from './types'; import { useEdit } from 'utils/hooks'; const AnnotationHighlight: React.SFC = (props) => { const {annotation, selected} = props; const ref = useRef>(null); const position = useMemo(() => annotation.geometry.type === 'Point' ? circleToPolygon( annotation.geometry.coordinates, annotation.properties.radius, 50, ) : coordsToLatLngs( annotation.geometry.coordinates, annotation.geometry.type === 'Polygon' ? 1 : 2, ).toJS() , [selected]); useEdit(ref, props.editable && selected); const outerShape = [ { lat: -500, lng: 500, }, { lat: 500, lng: 500, }, { lat: 500, lng: -500, }, { lat: -500, lng: -500, }, ]; return ( {(!selected || !props.editable) && ( {annotation.properties.content} )} ); }; export default AnnotationHighlight;