File size: 26,590 Bytes
5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 73d1a9b 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 73d1a9b 075f1a3 73d1a9b 075f1a3 73d1a9b 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 5879217 075f1a3 986a743 075f1a3 5879217 986a743 5879217 986a743 5879217 986a743 5879217 986a743 5879217 986a743 075f1a3 5879217 075f1a3 5879217 986a743 5879217 986a743 5879217 986a743 5879217 986a743 5879217 986a743 075f1a3 5879217 | 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 | import React, { useEffect, useRef, useState } from 'react'
interface MapModalProps {
isOpen: boolean
onClose: () => void
address: string
restaurantName: string
coordinates?: {
latitude: number
longitude: number
}
}
// Google Maps types
declare global {
interface Window {
google: any
initGoogleMaps: () => void
}
}
export function MapModal({ isOpen, onClose, address, restaurantName, coordinates }: MapModalProps) {
const mapRef = useRef<HTMLDivElement>(null)
const mapInstanceRef = useRef<any>(null)
const markersRef = useRef<any[]>([])
const infoWindowRef = useRef<any>(null)
const directionsRendererRef = useRef<any>(null)
const [error, setError] = useState<string | null>(null)
const [geocodedLocation, setGeocodedLocation] = useState<{ lat: number; lng: number } | null>(null)
const [isGeocoding, setIsGeocoding] = useState(false)
const [userLocation, setUserLocation] = useState<{ lat: number; lng: number } | null>(null)
const [isGoogleMapsLoaded, setIsGoogleMapsLoaded] = useState(false)
const [placeDetails, setPlaceDetails] = useState<any>(null)
const [apiKey, setApiKey] = useState<string | null>(null)
// Geocode address to get coordinates using Google Maps Geocoding API
useEffect(() => {
if (!isOpen || !address) return
// If coordinates are provided, use them directly
if (coordinates) {
setGeocodedLocation({ lat: coordinates.latitude, lng: coordinates.longitude })
setIsGeocoding(false)
return
}
// Wait for Google Maps to be loaded
if (!isGoogleMapsLoaded) return
// Otherwise, geocode the address using Google Maps Geocoding API
const geocodeAddress = async () => {
setIsGeocoding(true)
setError(null)
try {
const google = window.google
if (!google || !google.maps || !google.maps.Geocoder) {
throw new Error('Google Maps not loaded')
}
const geocoder = new google.maps.Geocoder()
geocoder.geocode({ address: address }, (results: any[], status: string) => {
if (status === 'OK' && results && results.length > 0) {
const location = results[0].geometry.location
setGeocodedLocation({
lat: location.lat(),
lng: location.lng()
})
setError(null)
} else {
throw new Error('Address not found')
}
setIsGeocoding(false)
})
} catch (err) {
console.error('Geocoding error:', err)
setError('Unable to locate address on map')
setGeocodedLocation(null)
setIsGeocoding(false)
}
}
geocodeAddress()
}, [isOpen, address, coordinates, isGoogleMapsLoaded])
// Get user's current location
useEffect(() => {
if (!isOpen) return
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(
(position) => {
setUserLocation({
lat: position.coords.latitude,
lng: position.coords.longitude
})
},
(err) => {
console.warn('Geolocation error:', err)
// Don't set error state, just silently fail - user location is optional
}
)
}
}, [isOpen])
// Load API key from backend or environment
useEffect(() => {
if (!isOpen) return
const loadApiKey = async () => {
// First try to get from build-time environment variable
let key = import.meta.env.VITE_GOOGLE_MAPS_API_KEY || ''
// If not available, try to get from backend API
if (!key) {
try {
const BASE_URL = import.meta.env.VITE_API_BASE_URL ||
(import.meta.env.PROD ? '' : 'http://localhost:8000')
const response = await fetch(`${BASE_URL}/api/config`)
if (response.ok) {
const config = await response.json()
key = config.googleMapsApiKey || ''
}
} catch (err) {
console.warn('Failed to load config from backend:', err)
}
}
if (!key) {
setError('Google Maps API key is not configured. Please set VITE_GOOGLE_MAPS_API_KEY environment variable.')
return
}
setApiKey(key)
}
loadApiKey()
}, [isOpen])
// Load Google Maps API
useEffect(() => {
if (!isOpen || !apiKey) return
// Check if Google Maps is already loaded
if (window.google && window.google.maps) {
setIsGoogleMapsLoaded(true)
return
}
// Check if script is already being loaded
if (document.querySelector('script[src*="maps.googleapis.com"]')) {
// Wait for it to load
const checkLoaded = setInterval(() => {
if (window.google && window.google.maps) {
setIsGoogleMapsLoaded(true)
clearInterval(checkLoaded)
}
}, 100)
return () => clearInterval(checkLoaded)
}
// Load Google Maps JavaScript API with Places library
const script = document.createElement('script')
script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=geometry,places`
script.async = true
script.defer = true
script.onload = () => {
setIsGoogleMapsLoaded(true)
}
script.onerror = () => {
setError('Failed to load Google Maps')
}
document.head.appendChild(script)
// Cleanup function
return () => {
// Don't remove the script, it might be used elsewhere
}
}, [isOpen, apiKey])
// Initialize Google Maps
useEffect(() => {
if (!isOpen || !mapRef.current || !isGoogleMapsLoaded) return
// Wait for geocoding to complete if needed
if (!coordinates && !geocodedLocation && isGeocoding) return
// Get the final restaurant location
const finalLocation = coordinates
? { lat: coordinates.latitude, lng: coordinates.longitude }
: geocodedLocation
// Don't initialize map if we don't have restaurant location
if (!finalLocation) return
const google = window.google
if (!google || !google.maps) return
// Clear existing markers if map instance exists
if (mapInstanceRef.current) {
markersRef.current.forEach(marker => marker.setMap(null))
markersRef.current = []
}
// Determine center point and zoom
let centerLat = finalLocation.lat
let centerLng = finalLocation.lng
let zoom = 15
// If we have both locations, center between them
if (userLocation) {
centerLat = (finalLocation.lat + userLocation.lat) / 2
centerLng = (finalLocation.lng + userLocation.lng) / 2
zoom = 13
}
// Create map
const map = new google.maps.Map(mapRef.current, {
center: { lat: centerLat, lng: centerLng },
zoom: zoom,
mapTypeControl: true,
streetViewControl: true,
fullscreenControl: true
})
// Create restaurant marker using Google Maps default marker
const restaurantMarker = new google.maps.Marker({
position: { lat: finalLocation.lat, lng: finalLocation.lng },
map: map,
title: restaurantName
})
// Create InfoWindow with loading content
const restaurantInfoWindow = new google.maps.InfoWindow({
content: `<div style="padding: 12px; min-width: 250px;">
<div style="font-weight: 600; font-size: 16px; margin-bottom: 4px;">${restaurantName}</div>
<div style="color: #666; font-size: 14px;">${address}</div>
<div style="margin-top: 8px; color: #666; font-size: 12px;">Loading details...</div>
</div>`
})
// Open InfoWindow initially
restaurantInfoWindow.open(map, restaurantMarker)
infoWindowRef.current = restaurantInfoWindow
// Function to search for place details using Google Places API
const searchPlaceDetails = () => {
if (!google.maps.places) {
// Fallback if Places API is not available - show basic info
updateInfoWindow(null)
return
}
const service = new google.maps.places.PlacesService(map)
const request = {
query: `${restaurantName}, ${address}`,
fields: ['name', 'formatted_address', 'rating', 'user_ratings_total', 'price_level',
'opening_hours', 'photos', 'place_id', 'website', 'formatted_phone_number', 'reviews']
}
service.textSearch(request, (results: any[], status: string) => {
if (status === google.maps.places.PlacesServiceStatus.OK && results && results.length > 0) {
const place = results[0]
// Get detailed place information
const placeId = place.place_id
const detailsRequest = {
placeId: placeId,
fields: ['name', 'formatted_address', 'rating', 'user_ratings_total', 'price_level',
'opening_hours', 'photos', 'website', 'formatted_phone_number', 'reviews',
'geometry', 'url']
}
service.getDetails(detailsRequest, (placeDetailsResult: any, detailsStatus: string) => {
if (detailsStatus === google.maps.places.PlacesServiceStatus.OK && placeDetailsResult) {
setPlaceDetails(placeDetailsResult)
updateInfoWindow(placeDetailsResult)
} else {
// If detailed search fails, use basic place info
setPlaceDetails(place)
updateInfoWindow(place)
}
})
} else {
// If search fails, show basic info with link to Google Maps
console.log('Place search failed:', status)
updateInfoWindow(null)
}
})
}
// Function to create rich InfoWindow content
const updateInfoWindow = (place: any) => {
let content = `<div style="padding: 0; max-width: 300px;">`
// Header with name
content += `<div style="padding: 12px 16px; border-bottom: 1px solid #e0e0e0;">
<div style="font-weight: 600; font-size: 16px; margin-bottom: 4px; color: #1a1a1a;">${restaurantName}</div>
<div style="color: #666; font-size: 14px;">${address}</div>
</div>`
// Details section
if (place) {
content += `<div style="padding: 12px 16px;">`
// Rating
if (place.rating) {
const stars = '★'.repeat(Math.round(place.rating))
const ratingColor = place.rating >= 4.0 ? '#0f9d58' : place.rating >= 3.0 ? '#fbbc04' : '#ea4335'
content += `<div style="margin-bottom: 8px; display: flex; align-items: center; gap: 8px;">
<span style="color: ${ratingColor}; font-size: 18px;">${stars}</span>
<span style="font-weight: 600; font-size: 14px;">${place.rating.toFixed(1)}</span>
${place.user_ratings_total ? `<span style="color: #666; font-size: 12px;">(${place.user_ratings_total.toLocaleString()} reviews)</span>` : ''}
</div>`
}
// Price level
if (place.price_level !== undefined) {
const priceSymbols = '$'.repeat(place.price_level)
content += `<div style="margin-bottom: 8px; color: #666; font-size: 14px;">
Price: <span style="font-weight: 600;">${priceSymbols}</span>
</div>`
}
// Opening hours
if (place.opening_hours && place.opening_hours.weekday_text) {
const isOpen = place.opening_hours.isOpen()
content += `<div style="margin-bottom: 8px;">
<div style="font-weight: 600; font-size: 14px; color: ${isOpen ? '#0f9d58' : '#ea4335'};">
${isOpen ? '● Open now' : '● Closed'}
</div>
<div style="color: #666; font-size: 12px; margin-top: 2px;">
${place.opening_hours.weekday_text[new Date().getDay()] || ''}
</div>
</div>`
}
// Photo
if (place.photos && place.photos.length > 0) {
const photoUrl = place.photos[0].getUrl({ maxWidth: 300, maxHeight: 200 })
content += `<div style="margin-bottom: 8px;">
<img src="${photoUrl}" alt="${restaurantName}" style="width: 100%; border-radius: 4px; object-fit: cover; height: 120px;" />
</div>`
}
content += `</div>` // Close details section
// Actions section
content += `<div style="padding: 8px 16px; border-top: 1px solid #e0e0e0; display: flex; gap: 8px;">`
// Directions button
const directionsUrl = `https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(address)}`
content += `<a href="${directionsUrl}" target="_blank" style="flex: 1; padding: 8px; background: #4285f4; color: white; text-decoration: none; text-align: center; border-radius: 4px; font-size: 14px; font-weight: 500;">
Directions
</a>`
// View in Google Maps
if (place.url) {
content += `<a href="${place.url}" target="_blank" style="flex: 1; padding: 8px; background: #f1f3f4; color: #1a1a1a; text-decoration: none; text-align: center; border-radius: 4px; font-size: 14px; font-weight: 500;">
View
</a>`
}
content += `</div>` // Close actions section
} else {
// Basic info if place details not available
content += `<div style="padding: 12px 16px;">
<a href="https://www.google.com/maps/search/?api=1&query=${encodeURIComponent(`${restaurantName}, ${address}`)}" target="_blank" style="display: inline-block; padding: 8px 16px; background: #4285f4; color: white; text-decoration: none; border-radius: 4px; font-size: 14px; font-weight: 500;">
View in Google Maps
</a>
</div>`
}
content += `</div>` // Close main container
restaurantInfoWindow.setContent(content)
restaurantInfoWindow.open(map, restaurantMarker)
}
// Search for place details
searchPlaceDetails()
// Add click listener to marker - reopen InfoWindow when clicked
restaurantMarker.addListener('click', () => {
restaurantInfoWindow.open(map, restaurantMarker)
})
markersRef.current.push(restaurantMarker)
// Add user location marker if available using Google Maps default marker
if (userLocation) {
const userMarker = new google.maps.Marker({
position: { lat: userLocation.lat, lng: userLocation.lng },
map: map,
title: 'Your Location'
})
const userInfoWindow = new google.maps.InfoWindow({
content: '<div style="padding: 8px;"><strong>Your Location</strong></div>'
})
userMarker.addListener('click', () => {
userInfoWindow.open(map, userMarker)
})
markersRef.current.push(userMarker)
// Calculate and display driving route
const directionsService = new google.maps.DirectionsService()
const directionsRenderer = new google.maps.DirectionsRenderer({
map: map,
suppressMarkers: true, // Hide default markers since we already have custom markers
preserveViewport: false, // Allow map to adjust viewport to fit route
polylineOptions: {
strokeColor: '#4285f4',
strokeWeight: 5,
strokeOpacity: 0.8
}
})
directionsRendererRef.current = directionsRenderer
// Request driving directions
directionsService.route(
{
origin: { lat: userLocation.lat, lng: userLocation.lng },
destination: { lat: finalLocation.lat, lng: finalLocation.lng },
travelMode: google.maps.TravelMode.DRIVING
},
(result: any, status: string) => {
if (status === 'OK') {
directionsRenderer.setDirections(result)
// Adjust map bounds to fit the route
if (result.routes && result.routes[0] && result.routes[0].bounds) {
map.fitBounds(result.routes[0].bounds, { padding: 50 })
} else {
// Fallback: adjust bounds to fit both markers
const bounds = new google.maps.LatLngBounds()
bounds.extend({ lat: userLocation.lat, lng: userLocation.lng })
bounds.extend({ lat: finalLocation.lat, lng: finalLocation.lng })
map.fitBounds(bounds, { padding: 50 })
}
} else {
console.error('Directions request failed:', status)
// If route fails, just adjust bounds to fit both markers
const bounds = new google.maps.LatLngBounds()
bounds.extend({ lat: userLocation.lat, lng: userLocation.lng })
bounds.extend({ lat: finalLocation.lat, lng: finalLocation.lng })
map.fitBounds(bounds, { padding: 50 })
}
}
)
} else {
// If no user location, just center on restaurant
map.setCenter({ lat: finalLocation.lat, lng: finalLocation.lng })
map.setZoom(15)
}
mapInstanceRef.current = map
// Cleanup function
return () => {
// Clear markers
markersRef.current.forEach(marker => marker.setMap(null))
markersRef.current = []
// Clear directions renderer
if (directionsRendererRef.current) {
directionsRendererRef.current.setMap(null)
directionsRendererRef.current = null
}
}
}, [isOpen, coordinates, geocodedLocation, isGeocoding, userLocation, address, restaurantName, isGoogleMapsLoaded])
// Function to zoom to restaurant location
const zoomToRestaurant = () => {
if (!mapInstanceRef.current) return
const finalLocation = coordinates
? { lat: coordinates.latitude, lng: coordinates.longitude }
: geocodedLocation
if (finalLocation) {
mapInstanceRef.current.setCenter({ lat: finalLocation.lat, lng: finalLocation.lng })
mapInstanceRef.current.setZoom(15)
}
}
// Function to zoom to user location
const zoomToUser = () => {
if (!mapInstanceRef.current || !userLocation) return
mapInstanceRef.current.setCenter({ lat: userLocation.lat, lng: userLocation.lng })
mapInstanceRef.current.setZoom(15)
}
if (!isOpen) return null
return (
<>
{/* Backdrop */}
<div
onClick={onClose}
style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0, 0, 0, 0.5)',
zIndex: 9998,
backdropFilter: 'blur(2px)'
}}
/>
{/* Modal Container - Floating Window */}
<div
style={{
position: 'fixed',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
width: '90%',
maxWidth: '800px',
height: '70vh',
maxHeight: '600px',
backgroundColor: 'var(--card-bg)',
borderRadius: 'var(--radius-lg)',
boxShadow: '0 10px 40px rgba(0, 0, 0, 0.2)',
zIndex: 9999,
display: 'flex',
flexDirection: 'column',
overflow: 'hidden',
border: '1px solid var(--border)'
}}
>
{/* Header */}
<div
style={{
padding: '16px 20px',
borderBottom: '1px solid var(--border)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'var(--card-bg)',
flexShrink: 0
}}
>
<div style={{ flex: 1, minWidth: 0 }}>
<h3 style={{ margin: 0, color: 'var(--fg)', fontSize: '1.1em', fontWeight: 600, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{restaurantName}
</h3>
<p style={{ margin: '4px 0 0 0', color: 'var(--fg-secondary)', fontSize: '0.875em', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
{address}
</p>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: '12px', marginLeft: '16px' }}>
{/* Legend - Simplified for Google Maps default markers */}
<div style={{ display: 'flex', gap: '10px', alignItems: 'center' }}>
<button
onClick={zoomToRestaurant}
style={{
background: 'linear-gradient(135deg, rgba(179, 122, 76, 0.95) 0%, rgba(157, 107, 66, 0.95) 100%)',
backdropFilter: 'blur(10px)',
border: '1px solid rgba(179, 122, 76, 0.3)',
cursor: 'pointer',
padding: '10px 16px',
borderRadius: '12px',
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
color: 'white',
fontSize: '0.875em',
fontWeight: 600,
display: 'flex',
alignItems: 'center',
gap: '8px',
boxShadow: '0 4px 12px rgba(179, 122, 76, 0.25), 0 2px 4px rgba(0, 0, 0, 0.1)',
position: 'relative',
overflow: 'hidden'
}}
onMouseEnter={(e) => {
e.currentTarget.style.background = 'linear-gradient(135deg, rgba(179, 122, 76, 1) 0%, rgba(157, 107, 66, 1) 100%)'
e.currentTarget.style.transform = 'translateY(-2px) scale(1.02)'
e.currentTarget.style.boxShadow = '0 6px 20px rgba(179, 122, 76, 0.35), 0 4px 8px rgba(0, 0, 0, 0.15)'
}}
onMouseLeave={(e) => {
e.currentTarget.style.background = 'linear-gradient(135deg, rgba(179, 122, 76, 0.95) 0%, rgba(157, 107, 66, 0.95) 100%)'
e.currentTarget.style.transform = 'translateY(0) scale(1)'
e.currentTarget.style.boxShadow = '0 4px 12px rgba(179, 122, 76, 0.25), 0 2px 4px rgba(0, 0, 0, 0.1)'
}}
title="Click to zoom to restaurant"
>
<span style={{ fontSize: '1.2em', lineHeight: 1, filter: 'drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2))' }}>🍽️</span>
<span style={{ letterSpacing: '0.3px' }}>Restaurant</span>
</button>
{userLocation && (
<button
onClick={zoomToUser}
style={{
background: 'linear-gradient(135deg, rgba(66, 133, 244, 0.95) 0%, rgba(53, 122, 232, 0.95) 100%)',
backdropFilter: 'blur(10px)',
border: '1px solid rgba(66, 133, 244, 0.3)',
cursor: 'pointer',
padding: '10px 16px',
borderRadius: '12px',
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
color: 'white',
fontSize: '0.875em',
fontWeight: 600,
display: 'flex',
alignItems: 'center',
gap: '8px',
boxShadow: '0 4px 12px rgba(66, 133, 244, 0.25), 0 2px 4px rgba(0, 0, 0, 0.1)',
position: 'relative',
overflow: 'hidden'
}}
onMouseEnter={(e) => {
e.currentTarget.style.background = 'linear-gradient(135deg, rgba(66, 133, 244, 1) 0%, rgba(53, 122, 232, 1) 100%)'
e.currentTarget.style.transform = 'translateY(-2px) scale(1.02)'
e.currentTarget.style.boxShadow = '0 6px 20px rgba(66, 133, 244, 0.35), 0 4px 8px rgba(0, 0, 0, 0.15)'
}}
onMouseLeave={(e) => {
e.currentTarget.style.background = 'linear-gradient(135deg, rgba(66, 133, 244, 0.95) 0%, rgba(53, 122, 232, 0.95) 100%)'
e.currentTarget.style.transform = 'translateY(0) scale(1)'
e.currentTarget.style.boxShadow = '0 4px 12px rgba(66, 133, 244, 0.25), 0 2px 4px rgba(0, 0, 0, 0.1)'
}}
title="Click to zoom to your location"
>
<span style={{ fontSize: '1.2em', lineHeight: 1, filter: 'drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2))' }}>📍</span>
<span style={{ letterSpacing: '0.3px' }}>You</span>
</button>
)}
</div>
{/* Close Button */}
<button
onClick={onClose}
style={{
background: 'transparent',
border: 'none',
fontSize: '24px',
cursor: 'pointer',
color: 'var(--fg-secondary)',
padding: '4px 8px',
borderRadius: 'var(--radius-sm)',
transition: 'all 0.2s',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '32px',
height: '32px',
lineHeight: 1
}}
onMouseEnter={(e) => {
e.currentTarget.style.backgroundColor = 'var(--hover-bg)'
e.currentTarget.style.color = 'var(--fg)'
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = 'transparent'
e.currentTarget.style.color = 'var(--fg-secondary)'
}}
title="Close"
>
×
</button>
</div>
</div>
{/* Map Container */}
<div
ref={mapRef}
style={{
width: '100%',
flex: 1,
minHeight: 0,
position: 'relative'
}}
/>
{isGeocoding && (
<div style={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
padding: '12px 20px',
backgroundColor: 'var(--card-bg)',
borderRadius: 'var(--radius-md)',
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.15)',
color: 'var(--fg)',
fontSize: '0.9em',
zIndex: 1000,
display: 'flex',
alignItems: 'center',
gap: '8px'
}}>
<span>Loading location...</span>
</div>
)}
{error && (
<div style={{
padding: '8px 20px',
backgroundColor: 'var(--hover-bg)',
color: 'var(--muted)',
fontSize: '0.8em',
textAlign: 'center',
borderTop: '1px solid var(--border)'
}}>
{error}
</div>
)}
</div>
</>
)
}
|