From ddc0dddebdfac1d33a2aec333357e35d2d4d11d8 Mon Sep 17 00:00:00 2001
From: Aliyan Haq <55751566+AliyanH@users.noreply.github.com>
Date: Wed, 24 May 2023 17:16:40 -0400
Subject: [PATCH 1/4] initial map-input setup
---
Gruntfile.js | 2 +
index.html | 59 +++--------------
src/map-input.js | 66 +++++++++++++++++--
src/mapml-viewer.js | 2 +
.../elementSupport/inputs/heightInput.js | 12 ++++
.../elementSupport/inputs/hiddenInput.js | 13 ++++
.../elementSupport/inputs/locationInput.js | 22 +++++++
src/mapml/elementSupport/inputs/widthInput.js | 12 ++++
src/mapml/elementSupport/inputs/zoomInput.js | 19 ++++++
9 files changed, 152 insertions(+), 55 deletions(-)
create mode 100644 src/mapml/elementSupport/inputs/heightInput.js
create mode 100644 src/mapml/elementSupport/inputs/hiddenInput.js
create mode 100644 src/mapml/elementSupport/inputs/locationInput.js
create mode 100644 src/mapml/elementSupport/inputs/widthInput.js
create mode 100644 src/mapml/elementSupport/inputs/zoomInput.js
diff --git a/Gruntfile.js b/Gruntfile.js
index 41145842b..ef794e121 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -29,6 +29,8 @@ module.exports = function(grunt) {
'dist/map-caption.js': ['src/map-caption.js'],
'dist/map-feature.js': ['src/map-feature.js'],
'dist/map-extent.js': ['src/map-extent.js'],
+ 'dist/map-input.js': ['src/map-input.js'],
+ 'dist/zoomInput.js': ['src/mapml/elementSupport/inputs/zoomInput.js'],
'dist/map-area.js': ['src/map-area.js'],
'dist/layer.js': ['src/layer.js'],
'dist/leaflet.js': ['dist/leaflet-src.js',
diff --git a/index.html b/index.html
index ddfa9d00d..d612a76e3 100644
--- a/index.html
+++ b/index.html
@@ -72,57 +72,14 @@
-
- A pleasing map of Canada
-
-
-
-
-
-
-
- code |
- 1200020 |
-
-
- accuracy |
- 26 |
-
-
- valdate |
- 1995 |
-
-
- image |
-
-
-
- |
-
-
- theme |
- FO |
-
-
- type |
- 2 |
-
-
- elevation |
- 61 |
-
-
- altiaccu |
- 5 |
-
-
-
-
-
- -75.705278 45.397778
-
-
-
+
+
+
+
+
+
+
+
diff --git a/src/map-input.js b/src/map-input.js
index bd92e01b1..bd0a0db32 100644
--- a/src/map-input.js
+++ b/src/map-input.js
@@ -1,4 +1,4 @@
-import { MapLink } from './map-link.js';
+import { ZoomInput } from './zoomInput.js';
export class MapInput extends HTMLElement {
static get observedAttributes() {
@@ -89,7 +89,7 @@ export class MapInput extends HTMLElement {
}
}
get step() {
- return this.getAttribute('step');
+ return this.getAttribute('step') || 1;
}
set step(val) {
if (val) {
@@ -97,6 +97,7 @@ export class MapInput extends HTMLElement {
}
}
attributeChangedCallback(name, oldValue, newValue) {
+ console.log(name);
switch (name) {
case 'name':
if (oldValue !== newValue) {
@@ -154,7 +155,64 @@ export class MapInput extends HTMLElement {
// Always call super first in constructor
super();
}
- connectedCallback() {}
+ connectedCallback() {
+ switch (this.type) {
+ case 'zoom':
+ // input will store the input Class specific to the input type
+ this.input = new ZoomInput(
+ this.name,
+ this.min,
+ this.max,
+ this.value,
+ this.step
+ );
+ break;
+ case 'location':
+ //this.input = ...
+ break;
+ case 'width':
+ //this.input = ...
+ break;
+ case 'height':
+ //this.input = ...
+ break;
+ case 'hidden':
+ //this.input = ...
+ break;
+ }
+ }
disconnectedCallback() {}
+
+ //https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/checkValidity
+ checkValidity() {
+ if (this.input.validateInput()) {
+ return true;
+ } else {
+ const evt = new Event('invalid', {
+ bubbles: true,
+ cancelable: true,
+ composed: true
+ });
+ this.dispatchEvent(evt);
+ return false;
+ }
+ }
+
+ //https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/reportValidity
+ reportValidity() {
+ if (this.input.validateInput()) {
+ return true;
+ } else {
+ const evt = new Event('invalid', {
+ bubbles: true,
+ cancelable: true,
+ composed: true
+ });
+ this.dispatchEvent(evt);
+ //if the event isn't canceled reports the problem to the user.
+ // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#dom-cva-reportvalidity-dev
+ console.log("Input type='" + this.type + "' is not valid!");
+ return false;
+ }
+ }
}
-window.customElements.define('map-input', MapInput);
diff --git a/src/mapml-viewer.js b/src/mapml-viewer.js
index 1210f4b72..fb2c61b8a 100644
--- a/src/mapml-viewer.js
+++ b/src/mapml-viewer.js
@@ -5,6 +5,7 @@ import { MapLayer } from './layer.js';
import { MapCaption } from './map-caption.js';
import { MapFeature } from './map-feature.js';
import { MapExtent } from './map-extent.js';
+import { MapInput } from './map-input.js';
export class MapViewer extends HTMLElement {
static get observedAttributes() {
@@ -1304,3 +1305,4 @@ window.customElements.define('layer-', MapLayer);
window.customElements.define('map-caption', MapCaption);
window.customElements.define('map-feature', MapFeature);
window.customElements.define('map-extent', MapExtent);
+window.customElements.define('map-input', MapInput);
diff --git a/src/mapml/elementSupport/inputs/heightInput.js b/src/mapml/elementSupport/inputs/heightInput.js
new file mode 100644
index 000000000..26d2034a4
--- /dev/null
+++ b/src/mapml/elementSupport/inputs/heightInput.js
@@ -0,0 +1,12 @@
+export class HeightInput {
+ constructor(name) {
+ this.name = name;
+ }
+
+ validateInput() {
+ // name is required
+ //
+ // checks here...
+ return;
+ }
+}
diff --git a/src/mapml/elementSupport/inputs/hiddenInput.js b/src/mapml/elementSupport/inputs/hiddenInput.js
new file mode 100644
index 000000000..8fffbf86e
--- /dev/null
+++ b/src/mapml/elementSupport/inputs/hiddenInput.js
@@ -0,0 +1,13 @@
+export class HiddenInput {
+ constructor(name, value) {
+ this.name = name;
+ this.value = value;
+ }
+
+ validateInput() {
+ // name is required
+ // value is required
+ // checks here...
+ return;
+ }
+}
diff --git a/src/mapml/elementSupport/inputs/locationInput.js b/src/mapml/elementSupport/inputs/locationInput.js
new file mode 100644
index 000000000..34f920eb3
--- /dev/null
+++ b/src/mapml/elementSupport/inputs/locationInput.js
@@ -0,0 +1,22 @@
+export class LocationInput {
+ constructor(name, position, axis, cs, min, max, rel) {
+ this.name = name;
+ this.position = position;
+ this.axis = axis;
+ this.cs = cs; // units
+ this.min = min;
+ this.max = max;
+ this.rel = rel;
+ }
+
+ validateInput() {
+ // name is required
+ // axis is required
+ // cs is required
+ // position is not required, will default to top-left
+ // min max fallbacks, map-meta -> projection
+ // rel not required, default is image/extent
+ // checks here...
+ return;
+ }
+}
diff --git a/src/mapml/elementSupport/inputs/widthInput.js b/src/mapml/elementSupport/inputs/widthInput.js
new file mode 100644
index 000000000..13cc1087c
--- /dev/null
+++ b/src/mapml/elementSupport/inputs/widthInput.js
@@ -0,0 +1,12 @@
+export class WidthInput {
+ constructor(name) {
+ this.name = name;
+ }
+
+ validateInput() {
+ // name is required
+ //
+ // checks here...
+ return;
+ }
+}
diff --git a/src/mapml/elementSupport/inputs/zoomInput.js b/src/mapml/elementSupport/inputs/zoomInput.js
new file mode 100644
index 000000000..4944f0fd3
--- /dev/null
+++ b/src/mapml/elementSupport/inputs/zoomInput.js
@@ -0,0 +1,19 @@
+export class ZoomInput {
+ constructor(name, min, max, value, step) {
+ this.name = name;
+ this.min = min;
+ this.max = max;
+ this.value = value;
+ this.step = step;
+ }
+
+ validateInput() {
+ // name is required
+ // min and max can not be present
+ // fallback would be layer's meta, -> projection min, max
+ // don't need value, map-meta max value, -> fallback is max zoom of projection
+ // don't need step, defaults to 1
+ // checks here...
+ return;
+ }
+}
From 1c168bc42af2c7cf535f7400326c5f36f377571a Mon Sep 17 00:00:00 2001
From: AliyanH
Date: Fri, 26 May 2023 14:52:21 -0400
Subject: [PATCH 2/4] implement Classes for different types of map-input types
---
Gruntfile.js | 4 +
index.html | 31 +++++-
src/map-input.js | 95 +++++++++++++---
.../elementSupport/inputs/heightInput.js | 26 +++--
.../elementSupport/inputs/hiddenInput.js | 28 +++--
.../elementSupport/inputs/locationInput.js | 104 ++++++++++++++----
src/mapml/elementSupport/inputs/widthInput.js | 26 +++--
src/mapml/elementSupport/inputs/zoomInput.js | 23 ++--
8 files changed, 261 insertions(+), 76 deletions(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index ef794e121..5073aa0b6 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -31,6 +31,10 @@ module.exports = function(grunt) {
'dist/map-extent.js': ['src/map-extent.js'],
'dist/map-input.js': ['src/map-input.js'],
'dist/zoomInput.js': ['src/mapml/elementSupport/inputs/zoomInput.js'],
+ 'dist/hiddenInput.js': ['src/mapml/elementSupport/inputs/hiddenInput.js'],
+ 'dist/widthInput.js': ['src/mapml/elementSupport/inputs/widthInput.js'],
+ 'dist/heightInput.js': ['src/mapml/elementSupport/inputs/heightInput.js'],
+ 'dist/locationInput.js': ['src/mapml/elementSupport/inputs/locationInput.js'],
'dist/map-area.js': ['src/map-area.js'],
'dist/layer.js': ['src/layer.js'],
'dist/leaflet.js': ['dist/leaflet-src.js',
diff --git a/index.html b/index.html
index d612a76e3..1c5b34d1d 100644
--- a/index.html
+++ b/index.html
@@ -23,9 +23,9 @@
/* Responsive map. */
max-width: 100%;
- /* Full viewport. */
+ /* Full viewport.
width: 100%;
- height: 100%;
+ height: 100%; */
/* Remove default (native-like) border. */
border: none;
@@ -72,15 +72,38 @@
-
+
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+