Open ryanfchase opened 4 months ago
This ticket is ready to be picked up
Assigning this to @DrAcula27 based on conversation from earlier in the day.
@DrAcula27 please provide the following information:
Thank you!
ETA: 10 September Availability: weekdays after 2pm Pacific time
Updated ETA: 17 September
Availability: weekdays after 2pm Pacific time
Finally finished the large issue for the website team 🚀
@ryanfchase As mentioned in the meeting tonight, I'd like to schedule a quick meetup with someone to walk through the codebase, so I can more easily tackle this issue.
ETA: October 11 with a check-in on the 2nd via either GitHub or Slack.
@ryanfchase @traycn
not-allowed
cursor, the aria-disabled
label does not toggle to true
, and no tooltip appears when I hover over the zoom controls. The code I am using is:
// grey out and disable the zoom buttons
const zoomInButton = document.querySelector(
'.mapboxgl-ctrl-zoom-in'
);
const zoomOutButton = document.querySelector(
'.mapboxgl-ctrl-zoom-out'
);
if (zoomInButton && zoomOutButton) { zoomInButton.style.opacity = '0.5'; zoomInButton.style.pointerEvents = 'none'; zoomInButton.style.cursor = 'not-allowed'; zoomInButton.setAttribute('aria-disabled', 'true');
zoomOutButton.style.opacity = '0.5'; zoomOutButton.style.pointerEvents = 'none'; zoomOutButton.style.cursor = 'not-allowed'; zoomOutButton.setAttribute('aria-disabled', 'true'); }
What am I missing here?
> Some thoughts are, changing the `pointerEvents` style to `none` might be messing with things, Mapbox versioning issues, and styles overriding each other.
- Once I get this working, how can I use the `getZoom()` Mapbox method to allow the user to zoom between max allowed zoom and the zoom level the map goes to when a NC is selected?
@DrAcula27 I think that setting pointer events to none was definitely preventing the cursor styles from being applied. I actually removed both these lines (from their respective blocks):
zoomInButton.style.pointerEvents = 'none'; // remove this
zoomInButton.style.cursor = 'not-allowed'; // remove this
I then simply zoomed in until I hit the max zoom level, and the pointer: not-allowed
and aria-disabled="true"
were applied automatically without needing custom CSS. I guess Mapbox simply wants control over these rules.
I've done some digging into programmatically setting min + max zooms. I cannot find any documentation on this, HOWEVER, you can simply call this.map.setMinZoom(z1)
and this.map.setMaxZoom(z2)
.
You'll notice that when activating an NC, we frame the camera around that NC's bounding box. To get this exact zoom level, I think you can call this.map.getZoom()
, and then plug that into setMinZoom()
, perhaps with a few fractional zoom levels of wiggle room (up to you, we can review when we demo this).
Update: I worry there is some funkiness of grabbing this.map.getZoom
right when we ask the map to zoom in on an NC. I think we would need to look into this.map.once('zoomend', () => ...)
to ensure we grab the desired zoom level.
Another approach would be to prevent panning beyond the NC's bounding box. To do this, you can call boundingBox(geo)
, provided from geoUtils.js
. I'm not sure off the top of my head where to obtain the geo
feature, but I assume that you'll have access to the NC's geo object when you select it. I'm fairly certain geo, in this context, means a Feature, taking on the geojson shape as an object.
A single geojson Feature:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}
Source on setting max bounds: https://stackoverflow.com/questions/61523571/how-to-fit-bounds-and-set-max-bounds-at-same-time-on-window-resize-in-mapbox
Where to find all NC geojson: data/ncGeojson.js
I've just remembered that in the design ticket (https://github.com/hackforla/311-data/issues/1700#issuecomment-2311594526) we specified to use a max zoom of 18, and a min zoom of 9 when an NC is selected. PMs will want to check this behavior and determine if it is good enough. To avoid complexity mentioned above, feel free to move forward with these hard-coded zoom values before worrying about NC bounding boxes or pan areas.
Zoom features are disabled while locked into a neighborhood council. To enable zoom features, please exit by clicking out of the selected area.
Zoom features are limited while locked into a neighborhood council. To reset zoom features, please exit by clicking out of the selected area.
this.map.setMinZoom(<zoomLevel>)
after the this.map.once('zoomend', () => ...)
code block, testing revealed that the screen whites out for about a second when selecting a NC. When deselecting, this white-out does not happen.this.map.setMinZoom(<zoomLevel>)
to inside the this.map.once('zoomend', () => ...)
code block.In the PR, #1843, I suggested a different approach. I'll list in more detail how to implement my suggestion:
On map load, we'd like to wrap a zoom control with the Tooltip component. This lets us reuse styles that we've utilized for the Datepicker tooltip, etc.
<button class="mapboxgl-ctrl-zoom-out" type="button" aria-label="Zoom Out" aria-disabled="false">
<span class="mapboxgl-ctrl-icon" aria-hidden="true" title="Zoom Out"></span> <!-- hint: wrap this one! -->
</button>
MUI Docs
NPM
Stack Overflow
Also, I have another approach which is slightly simpler. It is detailed below, but note that you cannot utilize any of the styles defined in our React components. We'll need to significantly modify the CSS to match the specs.
new mapboxgl.Map({
// ... the usual options ...
locale: {
'NavigationControl.ZoomIn: 'my-custom-tooltip-text',
}
})
<button class="mapboxgl-ctrl-zoom-out" type="button" aria-label="my-custom-tooltip-text" aria-disabled="false">
<span class="mapboxgl-ctrl-icon" aria-hidden="true" title="my-custom-tooltip-text"></span> <!-- here! -->
</button>
title
attribute on the span does the heavy lifting here, I haven't observed changes on button.aria-label
doing anything usefulspan.title
like so:
span.title
to be: (this is the desired text we agreed upon earlier)
Zoom features are limited while locked into a neighborhood council. To reset zoom features, please exit by clicking out of the selected area.
span.title
back to Zoom Out
Updated ETA
@ryanfchase I've got the tooltip implemented, but with default styles. Let me know if I should make the PR as-is, or if I should work on implementing style changes.
@DrAcula27 let's give design a little more time to review and officially hand off their work. In the meantime, please prepare all of your work in your PR and prepare for official review. I think you've done a lot of good work, I'd like to get these changes into the codebase before our Vite migration on Wednesday (10/30). The code for styling for this design will come in a separate ticket, most likely.
For updating the styles of the tooltip: https://mui.com/material-ui/react-tooltip/#customization
I've provided my review. @DrAcula27 please move this ticket to In Review
when you are ready for re-review. Thanks, and good work!
Overview
We need to add zoom controls to our map page to improve accessibility and make it clear when user has an NC selected.
Overview
Resources (R)
PM Review Section
Screenshot before proposed changes
![image](https://github.com/user-attachments/assets/e939d05b-c6c6-4c59-b683-a6d80028e398)
TODO: Screenshot after proposed changes
[insert screenshot here]
Resolved Dependency Info
Dependency (Resolved) - [x] Need to confirm with design team NC selected zoom behavior - don't disable zoom controls when NC is selected - prevent users from zooming too far out when NC is selected - [x] Need to establish zoom levels for NC selected - [x] Minimum zoom level - [x] Maximum zoom level