You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Map.jsx 813B

12345678910111213141516171819202122232425262728293031323334
  1. import { GoogleMap, Marker, useLoadScript } from '@react-google-maps/api';
  2. import LoadingSpinner from '../loader/basic-spinner/LoadSpinner';
  3. import { center, libraries, mapContainerStyle } from './MapConst';
  4. const Map = () => {
  5. const { isLoaded, loadError } = useLoadScript({
  6. googleMapsApiKey: `${process.env.NEXT_PUBLIC_MAP_KEY}`,
  7. libraries,
  8. });
  9. let content = (
  10. <GoogleMap
  11. id="map"
  12. mapContainerStyle={mapContainerStyle}
  13. zoom={14}
  14. center={center}
  15. >
  16. <Marker
  17. key={`${center.lat - center.lng}`}
  18. position={{
  19. lat: center.lat,
  20. lng: center.lng,
  21. }}
  22. />
  23. </GoogleMap>
  24. );
  25. if (loadError) return 'Error loading map';
  26. if (!isLoaded) content = <LoadingSpinner />;
  27. return <>{content}</>;
  28. };
  29. export default Map;