import { useState } from 'react' import { Box, IconButton, Tooltip, Typography } from '@mui/material' import { MapPin, Map } from 'lucide-react' interface Props { imageUrl?: string lat?: number lng?: number address?: string cityLabel?: string height?: number } // TODO: replace placeholder with Google Maps Static API: // https://maps.googleapis.com/maps/api/staticmap?center={lat},{lng}&zoom=15&size=800x400&key=YOUR_KEY function buildMapsUrl(lat?: number, lng?: number, address?: string): string { if (lat != null && lng != null) { return `https://www.google.com/maps/search/?api=1&query=${lat},${lng}` } if (address) { return `https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(address)}` } return 'https://www.google.com/maps' } export function LocationPreview({ imageUrl, lat, lng, address, cityLabel, height = 180 }: Props) { const [imgError, setImgError] = useState(false) const mapsUrl = buildMapsUrl(lat, lng, address) const showImage = !!imageUrl && !imgError return ( {showImage ? ( {cityLabel setImgError(true)} style={{ width: '100%', height: '100%', objectFit: 'cover', display: 'block' }} /> ) : ( {cityLabel && ( {cityLabel} )} )} {/* Google Maps button */} ) }