Skip to content

Commit 46b9531

Browse files
authored
Merge pull request #109631 from stevemunk/map-add-controls-CodePen
Removed CodePen samples from 'Add controls to a map'
2 parents 94d0288 + fe235a5 commit 46b9531

File tree

3 files changed

+46
-30
lines changed

3 files changed

+46
-30
lines changed
Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
---
22
title: Add controls to a map | Microsoft Azure Maps
33
description: How to add zoom control, pitch control, rotate control and a style picker to a map in Microsoft Azure Maps.
4-
author: eriklindeman
5-
ms.author: eriklind
6-
ms.date: 07/29/2019
4+
author: dubiety
5+
ms.author: yuchungchen
6+
ms.date: 05/15/2023
77
ms.topic: conceptual
88
ms.service: azure-maps
99
ms.custom: devx-track-js
1010
---
1111

1212
# Add controls to a map
1313

14-
This article shows you how to add controls to a map. You'll also learn how to create a map with all controls and a [style picker](./choose-map-style.md).
14+
This article shows you how to add controls to a map. You'll also learn how to create a map with all controls and a [style picker].
1515

1616
## Add zoom control
1717

18-
A zoom control adds buttons for zooming the map in and out. The following code sample creates an instance of the [ZoomControl](/javascript/api/azure-maps-control/atlas.control.zoomcontrol) class, and adds it the bottom-right corner of the map.
18+
A zoom control adds buttons for zooming the map in and out. The following code sample creates an instance of the [ZoomControl] class, and adds it the bottom-right corner of the map.
1919

2020
```javascript
2121
//Construct a zoom control and add it to the map.
@@ -24,16 +24,15 @@ map.controls.add(new atlas.control.ZoomControl(), {
2424
});
2525
```
2626

27-
Below is the complete running code sample of the above functionality.
28-
27+
<!----------------------------------------------------------
2928
<br/>
30-
3129
<iframe height='500' scrolling='no' title='Adding a zoom control' src='//codepen.io/azuremaps/embed/WKOQyN/?height=265&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' loading="lazy" allowtransparency='true' allowfullscreen='true'>See the Pen <a href='https://codepen.io/azuremaps/pen/WKOQyN/'>Adding a zoom control</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
3230
</iframe>
31+
---------------------------------------------------------->
3332

3433
## Add pitch control
3534

36-
A pitch control adds buttons for tilting the pitch to map relative to the horizon. The following code sample creates an instance of the [PitchControl](/javascript/api/azure-maps-control/atlas.control.pitchcontrol) class. It adds the PitchControl to top-right corner of the map.
35+
A pitch control adds buttons for tilting the pitch to map relative to the horizon. The following code sample creates an instance of the [PitchControl] class. It adds the PitchControl to top-right corner of the map.
3736

3837
```javascript
3938
//Construct a pitch control and add it to the map.
@@ -42,16 +41,15 @@ map.controls.add(new atlas.control.PitchControl(), {
4241
});
4342
```
4443

45-
Below is the complete running code sample of the above functionality.
46-
44+
<!----------------------------------------------------------
4745
<br/>
48-
4946
<iframe height='500' scrolling='no' title='Adding a pitch control' src='//codepen.io/azuremaps/embed/xJrwaP/?height=500&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' loading="lazy" allowtransparency='true' allowfullscreen='true'>See the Pen <a href='https://codepen.io/azuremaps/pen/xJrwaP/'>Adding a pitch control</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
5047
</iframe>
48+
---------------------------------------------------------->
5149

5250
## Add compass control
5351

54-
A compass control adds a button for rotating the map. The following code sample creates an instance of the [CompassControl](/javascript/api/azure-maps-control/atlas.control.compasscontrol) class and adds it the bottom-left corner of the map.
52+
A compass control adds a button for rotating the map. The following code sample creates an instance of the [CompassControl] class and adds it the bottom-left corner of the map.
5553

5654
```javascript
5755
//Construct a compass control and add it to the map.
@@ -60,12 +58,11 @@ map.controls.add(new atlas.control.CompassControl(), {
6058
});
6159
```
6260

63-
Below is the complete running code sample of the above functionality.
64-
61+
<!----------------------------------------------------------
6562
<br/>
66-
6763
<iframe height='500' scrolling='no' title='Adding a rotate control' src='//codepen.io/azuremaps/embed/GBEoRb/?height=500&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' loading="lazy" allowtransparency='true' allowfullscreen='true'>See the Pen <a href='https://codepen.io/azuremaps/pen/GBEoRb/'>Adding a rotate control</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
6864
</iframe>
65+
---------------------------------------------------------->
6966

7067
## A Map with all controls
7168

@@ -82,25 +79,31 @@ map.controls.add([
8279
});
8380
```
8481

85-
The following code sample adds the zoom, compass, pitch, and style picker controls to the top-right corner of the map. Notice how they automatically stack. The order of the control objects in the script dictates the order in which they appear on the map. To change the order of the controls on the map, you can change their order in the array.
82+
The following image shows a map with the zoom, compass, pitch, and style picker controls in the top-right corner of the map. Notice how they automatically stack. The order of the control objects in the script dictates the order in which they appear on the map. To change the order of the controls on the map, you can change their order in the array.
8683

87-
<br/>
84+
:::image type="content" source="./media/map-add-controls/map-with-all-controls.png" alt-text="Screenshot showing a map displaying zoom, compass, pitch and style controls.":::
8885

86+
<!----------------------------------------------------------
87+
<br/>
8988
<iframe height='500' scrolling='no' title='A map with all the controls' src='//codepen.io/azuremaps/embed/qyjbOM/?height=500&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' loading="lazy" allowtransparency='true' allowfullscreen='true'>See the Pen <a href='https://codepen.io/azuremaps/pen/qyjbOM/'>A map with all the controls</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
9089
</iframe>
90+
---------------------------------------------------------->
9191

92-
The style picker control is defined by the [StyleControl](/javascript/api/azure-maps-control/atlas.control.stylecontrol) class. For more information on using the style picker control, see [choose a map style](choose-map-style.md).
92+
The style picker control is defined by the [StyleControl] class. For more information on using the style picker control, see [choose a map style].
9393

9494
## Customize controls
9595

96-
Here is a tool to test out the various options for customizing the controls.
96+
The [Navigation Control Options] sample is a tool to test out the various options for customizing the controls.
9797

98-
<br/>
98+
:::image type="content" source="./media/map-add-controls/map-navigation-control-options.png" alt-text="Screenshot showing the Map Navigation Control Options sample, which contains a map displaying zoom, compass, pitch and style controls and options on the left side of the screen that enable you to change the Control Position, Control Style, Zoom Delta, Pitch Delta, Compass Rotation Delta, Picker Styles, and Style Picker Layout properties.":::
9999

100+
<!----------------------------------------------------------
101+
<br/>
100102
<iframe height="700" scrolling="no" title="Navigation control options" src="//codepen.io/azuremaps/embed/LwBZMx/?height=700&theme-id=0&default-tab=result" frameborder='no' loading="lazy" allowtransparency="true" allowfullscreen="true">
101103
See the Pen <a href='https://codepen.io/azuremaps/pen/LwBZMx/'>Navigation control options</a> by Azure Maps
102104
(<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
103105
</iframe>
106+
---------------------------------------------------------->
104107

105108
If you want to create customized navigation controls, create a class that extends from the `atlas.Control` class or create an HTML element and position it above the map div. Have this UI control call the maps `setCamera` function to move the map.
106109

@@ -109,30 +112,43 @@ If you want to create customized navigation controls, create a class that extend
109112
Learn more about the classes and methods used in this article:
110113

111114
> [!div class="nextstepaction"]
112-
> [Compass Control](/javascript/api/azure-maps-control/atlas.control.compasscontrol)
115+
> [CompassControl]
113116
114117
> [!div class="nextstepaction"]
115-
> [PitchControl](/javascript/api/azure-maps-control/atlas.control.pitchcontrol)
118+
> [PitchControl]
116119
117120
> [!div class="nextstepaction"]
118-
> [StyleControl](/javascript/api/azure-maps-control/atlas.control.stylecontrol)
121+
> [StyleControl]
119122
120123
> [!div class="nextstepaction"]
121-
> [ZoomControl](/javascript/api/azure-maps-control/atlas.control.zoomcontrol)
124+
> [ZoomControl]
122125
123126
See the following articles for full code:
124127

125128
> [!div class="nextstepaction"]
126-
> [Add a pin](./map-add-pin.md)
129+
> [Add a pin]
127130
128131
> [!div class="nextstepaction"]
129-
> [Add a popup](./map-add-popup.md)
132+
> [Add a popup]
130133
131134
> [!div class="nextstepaction"]
132-
> [Add a line layer](map-add-line-layer.md)
135+
> [Add a line layer]
133136
134137
> [!div class="nextstepaction"]
135-
> [Add a polygon layer](map-add-shape.md)
138+
> [Add a polygon layer]
136139
137140
> [!div class="nextstepaction"]
138-
> [Add a bubble layer](map-add-bubble-layer.md)
141+
> [Add a bubble layer]
142+
143+
[style picker]: choose-map-style.md
144+
[ZoomControl]: /javascript/api/azure-maps-control/atlas.control.zoomcontrol
145+
[PitchControl]: /javascript/api/azure-maps-control/atlas.control.pitchcontrol
146+
[CompassControl]: /javascript/api/azure-maps-control/atlas.control.compasscontrol
147+
[StyleControl]: /javascript/api/azure-maps-control/atlas.control.stylecontrol
148+
[Navigation Control Options]: https://samples.azuremaps.com/?search=Map%20Navigation%20Control%20Options&sample=map-navigation-control-options
149+
[choose a map style]: choose-map-style.md
150+
[Add a pin]: map-add-pin.md
151+
[Add a popup]: map-add-popup.md
152+
[Add a line layer]: map-add-line-layer.md
153+
[Add a polygon layer]: map-add-shape.md
154+
[Add a bubble layer]: map-add-bubble-layer.md
922 KB
Loading
502 KB
Loading

0 commit comments

Comments
 (0)