diff --git a/src/Odyssey/SharePage.js b/src/Odyssey/SharePage.js index d25413e..10db462 100644 --- a/src/Odyssey/SharePage.js +++ b/src/Odyssey/SharePage.js @@ -23,7 +23,7 @@ const SharePage = ({ concerts, userLocation, mapStyle, setPosterName }) => { placeholder="Write a cool name for your trip here" InputProps={{ sx: { 'input': { textAlign: 'center', color: 'white' } } }} onChange={(e) => setPosterName(e.target.value)} /> - + diff --git a/src/Odyssey/map.js b/src/Odyssey/map.js index fea93af..1e41df4 100644 --- a/src/Odyssey/map.js +++ b/src/Odyssey/map.js @@ -1,5 +1,6 @@ import React, { useState, useEffect, useRef, useLayoutEffect } from "react"; import { GoogleMap, InfoWindowF, MarkerF, MarkerClusterer } from "@react-google-maps/api"; +import Box from '@mui/material/Box'; const concertToMarker = (concert) => { return { @@ -14,6 +15,18 @@ const concertToMarker = (concert) => { }; }; +const containerStyle = { + width: '100%', + paddingTop: '66.67%', // 3:2 aspect ratio + position: 'relative' +}; +const mapContainerStyle = { + position: 'absolute', + top: 0, + left: 0, + right: 0, + bottom: 0, +}; function useWindowSize() { @@ -139,96 +152,97 @@ function Map({ concerts, userLocation, mapStyle }) { console.log(output); return ( - setActiveMarker(null)} - options={{ - mapId: mapStyle, - minZoom: 1, - maxZoom: 20, - disableDefaultUI: true - }} - mapContainerStyle={(width / height) >= 1 ? { width: "100wh", height: "75vh" } : { width: "100wh", height: "75vh" }} - > - {userLocation && ( - - )} - - { - var pathCopy = [...path]; - // build the clusteringPolyline - // get markerclusters with more than one marker inside them - var clustersGreaterThanOne = clusterer.clusters.filter((cluster) => cluster.markers.length > 1); - //console.log(`total number of clusters: ${clusterer.clusters.length}`); - //console.log("cluster with more than 1 marker: "); - clustersGreaterThanOne.forEach(cluster => console.log(cluster)); - - // replace all points in each cluster in path with the center point - clustersGreaterThanOne.forEach((cluster) => { - let centerPoint = cluster.getCenter(); - let cleanedUpCenterPoint = { lat: centerPoint.lat(), lng: centerPoint.lng() }; - - let clusterPoints = cluster.markers.map((marker) => { - let markerPosition = marker.getPosition(); - return { lat: markerPosition.lat(), lng: markerPosition.lng() }; - }); + + setActiveMarker(null)} + options={{ + mapId: mapStyle, + minZoom: 1, + maxZoom: 20, + disableDefaultUI: true + }} + mapContainerStyle={mapContainerStyle} + > + {userLocation && ( + + )} + + { + var pathCopy = [...path]; + // build the clusteringPolyline + // get markerclusters with more than one marker inside them + var clustersGreaterThanOne = clusterer.clusters.filter((cluster) => cluster.markers.length > 1); + //console.log(`total number of clusters: ${clusterer.clusters.length}`); + //console.log("cluster with more than 1 marker: "); + clustersGreaterThanOne.forEach(cluster => console.log(cluster)); + + // replace all points in each cluster in path with the center point + clustersGreaterThanOne.forEach((cluster) => { + let centerPoint = cluster.getCenter(); + let cleanedUpCenterPoint = { lat: centerPoint.lat(), lng: centerPoint.lng() }; + + let clusterPoints = cluster.markers.map((marker) => { + let markerPosition = marker.getPosition(); + return { lat: markerPosition.lat(), lng: markerPosition.lng() }; + }); - pathCopy.forEach((point, index) => { - clusterPoints.forEach((clusterPoint) => { - if (clusterPoint.lat === point.lat && clusterPoint.lng === point.lng) { - pathCopy[index] = cleanedUpCenterPoint; - } + pathCopy.forEach((point, index) => { + clusterPoints.forEach((clusterPoint) => { + if (clusterPoint.lat === point.lat && clusterPoint.lng === point.lng) { + pathCopy[index] = cleanedUpCenterPoint; + } + }); }); }); - }); - - polylineRef.current.setPath(pathCopy); - }} - > - {(clusterer) => ( -
- {markers && - markers.map(({ id, name, position, artistImageUrl, address }) => ( - { - e.stop() - handleActiveMarker(id) - }} - > - {activeMarker === id ? ( - setActiveMarker(null)}> -
- {name} -

{name}

{address}

-
-
- ) : null} -
- ))} -
- )} -
-
+ polylineRef.current.setPath(pathCopy); + }} + > + {(clusterer) => ( +
+ {markers && + markers.map(({ id, name, position, artistImageUrl, address }) => ( + { + e.stop() + handleActiveMarker(id) + }} + > + {activeMarker === id ? ( + setActiveMarker(null)}> +
+ {name} +

{name}

{address}

+
+
+ ) : null} +
+ ))} +
+ )} +
+
+ ); } diff --git a/src/Voyage/Voyage.js b/src/Voyage/Voyage.js index 9fbbfc6..207efde 100644 --- a/src/Voyage/Voyage.js +++ b/src/Voyage/Voyage.js @@ -74,16 +74,17 @@ const Voyage = ({ const concerts1 = concerts.slice(0, middleIndex); const concerts2 = concerts.slice(middleIndex); - return ( - {isLoaded ? : null} - {posterName} - - - - - ); + return ( + + {isLoaded ? : null} + {posterName} + + + + + ); }; export default Voyage; \ No newline at end of file