-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add center prop and logic around it #436
base: main
Are you sure you want to change the base?
Conversation
packages/map-template/src/components/MapTemplate/MapTemplate.jsx
Outdated
Show resolved
Hide resolved
packages/map-template/src/components/MapTemplate/MapTemplate.jsx
Outdated
Show resolved
Hide resolved
packages/map-template/src/components/MapsIndoorsMap/MapsIndoorsMap.jsx
Outdated
Show resolved
Hide resolved
@ammapspeople I've added a few comments here which stood out at a first glance, to save you some time 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll pause reviewing this until the build error mentioned in the Jira ticket is resolved.
@@ -553,6 +556,13 @@ function MapTemplate({ apiKey, gmApiKey, mapboxAccessToken, venue, locationId, p | |||
setSearchExternalLocations(searchExternalLocations); | |||
}, [searchExternalLocations]); | |||
|
|||
/* | |||
* TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do 😁
@@ -92,8 +93,9 @@ defineCustomElements(); | |||
* @param {boolean} [props.showRoadNames] - A boolean parameter that dictates whether Mapbox road names should be shown. By default, Mapbox road names are hidden when MapsIndoors data is shown. It is dictated by `mi-transition-level` which default value is 17. | |||
* @param {boolean} [props.showExternalIDs] - Determine whether the location details on the map should have an external ID visible. The default value is set to false. | |||
* @param {boolean} [props.searchExternalLocations] - If you want to perform search for external locations in the Wayfinding mode. If set to true, Mapbox/Google places will be displayed depending on the Map Provider you are using. If set to false, the results returned will only be MapsIndoors results. The default is true. | |||
* @param {string} [props.center] - TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs explanation
@@ -36,6 +36,7 @@ import getBooleanValue from "../../helpers/GetBooleanValue.js"; | |||
* @param {boolean} [props.showExternalIDs] - Determine whether the location details on the map should have an external ID visible. The default value is set to false. | |||
* @param {boolean} [props.showRoadNames] - A boolean parameter that dictates whether Mapbox road names should be shown. By default, Mapbox road names are hidden when MapsIndoors data is shown. It is dictated by `mi-transition-level` which default value is 17. | |||
* @param {boolean} [props.searchExternalLocations] - If you want to perform search for external results in the Wayfinding mode. If set to true, Mapbox/Google places will be displayed depending on the Map Provider you are using. If set to false, the results returned will only be MapsIndoors results. The default is true. | |||
* @param {string} [props.center] - TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs explanation.
const venuesInSolution = useRecoilValue(venuesInSolutionState); | ||
const currentPitch = useRecoilValue(currentPitchSelector); | ||
const venueWasSelected = useRecoilValue(venueWasSelectedState); | ||
const [kioskLocationDisplayRuleWasChanged, setKioskLocationDisplayRuleWasChanged] = useState(false); | ||
let centerValue = useRecoilValue(centerState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we name it center
to follow the existing pattern?
getDesktopPaddingBottom().then(desktopPaddingBottom => { | ||
desktopPadBottom = desktopPaddingBottom; | ||
}); | ||
|
||
getMobilePaddingBottom().then(mobilePaddingBottom => { | ||
mobilePadBottom = mobilePaddingBottom | ||
}); | ||
|
||
getDesktopPaddingLeft().then(desktopPaddingLeft => { | ||
desktopPadLeft = desktopPaddingLeft; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Promise.all() instead of running them one by one. Then you'll get an array with all the values when all have resolved. See for example the onLocationClicked
function in the Search
component.
I now addressed all your comments @andreeaceachir142 and @ammapspeople |
packages/map-template/src/components/MapTemplate/MapTemplate.jsx
Outdated
Show resolved
Hide resolved
const zoomLevel = startZoomLevel ?? 16; | ||
|
||
|
||
Promise.all([getDesktopPaddingBottom(), getDesktopPaddingLeft(), getMobilePaddingBottom()]).then(([desktopPaddingBottom, desktopPaddingLeft, mobilePaddingBottom]) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't we risk that the "pad" variables are null since this is asynchronous and the code following it is immediately executed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reversed the code as it was before. Because version before works.
Co-authored-by: Anders Mogensen <[email protected]>
The center prop is not reacting to changes runtime. It should. Kapture.2025-01-10.at.09.36.53.mp4 |
I believe I addressed all your comments @ammapspeople |
@@ -36,6 +36,7 @@ import getBooleanValue from "../../helpers/GetBooleanValue.js"; | |||
* @param {boolean} [props.showExternalIDs] - Determine whether the location details on the map should have an external ID visible. The default value is set to false. | |||
* @param {boolean} [props.showRoadNames] - A boolean parameter that dictates whether Mapbox road names should be shown. By default, Mapbox road names are hidden when MapsIndoors data is shown. It is dictated by `mi-transition-level` which default value is 17. | |||
* @param {boolean} [props.searchExternalLocations] - If you want to perform search for external results in the Wayfinding mode. If set to true, Mapbox/Google places will be displayed depending on the Map Provider you are using. If set to false, the results returned will only be MapsIndoors results. The default is true. | |||
* @param {string} [props.center] - Specifies the coordinates where the map should load, represented as latitude and longitude values separated by a comma. If the specified coordinates intersect with a Venue, that Venue will be selected in the Venue Selector. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use the same phrasing pattern as for the venue and locationId prop: "If you want the map to center on a specific coordinate, provide [...]"
const centerPoint = { geometry: { type: 'Point', coordinates: [latitude, longitude] } }; | ||
|
||
// Returns Venue that intersects with center prop. | ||
const intersectingVenueWithCenterPoint = venuesInSolution.find(venue => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary to calculate at this point in time, since the value is only used in some cases. Postpone to be calculated only when we know it's going to be used.
if (venueWasSelected) { | ||
// If switching Venues, while having center prop defined, set center prop to undefined. | ||
// It is required to be able to switch between Venues inside Venue Selector. | ||
center = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not set Recoil atoms to undefined. I guess that would stop the reactivity of it. Instead use a useRecoilState instead of a useRecoilValue hook for the center atom to get access to a setter function.
I applied your suggestions @ammapspeople |
I added possibility to read center's value from the URL.
Based on this value and other URL prop values I created a logic where the map should be centred.