Skip to content

Commit

Permalink
Rename AnnounceMovement handler to PanZoom / meaningfulPanZoom handler
Browse files Browse the repository at this point in the history
  • Loading branch information
prushforth committed Mar 30, 2023
1 parent 3e29319 commit c557804
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/mapml-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class MapViewer extends HTMLElement {
projection: this.projection,
query: true,
contextMenu: true,
announceMovement: M.options.announceMovement,
meaningfulPanZoom: true,
featureIndex: true,
mapEl: this,
crs: M[this.projection],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export var AnnounceMovement = L.Handler.extend({
export var PanZoomHandler = L.Handler.extend({
addHooks: function () {
this._map.on({
layeradd: this.totalBounds,
layerremove: this.totalBounds,
layerremove: this.totalBounds
});

this._map.options.mapEl.addEventListener('moveend', this.announceBounds);
Expand All @@ -12,7 +12,7 @@ export var AnnounceMovement = L.Handler.extend({
removeHooks: function () {
this._map.off({
layeradd: this.totalBounds,
layerremove: this.totalBounds,
layerremove: this.totalBounds
});

this._map.options.mapEl.removeEventListener('moveend', this.announceBounds);
Expand Down Expand Up @@ -127,4 +127,4 @@ export var AnnounceMovement = L.Handler.extend({
this.wasDragged = true;
}

});
});
10 changes: 5 additions & 5 deletions src/mapml/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ import { Util } from './utils/Util';
import { ReloadButton, reloadButton } from './control/ReloadButton';
import { ScaleBar, scaleBar } from './control/ScaleBar';
import { FullscreenButton, fullscreenButton } from './control/FullscreenButton';
import {attributionControl} from "./control/AttributionControl";
import { attributionControl } from "./control/AttributionControl";
import { Crosshair, crosshair } from "./layers/Crosshair";
import { Feature, feature } from "./features/feature";
import { FeatureRenderer, featureRenderer } from './features/featureRenderer';
import { FeatureGroup, featureGroup} from './features/featureGroup';
import {AnnounceMovement} from "./handlers/AnnounceMovement";
import {AnnounceScale,announceScale} from "./control/AnnounceScale";
import { PanZoomHandler } from "./handlers/PanZoom";
import { AnnounceScale,announceScale } from "./control/AnnounceScale";
import { FeatureIndex } from "./handlers/FeatureIndex";
import { Options } from "./options";
import "./keyboard";
Expand Down Expand Up @@ -620,15 +620,15 @@ M.mapml2geojson = Util.mapml2geojson;

M.QueryHandler = QueryHandler;
M.ContextMenu = ContextMenu;
M.AnnounceMovement = AnnounceMovement;
M.PanZoomHandler = PanZoomHandler;
M.announceScale = announceScale;
M.AnnounceScale = AnnounceScale;
M.FeatureIndex = FeatureIndex;

// see https://leafletjs.com/examples/extending/extending-3-controls.html#handlers
L.Map.addInitHook('addHandler', 'query', M.QueryHandler);
L.Map.addInitHook('addHandler', 'contextMenu', M.ContextMenu);
L.Map.addInitHook('addHandler', 'announceMovement', M.AnnounceMovement);
L.Map.addInitHook('addHandler', 'meaningfulPanZoom', M.PanZoomHandler);
L.Map.addInitHook('addHandler', 'featureIndex', M.FeatureIndex);

M.MapMLLayer = MapMLLayer;
Expand Down
3 changes: 1 addition & 2 deletions src/mapml/options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export var Options = {
featureIndexOverlayOption: false,
announceMovement: false,
announceScale: {"metric": true, "imperial": false},
defaultExtCoor: 'pcrs',
defaultLocCoor: 'gcrs',
Expand Down Expand Up @@ -47,4 +46,4 @@ export var Options = {
kbdNextFeature: "Next feature",
dfLayer: "Layer",
}
};
};
2 changes: 1 addition & 1 deletion src/web-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ export class WebMap extends HTMLMapElement {
projection: this.projection,
query: true,
contextMenu: true,
announceMovement: M.options.announceMovement,
meaningfulPanZoom: true,
featureIndex: true,
mapEl: this,
crs: M[this.projection],
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/e2e/mapml-viewer/mapml-viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="UTF-8">
<script>
let options = document.createElement("map-options");
options.innerHTML = '{"announceMovement":true}';
options.innerHTML = '{"announceZoom":true}';
document.head.appendChild(options);
</script>
<script type="module" src="mapml-viewer.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/web-map/map.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="UTF-8">
<script>
let options = document.createElement("map-options");
options.innerHTML = '{"announceMovement":true}';
options.innerHTML = '{"announceZoom":true}';
document.head.appendChild(options);
</script>
<script type="module" src="web-map.js"></script>
Expand Down
4 changes: 2 additions & 2 deletions test/utils/options.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe("M.Options Tests", () => {
test("M.options.announceMovement default set", async () => {
await expect(M.options.announceMovement).toEqual(false);
test("M.options.announceZoom default set", async () => {
await expect(M.options.announceZoom).toEqual(false);
});
});

0 comments on commit c557804

Please sign in to comment.