generated from agiledev-students-fall2023/generic-project-repository
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'user-story/18/task/57/map-api'
- Loading branch information
Showing
5 changed files
with
59 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Outlet } from "react-router-dom" | ||
|
||
const InfoLayout = () => { | ||
return ( | ||
<> | ||
<div className="min-h-screen flex flex-col"> | ||
<NavBar> | ||
<LeftBtn /> | ||
<RightBtn handleRightClick={handleRightClick}/> | ||
</NavBar> | ||
<Outlet /> | ||
</div> | ||
|
||
</> | ||
) | ||
} | ||
|
||
export default InfoLayout |
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 |
---|---|---|
@@ -1,31 +1,41 @@ | ||
import { useState } from 'react' | ||
import { MapContainer, TileLayer, Marker, Popup } from 'react-leaflet' | ||
import { MapContainer, TileLayer, Marker, Popup, useMapEvents } from 'react-leaflet' | ||
import { Icon } from 'leaflet'; | ||
import usePreventZoom from '../../util/hooks/usePreventZoom'; | ||
|
||
const MainMap = () => { | ||
usePreventZoom() | ||
const [position, setPosition] = useState([51.505, -0.09]); | ||
|
||
const customIcon = new Icon({ | ||
iconUrl: "/mapicon.png", | ||
iconSize: [38, 38], | ||
}); | ||
const [position, setPosition] = useState([51.505, -0.09]) | ||
return( | ||
<> | ||
<MapContainer className='mapContainer' center={position} zoom={4} scrollWheelZoom={false}> | ||
<TileLayer | ||
attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' | ||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" | ||
/> | ||
<Marker position={position} icon={customIcon}> | ||
<Popup> | ||
A pretty CSS3 popup. <br /> Easily customizable. | ||
</Popup> | ||
</Marker> | ||
<LocationMarker position={position} setPosition={setPosition}/> | ||
</MapContainer> | ||
</> | ||
) | ||
} | ||
|
||
function LocationMarker(props) { | ||
useMapEvents({ | ||
click(evt) { | ||
props.setPosition([evt.latlng.lat, evt.latlng.lng]) | ||
}, | ||
}) | ||
const customIcon = new Icon({ | ||
iconUrl: "/mapicon.png", | ||
iconSize: [38, 38], | ||
}); | ||
return( | ||
<Marker icon={customIcon} position={props.position}> | ||
<Popup> | ||
A pretty CSS3 popup. <br /> Easily customizable. | ||
</Popup> | ||
</Marker> | ||
|
||
) | ||
} | ||
|
||
|
||
export default MainMap |
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