|
10 | 10 | <meta name="description" content="This sample compares the route a truck has to take to the route a car can take." /> |
11 | 11 | <meta name="keywords" content="Microsoft maps, map, gis, API, SDK, truck, car, routing, route, directions" /> |
12 | 12 | <meta name="author" content="Microsoft Azure Maps" /> |
13 | | - <meta name="version" content="1.0" /> |
| 13 | + <meta name="version" content="2.0" /> |
14 | 14 | <meta name="screenshot" content="screenshot.jpg" /> |
15 | 15 |
|
16 | 16 | <!-- Add references to the Azure Maps Map control JavaScript and CSS files. --> |
|
34 | 34 | { from: '40.429993,-79.998690', to: '40.414211,-80.009550', height: '', width: '', length: '', weight: '', load: ['USHazmatClass3'], description: 'Flammable load', streetsideLink: 'https://binged.it/2hd6P3s' } |
35 | 35 | ]; |
36 | 36 |
|
| 37 | + // Your Azure Maps client id for accessing your Azure Maps account. |
| 38 | + var azureMapsClientId = 'e6b6ab59-eb5d-4d25-aa57-581135b927f0'; |
| 39 | + |
| 40 | + // URL to your authentication service that retrieves an Microsoft Entra ID Token. |
| 41 | + var tokenServiceUrl = 'https://samples.azuremaps.com/api/GetAzureMapsToken'; |
| 42 | + |
| 43 | + // Function to retrieve an Azure Maps access token. |
| 44 | + function getToken(resolve, reject, map) { |
| 45 | + fetch(tokenServiceUrl).then(response => { |
| 46 | + if (response.ok) { |
| 47 | + return response.text(); |
| 48 | + } |
| 49 | + throw new Error('Failed to retrieve Azure Maps token.'); |
| 50 | + }).then(token => resolve(token)).catch(error => reject(error)); |
| 51 | + } |
| 52 | + |
37 | 53 | function getMap() { |
38 | 54 | //Initialize a map instance. |
39 | 55 | map = new atlas.Map('myMap', { |
40 | 56 | view: 'Auto', |
41 | 57 |
|
42 | | - //Add authentication details for connecting to Azure Maps. |
| 58 | + // Add authentication details for connecting to Azure Maps. |
43 | 59 | authOptions: { |
44 | | - //Use Microsoft Entra ID authentication. |
| 60 | + // Use Microsoft Entra ID authentication. |
45 | 61 | authType: 'anonymous', |
46 | | - clientId: 'e6b6ab59-eb5d-4d25-aa57-581135b927f0', //Your Azure Maps client id for accessing your Azure Maps account. |
47 | | - getToken: function (resolve, reject, map) { |
48 | | - //URL to your authentication service that retrieves an Microsoft Entra ID Token. |
49 | | - var tokenServiceUrl = 'https://samples.azuremaps.com/api/GetAzureMapsToken'; |
50 | | - |
51 | | - fetch(tokenServiceUrl).then(r => r.text()).then(token => resolve(token)); |
52 | | - } |
| 62 | + clientId: azureMapsClientId, |
| 63 | + getToken: getToken |
53 | 64 |
|
54 | | - //Alternatively, use an Azure Maps key. Get an Azure Maps key at https://azure.com/maps. NOTE: The primary key should be used as the key. |
| 65 | + // Alternatively, use an Azure Maps key. |
| 66 | + // Get an Azure Maps key at https://azure.com/maps. |
| 67 | + // NOTE: The primary key should be used as the key. |
55 | 68 | //authType: 'subscriptionKey', |
56 | 69 | //subscriptionKey: '[YOUR_AZURE_MAPS_KEY]' |
57 | 70 | } |
|
0 commit comments