|
53 | 53 | // Initialize a map instance. |
54 | 54 | map = new atlas.Map('myMap', { |
55 | 55 | center: [-105.076, 40.56], |
56 | | - zoom: 11, |
| 56 | + zoom: 12, |
57 | 57 | style: 'grayscale_light', |
58 | 58 | view: 'Auto', |
59 | 59 |
|
|
76 | 76 | map.events.add('ready', function () { |
77 | 77 |
|
78 | 78 | // Load the custom image icon into the map resources. |
79 | | - map.imageSprite.add('fire-shield-icon', '/images/icons/fire_shield.png'); |
| 79 | + map.imageSprite.add('home-icon', '/images/icons/home.png'); |
| 80 | + map.imageSprite.add('depot-icon', '/images/icons/factory.png'); |
80 | 81 |
|
81 | 82 | // Download stop and depot location GeoJSON data. |
82 | 83 | Promise.all([ |
|
104 | 105 |
|
105 | 106 | // Add rendering layers below labels. |
106 | 107 | map.layers.add([ |
107 | | - new atlas.layer.LineLayer(routeDataSource, null, { |
| 108 | + // Add a line layer for rendering the route. |
| 109 | + new atlas.layer.LineLayer(routeDataSource, 'routes', { |
108 | 110 | strokeColor: ['get', 'strokeColor'], |
109 | 111 | strokeWidth: 5, |
110 | 112 | strokeOpacity: 0.8, |
111 | 113 | lineJoin: 'round', |
112 | 114 | lineCap: 'round' |
113 | | - }), |
114 | | - new atlas.layer.BubbleLayer(stopDataSource, null, { |
115 | | - createIndicators: true, // to enable bubble layer a11y feature |
116 | | - radius: 4, |
117 | | - strokeWidth: 0 |
118 | 115 | }) |
119 | 116 | ], 'labels'); |
120 | 117 |
|
121 | | - // Render an icon for each depot. |
122 | | - map.layers.add(new atlas.layer.SymbolLayer(depotDataSource, null, { |
123 | | - iconOptions: { |
124 | | - image: 'fire-shield-icon', |
125 | | - size: 0.5, |
126 | | - anchor: "center", |
127 | | - allowOverlap: true, |
128 | | - ignorePlacement: true |
129 | | - }, |
130 | | - textOptions: { |
131 | | - textField: ['id'], |
132 | | - color: 'white', |
133 | | - size: 12, |
134 | | - offset: [0, 0.4], |
135 | | - allowOverlap: true, |
136 | | - ignorePlacement: true |
137 | | - } |
138 | | - })); |
| 118 | + // Add rendering layers above labels. |
| 119 | + map.layers.add([ |
| 120 | + // Render an icon for each depot. |
| 121 | + new atlas.layer.SymbolLayer(depotDataSource, 'depot', { |
| 122 | + iconOptions: { |
| 123 | + image: 'depot-icon', |
| 124 | + size: 0.2, |
| 125 | + anchor: "center", |
| 126 | + allowOverlap: true, |
| 127 | + ignorePlacement: true |
| 128 | + } |
| 129 | + }), |
| 130 | + // Render a red icon for each stop. |
| 131 | + new atlas.layer.SymbolLayer(stopDataSource, 'stops', { |
| 132 | + iconOptions: { |
| 133 | + image: 'home-icon', |
| 134 | + size: 0.2, |
| 135 | + anchor: "center", |
| 136 | + allowOverlap: true, |
| 137 | + ignorePlacement: true |
| 138 | + } |
| 139 | + }) |
| 140 | + ]); |
139 | 141 | }); |
140 | 142 | }); |
141 | 143 | } |
|
152 | 154 | // We need all coordinates together depots + stops |
153 | 155 | const allCoordinates = [...depots, ...stops]; |
154 | 156 |
|
155 | | - // Get the matrix for all coordinates |
| 157 | + // Get the Azure Maps Matrix results for all coordinates |
156 | 158 | const matrix = await getMatrixAsync(allCoordinates); |
157 | 159 |
|
158 | | - // We use the NVIDIA cuOpt optimizer service to calculate the Multi-Itinerary Optimization. |
| 160 | + // We use the NVIDIA cuOpt optimizer service to calculate the Multi-Itinerary Optimization |
159 | 161 | // more details: https://docs.nvidia.com/cuopt/user-guide/supported-features.html |
160 | 162 | const solver = await getOptimizedRouteAsync(matrix); |
161 | 163 |
|
162 | | - // Render the route on the map for each vehicle |
| 164 | + // Render the route on the map for each vehicle using Azure Maps Route API |
163 | 165 | renderRoutes(allCoordinates, solver); |
164 | 166 |
|
165 | 167 | // Hide loading icon |
|
0 commit comments