copy base dmenu to dkala
This commit is contained in:
@@ -0,0 +1,303 @@
|
||||
.map-google-style {
|
||||
background-color: var(--background);
|
||||
font-family: "irancell", system-ui, -apple-system, sans-serif;
|
||||
}
|
||||
|
||||
/* Map tiles styling */
|
||||
.map-google-style .leaflet-tile-pane {
|
||||
filter: saturate(0.95) contrast(0.95) brightness(1.02);
|
||||
}
|
||||
|
||||
/* Base font for all map elements */
|
||||
.map-google-style,
|
||||
.map-google-style .leaflet-container {
|
||||
font-family: "irancell", system-ui, -apple-system, sans-serif !important;
|
||||
}
|
||||
|
||||
/* Improve tile loading appearance */
|
||||
.map-google-style .leaflet-tile-loading {
|
||||
opacity: 0;
|
||||
transition: opacity 0.2s ease-in-out;
|
||||
}
|
||||
|
||||
/* Custom popup style */
|
||||
.map-google-style .leaflet-popup-content-wrapper {
|
||||
border-radius: 16px;
|
||||
padding: 0;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||
backdrop-filter: blur(8px);
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
}
|
||||
|
||||
.map-google-style .leaflet-popup-content {
|
||||
margin: 16px 20px;
|
||||
line-height: 1.6;
|
||||
font-size: 14px;
|
||||
color: #1f2937;
|
||||
font-weight: 500;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.map-google-style .leaflet-popup-tip {
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
backdrop-filter: blur(8px);
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
|
||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.map-google-style .leaflet-popup-close-button {
|
||||
padding: 12px !important;
|
||||
color: #6b7280 !important;
|
||||
opacity: 0.7;
|
||||
transition: opacity 0.2s ease;
|
||||
}
|
||||
|
||||
.map-google-style .leaflet-popup-close-button:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
/* Marker styles */
|
||||
.map-google-style .leaflet-marker-icon,
|
||||
.map-google-style .leaflet-marker-shadow {
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
transform-origin: bottom center;
|
||||
}
|
||||
|
||||
.map-google-style .leaflet-marker-icon {
|
||||
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
|
||||
}
|
||||
|
||||
.map-google-style .leaflet-marker-icon:hover {
|
||||
transform: scale(1.1) translateY(-4px);
|
||||
filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.15));
|
||||
}
|
||||
|
||||
.map-google-style .leaflet-marker-icon:hover + .leaflet-marker-shadow {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
/* Custom restaurant marker styles */
|
||||
.map-google-style .custom-restaurant-marker {
|
||||
background: transparent !important;
|
||||
border: none !important;
|
||||
}
|
||||
|
||||
.map-google-style .custom-restaurant-marker img {
|
||||
filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
|
||||
}
|
||||
|
||||
/* Restaurant popup smaller size */
|
||||
.map-google-style .restaurant-popup .leaflet-popup-content-wrapper {
|
||||
padding: 8px 25px 8px 12px;
|
||||
position: relative;
|
||||
min-height: 32px;
|
||||
}
|
||||
|
||||
.map-google-style .restaurant-popup .leaflet-popup-content {
|
||||
margin: 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.4;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.map-google-style .restaurant-popup .leaflet-popup-close-button {
|
||||
position: absolute !important;
|
||||
top: 4px !important;
|
||||
right: 4px !important;
|
||||
padding: 4px 6px !important;
|
||||
font-size: 16px !important;
|
||||
line-height: 1 !important;
|
||||
width: 20px !important;
|
||||
height: 20px !important;
|
||||
text-align: center !important;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
/* Attribution styling */
|
||||
.map-google-style .leaflet-control-attribution {
|
||||
display: none;
|
||||
/* background: rgba(255,255,255,0.9) !important;
|
||||
backdrop-filter: blur(8px);
|
||||
padding: 6px 12px !important;
|
||||
border-radius: 12px;
|
||||
margin: 8px !important;
|
||||
font-size: 11px !important;
|
||||
color: #4b5563 !important;
|
||||
box-shadow: 0 2px 8px rgba(0,0,0,0.05);
|
||||
border: 1px solid rgba(0,0,0,0.08); */
|
||||
}
|
||||
|
||||
/* Zoom controls */
|
||||
.map-zoom-controls {
|
||||
position: absolute;
|
||||
right: 20px;
|
||||
bottom: 40px;
|
||||
background: var(--background);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||
overflow: hidden;
|
||||
backdrop-filter: blur(8px);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.zoom-button {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: transparent;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
color: #4b5563;
|
||||
font-size: 22px;
|
||||
font-weight: 500;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
|
||||
.zoom-button:first-child {
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.zoom-button:hover {
|
||||
background-color: rgba(59, 130, 246, 0.05);
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
.zoom-button:active {
|
||||
background-color: rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
|
||||
/* Selected location indicator */
|
||||
.selected-location-indicator {
|
||||
position: fixed;
|
||||
bottom: 24px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
backdrop-filter: blur(8px);
|
||||
padding: 14px 24px;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||
color: #1f2937;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 1.6;
|
||||
max-width: 90%;
|
||||
width: auto;
|
||||
text-align: center;
|
||||
z-index: 1000;
|
||||
animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
transform: translate(-50%, 100%);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translate(-50%, 0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loading state */
|
||||
.map-loading {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: rgba(255, 255, 255, 0.9);
|
||||
backdrop-filter: blur(4px);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Container styling */
|
||||
.map-container {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: linear-gradient(to bottom, #e5e7eb 0%, #f3f4f6 100%);
|
||||
}
|
||||
|
||||
/* Search box styling */
|
||||
.map-search-container {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
width: 90%;
|
||||
max-width: 480px;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.map-search-input {
|
||||
width: 100%;
|
||||
padding: 14px 20px;
|
||||
background: rgba(255, 255, 255, 0.95);
|
||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.05);
|
||||
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
font-size: 15px;
|
||||
font-weight: 500;
|
||||
text-align: right;
|
||||
backdrop-filter: blur(8px);
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.map-search-input:focus {
|
||||
box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.08);
|
||||
border-color: rgba(59, 130, 246, 0.5);
|
||||
background: rgba(255, 255, 255, 0.98);
|
||||
}
|
||||
|
||||
.map-search-input::placeholder {
|
||||
color: #6b7280;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.map-search-results {
|
||||
margin-top: 12px;
|
||||
background: var(--container);
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.05);
|
||||
overflow: hidden;
|
||||
border: 1px solid rgba(0, 0, 0, 0.08);
|
||||
backdrop-filter: blur(8px);
|
||||
}
|
||||
|
||||
.map-search-result-item {
|
||||
padding: 14px 20px;
|
||||
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.05);
|
||||
font-size: 13px;
|
||||
font-weight: 400;
|
||||
color: var(--foreground);
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.map-search-result-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.map-search-result-item:hover {
|
||||
background-color: rgba(59, 130, 246, 0.05);
|
||||
color: #2563eb;
|
||||
}
|
||||
|
||||
[data-theme="dark"] .map-search-result-item:hover {
|
||||
color: var(--disabled-text);
|
||||
}
|
||||
|
||||
.map-search-result-item:active {
|
||||
background-color: rgba(59, 130, 246, 0.1);
|
||||
}
|
||||
@@ -0,0 +1,359 @@
|
||||
'use client';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { MapContainer, TileLayer, Marker, Popup, useMap, useMapEvents, Polygon } from 'react-leaflet';
|
||||
import L from 'leaflet';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import './CustomMap.css';
|
||||
import { ActiveSearchbox } from '../input/ActiveSearchbox';
|
||||
|
||||
// Define types for our props
|
||||
interface ServiceArea {
|
||||
type: "Polygon";
|
||||
coordinates: number[][][];
|
||||
}
|
||||
|
||||
interface CustomMapProps {
|
||||
initialPosition: [number, number];
|
||||
zoom?: number;
|
||||
markers?: Array<{
|
||||
position: [number, number];
|
||||
title: string;
|
||||
icon?: L.Icon | L.DivIcon;
|
||||
}>;
|
||||
serviceArea?: ServiceArea | null;
|
||||
onPositionSelect?: (position: [number, number]) => void;
|
||||
onZoomChange?: (zoom: number) => void;
|
||||
onClick?: (event: L.LeafletMouseEvent) => void;
|
||||
searchEnabled?: boolean
|
||||
markerActive?: boolean
|
||||
onMapReady?: (map: L.Map) => void;
|
||||
}
|
||||
|
||||
// Component to handle map events and position updates
|
||||
function MapEvents({
|
||||
onZoomChange,
|
||||
onClick,
|
||||
center,
|
||||
setMapRef,
|
||||
}: Pick<CustomMapProps, 'onZoomChange' | 'onClick'> & {
|
||||
center: [number, number];
|
||||
setMapRef: (map: L.Map) => void;
|
||||
}) {
|
||||
const map = useMapEvents({
|
||||
zoom: () => {
|
||||
onZoomChange?.(map.getZoom());
|
||||
},
|
||||
click: (e) => {
|
||||
onClick?.(e);
|
||||
},
|
||||
});
|
||||
|
||||
// Update map center when center prop changes
|
||||
React.useEffect(() => {
|
||||
map.setView(center, map.getZoom(), {
|
||||
animate: true,
|
||||
duration: 1
|
||||
});
|
||||
}, [map, center]);
|
||||
|
||||
// Set map reference
|
||||
React.useEffect(() => {
|
||||
setMapRef(map);
|
||||
}, [map, setMapRef]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Component to handle marker updates on zoom
|
||||
function MarkerUpdater({ markers }: { markers?: CustomMapProps['markers'] }) {
|
||||
const map = useMap();
|
||||
|
||||
useEffect(() => {
|
||||
// You can implement custom marker scaling or clustering logic here
|
||||
const zoom = map.getZoom();
|
||||
// Example: Scale markers based on zoom level
|
||||
markers?.forEach(marker => {
|
||||
const element = document.querySelector(`[title="${marker.title}"]`);
|
||||
if (element) {
|
||||
const scale = Math.min(1 + (zoom / 20), 1.5);
|
||||
(element as HTMLElement).style.transform = `scale(${scale})`;
|
||||
}
|
||||
});
|
||||
}, [map, markers]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Component to auto-open popup for restaurant marker
|
||||
function MarkerWithAutoOpen({ position, icon, title }: { position: [number, number]; icon?: L.Icon | L.DivIcon; title: string }) {
|
||||
const markerRef = React.useRef<L.Marker>(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (markerRef.current && title === 'موقعیت رستوران') {
|
||||
markerRef.current.openPopup();
|
||||
}
|
||||
}, [title]);
|
||||
|
||||
return (
|
||||
<Marker ref={markerRef} position={position} icon={icon}>
|
||||
<Popup className="restaurant-popup">
|
||||
<div className="text-xs font-medium">{title}</div>
|
||||
</Popup>
|
||||
</Marker>
|
||||
);
|
||||
}
|
||||
|
||||
const CustomMap: React.FC<CustomMapProps> = ({
|
||||
initialPosition,
|
||||
zoom = 13,
|
||||
markers = [],
|
||||
serviceArea,
|
||||
onPositionSelect,
|
||||
onZoomChange,
|
||||
onClick,
|
||||
markerActive = true,
|
||||
searchEnabled = true,
|
||||
onMapReady,
|
||||
}) => {
|
||||
const [selectedPosition, setSelectedPosition] = useState<[number, number] | null>(null);
|
||||
const [mapInstance, setMapInstance] = useState<L.Map | null>(null);
|
||||
const [isSearching, setIsSearching] = useState(false);
|
||||
const [searchResults, setSearchResults] = useState<Array<{ id: string; title: string; position: [number, number] }>>([]);
|
||||
const [isMapLoading, setIsMapLoading] = useState(true);
|
||||
|
||||
// Handle map load complete
|
||||
useEffect(() => {
|
||||
const checkTiles = () => {
|
||||
if (mapInstance) {
|
||||
const container = document.querySelector('.leaflet-tile-container');
|
||||
if (container && container.children.length > 0) {
|
||||
setIsMapLoading(false);
|
||||
} else {
|
||||
setTimeout(checkTiles, 100);
|
||||
}
|
||||
}
|
||||
};
|
||||
checkTiles();
|
||||
}, [mapInstance]);
|
||||
|
||||
// Notify parent when map is ready
|
||||
useEffect(() => {
|
||||
if (mapInstance && onMapReady) {
|
||||
onMapReady(mapInstance);
|
||||
}
|
||||
}, [mapInstance, onMapReady]);
|
||||
|
||||
// Initialize default icon on client side only
|
||||
useEffect(() => {
|
||||
// Dynamic import of Leaflet on the client side
|
||||
// Fix for default marker icon in Next.js
|
||||
delete ((L.Icon.Default.prototype) as { _getIconUrl?: unknown })._getIconUrl;
|
||||
L.Icon.Default.mergeOptions({
|
||||
iconRetinaUrl: '/marker-icon-2x.png',
|
||||
iconUrl: '/marker-icon.png',
|
||||
shadowUrl: '/marker-shadow.png',
|
||||
});
|
||||
}, []);
|
||||
|
||||
const handleMapClick = (e: L.LeafletMouseEvent) => {
|
||||
const newPosition: [number, number] = [e.latlng.lat, e.latlng.lng];
|
||||
if (markerActive) {
|
||||
setSelectedPosition(newPosition);
|
||||
}
|
||||
onPositionSelect?.(newPosition);
|
||||
onClick?.(e);
|
||||
};
|
||||
|
||||
const [searchTimeout, setSearchTimeout] = useState<NodeJS.Timeout>();
|
||||
|
||||
const handleSearch = async (value: string) => {
|
||||
if (!value || value.trim().length === 0) {
|
||||
setSearchResults([]);
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear previous timeout
|
||||
if (searchTimeout) {
|
||||
clearTimeout(searchTimeout);
|
||||
}
|
||||
|
||||
setIsSearching(true);
|
||||
|
||||
// Set new timeout
|
||||
const timeout = setTimeout(async () => {
|
||||
try {
|
||||
// Iran's bounding box coordinates (roughly)
|
||||
const viewbox = '44.0,25.0,63.0,40.0'; // [min lon, min lat, max lon, max lat]
|
||||
const response = await fetch(
|
||||
`https://nominatim.openstreetmap.org/search?` +
|
||||
`format=json&` +
|
||||
`q=${encodeURIComponent(value)}&` +
|
||||
`countrycodes=ir&` + // Prioritize Iran
|
||||
`viewbox=${viewbox}&` +
|
||||
`bounded=0&` + // Allow results outside viewbox but prioritize inside
|
||||
`limit=10&` + // Limit results to 10
|
||||
`namedetails=1&` + // Get native names
|
||||
`accept-language=fa` // Request Persian results
|
||||
, {
|
||||
headers: {
|
||||
'Accept-Language': 'fa,en;q=0.9' // Prefer Persian, fallback to English
|
||||
}
|
||||
});
|
||||
interface SearchResult {
|
||||
place_id: string;
|
||||
display_name: string;
|
||||
lat: string;
|
||||
lon: string;
|
||||
namedetails?: {
|
||||
name?: string;
|
||||
'name:fa'?: string;
|
||||
alt_name?: string;
|
||||
'alt_name:fa'?: string;
|
||||
};
|
||||
}
|
||||
const data: SearchResult[] = await response.json();
|
||||
setSearchResults(data.map((item) => ({
|
||||
id: item.place_id,
|
||||
// Use Persian name if available, fallback to display_name
|
||||
title: /* item.namedetails?.['name:fa'] ||
|
||||
item.namedetails?.name ||
|
||||
item.namedetails?.['alt_name:fa'] ||
|
||||
item.namedetails?.alt_name || */
|
||||
item.display_name,
|
||||
position: [parseFloat(item.lat), parseFloat(item.lon)] as [number, number]
|
||||
})));
|
||||
} catch (error) {
|
||||
console.error('Search error:', error);
|
||||
setSearchResults([]);
|
||||
} finally {
|
||||
setIsSearching(false);
|
||||
}
|
||||
}, 500); // Wait 500ms after last keystroke
|
||||
|
||||
setSearchTimeout(timeout);
|
||||
};
|
||||
|
||||
const handleSearchResultSelect = (result: { id: string; title: string; position: [number, number] }) => {
|
||||
console.log(result);
|
||||
setSelectedPosition(result.position);
|
||||
if (mapInstance) {
|
||||
mapInstance.setView(result.position, mapInstance.getZoom());
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="w-full h-full relative">
|
||||
{searchEnabled &&
|
||||
<ActiveSearchbox
|
||||
placeholder="جستجو"
|
||||
onSearch={handleSearch}
|
||||
isLoading={isSearching}
|
||||
results={searchResults}
|
||||
onResultSelect={(v) => {
|
||||
// Find the full result object with position
|
||||
const result = searchResults.find(r => r.id === v.id && r.title === v.title);
|
||||
if (result) {
|
||||
handleSearchResultSelect(result);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
}
|
||||
<div className="map-zoom-controls">
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (mapInstance) {
|
||||
const center = selectedPosition || mapInstance.getCenter();
|
||||
mapInstance.setZoomAround(center, mapInstance.getZoom() + 1);
|
||||
}
|
||||
}}
|
||||
className="zoom-button"
|
||||
aria-label="بزرگنمایی"
|
||||
>
|
||||
+
|
||||
</button>
|
||||
<button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
if (mapInstance) {
|
||||
const center = selectedPosition || mapInstance.getCenter();
|
||||
mapInstance.setZoomAround(center, mapInstance.getZoom() - 1);
|
||||
}
|
||||
}}
|
||||
className="zoom-button"
|
||||
aria-label="کوچک نمایی"
|
||||
>
|
||||
−
|
||||
</button>
|
||||
</div>
|
||||
{isMapLoading && (
|
||||
<div className="absolute inset-0 bg-zinc-50/80 backdrop-blur-sm z-[400]">
|
||||
<div className="grid grid-cols-3 gap-4 p-8 h-full">
|
||||
<Skeleton className="h-full" />
|
||||
<Skeleton className="h-full" />
|
||||
<Skeleton className="h-full" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<MapContainer
|
||||
center={initialPosition}
|
||||
zoom={zoom}
|
||||
className="map-google-style"
|
||||
style={{ height: '100%', width: '100%' }}
|
||||
zoomControl={false} // Disable default zoom control
|
||||
>
|
||||
<TileLayer
|
||||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
||||
/>
|
||||
|
||||
{/* Service Area Polygon */}
|
||||
{serviceArea && serviceArea.coordinates && serviceArea.coordinates.length > 0 && (
|
||||
<Polygon
|
||||
positions={serviceArea.coordinates[0].map(coord => [coord[1], coord[0]] as [number, number])}
|
||||
pathOptions={{
|
||||
color: '#3b82f6',
|
||||
fillColor: '#3b82f6',
|
||||
fillOpacity: 0.2,
|
||||
weight: 2,
|
||||
interactive: false,
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Custom markers */}
|
||||
{markers.map((marker, index) => (
|
||||
<MarkerWithAutoOpen
|
||||
key={`${marker.position}-${index}`}
|
||||
position={marker.position}
|
||||
icon={marker.icon}
|
||||
title={marker.title}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* Selected position marker */}
|
||||
{selectedPosition && (
|
||||
<Marker position={selectedPosition}>
|
||||
<Popup>
|
||||
<div className="text-sm px-2">موقعیت انتخاب شده</div>
|
||||
</Popup>
|
||||
</Marker>
|
||||
)}
|
||||
|
||||
{/* Event handlers */}
|
||||
<MapEvents
|
||||
onZoomChange={onZoomChange}
|
||||
onClick={handleMapClick}
|
||||
center={initialPosition}
|
||||
setMapRef={setMapInstance}
|
||||
/>
|
||||
{/* Marker updater for zoom effects */}
|
||||
<MarkerUpdater markers={markers} />
|
||||
</MapContainer>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomMap;
|
||||
Reference in New Issue
Block a user