Skip to content

Commit 0f30735

Browse files
authored
Merge pull request #238006 from eriklindeman/codepen-choose-map-style
Codepen choose map style
2 parents 2423899 + 00c5c53 commit 0f30735

File tree

4 files changed

+34
-9
lines changed

4 files changed

+34
-9
lines changed

articles/azure-maps/choose-map-style.md

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,23 @@ map.setStyle({
3838
});
3939
```
4040
41-
The following tool shows how the different style options change how the map is rendered. To see the 3D buildings, zoom in close to a major city.
41+
For a fully functional sample that shows how the different styles affect how the map is rendered, see [Map style options] in the [Azure Maps Samples].
4242
43+
<!-----------------------------------------------------------------------------------------------
4344
<br/>
44-
4545
<iframe height="700" scrolling="no" title="Map style options" src="https://codepen.io/azuremaps/embed/eYNMjPb?height=700&theme-id=0&default-tab=result" frameborder="no" allowtransparency="true" allowfullscreen="true">
4646
See the Pen <a href='https://codepen.io/azuremaps/pen/eYNMjPb'>Map style options</a> by Azure Maps
4747
(<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
4848
</iframe>
49-
49+
----------------------------------------------------------------------------------------------->
5050
## Set a base map style
5151
5252
You can also initialize the map control with one of the [base map styles] that are available in the Web SDK. You can then use the `setStyle` function to update the base style with a different map style.
5353
5454
### Set a base map style on initialization
5555
56-
Base styles of the map control can be set during initialization. In the following code, the `style` option of the map control is set to the [`grayscale_dark` base map style].
56+
Base styles of the map control can be set during initialization. In the following code, the `style` option of the map control is set to the
57+
[grayscale_dark] base map style.
5758
5859
```javascript
5960
var map = new atlas.Map('map', {
@@ -63,25 +64,32 @@ var map = new atlas.Map('map', {
6364
);
6465
```
6566
66-
<br/>
67+
:::image type="content" source="./media/choose-map-style/set-base-map-style-on-initialization.png" alt-text="Screenshot showing the grayscale dark style being set during the map load process.":::
6768
69+
<!-----------------------------------------------------------------------------------------------
70+
<br/>
6871
<iframe height='500' scrolling='no' title='Setting the style on map load' src='//codepen.io/azuremaps/embed/WKOQRq/?height=265&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' allowtransparency='true' allowfullscreen='true'>See the Pen <a href='https://codepen.io/azuremaps/pen/WKOQRq/'>Setting the style on map load</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
6972
</iframe>
73+
----------------------------------------------------------------------------------------------->
7074
7175
### Update the base map style
7276
7377
The base map style can be updated by using the `setStyle` function and setting the `style` option to either change to a different base map style or add more style options.
7478
79+
In the following code, after a map instance is loaded, the map style is updated from `grayscale_dark` to `satellite` using the [setStyle] function.
80+
7581
```javascript
7682
map.setStyle({ style: 'satellite' });
7783
```
7884
79-
In the following code, after a map instance is loaded, the map style is updated from `grayscale_dark` to `satellite` using the [setStyle] function.
85+
:::image type="content" source="./media/choose-map-style/update-base-map-style.png" alt-text="Screenshot showing the satellite style, set after the map load process.":::
8086
87+
<!-----------------------------------------------------------------------------------------------
8188
<br/>
8289
8390
<iframe height='500' scrolling='no' title='Updating the style' src='//codepen.io/azuremaps/embed/yqXYzY/?height=265&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' allowtransparency='true' allowfullscreen='true'>See the Pen <a href='https://codepen.io/azuremaps/pen/yqXYzY/'>Updating the style</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
8491
</iframe>
92+
----------------------------------------------------------------------------------------------->
8593
8694
## Add the style picker control
8795
@@ -102,10 +110,24 @@ The following image shows the style picker control displayed in `list` layout.
102110
103111
The following code shows you how to override the default `mapStyles` base style list. In this example, we're setting the `mapStyles` option to list the base styles to display in the style picker control.
104112
113+
```javascript
114+
/*Add the Style Control to the map*/
115+
map.controls.add(new atlas.control.StyleControl({
116+
mapStyles: ['road', 'grayscale_dark', 'night', 'road_shaded_relief', 'satellite', 'satellite_road_labels'],
117+
layout: 'list'
118+
}), {
119+
position: 'top-right'
120+
});
121+
```
122+
123+
:::image type="content" source="./media/choose-map-style/Add-style-picker-control.png" alt-text="Screenshot showing a map with the Style picker control with the layout property set to list.":::
124+
125+
<!-----------------------------------------------------------------------------------------------
105126
<br/>
106127
107128
<iframe height='500' scrolling='no' title='Adding the style picker' src='//codepen.io/azuremaps/embed/OwgyvG/?height=265&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' allowtransparency='true' allowfullscreen='true'>See the Pen <a href='https://codepen.io/azuremaps/pen/OwgyvG/'>Adding the style picker</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
108129
</iframe>
130+
----------------------------------------------------------------------------------------------->
109131
110132
## Next steps
111133
@@ -136,13 +158,16 @@ See the following articles for more code samples to add to your maps:
136158
137159
[style options]: /javascript/api/azure-maps-control/atlas.styleoptions
138160
[base map styles]: supported-map-styles.md
139-
[`grayscale_dark` base map style]: supported-map-styles.md#grayscale_dark
140-
[setStyle]: /javascript/api/azure-maps-control/atlas.map#setstyle-styleoptions-
161+
162+
[grayscale_dark]: supported-map-styles.md#grayscale_dark
163+
[setStyle]: /javascript/api/azure-maps-control/atlas.map?view=azure-maps-typescript-latest#azure-maps-control-atlas-map-setstyle
141164
[Style Control Options]: /javascript/api/azure-maps-control/atlas.stylecontroloptions
142165
[Map]: /javascript/api/azure-maps-control/atlas.map
143166
[StyleOptions]: /javascript/api/azure-maps-control/atlas.styleoptions
144167
[StyleControl]: /javascript/api/azure-maps-control/atlas.control.stylecontrol
145168
[StyleControlOptions]: /javascript/api/azure-maps-control/atlas.stylecontroloptions
146169
[Add map controls]: map-add-controls.md
147170
[Add a symbol layer]: map-add-pin.md
148-
[Add a bubble layer]: map-add-bubble-layer.md
171+
[Add a bubble layer]: map-add-bubble-layer.md
172+
[Map style options]: https://samples.azuremaps.com/?search=style%20option&sample=map-style-options
173+
[Azure Maps Samples]: https://samples.azuremaps.com
101 KB
Loading
142 KB
Loading
464 KB
Loading

0 commit comments

Comments
 (0)