-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from moinulhossainmahim/SR-9
SR-9
- Loading branch information
Showing
9 changed files
with
201 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { MapContainer, TileLayer, MapContainerProps } from 'react-leaflet'; | ||
|
||
import "leaflet/dist/leaflet.css"; | ||
import "leaflet-defaulticon-compatibility/dist/leaflet-defaulticon-compatibility.css"; | ||
import "leaflet-defaulticon-compatibility"; | ||
|
||
import Pin from './Pin'; | ||
import { IListing } from '@/types'; | ||
|
||
interface MapsProps { | ||
items: IListing[]; | ||
} | ||
|
||
const Map: React.FC<MapsProps> = ({ items }) => { | ||
const mapProps: MapContainerProps = { | ||
center: [23.8041, 90.4152], | ||
zoom: 7, | ||
scrollWheelZoom: false, | ||
className: "w-full h-full rounded-lg z-10" | ||
}; | ||
|
||
return ( | ||
<MapContainer {...mapProps}> | ||
<TileLayer | ||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' | ||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" | ||
/> | ||
{items.map(item => ( | ||
<Pin item={item} key={item.id} /> | ||
))} | ||
</MapContainer> | ||
); | ||
} | ||
|
||
export default Map; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { IListing } from "@/types"; | ||
import Link from "next/link"; | ||
import { Marker, Popup } from "react-leaflet"; | ||
|
||
interface PinProps { | ||
item: IListing; | ||
} | ||
|
||
function Pin({ item } : PinProps) { | ||
return ( | ||
<Marker position={[item.latitude, item.longitude]}> | ||
<Popup> | ||
<div className="flex gap-5"> | ||
<img src={item.featuredImg} alt="" className="w-16 h-12 object-cover rounded" /> | ||
<div className="flex flex-col justify-between"> | ||
<Link href={`/listings/${item.id}`} className="text-blue-500 hover:underline">{item.title}</Link> | ||
<span>{item.roomCount} bedroom</span> | ||
<b>৳ {item.price}k</b> | ||
</div> | ||
</div> | ||
</Popup> | ||
</Marker> | ||
); | ||
} | ||
|
||
export default Pin; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.