|
| 1 | +--- |
| 2 | +name: mapml-link-markup |
| 3 | +description: Tells you how to correctly create and edit the markup for a <map-link> element. Use it when generating MapML output markup in an HTML page. |
| 4 | +--- |
| 5 | + |
| 6 | +# MapML `<map-link>` Element Markup Constraints |
| 7 | + |
| 8 | +## Purpose |
| 9 | +Document constraints and guidelines for generating valid `<map-link>` elements. |
| 10 | + |
| 11 | +## Required Attributes |
| 12 | +- `rel` - Relationship type of the link |
| 13 | +- Either `href` (static URL) OR `tref` (templated URL) |
| 14 | + |
| 15 | +When the `<map-link>` is found outside of the `<map-extent>` element content, it is not "templated", it is "static", and must not contain the `tref` attribute, and must contain the `href` attribute. |
| 16 | + |
| 17 | +## Templated Link Relationship Types (`rel`) |
| 18 | +- `tile` - Raster or vector tile resource (depends on the `type` attribute value) |
| 19 | +- `image` - Static image resource that covers the whole viewport |
| 20 | +- `features` - Vector features resource that covers the whole viewport |
| 21 | +- `query` - Query endpoint templated link (e.g., WMS GetFeatureInfo) |
| 22 | + |
| 23 | +### Query Link Requirements |
| 24 | +When generating a `rel="query"` link for WMS GetFeatureInfo: |
| 25 | + |
| 26 | +1. **Template Variables**: Ensure `<map-input>` elements exist for ALL template variables used in the `tref`: |
| 27 | + - Bounding box: `{xmin}`, `{ymin}`, `{xmax}`, `{ymax}` |
| 28 | + - Dimensions: `{w}`, `{h}` |
| 29 | + - Click position: `{i}`, `{j}` (pixel coordinates within the image) |
| 30 | + |
| 31 | +2. **INFO_FORMAT Parameter**: Always include the `INFO_FORMAT` parameter in the query URL template, set to the desired response format (e.g., `text/html`, `application/json`, `text/plain`). This should match a format advertised in the WMS capabilities document. |
| 32 | + |
| 33 | +3. **WMS Version-Specific Parameters**: |
| 34 | + - **WMS 1.3.0**: Use `I={i}&J={j}` for click position parameters |
| 35 | + - **WMS 1.1.1 and earlier**: Use `X={i}&Y={j}` for click position parameters |
| 36 | + - The parameter names changed between WMS versions |
| 37 | + |
| 38 | +4. **QUERY_LAYERS Parameter**: Must be included and typically matches the `LAYERS` parameter value. This specifies which layer(s) to query for feature information. |
| 39 | + |
| 40 | +5. **Coordinate Reference System**: Use the same CRS/SRS parameter as the corresponding `rel="image"` link. |
| 41 | + |
| 42 | +6. **Click Position Inputs**: The `{i}` and `{j}` variables require corresponding `<map-input>` elements with: |
| 43 | + - `type="location"` |
| 44 | + - `units="map"` (viewport pixel coordinates) |
| 45 | + - `axis="i"` and `axis="j"` respectively |
| 46 | + |
| 47 | +**Example WMS 1.3.0 Query Link:** |
| 48 | +```html |
| 49 | +<map-link rel="query" tref="https://example.com/wms?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&LAYERS=mylayer&QUERY_LAYERS=mylayer&CRS=EPSG:3857&BBOX={xmin},{ymin},{xmax},{ymax}&WIDTH={w}&HEIGHT={h}&INFO_FORMAT=text/html&I={i}&J={j}"></map-link> |
| 50 | +``` |
| 51 | + |
| 52 | +**Example WMS 1.1.1 Query Link:** |
| 53 | +```html |
| 54 | +<map-link rel="query" tref="https://example.com/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&LAYERS=mylayer&QUERY_LAYERS=mylayer&SRS=EPSG:4326&BBOX={xmin},{ymin},{xmax},{ymax}&WIDTH={w}&HEIGHT={h}&INFO_FORMAT=application/json&X={i}&Y={j}"></map-link> |
| 55 | +``` |
| 56 | + |
| 57 | +## Static Link Relationship Types (`rel`) |
| 58 | +- `license` - License information |
| 59 | +- `alternate` - Alternate representation |
| 60 | +- `stylesheet` - CSS stylesheet or PMTiles stylesheet module (depends on the `type` attribute) |
| 61 | + |
| 62 | +## Optional Attributes |
| 63 | +- `type` - MIME type of the resource |
| 64 | +- `tms` - Boolean, for TMS tile ordering |
| 65 | + |
| 66 | +## Constraints |
| 67 | +- Must be child of `<map-extent>` or `<map-layer>` |
| 68 | +- `tref` values can use variable substitution with `{variableName}` syntax |
| 69 | +- Variables in `tref` must have corresponding `<map-input>` elements |
| 70 | + |
| 71 | +When generating a `<map-link>` element, the closing tag `</map-link>` MUST be used even if the element permits no content. Never use the empty element `<map-link type="..." />` (XML) form of markup. The `<map-link>...</map-link>` form of markup does not harm the parsing process when using the XML parser, so the HTML form of the element should be used when generating the the element both in HTML documents ("inline") and in a standalone ("remote:) XHTML XML-encoded MapML document (`text/mapml`). |
| 72 | + |
| 73 | +## Example |
| 74 | +```html |
| 75 | +<!-- Templated tile link --> |
| 76 | +<map-link rel="tile" tref="https://example.com/tiles/{z}/{x}/{y}.png"></map-link> |
| 77 | + |
| 78 | +<!-- Static link --> |
| 79 | +<map-link rel="license" href="https://example.com/license.html"></map-link> |
| 80 | +``` |
| 81 | + |
| 82 | +## Notes |
| 83 | +- |
0 commit comments