Skip to content

Commit

Permalink
Make MapWithMarker a functional component
Browse files Browse the repository at this point in the history
  • Loading branch information
tomcur committed Jul 25, 2023
1 parent ef22e37 commit 3954a24
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions astroplant-frontend/src/Components/MapWithMarker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,26 @@ type Props = {
location: { latitude: number; longitude: number };
};

export default class MapWithMarker extends React.Component<
React.PropsWithChildren<Props>
> {
render() {
const { location } = this.props;
return (
<MapContainer
center={[location.latitude, location.longitude]}
zoom={10}
style={{ height: "45em" }}
export default function MapWithMarker({
location,
children,
}: React.PropsWithChildren<Props>) {
return (
<MapContainer
center={[location.latitude, location.longitude]}
zoom={10}
style={{ height: "45em" }}
>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
/>
<Marker
icon={MarkerIcon}
position={[location.latitude, location.longitude]}
>
<TileLayer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
attribution='&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'
/>
<Marker
icon={MarkerIcon}
position={[location.latitude, location.longitude]}
>
{this.props.children && <Popup>{this.props.children}</Popup>}
</Marker>
</MapContainer>
);
}
{children && <Popup>{children}</Popup>}
</Marker>
</MapContainer>
);
}

0 comments on commit 3954a24

Please sign in to comment.