-
Notifications
You must be signed in to change notification settings - Fork 16
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
Announce zoom and move and implementing map boundaries #533
Conversation
You may want to consider creating a new handler that extends L.Handler similar to ContextMenu.js. Then in that handler you can listen for zoom and moveend events in one place without having to modify all the different moveend handlers in the layers. You would also be able to conditionally add the new handler. So you'd only need to check if M.options.announceMovement is true or not once rather than on every moveend. For contextmenu, it looks like this, For announceMovement, you could do the same and instead of true pass in M.options.announceMovement. This is a good resource: https://leafletjs.com/examples/extending/extending-3-controls.html |
src/mapml-viewer.js
Outdated
@@ -5,6 +5,32 @@ import './mapml.js'; // refactored URI usage, replaced with URL standard | |||
import './Leaflet.fullscreen.js'; | |||
import { MapLayer } from './layer.js'; | |||
|
|||
class ExtendedMap extends L.Map { |
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 am not sure it's a good idea to include one class definition in the definition file for another. Maybe it's own class file, if indeed a class is necessary.
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 have so far not had to extend L.Map, so would try to stay away from that. If that's impossible, I don't think that Leaflet yet (properly) supports ES6 modules, it has its own extension mechanism, see here: https://leafletjs.com/examples/extending/extending-1-classes.html and here https://leafletjs.com/examples/extending/extending-3-controls.html
src/mapml-viewer.js
Outdated
@@ -100,7 +126,8 @@ export class MapViewer extends HTMLElement { | |||
constructor() { | |||
// Always call super first in constructor | |||
super(); | |||
|
|||
this.insertAdjacentHTML("beforebegin", "<output role='status' aria-live='polite' aria-atomic='true' id='screenReaderOutput' style='clip: rect(0 0 0 0);clip-path: inset(50%);height: 1px;overflow: hidden;position: absolute;white-space: nowrap;width: 1px;'></output>"); |
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 apologize, I think I mentioned an "attached" method, which no longer is part of custom elements; I should have said "connectedCallback" might be a good location for this. However, I thought I remembered from somewhere that you shouldn't do DOM manipulation in the constructor, but in reading our own code, that doesn't make sense, so maybe where you've got it is correct TBD.
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.
Anyhow, for reference, some best practices: https://developers.google.com/web/fundamentals/web-components/best-practices#create-your-shadow-root-in-the-constructor.
addHooks: function () { | ||
this._map.on({ | ||
moveend: this.announceBounds, | ||
zoomend: this.totalBounds, |
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.totalLayerBounds = bounds; |
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.
The calculated bounds seems to be static, if a layer is deselected the value doesn't reflect that. If a layer is deselected I'm not sure if it should be considered, unless that was something that was decided on.
let visible = mapZoom <= this._layersMaxZoom && mapZoom >= this._layersMinZoom && | ||
this.totalLayerBounds.overlaps(mapBounds); | ||
|
||
if(!this.totalLayerBounds){ |
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.totalLayerBounds
is checked after the variable is already used, the mapZoom <= this._layersMaxZoom && mapZoom >= this._layersMinZoom && this.totalLayerBounds.overlaps(mapBounds);
could be conditionally called, something like:
let visible = true;
if(this.totalLayerBounds){
visible = mapZoom <= this._layersMaxZoom && mapZoom >= this._layersMinZoom &&
this.totalLayerBounds.overlaps(mapBounds);
}
let standard = "zoom level " + mapZoom + " column " + column + " row " + row; | ||
|
||
if(!visible){ | ||
mapEl._addToHistory(); |
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.
Manually adding to history may cause other issues, one I noticed was after being out of bounds you cannot go back (the index also has other odd behaviors):
2021-10-25.14-29-28.mp4
Hopefully resolved the indexing issues but now when reaching the top bounds, the map bounces back to an unexpected location on certain occasions. 2021-10-26.11-26-08.movMoved to issue #542 |
@Malvoz why don't links announce where they go? For map links, I think it would be good to know whether the link will navigate the page or the map, for example. Do web links not have that notion? For visual users, we see the destination of the link in the bottom left of the screen/map, so there's some sense that we're not going to hell by clicking on the link. Do non-visual users not get that same assurance somehow? |
@prushforth To my knowledge links are always just announced "link" along with their accessible name/desc, even when they're |
505c808
to
dd5dd10
Compare
f9f1362
to
ddbe48a
Compare
Create util function for zoom/movement screen reader support Fix setTimeout Focus on the map Focus on the map Fix focus on the map Add announceMoveAndZoom functionality to all layer types Use aria-label for announce zoom and move Use output element for announcing zoom and move Add/Fix zoom and pan bounds Add dragging bounds Create new handler to listen for move events Add bounds Implement combined bounds to handle multiple layers bound check [work in progress] Implement combined bounds to handle multiple layers bound check [work in progress] Fix total bounds and bounds check Add total bounds rectangle to debug layer Change output element and total layer bounds rectangle position in dom to satisfy tests Disable bounds check when no bounds are present Refactor output element Set initial bounds to center of first bounds instead of [0,0] Clean up code Refactor output element class name Resolve indexing issues [work in progress] Make deselected layers not considered for the total bounds Use layeradd/layerremove instead of checkdisable for timing reasons Announce location on focus Fix max/min zoom announcements Fix dragged out of bounds condition Fix dragged out of bounds condition Merge in history fix Fix double moveend call issue Remove console log Add announceMovement test
a40b530
to
357b403
Compare
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 take it you have to reload the map for the extension setting to take effect on announcing/not announcing map location. In general the experience is what I expect, more or less; a few extra things that I don't recognized are announced. In this example page, when you tab to the second map, initially the location isn't announced. rows and columns are projection specific, we may need to figure out improvements incrementally. For example, as you remove layers from the map, the bounds should change.
This is a big change @ben-lu-uw , thank you for your hard work on it. Merging.
This implements meaningful pan and zoom from issue #396 and "bounce back" when max/min pan has been reached.
As of the making of this draft this functionality has only been implemented for mapml-viewer + templatedtilelayers and only been tested on tms.html. Currently looking for feedback.
Known issues: