You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-maps/web-sdk-best-practices.md
+46-21Lines changed: 46 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ titleSuffix: Microsoft Azure Maps
4
4
description: Learn tips & tricks to optimize your use of the Azure Maps Web SDK.
5
5
author: sinnypan
6
6
ms.author: sipa
7
-
ms.date: 11/29/2021
7
+
ms.date: 04/13/2023
8
8
ms.topic: conceptual
9
9
ms.service: azure-maps
10
10
services: azure-maps
@@ -20,7 +20,7 @@ Generally, when looking to improve performance of the map, look for ways to redu
20
20
21
21
## Security best practices
22
22
23
-
For more information on security best practices, see [Authentication and authorization best practices](authentication-best-practices.md).
23
+
For more information on security best practices, see [Authentication and authorization best practices].
24
24
25
25
### Use the latest versions of Azure Maps
26
26
@@ -30,10 +30,13 @@ If self-hosting the Azure Maps Web SDK via the npm module, be sure to use the ca
30
30
31
31
```json
32
32
"dependencies": {
33
-
"azure-maps-control": "^2.0.30"
33
+
"azure-maps-control": "^2.2.6"
34
34
}
35
35
```
36
36
37
+
> [!TIP]
38
+
> Always use the latest version of the npm Azure Maps Control. For more information, see [azure-maps-control] in the npm documentation.
39
+
37
40
## Optimize initial map load
38
41
39
42
When a web page is loading, one of the first things you want to do is start rendering something as soon as possible so that the user isn't staring at a blank screen.
@@ -60,7 +63,7 @@ If the map takes a while to load due to network limitations or other priorities
60
63
61
64
### Set initial map style and camera options on initialization
62
65
63
-
Often apps want to load the map to a specific location or style. Sometimes developers wait until the map has loaded (or wait for the `ready` event), and then use the `setCemer` or `setStyle` functions of the map. This often takes longer to get to the desired initial map view since many resources end up being loaded by default before the resources needed for the desired map view are loaded. A better approach is to pass in the desired map camera and style options into the map when initializing it.
66
+
Often apps want to load the map to a specific location or style. Sometimes developers wait until the map has loaded (or wait for the `ready` event), and then use the `setCamera` or `setStyle` functions of the map. This often takes longer to get to the desired initial map view since many resources end up being loaded by default before the resources needed for the desired map view are loaded. A better approach is to pass in the desired map camera and style options into the map when initializing it.
64
67
65
68
## Optimize data sources
66
69
@@ -74,17 +77,17 @@ The Web SDK has two data sources,
74
77
If working with larger datasets containing millions of features, the recommended way to achieve optimal performance is to expose the data using a server-side solution such as vector or raster image tile service.
75
78
Vector tiles are optimized to load only the data that is in view with the geometries clipped to the focus area of the tile and generalized to match the resolution of the map for the zoom level of the tile.
76
79
77
-
The [Azure Maps Creator platform](creator-indoor-maps.md) retrieves data in vector tile format. Other data formats can be using tools such as [Tippecanoe](https://github.com/mapbox/tippecanoe). For more information on working with vector tiles, see the Mapbox [awesome-vector-tiles](https://github.com/mapbox/awesome-vector-tiles#awesome-vector-tiles-) readme in GitHub.
80
+
The [Azure Maps Creator platform] retrieves data in vector tile format. Other data formats can be using tools such as [Tippecanoe]. For more information on working with vector tiles, see the Mapbox [awesome-vector-tiles] readme in GitHub.
78
81
79
82
It's also possible to create a custom service that renders datasets as raster image tiles on the server-side and load the data using the TileLayer class in the map SDK. This provides exceptional performance as the map only needs to load and manage a few dozen images at most. However, there are some limitations with using raster tiles since the raw data isn't available locally. A secondary service is often required to power any type of interaction experience, for example, find out what shape a user clicked on. Additionally, the file size of a raster tile is often larger than a compressed vector tile that contains generalized and zoom level optimized geometries.
80
83
81
-
For more information about data sources, see [Create a data source](create-data-source-web-sdk.md).
84
+
For more information about data sources, see [Create a data source].
82
85
83
86
### Combine multiple datasets into a single vector tile source
84
87
85
88
The less data sources the map has to manage, the faster it can process all features to be displayed. In particular, when it comes to tile sources, combining two vector tile sources together cuts the number of HTTP requests to retrieve the tiles in half, and the total amount of data would be slightly smaller since there's only one file header.
86
89
87
-
Combining multiple data sets in a single vector tile source can be achieved using a tool such as [Tippecanoe](https://github.com/mapbox/tippecanoe). Data sets can be combined into a single feature collection or separated into separate layers within the vector tile known as source-layers. When connecting a vector tile source to a rendering layer, you would specify the source-layer that contains the data that you want to render with the layer.
90
+
Combining multiple data sets in a single vector tile source can be achieved using a tool such as [Tippecanoe]. Data sets can be combined into a single feature collection or separated into separate layers within the vector tile known as source-layers. When connecting a vector tile source to a rendering layer, you would specify the source-layer that contains the data that you want to render with the layer.
88
91
89
92
### Reduce the number of canvas refreshes due to data updates
90
93
@@ -116,7 +119,7 @@ When features have numerous properties or content, it's much more performant to
116
119
117
120
Additionally, reducing the number of significant digits in the coordinates of features can also significantly reduce the data size. It isn't uncommon for coordinates to contain 12 or more decimal places; however, six decimal places have an accuracy of about 0.1 meter, which is often more precise than the location the coordinate represents (six decimal places is recommended when working with small location data such as indoor building layouts). Having any more than six decimal places will likely make no difference in how the data is rendered and requires the user to download more data for no added benefit.
118
121
119
-
Here's a list of [useful tools for working with GeoJSON data](https://github.com/tmcw/awesome-geojson).
122
+
Here's a list of [useful tools for working with GeoJSON data].
120
123
121
124
### Use a separate data source for rapidly changing data
122
125
@@ -167,7 +170,7 @@ That said, if you only have a few points to render on the map, the simplicity of
167
170
168
171
### Combine layers
169
172
170
-
The map is capable of rendering hundreds of layers, however, the more layers there are, the more time it takes to render a scene. One strategy to reduce the number of layers is to combine layers that have similar styles or can be styled using a [data-driven styles](data-driven-style-expressions-web-sdk.md).
173
+
The map is capable of rendering hundreds of layers, however, the more layers there are, the more time it takes to render a scene. One strategy to reduce the number of layers is to combine layers that have similar styles or can be styled using a [data-driven styles].
171
174
172
175
For example, consider a data set where all features have a `isHealthy` property that can have a value of `true` or `false`. If creating a bubble layer that renders different colored bubbles based on this property, there are several ways to do this as shown in the following list, from least performant to most performant.
173
176
@@ -261,7 +264,7 @@ The symbol layer has two options that exist for both icon and text called `allow
261
264
When working with large sets of data points you may find that when rendered at certain zoom levels, many of the points overlap and are only partial visible, if at all. Clustering is process of grouping points that are close together and representing them as a single clustered point. As the user zooms in the map, clusters break apart into their individual points. This can significantly reduce the amount of data that needs to be rendered, make the map feel less cluttered, and improve performance. The `DataSource` class has options for clustering data locally. Additionally, many tools that generate vector tiles also have clustering options.
262
265
263
266
Additionally, increase the size of the cluster radius to improve performance. The larger the cluster radius, the less clustered points there's to keep track of and render.
264
-
For more information, see [Clustering point data in the Web SDK](clustering-point-data-web-sdk.md)
267
+
For more information, see [Clustering point data in the Web SDK].
265
268
266
269
### Use weighted clustered heat maps
267
270
@@ -273,15 +276,15 @@ var layer = new atlas.layer.HeatMapLayer(source, null, {
273
276
});
274
277
```
275
278
276
-
For more information, see [Clustering and the heat maps layer](clustering-point-data-web-sdk.md#clustering-and-the-heat-maps-layer)
279
+
For more information, see [Clustering and the heat maps layer].
277
280
278
281
### Keep image resources small
279
282
280
283
Images can be added to the maps image sprite for rendering icons in a symbol layer or patterns in a polygon layer. Keep these images small to minimize the amount of data that has to be downloaded and the amount of space they take up in the maps image sprite. When using a symbol layer that scales the icon using the `size` option, use an image that is the maximum size your plan to display on the map and no bigger. This ensures the icon is rendered with high resolution while minimizing the resources it uses. Additionally, SVGs can also be used as a smaller file format for simple icon images.
281
284
282
285
## Optimize expressions
283
286
284
-
[Data-driven style expressions](data-driven-style-expressions-web-sdk.md) provide flexibility and power for filtering and styling data on the map. There are many ways in which expressions can be optimized. Here are a few tips.
287
+
[Data-driven style expressions] provide flexibility and power for filtering and styling data on the map. There are many ways in which expressions can be optimized. Here are a few tips.
285
288
286
289
### Reduce the complexity of filters
287
290
@@ -341,7 +344,7 @@ Things to check:
341
344
* Ensure that you complete your authentication options in the map. Without authentication, the map loads a blank canvas and returns a 401 error in the network tab of the browser's developer tools.
342
345
* Ensure that you have an internet connection.
343
346
* Check the console for errors of the browser's developer tools. Some errors may cause the map not to render. Debug your application.
344
-
* Ensure you're using a [supported browser](supported-browsers.md).
347
+
* Ensure you're using a [supported browser].
345
348
346
349
**All my data is showing up on the other side of the world, what's going on?**
347
350
@@ -376,39 +379,61 @@ Things to check:
376
379
Yes.
377
380
378
381
> [!TIP]
379
-
> Safari has a [bug](https://bugs.webkit.org/show_bug.cgi?id=170075) that prevents sandboxed iframes from running web workers, a requirement of the Azure Maps Web SDK. The solution is to add the `"allow-same-origin"` tag to the sandbox property of the iframe.
382
+
> Safari has a [bug] that prevents sandboxed iframes from running web workers, a requirement of the Azure Maps Web SDK. The solution is to add the `"allow-same-origin"` tag to the sandbox property of the iframe.
380
383
381
384
## Get support
382
385
383
386
The following are the different ways to get support for Azure Maps depending on your issue.
384
387
385
388
**How do I report a data issue or an issue with an address?**
386
389
387
-
Report issues using the [Azure Maps feedback tool](https://feedback.azuremaps.com). Detailed instructions on reporting data issues are provided in the [Provide data feedback to Azure Maps](how-to-use-feedback-tool.md) article.
390
+
Report issues using the [Azure Maps feedback] site. Detailed instructions on reporting data issues are provided in the [Provide data feedback to Azure Maps] article.
388
391
389
392
> [!NOTE]
390
393
> Each issue submitted generates a unique URL to track it. Resolution times vary depending on issue type and the time required to verify the change is correct. The changes will appear in the render services weekly update, while other services such as geocoding and routing are updated monthly.
391
394
392
395
**How do I report a bug in a service or API?**
393
396
394
-
Report issues on Azure's [Help + support](https://portal.azure.com/#blade/Microsoft_Azure_Support/HelpAndSupportBlade/overview) page by selecting the **Create a support request** button.
397
+
Report issues on Azure's [Help + support] page by selecting the **Create a support request** button.
395
398
396
399
**Where do I get technical help for Azure Maps?**
397
400
398
-
* For questions related to the Azure Maps Power BI visual, contact [Power BI support](https://powerbi.microsoft.com/support/).
401
+
* For questions related to the Azure Maps Power BI visual, contact [Power BI support].
399
402
400
-
* For all other Azure Maps services, contact [Azure support](https://azure.com/support).
403
+
* For all other Azure Maps services, contact [Azure support].
401
404
402
-
* For question or comments on specific Azure Maps Features, use the [Azure Maps developer forums](/answers/topics/azure-maps.html).
405
+
* For question or comments on specific Azure Maps Features, use the [Azure Maps developer forums].
403
406
404
407
## Next steps
405
408
406
409
See the following articles for more tips on improving the user experience in your application.
407
410
408
411
> [!div class="nextstepaction"]
409
-
> [Make your application accessible](map-accessibility.md)
412
+
> [Make your application accessible]
410
413
411
414
Learn more about the terminology used by Azure Maps and the geospatial industry.
412
415
413
416
> [!div class="nextstepaction"]
414
-
> [Azure Maps glossary](glossary.md)
417
+
> [Azure Maps glossary]
418
+
419
+
[Authentication and authorization best practices]: authentication-best-practices.md
0 commit comments