Skip to content

Commit 8f0f2c4

Browse files
Merge pull request #87752 from KingdomOfEnds/am-code-formatting
code formatting
2 parents 78c1ec0 + b5843df commit 8f0f2c4

File tree

4 files changed

+70
-69
lines changed

4 files changed

+70
-69
lines changed

articles/azure-maps/how-to-use-services-module.md

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -68,52 +68,52 @@ The Azure Maps Web SDK provides a *services module*. This module is a helper lib
6868
// This time-out must be cleared when the TokenCredential object is no longer needed.
6969
// If the time-out is not cleared, the memory used by the TokenCredential will never be reclaimed.
7070
var renewToken = async () => {
71-
try {
72-
console.log("Renewing token");
73-
var token = await getAadToken();
74-
tokenCredential.token = token;
75-
tokenRenewalTimer = setTimeout(renewToken, getExpiration(token));
76-
} catch (error) {
77-
console.log("Caught error when renewing token");
78-
clearTimeout(tokenRenewalTimer);
79-
throw error;
80-
}
71+
try {
72+
console.log("Renewing token");
73+
var token = await getAadToken();
74+
tokenCredential.token = token;
75+
tokenRenewalTimer = setTimeout(renewToken, getExpiration(token));
76+
} catch (error) {
77+
console.log("Caught error when renewing token");
78+
clearTimeout(tokenRenewalTimer);
79+
throw error;
80+
}
8181
}
8282
tokenRenewalTimer = setTimeout(renewToken, getExpiration(aadToken));
8383

8484
// Use tokenCredential to create a pipeline.
8585
var pipeline = atlas.service.MapsURL.newPipeline(tokenCredential, {
86-
retryOptions: { maxTries: 4 } // Retry options
86+
retryOptions: { maxTries: 4 } // Retry options
8787
});
8888

8989
// Create an instance of the SearchURL client.
9090
var searchURL = new atlas.service.SearchURL(pipeline);
9191

9292
function getAadToken() {
93-
// Use the signed-in auth context to get a token.
94-
return new Promise((resolve, reject) => {
95-
// The resource should always be https://atlas.microsoft.com/.
96-
const resource = "https://atlas.microsoft.com/";
97-
authContext.acquireToken(resource, (error, token) => {
98-
if (error) {
99-
reject(error);
100-
} else {
101-
resolve(token);
102-
}
103-
});
104-
})
93+
// Use the signed-in auth context to get a token.
94+
return new Promise((resolve, reject) => {
95+
// The resource should always be https://atlas.microsoft.com/.
96+
const resource = "https://atlas.microsoft.com/";
97+
authContext.acquireToken(resource, (error, token) => {
98+
if (error) {
99+
reject(error);
100+
} else {
101+
resolve(token);
102+
}
103+
});
104+
})
105105
}
106106

107107
function getExpiration(jwtToken) {
108-
// Decode the JSON Web Token (JWT) to get the expiration time stamp.
109-
const json = atob(jwtToken.split(".")[1]);
110-
const decode = JSON.parse(json);
111-
112-
// Return the milliseconds remaining until the token must be renewed.
113-
// Reduce the time until renewal by 5 minutes to avoid using an expired token.
114-
// The exp property is the time stamp of the expiration, in seconds.
115-
const renewSkew = 300000;
116-
return (1000 * decode.exp) - Date.now() - renewSkew;
108+
// Decode the JSON Web Token (JWT) to get the expiration time stamp.
109+
const json = atob(jwtToken.split(".")[1]);
110+
const decode = JSON.parse(json);
111+
112+
// Return the milliseconds remaining until the token must be renewed.
113+
// Reduce the time until renewal by 5 minutes to avoid using an expired token.
114+
// The exp property is the time stamp of the expiration, in seconds.
115+
const renewSkew = 300000;
116+
return (1000 * decode.exp) - Date.now() - renewSkew;
117117
}
118118
```
119119

@@ -123,29 +123,30 @@ The Azure Maps Web SDK provides a *services module*. This module is a helper lib
123123

124124
```javascript
125125
// Search for "1 microsoft way, redmond, wa".
126-
searchURL.searchAddress(atlas.service.Aborter.timeout(10000), '1 microsoft way, redmond, wa').then(response => {
127-
var html = [];
128-
129-
// Display the total results.
130-
html.push('Total results: ', response.summary.numResults, '<br/><br/>');
131-
132-
// Create a table of the results.
133-
html.push('<table><tr><td></td><td>Result</td><td>Latitude</td><td>Longitude</td></tr>');
134-
135-
for(var i=0;i<response.results.length;i++){
136-
html.push('<tr><td>', (i+1), '.</td><td>',
137-
response.results[i].address.freeformAddress,
138-
'</td><td>',
139-
response.results[i].position.lat,
140-
'</td><td>',
141-
response.results[i].position.lon,
142-
'</td></tr>');
143-
}
144-
145-
html.push('</table>');
146-
147-
// Add the resulting HTML to the body of the page.
148-
document.body.innerHTML = html.join('');
126+
searchURL.searchAddress(atlas.service.Aborter.timeout(10000), '1 microsoft way, redmond, wa')
127+
.then(response => {
128+
var html = [];
129+
130+
// Display the total results.
131+
html.push('Total results: ', response.summary.numResults, '<br/><br/>');
132+
133+
// Create a table of the results.
134+
html.push('<table><tr><td></td><td>Result</td><td>Latitude</td><td>Longitude</td></tr>');
135+
136+
for(var i=0;i<response.results.length;i++){
137+
html.push('<tr><td>', (i+1), '.</td><td>',
138+
response.results[i].address.freeformAddress,
139+
'</td><td>',
140+
response.results[i].position.lat,
141+
'</td><td>',
142+
response.results[i].position.lon,
143+
'</td></tr>');
144+
}
145+
146+
html.push('</table>');
147+
148+
// Add the resulting HTML to the body of the page.
149+
document.body.innerHTML = html.join('');
149150
});
150151
```
151152

articles/azure-maps/set-android-map-styles.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The `mapcontrol_style` attribute above sets the map style to **grayscale_dark**.
5757
Map style can be set in the activity class. Copy the following code snippet into the **onCreate()** method of your `MainActivity.java` class. This will set the map style to **satellite_road_labels**.
5858

5959
```Java
60-
mapControl.onReady(map -> {
60+
mapControl.onReady(map -> {
6161
//Set the camera of the map.
6262
map.setCamera(center(47.64, -122.33), zoom(14));
6363

articles/azure-maps/supported-browsers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ manager: cpendleton
1414

1515
The Azure Maps Web SDK provides a helper function called [atlas.isSupported](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas?view=azure-iot-typescript-latest#issupported-boolean-). This function detects whether a web browser has the minimum set of WebGL features required to support loading and rendering the map control. Here's an example of how to use the function:
1616

17-
```
18-
if(!atlas.isSupported()) {
17+
```JavaScript
18+
if (!atlas.isSupported()) {
1919
alert('Your browser is not supported by Azure Maps');
20-
} else if(!atlas.isSupported(true)) {
20+
} else if (!atlas.isSupported(true)) {
2121
alert('Your browser is supported by Azure Maps, but may have major performance caveats.');
2222
} else {
2323
// Your browser is supported. Add your map code here.

articles/azure-maps/tutorial-iot-hub-maps.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ In our use case, the rental cars are equipped with IoT devices that send telemet
3838
```JSON
3939
{
4040
"data": {
41-
"properties": {
41+
"properties": {
4242
"Engine": "ON"
43-
},
44-
"systemProperties": {
43+
},
44+
"systemProperties": {
4545
"iothub-content-type": "application/json",
4646
"iothub-content-encoding": "utf-8",
4747
"iothub-connection-device-id": "ContosoRentalDevice",
4848
"iothub-connection-auth-method": "{\"scope\":\"device\",\"type\":\"sas\",\"issuer\":\"iothub\",\"acceptingIpFilterRule\":null}",
4949
"iothub-connection-auth-generation-id": "636959817064335548",
5050
"iothub-enqueuedtime": "2019-06-18T00:17:20.608Z",
5151
"iothub-message-source": "Telemetry"
52-
},
53-
"body": {
54-
"location": {
55-
"type": "Point",
56-
"coordinates": [ -77.025988698005662, 38.9015330523316 ]
57-
}
58-
}
52+
},
53+
"body": {
54+
"location": {
55+
"type": "Point",
56+
"coordinates": [ -77.025988698005662, 38.9015330523316 ]
57+
}
58+
}
5959
}
6060
}
6161
```

0 commit comments

Comments
 (0)