Skip to content

Commit d44759b

Browse files
prushforprushfor
prushfor
authored and
prushfor
committed
First pass at documenting-specifying how map media / container queries
should work.
1 parent 8f19bd8 commit d44759b

File tree

6 files changed

+80
-1
lines changed

6 files changed

+80
-1
lines changed

docs/api/layer-api.md

+4
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ To get the `<layer->`'s opacity value:
124124
let layer = document.querySelector('layer-');
125125
let opacity = layer.opacity;
126126
```
127+
---
128+
### media
129+
130+
Reflects the [media](../elements/layer#media) attribute of the `<layer->` element.
127131

128132
---
129133
## Methods

docs/api/map-link-api.md

+15
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ title: HTMLLinkElement
44
slug: /api/map-link-api
55
---
66

7+
# HTMLLinkElement
8+
9+
The `<map-link>` element is intended to implement an extension of the HTML `<link>`
10+
element and `HTMLLinkElement` API. This document reflects proposed changes to that
11+
API and is a work in progress.
12+
13+
14+
## Properties
15+
16+
### media
17+
18+
Reflects the [media](../elements/link#media) attribute of the `<map-link>` element.
19+
20+
---
21+
722
This document is copied from the old "Custom Rendering API" page, and is under
823
construction. It will eventually describe the API of the map-link custom element;
924
the "Custom Rendering API" is currently sourced from the map-link custom element,

docs/api/mapml-viewer-api.mdx

+15
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ let zoom = map.zoom;
222222
| [defineCustomProjection(options)](#definecustomprojectionoptions) | Define a custom projection for use by the page. |
223223
| [zoomTo(lat, lon, zoom)](#zoomtolat-lon-zoom) | Fly or pan the map to a (new) location and zoom level.|
224224
| [geojson2mapml(json, options)](#zoomtolat-lon-zoom) | Add a GeoJSON Layer to the map. |
225+
| [matchMedia(mediaQueryString)](#matchmediamediaquerystring) | Returns a [MediaQueryList](https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList) object.
225226

226227

227228
### back()
@@ -358,6 +359,20 @@ Check out [this application](https://maps4html.org/experiments/api/custom-map-ui
358359

359360
---
360361

362+
### matchMedia(mediaQueryString)
363+
364+
Returns a [MediaQueryList object](https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList).
365+
The `matches` property of the MediaQueryList object can be used for an instantaneous
366+
determination of if the map meets the media conditions. To react to changes in
367+
the map media conditions, use MediaQueryList.addEventListener('change', callbackFn)
368+
to add an event listener for `change` events that are triggered by changes in the
369+
state of the queried map properties (projection, zoom, extent); any change to the
370+
map that results in a change in state of the
371+
[MediaQueryListEvent `matches` boolean property](https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList/change_event)
372+
triggers the `change` event and calls the callbackFn.
373+
374+
---
375+
361376
## Events
362377

363378
| Event name | Description |

docs/elements/layer.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
id: layer
33
title: "<layer->"
4-
slug: /layers/layer/
4+
slug: /elements/layer/
55
---
66

77
Maps have one or more layers. Map layers are implemented by the `<layer->` custom element.
@@ -63,6 +63,21 @@ and the fetched `<map-title>` element is used.
6363

6464
---
6565

66+
### `media`
67+
68+
The `media` attribute is used to express media conditions under which the layer
69+
content should be used / loaded from `src`. Media conditions evaluate to `true` or `false`.
70+
A layer for which the media condition evaluates to `false` is by default hidden.
71+
A layer for which the media condition evaluates to `true` is added to the map
72+
according to its `checked` attribute, and is added to the layer control according
73+
to its `hidden` attribute.
74+
75+
Map media queries can include extended CSS map properties including:
76+
[projection](../../api/mapml-viewer-api#projection), [zoom](../../api/mapml-viewer-api#zoom),
77+
and [extent](../../api/mapml-viewer-api#extent).
78+
79+
---
80+
6681
### `opacity`
6782

6883
The `opacity` attribute is used to set the initial opacity of the `<layer->` element.

docs/elements/link.md

+14
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,20 @@ Projection values [defined by the polyfill](../mapml-viewer#projection) include:
130130
| Permitted ARIA roles | No roles permitted. |
131131
| DOM Interface | [HTMLLinkElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLinkElement) |
132132

133+
---
134+
### `media`
135+
136+
The `media` attribute is used to express media conditions under which the linked
137+
content should be loaded from its `href` attribute. Media conditions evaluate to `true` or `false`.
138+
A map-link for which the media condition evaluates to `false` is not loaded / unloaded.
139+
Content linked via a map-link for which the media condition evaluates to `true`
140+
is loaded from its `href` attribute; when the condition subsequently evaluates to
141+
`false`, the content is unloaded.
142+
143+
Map media queries can include extended CSS map properties including:
144+
[projection](../../api/mapml-viewer-api#projection), [zoom](../../api/mapml-viewer-api#zoom),
145+
and [extent](../../api/mapml-viewer-api#extent).
146+
133147
---
134148

135149
## Examples

docs/elements/style.md

+16
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,22 @@ slug: /elements/style/
66

77
The `<map-style>` element allows map authors to embed CSS into map layers. The CSS can be used to style the geometry of the layer using [`<map-span>`](../../other-elements/span/), and by setting the class attribute to the [child elements](../geometry/#child-elements) of the geometry.
88

9+
## Attributes
10+
11+
### `media`
12+
13+
The `media` attribute is used to express media conditions under which the contained
14+
styles should be applied. Media conditions evaluate to `true` or `false`. A map-style
15+
for which the media condition evaluates to `false` is not loaded / removed. Styles
16+
contained in a `<map-style>` for which the media condition evaluates to `true`
17+
are applied; when the condition subsequently evaluates to `false`, the styles are removed.
18+
19+
Map media queries can include extended CSS map properties including:
20+
[projection](../../api/mapml-viewer-api#projection), [zoom](../../api/mapml-viewer-api#zoom),
21+
and [extent](../../api/mapml-viewer-api#extent).
22+
23+
---
24+
925
:::note
1026

1127
All the Demo's on the documentation pages contain a "CSS" tab which adds the CSS using the `<map-style>` element dynamically.

0 commit comments

Comments
 (0)