Skip to content

Commit b1495f7

Browse files
authored
Merge pull request #183733 from MicrosoftDocs/master
12/28/2021 AM Publish
2 parents 731ca82 + fbd86c6 commit b1495f7

File tree

99 files changed

+1370
-1070
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+1370
-1070
lines changed

articles/automanage/automanage-hotpatch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ To start using Hotpatch on a new VM, follow these steps:
6262
The following example describes how to enable the preview for your subscription:
6363

6464
```
65-
POST on `/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/Microsoft.Compute/features/ InGuestHotPatchVMPreview/register?api-version=2015-12-01`
65+
POST on `/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/Microsoft.Compute/features/InGuestHotPatchVMPreview/register?api-version=2015-12-01`
6666
POST on `/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/Microsoft.Compute/features/InGuestAutoPatchVMPreview/register?api-version=2015-12-01`
6767
POST on `/subscriptions/{subscriptionId}/providers/Microsoft.Features/providers/Microsoft.Compute/features/InGuestPatchVMPreview/register?api-version=2015-12-01`
6868
```

articles/azure-maps/tutorial-search-location.md

Lines changed: 48 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
2-
title: 'Tutorial: Search for nearby locations on a map | Microsoft Azure Maps'
2+
title: 'Tutorial: Search for nearby locations on a map'
3+
titleSuffix: Microsoft Azure Maps
34
description: Tutorial on how to search for points of interest on a map. See how to use the Azure Maps Web SDK to add search capabilities and interactive pop-up boxes to a map.
45
author: stevemunk
56
ms.author: v-munksteve
6-
ms.date: 10/28/2021
7+
ms.date: 12/23/2021
78
ms.topic: tutorial
89
ms.service: azure-maps
910
services: azure-maps
@@ -44,13 +45,12 @@ The Map Control API is a convenient client library. This API allows you to easil
4445
<html>
4546
<head>
4647
<title>Map Search</title>
47-
<meta charset="utf-8">
48-
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
49-
48+
<meta charset="utf-8" />
49+
5050
<!-- Add references to the Azure Maps Map control JavaScript and CSS files. -->
51-
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" type="text/css">
51+
<link rel="stylesheet" href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.css" type="text/css" />
5252
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/2/atlas.min.js"></script>
53-
53+
5454
<!-- Add a reference to the Azure Maps Services Module JavaScript file. -->
5555
<script src="https://atlas.microsoft.com/sdk/javascript/service/2/atlas-service.min.js"></script>
5656

@@ -81,26 +81,36 @@ The Map Control API is a convenient client library. This API allows you to easil
8181
</html>
8282
```
8383

84-
Notice that the HTML header includes the CSS and JavaScript resource files hosted by the Azure Map Control library. Note the `onload` event on the body of the page, which will call the `GetMap` function when the body of the page has loaded. The `GetMap` function will contain the inline JavaScript code to access the Azure Maps APIs.
84+
Some things to know regarding the above HTML:
85+
86+
* The HTML header includes CSS and JavaScript resource files that are hosted by the Azure Map Control library.
87+
* The `onload` event in the body of the page calls the `GetMap` function when the body of the page has loaded.
88+
* The `GetMap` function will contain the inline JavaScript code used to access the Azure Maps APIs. It is added in the next step.
8589

86-
3. Add the following JavaScript code to the `GetMap` function of the HTML file. Replace the string `<Your Azure Maps Key>` with the primary key that you copied from your Maps account.
90+
3. Add the following JavaScript code to the `GetMap` function of the HTML file. Replace the string `<Your Azure Maps Key>` with the primary key that you copied from your Azure Maps account.
8791

8892
```JavaScript
8993
//Instantiate a map object
9094
var map = new atlas.Map("myMap", {
91-
//Add your Azure Maps subscription key to the map SDK. Get an Azure Maps key at https://azure.com/maps
95+
view: 'Auto',
96+
97+
// Add your Azure Maps primary subscription key. https://aka.ms/am-primaryKey
9298
authOptions: {
9399
authType: 'subscriptionKey',
94100
subscriptionKey: '<Your Azure Maps Key>'
95101
}
96102
});
97103
```
98104

99-
This segment initializes the Map Control API for your Azure Maps account key. `atlas` is the namespace that contains the API and related visual components. `atlas.Map` provides the control for a visual and interactive web map.
105+
Some things to know regarding the above JavaScript:
106+
107+
* This is the core of the `GetMap` function, which initializes the Map Control API for your Azure Maps account key.
108+
* `atlas` is the namespace that contains the API and related visual components.
109+
* `atlas.Map` provides the control for a visual and interactive web map.
100110

101111
4. Save your changes to the file and open the HTML page in a browser. The map shown is the most basic map that you can make by calling `atlas.Map` using your account key.
102112

103-
![View the map](./media/tutorial-search-location/basic-map.png)
113+
![A screen shot showing the most basic map that you can make by calling atlas.Map using your Azure Maps account key.](./media/tutorial-search-location/basic-map.png)
104114

105115
5. In the `GetMap` function, after initializing the map, add the following JavaScript code.
106116

@@ -128,7 +138,12 @@ The Map Control API is a convenient client library. This API allows you to easil
128138
});
129139
```
130140

131-
In this code segment, a `ready` event is added to the map, which will fire when the map resources have been loaded and the map is ready to be accessed. In the map `ready` event handler, a data source is created to store result data. A symbol layer is created and attached to the data source. This layer specifies how the result data in the data source should be rendered. In this case, the result is rendered with a dark blue round pin icon, centered over the results coordinate, and allows other icons to overlap. The result layer is added to the map layers.
141+
About this code:
142+
143+
* A `ready` event is added to the map, which fires when the map resources finnish loading and the map is ready to be accessed.
144+
* In the map `ready` event handler, a data source is created to store result data.
145+
* A symbol layer is created and attached to the data source. This layer specifies how the result data in the data source should be rendered. In this case, the result is rendered with a dark blue round pin icon, centered over the results coordinate, that allows other icons to overlap.
146+
* The result layer is added to the map layers.
132147

133148
<a id="usesearch"></a>
134149

@@ -138,25 +153,24 @@ This section shows how to use the Maps [Search API](/rest/api/maps/search) to fi
138153

139154
### Service Module
140155

141-
1. In the map `ready` event handler, construct the search service URL by adding the following JavaScript code.
156+
1. In the map `ready` event handler, construct the search service URL by adding the following JavaScript code immediately after `map.layers.add(resultLayer);`:
142157

143158
```javascript
144-
// Use SubscriptionKeyCredential with a subscription key
145-
var subscriptionKeyCredential = new atlas.service.SubscriptionKeyCredential(atlas. getSubscriptionKey());
146-
147-
// Use subscriptionKeyCredential to create a pipeline
148-
var pipeline = atlas.service.MapsURL.newPipeline(subscriptionKeyCredential);
149-
159+
//Use MapControlCredential to share authentication between a map control and the service module.
160+
var pipeline = atlas.service.MapsURL.newPipeline(new atlas.service.MapControlCredential(map));
161+
150162
// Construct the SearchURL object
151163
var searchURL = new atlas.service.SearchURL(pipeline);
152164
```
153165

154-
The `SubscriptionKeyCredential` creates a `SubscriptionKeyCredentialPolicy` to authenticate HTTP requests to Azure Maps with the subscription key. The `atlas.service.MapsURL.newPipeline()` takes in the `SubscriptionKeyCredential` policy and creates a [Pipeline](/javascript/api/azure-maps-rest/atlas.service.pipeline) instance. The `searchURL` represents a URL to Azure Maps [Search](/rest/api/maps/search) operations.
166+
* Use [MapControlCredential](/javascript/api/azure-maps-rest/atlas.service.mapcontrolcredential) to share authentication between a map control and the service module when creating a new [pipeline](/javascript/api/azure-maps-rest/atlas.service.pipeline) object.
167+
168+
* The [searchURL](/javascript/api/azure-maps-rest/atlas.service.searchurl) represents a URL to Azure Maps [Search](/rest/api/maps/search) operations.
155169

156-
2. Next add the following script block to build the search query. It uses the Fuzzy Search Service, which is a basic search API of the Search Service. Fuzzy Search Service handles most fuzzy inputs like addresses, places, and points of interest (POI). This code searches for nearby Gasoline Stations within the specified radius of the provided latitude and longitude. A GeoJSON feature collection from the response is then extracted using the `geojson.getFeatures()` method and added to the data source, which automatically results in the data being rendered on the map via the symbol layer. The last part of the script sets the maps camera view using the bounding box of the results using the Map's [setCamera](/javascript/api/azure-maps-control/atlas.map#setcamera-cameraoptions---cameraboundsoptions---animationoptions-) property.
170+
2. Next add the following script block just below the previous code just added in the map `ready` event handler. This is the code to build the search query. It uses the [Fuzzy Search Service](/rest/api/maps/search/get-search-fuzzy), a basic search API of the Search Service. Fuzzy Search Service handles most fuzzy inputs like addresses, places, and points of interest (POI). This code searches for nearby gas stations within the specified radius of the provided latitude and longitude. A GeoJSON feature collection from the response is then extracted using the `geojson.getFeatures()` method and added to the data source, which automatically results in the data being rendered on the maps symbol layer. The last part of this script block sets the maps camera view using the bounding box of the results using the Map's [setCamera](/javascript/api/azure-maps-control/atlas.map#setcamera-cameraoptions---cameraboundsoptions---animationoptions-) property.
157171

158172
```JavaScript
159-
var query = 'gasoline-station';
173+
var query = 'gasoline-station';
160174
var radius = 9000;
161175
var lat = 47.64452336193245;
162176
var lon = -122.13687658309935;
@@ -165,7 +179,8 @@ This section shows how to use the Maps [Search API](/rest/api/maps/search) to fi
165179
limit: 10,
166180
lat: lat,
167181
lon: lon,
168-
radius: radius
182+
radius: radius,
183+
view: 'Auto'
169184
}).then((results) => {
170185

171186
// Extract GeoJSON feature collection from the response and add it to the datasource
@@ -175,14 +190,15 @@ This section shows how to use the Maps [Search API](/rest/api/maps/search) to fi
175190
// set camera to bounds to show the results
176191
map.setCamera({
177192
bounds: data.bbox,
178-
zoom: 10
193+
zoom: 10,
194+
padding: 15
179195
});
180196
});
181197
```
182198

183-
3. Save the **MapSearch.html** file and refresh your browser. You should see the map centered on Seattle with round-blue pins for locations of gasoline stations in the area.
199+
3. Save the **MapSearch.html** file and refresh your browser. You should see the map centered on Seattle with round-blue pins for locations of gas stations in the area.
184200

185-
![View the map with search results](./media/tutorial-search-location/pins-map.png)
201+
![A screen shot showing the map resulting from the search, which is a map showing Seattle with round-blue pins at locations of gas stations.](./media/tutorial-search-location/pins-map.png)
186202

187203
4. You can see the raw data that the map is rendering by entering the following HTTPRequest in your browser. Replace \<Your Azure Maps Key\> with your primary key.
188204

@@ -206,9 +222,9 @@ The map that we've made so far only looks at the longitude/latitude data for the
206222
map.events.add('mouseover', resultLayer, showPopup);
207223
```
208224

209-
The API `*atlas.Popup` provides an information window anchored at the required position on the map.
225+
The API `*atlas.Popup` provides an information window anchored at the required position on the map.
210226

211-
2. Add the following code within the `GetMap` function, to show the moused over result information in the popup.
227+
2. Add the following lines of code in the map `ready` event handler after the code to create an instance of a Popup and add a mouseover event to the symbol layer. This code shows a popup window with the results when you mouse over a point of interest.
212228

213229
```JavaScript
214230
function showPopup(e) {
@@ -238,13 +254,10 @@ The map that we've made so far only looks at the longitude/latitude data for the
238254

239255
3. Save the file and refresh your browser. Now the map in the browser shows information popups when you hover over any of the search pins.
240256

241-
![Azure Map Control and Search Service](./media/tutorial-search-location/popup-map.png)
242-
243-
To view the full code for this tutorial, click [here](https://github.com/Azure-Samples/AzureMapsCodeSamples/blob/master/AzureMapsCodeSamples/Tutorials/search.html). To view the live sample, click [here](https://azuremapscodesamples.azurewebsites.net/?sample=Search%20for%20points%20of%20interest)
244-
245-
## Clean up resources
257+
![A screen shot of a map with information popups that appear when you hover over a search pin.](./media/tutorial-search-location/popup-map.png)
246258

247-
There are no resources that require cleanup.
259+
* For the completed code used in this tutorial, see [search.html](https://github.com/Azure-Samples/AzureMapsCodeSamples/blob/master/AzureMapsCodeSamples/Tutorials/search.html) on GitHub.
260+
* To view this sample live, see [Search for points of interest](https://azuremapscodesamples.azurewebsites.net/?sample=Search%20for%20points%20of%20interest) on the **Azure Maps Code Samples** site.
248261

249262
## Next steps
250263

0 commit comments

Comments
 (0)