Feature/show car details

This commit is contained in:
2024-11-23 10:58:27 +00:00
committed by AmirHossein Mahmoodi
parent 67212fe16e
commit 77edae4880
7 changed files with 331 additions and 1 deletions

View File

@@ -0,0 +1,21 @@
"use client";
import { Polyline, useMap } from "react-leaflet";
import { useEffect } from "react";
const purpleOptions = { color: "purple" };
const FlyToPolyline = ({ polyline }) => {
const map = useMap();
useEffect(() => {
if (map) {
const leafletPolyline = L.polyline(polyline); // Create a Leaflet polyline
const bounds = leafletPolyline.getBounds(); // Get bounds from the polyline
map.flyToBounds(bounds, { padding: [50, 50] }); // Fly to the polyline bounds
}
}, [map, polyline]);
return <Polyline pathOptions={purpleOptions} positions={polyline} />; // Render the polyline
};
export default FlyToPolyline;