Skip to content

Commit 224b794

Browse files
authored
Merge pull request #108684 from stevemunk/how-to-use-image-templates-web-sdk
Minor improvements to grammar in how-to-use-image-templates-web-sdk.md
2 parents eaa54b5 + 5afe88d commit 224b794

File tree

1 file changed

+29
-32
lines changed

1 file changed

+29
-32
lines changed

articles/azure-maps/how-to-use-image-templates-web-sdk.md

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
---
22
title: Image templates in the Azure Maps Web SDK | Microsoft Azure Maps
33
description: Learn how to add image icons and pattern-filled polygons to maps by using the Azure Maps Web SDK. View available image and fill pattern templates.
4-
author: eriklindeman
5-
ms.author: eriklind
4+
author: sinnypan
5+
ms.author: sipa
66
ms.date: 8/6/2019
77
ms.topic: how-to
88
ms.service: azure-maps
99
services: azure-maps
10-
ms.custom: codepen, devx-track-js
10+
ms.custom: devx-track-js
1111
---
1212

1313
# How to use image templates
1414

1515
Images can be used with HTML markers and various layers within the Azure Maps web SDK:
1616

17-
- Symbol layers can render points on the map with an image icon. Symbols can also be rendered along a lines path.
18-
- Polygon layers can be rendered with a fill pattern image.
19-
- HTML markers can render points using images and other HTML elements.
17+
- Symbol layers can render points on the map with an image icon. Symbols can also be rendered along a lines path.
18+
- Polygon layers can be rendered with a fill pattern image.
19+
- HTML markers can render points using images and other HTML elements.
2020

2121
In order to ensure good performance with layers, load the images into the map image sprite resource before rendering. The [IconOptions](/javascript/api/azure-maps-control/atlas.iconoptions), of the SymbolLayer, preloads a couple of marker images in a handful of colors into the map image sprite, by default. These marker images and more are available as SVG templates. They can be used to create images with custom scales, or used as a customer primary and secondary color. In total there are 42 image templates provided: 27 symbol icons and 15 polygon fill patterns.
2222

@@ -35,20 +35,20 @@ The following code shows how to create an image from one of the built-in templat
3535
```javascript
3636
map.imageSprite.createFromTemplate('myTemplatedIcon', 'marker-flat', 'teal', '#fff').then(function () {
3737

38-
//Add a symbol layer that uses the custom created icon.
39-
map.layers.add(new atlas.layer.SymbolLayer(datasource, null, {
40-
iconOptions: {
41-
image: 'myTemplatedIcon'
42-
}
43-
}));
38+
//Add a symbol layer that uses the custom created icon.
39+
map.layers.add(new atlas.layer.SymbolLayer(datasource, null, {
40+
iconOptions: {
41+
image: 'myTemplatedIcon'
42+
}
43+
}));
4444
});
4545
```
4646

4747
## Use an image template with a symbol layer
4848

4949
Once an image template is loaded into the map image sprite, it can be rendered as a symbol in a symbol layer by referencing the image resource ID in the `image` option of the `iconOptions`.
5050

51-
The following sample renders a symbol layer using the `marker-flat` image template with a teal primary color and a white secondary color.
51+
The following sample renders a symbol layer using the `marker-flat` image template with a teal primary color and a white secondary color.
5252

5353
<br/>
5454

@@ -59,9 +59,9 @@ The following sample renders a symbol layer using the `marker-flat` image templa
5959

6060
## Use an image template along a lines path
6161

62-
Once an image template is loaded into the map image sprite, it can be rendered along the path of a line by adding a LineString to a data source and using a symbol layer with a `lineSpacing`option and by referencing the ID of the image resource in the `image` option of th `iconOptions`.
62+
Once an image template is loaded into the map image sprite, it can be rendered along the path of a line by adding a LineString to a data source and using a symbol layer with a `lineSpacing`option and by referencing the ID of the image resource in the `image` option of th `iconOptions`.
6363

64-
The following sample renders a pink line on the map and uses a symbol layer using the `car` image template with a dodger blue primary color and a white secondary color.
64+
The following sample renders a pink line on the map and uses a symbol layer using the `car` image template with a dodger blue primary color and a white secondary color.
6565

6666
<br/>
6767

@@ -87,7 +87,7 @@ The following sample renders a polygon layer using the `dot` image template with
8787
</iframe>
8888

8989
> [!TIP]
90-
> Setting the secondary color of fill patterns makes it easier to see the underlying map will still providing the primary pattern.
90+
> Setting the secondary color of fill patterns makes it easier to see the underlying map will still providing the primary pattern.
9191
9292
## Use an image template with an HTML marker
9393

@@ -102,9 +102,9 @@ The following sample uses the `marker-arrow` template with a red primary color,
102102
(<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
103103
</iframe>
104104

105-
106105
> [!TIP]
107106
> Image templates can be used outside of the map too. The getImageTemplate funciton returns an SVG string that has placeholders; `{color}`, `{secondaryColor}`, `{scale}`, `{text}`. Replace these placeholder values to create a valid SVG string. You can then either add the SVG string directly to the HTML DOM or convert it into a data URI and insert it into an image tag. For example:
107+
>
108108
> ```JavaScript
109109
> //Retrieve an SVG template and replace the placeholder values.
110110
> var svg = atlas.getImageTemplate('marker').replace(/{color}/, 'red').replace(/{secondaryColor}/, 'white').replace(/{text}/, '').replace(/{scale}/, 1);
@@ -115,24 +115,24 @@ The following sample uses the `marker-arrow` template with a red primary color,
115115
116116
## Create custom reusable templates
117117
118-
If your application uses the same icon with different icons or if you are creating a module that adds additional image templates, you can easily add and retrieve these icons from the Azure Maps web SDK. Use the following static functions on the `atlas` namespace.
118+
If your application uses the same icon within different modules or if you're creating a module that adds more image templates, you can easily add and retrieve these icons from the Azure Maps web SDK. Use the following static functions on the `atlas` namespace.
119119
120-
| Name | Return Type | Description |
121-
|-|-|-|
120+
| Name | Return Type | Description |
121+
|------|-------------|-------------|
122122
| `addImageTemplate(templateName: string, template: string, override: boolean)` | | Adds a custom SVG image template to the atlas namespace. |
123123
| `getImageTemplate(templateName: string, scale?: number)`| string | Retrieves an SVG template by name. |
124124
| `getAllImageTemplateNames()` | string[] | Retrieves an SVG template by name. |
125125
126126
SVG image templates support the following placeholder values:
127127
128-
| Placeholder | Description |
129-
|-|-|
130-
| `{color}` | The primary color. |
131-
| `{secondaryColor}` | The secondary color. |
132-
| `{scale}` | The SVG image is converted to an png image when added to the map image sprite. This placeholder can be used to scale a template before it is converted to ensure it renders clearly. |
128+
| Placeholder | Description |
129+
|-------------|--------------------|
130+
| `{color}` | The primary color. |
131+
| `{secondaryColor}` | The secondary color. |
132+
| `{scale}` | The SVG image is converted to an png image when added to the map image sprite. This placeholder can be used to scale a template before it's converted to ensure it renders clearly. |
133133
| `{text}` | The location to render text when used with an HTML Marker. |
134134
135-
The following example shows how to take an SVG template, and add it to the Azure Maps web SDK as a reusable icon template.
135+
The following example shows how to take an SVG template, and add it to the Azure Maps web SDK as a reusable icon template.
136136
137137
<br/>
138138
@@ -356,7 +356,6 @@ This table lists all image templates currently available within the Azure Maps w
356356
:::column-end:::
357357
:::row-end:::
358358
359-
360359
**Polygon fill pattern templates**
361360
362361
:::row:::
@@ -481,7 +480,7 @@ This table lists all image templates currently available within the Azure Maps w
481480
482481
**Preloaded image icons**
483482
484-
The map preloads a set of icons into the maps image sprite using the `marker`, `pin`, and `pin-round` templates. These icon names and their color values are listed in the table below.
483+
The map preloads a set of icons into the maps image sprite using the `marker`, `pin`, and `pin-round` templates. These icon names and their color values are listed in the following table.
485484
486485
| icon name | color | secondaryColor |
487486
|-----------|-------|----------------|
@@ -497,7 +496,6 @@ The map preloads a set of icons into the maps image sprite using the `marker`, `
497496
| `pin-round-darkblue` | `#003963` | `#ffffff` |
498497
| `pin-round-red` | `#ef4c4c` | `#ffffff` |
499498
500-
501499
## Try it now tool
502500
503501
With the following tool, you can render the different built-in image templates in various ways and customize the primary and secondary colors and scale.
@@ -517,8 +515,7 @@ Learn more about the classes and methods used in this article:
517515
> [ImageSpriteManager](/javascript/api/azure-maps-control/atlas.imagespritemanager)
518516
519517
> [!div class="nextstepaction"]
520-
> [atlas namespace](/javascript/api/azure-maps-control/atlas#functions
521-
)
518+
> [atlas namespace](/javascript/api/azure-maps-control/atlas#functions)
522519
523520
See the following articles for more code samples where image templates can be used:
524521
@@ -532,4 +529,4 @@ See the following articles for more code samples where image templates can be us
532529
> [Add a polygon layer](map-add-shape.md)
533530
534531
> [!div class="nextstepaction"]
535-
> [Add HTML Makers](map-add-bubble-layer.md)
532+
> [Add HTML Makers](map-add-bubble-layer.md)

0 commit comments

Comments
 (0)