|
| 1 | +--- |
| 2 | +id: templated-images |
| 3 | +title: Templated Images Layer |
| 4 | +slug: /layers/templated-images |
| 5 | +--- |
| 6 | + |
| 7 | +In this section, we will learn how to create a templated image layer. A templated image layer is a layer that fetches a single image file on pans and zooms. |
| 8 | + |
| 9 | +## Adding a templated image layer |
| 10 | + |
| 11 | +```html |
| 12 | +<layer- label="Toporama" checked> |
| 13 | + <meta name="zoom" content="min=4,max=5" /> |
| 14 | + <extent units="CBMTILE"> |
| 15 | + <input name="z" type="zoom" value="19" min="4" max="4" /> |
| 16 | + <input name="w" type="width" /> |
| 17 | + <input name="h" type="height" /> |
| 18 | + <input name="xmin" type="location" units="pcrs" position="top-left" axis="easting" min="-6207743" max="3952277" /> |
| 19 | + <input name="ymin" type="location" units="pcrs" position="bottom-left" axis="northing" min="-3362085" max="3952277" /> |
| 20 | + <input name="xmax" type="location" units="pcrs" position="top-right" axis="easting" min="-6207743" max="3952277" /> |
| 21 | + <input name="ymax" type="location" units="pcrs" position="top-left" axis="northing" min="-3362085" max="3952277" /> |
| 22 | + <link rel="image" tref="http://my-wms.ca?FORMAT=image/jpeg&WIDTH={w}&HEIGHT={h}&BBOX={xmin},{ymin},{xmax},{ymax}" /> |
| 23 | + </extent> |
| 24 | +</layer-> |
| 25 | +``` |
| 26 | + |
| 27 | +## Associated Elements |
| 28 | + |
| 29 | +### `<extent>` |
| 30 | + |
| 31 | +- `units` |
| 32 | + - This allows you to define what the [projection](http://example.org/) of the templated tiles are. |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +### `<input>` |
| 37 | + |
| 38 | +- `axis` |
| 39 | + - This attribute is only useful on inputs of type <strong>location</strong>, it sets the axis the following input defines. This value also defines what the <strong>min</strong> and <strong>max</strong> value's units. |
| 40 | + - Options are, row | column | easting | northing | latitude | longitude |
| 41 | + |
| 42 | +- `name` |
| 43 | + - This allows you to name the input, this name is then used in the url template used in the `<link>` href attribute. |
| 44 | + |
| 45 | +- `type` |
| 46 | + - Sets the <strong>type</strong> of the input. |
| 47 | + - Options are, zoom | location | width | height |
| 48 | + |
| 49 | +- `max` |
| 50 | + - Sets the maximum of the bounds of the layer on the given <strong>axis</strong>. |
| 51 | + |
| 52 | +- `min` |
| 53 | + - Sets the minimum of the bounds of the layer on the given <strong>axis</strong>. |
| 54 | + |
| 55 | +- `position` |
| 56 | + - Sets the position of the input, this can either be top-left or bottom-right. |
| 57 | + |
| 58 | +- `value` |
| 59 | + - Sets the zoom level the inputs of type <strong>location</strong>'s <strong>min</strong> and <strong>max</strong> are defined at. |
| 60 | + |
| 61 | +--- |
| 62 | + |
| 63 | +### `<link>` |
| 64 | + |
| 65 | +- `rel` |
| 66 | + - Set this to image in the case of a templated image layer. |
| 67 | + |
| 68 | +- `title` |
| 69 | + - Sets the title of the layer, this is the title shown in the layer controls. |
| 70 | + |
| 71 | +- `type` |
| 72 | + - Sets the type of the returned data. |
| 73 | + |
| 74 | +- `tref` |
| 75 | + - Sets the templated url of the templated tile layer, this must contain all the names of the inputs used to query a given tile. |
| 76 | + |
| 77 | +--- |
| 78 | + |
| 79 | +## Additional Context |
| 80 | + |
| 81 | +You can also provide a set of elements to further define the templated tile layer. This is the list of available additions with examples. |
| 82 | + |
| 83 | +#### `<meta name="zoom">` |
| 84 | +Sets the zoom range of the layer, in the following example the user can zoom from zoom level 1 to 5. |
| 85 | + |
| 86 | +```html |
| 87 | +<meta name="zoom" content="min=1,max=5" /> |
| 88 | +``` |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## Full Examples |
| 93 | + |
| 94 | +```html |
| 95 | +<mapml-viewer projection="CBMTILE" zoom="4" lat="53.331" lon="-91.667" controls> |
| 96 | + <layer- label="Toporama" checked> |
| 97 | + <meta name="zoom" content="min=4,max=5" /> |
| 98 | + <extent units="CBMTILE"> |
| 99 | + <input name="z" type="zoom" value="19" min="4" max="4" /> |
| 100 | + <input name="w" type="width" /> |
| 101 | + <input name="h" type="height" /> |
| 102 | + <input name="xmin" type="location" units="pcrs" position="top-left" axis="easting" min="-6207743.103886206" max="3952277.216154434" /> |
| 103 | + <input name="ymin" type="location" units="pcrs" position="bottom-left" axis="northing" min="-3362085.3441706896" max="3952277.216154434" /> |
| 104 | + <input name="xmax" type="location" units="pcrs" position="top-right" axis="easting" min="-6207743.103886206" max="3952277.216154434" /> |
| 105 | + <input name="ymax" type="location" units="pcrs" position="top-left" axis="northing" min="-3362085.3441706896" max="3952277.216154434" /> |
| 106 | + <link rel="image" tref="http://wms.ess-ws.nrcan.gc.ca/wms/toporama_en?SERVICE=WMS&REQUEST=GetMap&FORMAT=image/jpeg&TRANSPARENT=FALSE&STYLES=&VERSION=1.3.0&LAYERS=WMS-Toporama&WIDTH={w}&HEIGHT={h}&CRS=EPSG:3978&BBOX={xmin},{ymin},{xmax},{ymax}&m4h=t" /> |
| 107 | + </extent> |
| 108 | + </layer-> |
| 109 | +</mapml-viewer> |
| 110 | +``` |
| 111 | + |
| 112 | +[ADD MAP HERE] |
0 commit comments