diff --git a/src/components/SearchMap/index.tsx b/src/components/SearchMap/index.tsx new file mode 100644 index 0000000..f06a212 --- /dev/null +++ b/src/components/SearchMap/index.tsx @@ -0,0 +1,42 @@ +import { SearchMapProps, ViewPort } from "../../types"; +import { useState, useEffect } from "react"; +import Map from "react-map-gl"; + +export const SearchMap = ({ longitude, latitude }: SearchMapProps) => { + const [viewPort, setViewPort] = useState({ + attributionControl: false, + longitude: longitude, + latitude: latitude, + zoom: 5, + }); + + const [screenWidth, setScreenWidth] = useState(); + + useEffect(() => { + setScreenWidth(() => { + let width = window.innerWidth; + const getWidth = width >= 768 ? 1280 : 420; + + return getWidth; + }) + }); + + useEffect(() => { + setViewPort({ + attributionControl: false, + longitude: longitude, + latitude: latitude, + zoom: viewPort.zoom, + }); + }, [longitude, latitude]); + + return ( + + ); +}; +