Skip to content

Commit f87bed4

Browse files
authored
Merge pull request #106676 from rbrundritt/master
Minor updates to spatial io docs
2 parents 232d0d8 + 0093d38 commit f87bed4

21 files changed

+395
-186
lines changed

articles/azure-maps/choose-map-style.md

Lines changed: 93 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: Map style functionalities | Microsoft Azure Maps
3-
description: In this article, you will learn about style related functionalities available in Microsoft Azure Maps web SDK.
2+
title: Change the style of the map in Azure Maps | Microsoft Azure Maps
3+
description: In this article, you will learn about style-related functionalities available in Microsoft Azure Maps web SDK.
44
author: farah-alyasari
55
ms.author: v-faalya
66
ms.date: 07/29/2019
@@ -10,31 +10,104 @@ services: azure-maps
1010
manager: timlt
1111
---
1212

13-
# Choose a map style in Azure Maps
13+
# Change the style of the map
1414

15-
Many of the [supported map styles in Azure Maps](./supported-map-styles.md) are available in the Web SDK. This article shows how to use the style-related functionalities. Learn to set a style upon loading a map, and learn to set a new map style using the style picker control.
15+
The map supports several different [style options](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas.styleoptions) that can be set when the map is being initialized or later using the maps `setStyle` function. This article shows how to use these style options to customize the maps appearance. Learn to set a style upon loading a map, and learn to set a new map style using the style picker control.
1616

17-
## Set style on map load
17+
## Set the style options
1818

19-
In the following code, the `style` option of the map is set to `grayscale_dark` on initialization.
19+
Style options can be passed into the map when it is initialized or updated later using the maps `setStyle` function.
20+
21+
```javascript
22+
//Set the style options when creating the map.
23+
var map = new atlas.Map('map', {
24+
renderWorldCopies: false,
25+
showBuildingModels: true
26+
27+
//Additional map options.
28+
};
29+
30+
//Update the style options at anytime using setStyle function.
31+
map.setStyle({
32+
renderWorldCopies: true,
33+
showBuildingModels: false
34+
});
35+
```
36+
37+
The following tool shows how the different style options change how the map is rendered. To see the 3D buildings, zoom in close to a major city.
38+
39+
<br/>
40+
41+
<iframe height="700" style="width: 100%;" scrolling="no" title="Map style options" src="https://codepen.io/azuremaps/embed/eYNMjPb?height=700&theme-id=0&default-tab=result" frameborder="no" allowtransparency="true" allowfullscreen="true">
42+
See the Pen <a href='https://codepen.io/azuremaps/pen/eYNMjPb'>Map style options</a> by Azure Maps
43+
(<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
44+
</iframe>
45+
46+
## Choose a base map style
47+
48+
One of the most common map style options is used to change the style of the base map that is styled. Many of the [supported map styles in Azure Maps](supported-map-styles.md) are available in the Web SDK.
49+
50+
### Set base map style on map load
51+
52+
53+
The map style can be specified when initializing the map by setting the `style` option. In the following code, the `style` option of the map is set to `grayscale_dark` on initialization.
54+
55+
```javascript
56+
var map = new atlas.Map('map', {
57+
style: 'grayscale_dark',
58+
59+
//Additiona map options
60+
);
61+
```
2062
2163
<br/>
2264
2365
<iframe height='500' scrolling='no' title='Setting the style on map load' src='//codepen.io/azuremaps/embed/WKOQRq/?height=265&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='https://codepen.io/azuremaps/pen/WKOQRq/'>Setting the style on map load</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
2466
</iframe>
2567
26-
## Update the style
68+
### Update the base map style
69+
70+
The map style can be updated using the `setStyle` function and setting the `style` option to the desired map style.
2771
28-
In the following code, after a map instance is loaded, the map style is updated from `road` to `satellite` using the [setStyle](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas.map?view=azure-iot-typescript-latest) function.
72+
```javascript
73+
map.setStyle({ style: 'satellite' });
74+
```
75+
76+
In the following code, after a map instance is loaded, the map style is updated from `road` to `satellite` using the [setStyle](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas.map?view=azure-maps-typescript-latest#setstyle-styleoptions-) function.
2977
3078
<br/>
3179
3280
<iframe height='500' scrolling='no' title='Updating the style' src='//codepen.io/azuremaps/embed/yqXYzY/?height=265&theme-id=0&default-tab=js,result&embed-version=2&editable=true' frameborder='no' allowtransparency='true' allowfullscreen='true' style='width: 100%;'>See the Pen <a href='https://codepen.io/azuremaps/pen/yqXYzY/'>Updating the style</a> by Azure Maps (<a href='https://codepen.io/azuremaps'>@azuremaps</a>) on <a href='https://codepen.io'>CodePen</a>.
3381
</iframe>
3482
35-
## Add the style picker
83+
### Add the style picker
84+
85+
The style picker control provides an easy to use button with flyout panel that can be used to by the end user to change the map style. The style picker has two different layout options. By default the style picker uses the `icons` layout and displays all the map style as a horizontal row of icons.
86+
87+
<center>
88+
89+
![Style picker icon layout](media/choose-map-style/style-picker-icon-layout.png)</center>
90+
91+
The second layout option is called `list` and displays a scrollable list of map styles.
92+
93+
<center>
94+
95+
![Style picker list layout](media/choose-map-style/style-picker-list-layout.png)</center>
96+
3697
37-
The following code adds a [StyleControl](/javascript/api/azure-maps-control/atlas.control.stylecontrol) to the map, so the user can easily switch between the different map styles. Toggle the map style using the map style control near the top right corner.
98+
The following code shows how to create an instance of the style picker control and add it to the top right corner of the map. The style picker is set to have a dark style and show a selected few map styles using the list layer.
99+
100+
```javascript
101+
map.controls.add(new atlas.control.StyleControl({
102+
mapStyles: ['road', 'night', 'grayscale_dark', 'grayscale_light'],
103+
layout: 'list',
104+
style: 'dark'
105+
}), {
106+
position: 'top-right'
107+
});
108+
```
109+
110+
The following code adds a style picker control with its default settings to the map, so the user can easily switch between the different map styles. Toggle the map style using the map style control near the top right corner.
38111
39112
<br/>
40113
@@ -49,7 +122,16 @@ The following code adds a [StyleControl](/javascript/api/azure-maps-control/atla
49122
To learn more about the classes and methods used in this article:
50123
51124
> [!div class="nextstepaction"]
52-
> [Map](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas.map?view=azure-iot-typescript-latest)
125+
> [Map](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas.map)
126+
127+
> [!div class="nextstepaction"]
128+
> [StyleOptions](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas.styleoptions)
129+
130+
> [!div class="nextstepaction"]
131+
> [StyleControl](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas.control.stylecontrol)
132+
133+
> [!div class="nextstepaction"]
134+
> [StyleControlOptions](https://docs.microsoft.com/javascript/api/azure-maps-control/atlas.stylecontroloptions)
53135
54136
Add controls to your maps:
55137

articles/azure-maps/data-driven-style-expressions-web-sdk.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,44 @@ This layer will render the point feature as shown in the image below:
788788

789789
![Number format expression example](media/how-to-expressions/number-format-expression.png) </center>
790790

791+
### Image expression
792+
793+
An image expression can be used with the `image` and `textField` options of a symbol layer, and the `fillPattern` option of the polygon layer. This expression checks that the requested image exists in the style and will return either the resolved image name or `null`, depending on whether or not the image is currently in the style. This validation process is synchronous and requires the image to have been added to the style before requesting it in the image argument.
794+
795+
**Example**
796+
797+
The following example uses an `image` expression to add an icon inline with text in a symbol layer.
798+
799+
```javascript
800+
//Load the custom image icon into the map resources.
801+
map.imageSprite.add('wifi-icon', 'wifi.png').then(function () {
802+
803+
//Create a data source and add it to the map.
804+
datasource = new atlas.source.DataSource();
805+
map.sources.add(datasource);
806+
807+
//Create a point feature and add it to the data source.
808+
datasource.add(new atlas.data.Point(map.getCamera().center));
809+
810+
//Add a layer for rendering point data as symbols.
811+
map.layers.add(new atlas.layer.SymbolLayer(datasource, null, {
812+
iconOptions: {
813+
image: 'none'
814+
},
815+
textOptions: {
816+
//Create a formatted text string that has an icon in it.
817+
textField: ["format", 'Ricky\'s ', ["image", "wifi-icon"], ' Palace']
818+
}
819+
}));
820+
});
821+
```
822+
823+
This layer will render the text field in the symbol layer as shown in the image below:
824+
825+
<center>
826+
827+
![Image expression example](media/how-to-expressions/image-expression.png) </center>
828+
791829
## Zoom expression
792830

793831
A `zoom` expression is used to retrieve the current zoom level of the map at render time and is defined as `['zoom']`. This expression returns a number between the minimum and maximum zoom level range of the map. The Azure Maps interactive map controls for web and Android support 25 zoom levels, numbered 0 through 24. Using the `zoom` expression allows styles to be modified dynamically as the zoom level of the map is changed. The `zoom` expression may only be used with `interpolate` and `step` expressions.

articles/azure-maps/how-to-use-best-practices-for-search.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ https://atlas.microsoft.com/search/address/reverse/json?api-version=1.0&subscrip
109109
"municipality": "Redmond",
110110
"country": "United States",
111111
"countryCodeISO3": "USA",
112-
},
113112
"countrySubdivisionName": "Washington"
114113
},
115114
"position": "47.639454,-122.130455",

articles/azure-maps/how-to-use-spatial-io-module.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@ manager: philmea
1515

1616
The Azure Maps Web SDK provides the **Spatial IO module**, which integrates spatial data with the Azure Maps web SDK using JavaScript or TypeScript. The robust features in this module allow developers to:
1717

18-
- [Read and write data to common spatial files](spatial-io-read-write-spatial-data.md). Supported file formats include: KML, KMZ, GPX, GeoRSS, GML, and CSV files containing columns with spatial information.
19-
- [Connect to Open Geospatial Consortium (OGC) services and integrate with Azure Maps web SDK. Overlay Web Mapping Services (WMS) and Web Map Tile Services (WMTS) as layers on the map.](spatial-io-add-ogc-map-layer.md).
18+
- [Read and write data to common spatial files](spatial-io-read-write-spatial-data.md). Supported file formats include: KML, KMZ, GPX, GeoRSS, GML, and CSV files containing columns with spatial information. Also supports Well-Known Text (WKT).
19+
- [Connect to Open Geospatial Consortium (OGC) services and integrate with Azure Maps web SDK. Overlay Web Map Services (WMS) and Web Map Tile Services (WMTS) as layers on the map.](spatial-io-add-ogc-map-layer.md).
2020
- [Query data in a Web Feature Service (WFS)](spatial-io-connect-wfs-service.md).
2121
- [Overlay complex data sets that contain style information and have them render automatically](spatial-io-add-simple-data-layer.md).
2222
- [Leverage high-speed XML and delimited file reader and writer classes](spatial-io-core-operations.md).
2323

2424
In this guide, we'll learn how to integrate and use the Spatial IO module in a web application.
2525

26+
> [!WARNING]
27+
> Only use data and services that are from a source you trust, especially if referencing it from another domain. The spatial IO module does take steps to minimize risk, however the safest approach is too not allow any danagerous data into your application to begin with.
28+
2629
## Prerequisites
2730

2831
Before you can use the Spatial IO module, you'll need to [make an Azure Maps account](https://docs.microsoft.com/azure/azure-maps/quick-demo-map-app#create-an-account-with-azure-maps) and [get the primary subscription key for your account](https://docs.microsoft.com/azure/azure-maps/quick-demo-map-app#get-the-primary-key-for-your-account).
@@ -107,7 +110,7 @@ You can load the Azure Maps spatial IO module using one of the two options:
107110
</html>
108111
```
109112

110-
2. Load the Azure Maps spatial IO module. For this exercise, use the CDN for the Azure Maps spatial IO module. Add the reference below to the the `<head>` element of your HTML file:
113+
2. Load the Azure Maps spatial IO module. For this exercise, use the CDN for the Azure Maps spatial IO module. Add the reference below to the `<head>` element of your HTML file:
111114

112115
```html
113116
<script src="https://atlas.microsoft.com/sdk/javascript/spatial/0/atlas-spatial.js"></script>

articles/azure-maps/index.yml

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,16 @@ landingContent:
8080
url: tutorial-create-store-locator.md
8181
- linkListType: how-to-guide
8282
links:
83+
- text: Use the Azure Maps map control
84+
url: how-to-use-map-control.md
85+
- text: Use the drawing tools module
86+
url: set-drawing-options.md
87+
- text: Use the services module
88+
url: how-to-use-services-module.md
8389
- text: Use the spatial IO module
8490
url: how-to-use-spatial-io-module.md
85-
- text: Add a simple data layer
86-
url: spatial-io-add-simple-data-layer.md
87-
- text: Read and write spatial data
88-
url: spatial-io-read-write-spatial-data.md
89-
- text: Add an OGC map layer
90-
url: spatial-io-add-ogc-map-layer.md
91-
- text: Connect to a WFS service
92-
url: spatial-io-connect-wfs-service.md
93-
- text: Leverage core operations
94-
url: spatial-io-core-operations.md
95-
- text: Supported data format details
96-
url: spatial-io-supported-data-format-details.md
91+
- text: Web SDK supported browsers
92+
url: supported-browsers.md
9793
- linkListType: reference
9894
links:
9995
- text: Map control

articles/azure-maps/map-accessibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ There are several different ways in which the map can be zoomed, panned, rotated
3636
- Using a mouse, scroll the wheel to zoom the map.
3737
- Using a touch screen, touch the map with two fingers and pinch together to zoom out or spread the fingers apart to zoom in.
3838
- Using a touch screen, double tap the map to zoom in one level.
39-
- With the map focused, use the Plus sign (`+`) or *Equals sign (`=`) to zoom in one level.
39+
- With the map focused, use the Plus sign (`+`) or Equals sign (`=`) to zoom in one level.
4040
- With the map focused, use the Minus sign, Hyphen (`-`), or Underscore (`_`) to zoom out one level.
4141
- Using the zoom control with a mouse, touch or keyboard tab/enter keys.
4242
- Press and hold the `Shift` button and press the left mouse button down on the map and drag to draw out an area to zoom the map into.

articles/azure-maps/map-add-controls.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,20 @@ Below is the complete running code sample of the above functionality.
7070

7171
## A Map with all controls
7272

73-
The following code sample adds the style picker, zoom, pitch, and compass controls to the bottom-right corner of the map. Notice how they automatically stack. The order of the control objects in the script dictates the order in which they appear on the map. To change the order of the controls on the map, you can change their order in the script.
73+
Multiple controls can be put into an array and added to the map all at once and positioned in the same area of the map to simplify development. The following adds the standard navigation controls to the map using this approach.
74+
75+
```javascript
76+
map.controls.add([
77+
new atlas.control.ZoomControl(),
78+
new atlas.control.CompassControl(),
79+
new atlas.control.PitchControl(),
80+
new atlas.control.StyleControl()
81+
], {
82+
position: "top-right"
83+
});
84+
```
85+
86+
The following code sample adds the zoom, compass, pitch, and style picker controls to the top-right corner of the map. Notice how they automatically stack. The order of the control objects in the script dictates the order in which they appear on the map. To change the order of the controls on the map, you can change their order in the array.
7487

7588
<br/>
7689

articles/azure-maps/map-add-drawing-toolbar.md

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This article shows you how to use the Drawing Tools module and display the drawi
1818

1919
The following code creates an instance of the drawing manager and displays the toolbar on the map.
2020

21-
```Javascript
21+
```javascript
2222
//Create an instance of the drawing manager and display the drawing toolbar.
2323
drawingManager = new atlas.drawing.DrawingManager(map, {
2424
toolbar: new atlas.control.DrawingToolbar({
@@ -42,7 +42,7 @@ Below is the complete running code sample of the functionality above:
4242

4343
The following code creates an instance of the drawing manager and displays the toolbar with just a polygon drawing tool on the map.
4444

45-
```Javascript
45+
```javascript
4646
//Create an instance of the drawing manager and display the drawing toolbar with polygon drawing tool.
4747
drawingManager = new atlas.drawing.DrawingManager(map, {
4848
toolbar: new atlas.control.DrawingToolbar({
@@ -65,25 +65,53 @@ Below is the complete running code sample of the functionality above:
6565

6666
## Change drawing rendering style
6767

68-
The following code gets the rendering layers from the drawing manager and modifies their options to change rendering style for drawing. In this case, points will be rendered with a blue marker icon. Lines will be red and four pixels wide. Polygons will have a green fill color and an orange outline.
68+
The style of the shapes that are drawn can be customized by retrieving the underlying layers of the drawing manager by using the `drawingManager.getLayers()` function and then setting options on the individual layers. The drag handles that appear for coordinates when editing a shape are HTML markers. The style of the drag handles can be customized by passing HTML marker options into the `dragHandleStyle` and `secondaryDragHandleStyle` options of the drawing manager.
6969

70-
```Javascript
70+
The following code gets the rendering layers from the drawing manager and modifies their options to change rendering style for drawing. In this case, points will be rendered with a blue marker icon. Lines will be red and four pixels wide. Polygons will have a green fill color and an orange outline. It then changes the styles of the drag handles to be square icons.
71+
72+
```javascript
73+
//Get rendering layers of drawing manager.
7174
var layers = drawingManager.getLayers();
72-
layers.pointLayer.setOptions({
73-
iconOptions: {
74-
image: 'marker-blue'
75-
}
76-
});
77-
layers.lineLayer.setOptions({
78-
strokeColor: 'red',
79-
strokeWidth: 4
80-
});
81-
layers.polygonLayer.setOptions({
82-
fillColor: 'green'
83-
});
84-
layers.polygonOutlineLayer.setOptions({
85-
strokeColor: 'orange'
86-
});
75+
76+
//Change the icon rendered for points.
77+
layers.pointLayer.setOptions({
78+
iconOptions: {
79+
image: 'marker-blue'
80+
}
81+
});
82+
83+
//Change the color and width of lines.
84+
layers.lineLayer.setOptions({
85+
strokeColor: 'red',
86+
strokeWidth: 4
87+
});
88+
89+
//Change fill color of polygons.
90+
layers.polygonLayer.setOptions({
91+
fillColor: 'green'
92+
});
93+
94+
//Change the color of polygon outlines.
95+
layers.polygonOutlineLayer.setOptions({
96+
strokeColor: 'orange'
97+
});
98+
99+
//Update the style of the drag handles that appear when editting.
100+
drawingManager.setOptions({
101+
//Primary drag handle that represents coordinates in the shape.
102+
dragHandleStyle: {
103+
anchor: 'center',
104+
htmlContent: '<svg width="15" height="15" viewBox="0 0 15 15" xmlns="http://www.w3.org/2000/svg" style="cursor:pointer"><rect x="0" y="0" width="15" height="15" style="stroke:black;fill:white;stroke-width:4px;"/></svg>',
105+
draggable: true
106+
},
107+
108+
//Secondary drag hanle that represents mid-point coordinates that users can grab to add new cooridnates in the middle of segments.
109+
secondaryDragHandleStyle: {
110+
anchor: 'center',
111+
htmlContent: '<svg width="10" height="10" viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg" style="cursor:pointer"><rect x="0" y="0" width="10" height="10" style="stroke:white;fill:black;stroke-width:4px;"/></svg>',
112+
draggable: true
113+
}
114+
});
87115
```
88116

89117
Below is the complete running code sample of the functionality above:

0 commit comments

Comments
 (0)