You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-maps/how-to-use-map-control.md
+33-24Lines changed: 33 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,9 @@
2
2
title: How to use the Azure Maps web map control
3
3
titleSuffix: Microsoft Azure Maps
4
4
description: Learn how to add and localize maps to web and mobile applications by using the Map Control client-side JavaScript library in Azure Maps.
5
-
author: eriklindeman
6
-
ms.author: eriklind
7
-
ms.date: 11/29/2021
5
+
author: dubiety
6
+
ms.author: yuchungchen
7
+
ms.date: 06/29/2023
8
8
ms.topic: how-to
9
9
ms.service: azure-maps
10
10
services: azure-maps
@@ -15,15 +15,15 @@ ms.custom: devx-track-js
15
15
16
16
The Map Control client-side JavaScript library allows you to render maps and embedded Azure Maps functionality into your web or mobile application.
17
17
18
-
This article uses the Azure Maps Web SDK, however the Azure Maps services work with any map control. For a list of third-party map control plug-ins, see [Azure Maps community - Open-source projects](open-source-projects.md#third-part-map-control-plugins).
18
+
This article uses the Azure Maps Web SDK, however the Azure Maps services work with any map control. For a list of third-party map control plug-ins, see [Azure Maps community - Open-source projects].
19
19
20
20
## Prerequisites
21
21
22
22
To use the Map Control in a web page, you must have one of the following prerequisites:
23
23
24
24
* An [Azure Maps account]
25
25
* A [subscription key]
26
-
* Obtain your Azure Active Directory (AAD) credentials with [authentication options]
26
+
* Obtain your Azure Active Directory (Azure AD) credentials with [authentication options]
27
27
28
28
## Create a new map in a web page
29
29
@@ -33,18 +33,18 @@ You can embed a map in a web page by using the Map Control client-side JavaScrip
33
33
34
34
2. Load in the Azure Maps Web SDK. You can choose one of two options:
35
35
36
-
* Use the globally hosted CDN version of the Azure Maps Web SDK by adding references to the JavaScript and stylesheet in the `<head>` element of the HTML file:
36
+
* Use the globally hosted CDN version of the Azure Maps Web SDK by adding references to the JavaScript and `stylesheet` in the `<head>` element of the HTML file:
* Load the Azure Maps Web SDK source code locally using the [azure-maps-control](https://www.npmjs.com/package/azure-maps-control) npm package and host it with your app. This package also includes TypeScript definitions.
43
+
* Load the Azure Maps Web SDK source code locally using the [azure-maps-control] npm package and host it with your app. This package also includes TypeScript definitions.
44
44
45
45
> **npm install azure-maps-control**
46
46
47
-
Then add references to the Azure Maps stylesheet to the `<head>` element of the file:
47
+
Then add references to the Azure Maps `stylesheet` to the `<head>` element of the file:
@@ -80,7 +80,7 @@ You can embed a map in a web page by using the Map Control client-side JavaScrip
80
80
</body>
81
81
```
82
82
83
-
5.Now, we'll initialize the map control. In order to authenticate the control, you'll either need to own an Azure Maps subscription key or use Azure Active Directory (AAD) credentials with [authentication options](/javascript/api/azure-maps-control/atlas.authenticationoptions).
83
+
5.Next, initialize the map control. In order to authenticate the control, use an Azure Maps subscription key or Azure AD credentials with [authentication options].
84
84
85
85
If you're using a subscription key for authentication, copy and paste the following script element inside the `<head>` element, and below the first `<script>` element. Replace `<Your Azure Maps Key>` with your Azure Maps subscription key.
86
86
@@ -101,7 +101,7 @@ You can embed a map in a web page by using the Map Control client-side JavaScrip
101
101
</script>
102
102
```
103
103
104
-
If you're using Azure Active Directory (AAD) for authentication, copy and paste the following script element inside the `<head>` element, and below the first `<script>` element.
104
+
If you're using Azure AD for authentication, copy and paste the following script element inside the `<head>` element, and below the first `<script>` element.
105
105
106
106
```HTML
107
107
<script type="text/javascript">
@@ -122,7 +122,7 @@ You can embed a map in a web page by using the Map Control client-side JavaScrip
122
122
</script>
123
123
```
124
124
125
-
For more information about authentication with Azure Maps, see the [Authentication with Azure Maps](azure-maps-authentication.md) document. For a list of samples showing how to integrate Azure Active Directory (AAD) with Azure Maps, see [Azure Maps & Azure Active Directory Samples](https://github.com/Azure-Samples/Azure-Maps-AzureAD-Samples) in GitHub.
125
+
For more information about authentication with Azure Maps, see the [Authentication with Azure Maps] document. For a list of samples showing how to integrate Azure AD with Azure Maps, see [Azure Maps & Azure Active Directory Samples] in GitHub.
126
126
127
127
>[!TIP]
128
128
>In this example, we've passed in the `id` of the map `<div>`. Another way to do this is to pass in the `HTMLElement` object by passing`document.getElementById('myMap')` as the first parameter.
@@ -137,7 +137,7 @@ You can embed a map in a web page by using the Map Control client-side JavaScrip
Azure Maps provides two different ways of setting the language and regional view for the rendered map. The first option is to add this information to the global `atlas` namespace, which will result in all map control instances in your app defaulting to these settings. The following sets the language to French ("fr-FR") and the regional view to "Auto":
200
+
Azure Maps provides two different ways of setting the language and regional view for the rendered map. The first option is to add this information to the global `atlas` namespace, which results in all map control instances in your app defaulting to these settings. The following sets the language to French ("fr-FR") and the regional view to "Auto":
201
201
202
202
```javascript
203
203
atlas.setLanguage('fr-FR');
@@ -223,15 +223,15 @@ map = new atlas.Map('myMap', {
223
223
> [!NOTE]
224
224
> It is possible to load multiple map instances on the same page with different language and region settings. Additionally, these settings can be updated after the map loads using the `setStyle` function of the map.
225
225
226
-
Here is an example of Azure Maps with the language set to "fr-FR" and the regional view set to "Auto".
226
+
Here's an example of Azure Maps with the language set to "fr-FR" and the regional view set to `Auto`.
227
227
228
228

229
229
230
-
For a list of supported languages and regional views, see [Localization support in Azure Maps](supported-languages.md).
230
+
For a list of supported languages and regional views, see [Localization support in Azure Maps].
231
231
232
232
## Azure Government cloud support
233
233
234
-
The Azure Maps Web SDK supports the Azure Government cloud. All JavaScript and CSS URLs used to access the Azure Maps Web SDK remain the same. The following tasks will need to be done to connect to the Azure Government cloud version of the Azure Maps platform.
234
+
The Azure Maps Web SDK supports the Azure Government cloud. All JavaScript and CSS URLs used to access the Azure Maps Web SDK remain the same. The following tasks need to be done to connect to the Azure Government cloud version of the Azure Maps platform.
235
235
236
236
When using the interactive map control, add the following line of code before creating an instance of the `Map` class.
Be sure to use Azure Maps authentication details from the Azure Government cloud platform when authenticating the map and services.
243
243
244
-
When using the services module, the domain for the services needs to be set when creating an instance of an API URL endpoint. For example, the following code creates an instance of the `SearchURL` class and points the domain to the Azure Government cloud.
244
+
The domain for the services needs to be set when creating an instance of an API URL endpoint, when using the services module. For example, the following code creates an instance of the `SearchURL` class and points the domain to the Azure Government cloud.
245
245
246
246
```javascript
247
247
var searchURL =newatlas.service.SearchURL(pipeline, 'atlas.azure.us');
@@ -253,10 +253,10 @@ If directly accessing the Azure Maps REST services, change the URL domain to `at
253
253
254
254
If developing using a JavaScript framework, one of the following open-source projects may be useful:
255
255
256
-
*[ng-azure-maps](https://github.com/arnaudleclerc/ng-azure-maps) - Angular 10 wrapper around Azure maps.
257
-
*[AzureMapsControl.Components](https://github.com/arnaudleclerc/AzureMapsControl.Components) - An Azure Maps Blazor component.
258
-
*[Azure Maps React Component](https://github.com/WiredSolutions/react-azure-maps) - A react wrapper for the Azure Maps control.
259
-
*[Vue Azure Maps](https://github.com/rickyruiz/vue-azure-maps) - An Azure Maps component for Vue application.
256
+
*[ng-azure-maps] - Angular 10 wrapper around Azure maps.
257
+
*[AzureMapsControl.Components] - An Azure Maps Blazor component.
258
+
*[Azure Maps React Component] - A react wrapper for the Azure Maps control.
259
+
*[Vue Azure Maps] - An Azure Maps component for Vue application.
260
260
261
261
## Next steps
262
262
@@ -278,11 +278,20 @@ Learn best practices and see samples:
0 commit comments