Skip to content

Commit e1e09e4

Browse files
committed
Fix async batch geocode problem
1 parent c5864c4 commit e1e09e4

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Samples/Services Module/Methods for geocoding multiple addresses/Methods for geocoding multiple addresses.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<link href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css" rel="stylesheet" />
1818
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js"></script>
1919

20+
<!-- Add a reference to the Azure Maps Services Module JavaScript file. -->
21+
<script src="https://atlas.microsoft.com/sdk/javascript/service/2/atlas-service.min.js"></script>
22+
2023
<!-- Add a reference to the Azure Maps Rest Helper JavaScript file. -->
2124
<script src="https://samples.azuremaps.com/lib/azure-maps/azure-maps-helper.min.js"></script>
2225

@@ -146,8 +149,11 @@
146149
map.layers.add(new atlas.layer.BubbleLayer(datasource));
147150
});
148151

152+
//Use MapControlCredential to share authentication between a map control and the service module.
153+
var pipeline = atlas.service.MapsURL.newPipeline(new atlas.service.MapControlCredential(map));
154+
149155
//Create an instance of the SearchURL client.
150-
searchURL = new atlas.service.SearchURL(pipeline, atlas.getDomain());
156+
searchURL = new atlas.service.SearchURL(pipeline);
151157
}
152158

153159
var searchMethod;
@@ -223,12 +229,13 @@
223229
var requestUrl = 'https://{azMapsDomain}/search/address/batch/json?api-version=1.0';
224230
var res = await processPostRequest(requestUrl, body);
225231

226-
//Ge tthe batch status URL from the "location" response header.
232+
//Get the batch status URL from the "location" response header.
227233
var batchStatusUrl = res.headers.get('location');
234+
var signedRequest = await signRequest(requestUrl);
228235

229-
//Check the statuc of the batch job.
236+
//Check the status of the batch job.
230237
var res2 = await fetch(batchStatusUrl, {
231-
headers: new Headers(requestParams.headers)
238+
headers: new Headers(signedRequest.headers)
232239
});
233240

234241
//Check to see if batch process if complete.

0 commit comments

Comments
 (0)