Skip to content

Commit a32d599

Browse files
Update how-to-dev-guide-csharp-sdk.md
1 parent accf632 commit a32d599

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

articles/azure-maps/how-to-dev-guide-csharp-sdk.md

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ var client = new MapsSearchClient(credential);
139139
Call the `GetGeocoding` method to get the coordinate of an address.
140140

141141
```csharp
142-
using system;
143-
using Azure;
144-
using Azure.Core.GeoJson;
145-
using Azure.Maps.Search;
142+
using System;
146143
using Azure.Maps.Search.Models;
147144
// Use Azure Maps subscription key authentication
148145
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;
@@ -160,51 +157,56 @@ Console.WriteLine($"The Coordinate: ({searchResult.Value.Features[0].Geometry.Co
160157
This sample demonstrates how to perform batch search address.
161158

162159
```csharp
163-
using system;
164-
using Azure;
165-
using Azure.Core.GeoJson;
166-
using Azure.Maps.Search;
160+
using System;
161+
using System.Collections.Generic;
167162
using Azure.Maps.Search.Models;
163+
using Azure.Maps.Search.Models.Queries;
168164
// Use Azure Maps subscription key authentication
169165
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;
170166
var credential = new AzureKeyCredential(subscriptionKey);
171167
var client = new MapsSearchClient(credential);
172168

173169
List<GeocodingQuery> queries = new List<GeocodingQuery>
174-
{
175-
new GeocodingQuery()
176-
{
177-
Query ="15171 NE 24th St, Redmond, WA 98052, United States"
178-
},
179-
new GeocodingQuery()
180-
{
181-
Query = "400 Broad St, Seattle, WA 98109"
182-
},
183-
};
170+
{
171+
new GeocodingQuery()
172+
{
173+
Locality ="Seattle"
174+
},
175+
new GeocodingQuery()
176+
{
177+
AddressLine = "400 Broad St"
178+
},
179+
};
184180
Response<GeocodingBatchResponse> results = client.GetGeocodingBatch(queries);
185-
Console.WriteLine(results.Value.Summary);
181+
182+
//Print coordinates
183+
for (var i = 0; i < results.Value.BatchItems[0].Features.Count; i++)
184+
{
185+
Console.WriteLine("Coordinates", results.Value.BatchItems[0].Features[i].Geometry.Coordinates);
186+
}
186187
```
187188

188189
## Reverse geocode a coordinates
189190

190191
You can translate coordinates into human-readable street addresses. This process is also called reverse geocoding.
191192

192193
```csharp
193-
using system;
194-
using Azure;
194+
using System;
195195
using Azure.Core.GeoJson;
196-
using Azure.Maps.Search;
197196
using Azure.Maps.Search.Models;
197+
198198
// Use Azure Maps subscription key authentication
199199
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;
200200
var credential = new AzureKeyCredential(subscriptionKey);
201201
var client = new MapsSearchClient(credential);
202202

203203
GeoPosition coordinates = new GeoPosition(-122.138685, 47.6305637);
204204
Response<GeocodingResponse> result = client.GetReverseGeocoding(coordinates);
205+
206+
//Print addresses
205207
for (int i = 0; i < result.Value.Features.Count; i++)
206208
{
207-
Console.WriteLine(result.Value.Features[i].Geometry);
209+
Console.WriteLine(result.Value.Features[i].Properties.Address.AddressLine);
208210
}
209211
```
210212

@@ -213,11 +215,11 @@ for (int i = 0; i < result.Value.Features.Count; i++)
213215
Azure Maps Search also provides some batch query APIs. The Reverse Geocoding Batch API sends batches of queries to [Reverse Geocoding API](/rest/api/maps/search/get-reverse-geocoding) using just a single API call. The API allows caller to batch up to **100** queries.
214216

215217
```csharp
216-
using system;
217-
using Azure;
218+
using System;
219+
using System.Collections.Generic;
218220
using Azure.Core.GeoJson;
219-
using Azure.Maps.Search;
220221
using Azure.Maps.Search.Models;
222+
using Azure.Maps.Search.Models.Queries;
221223

222224
// Use Azure Maps subscription key authentication
223225
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;
@@ -236,19 +238,22 @@ List<ReverseGeocodingQuery> items = new List<ReverseGeocodingQuery>
236238
},
237239
};
238240
Response<GeocodingBatchResponse> result = client.GetReverseGeocodingBatch(items);
239-
Console.WriteLine(result.Value.Summary);
241+
//Print addresses
242+
for (var i = 0; i < result.Value.BatchItems.Count; i++)
243+
{
244+
Console.WriteLine(result.Value.BatchItems[i].Features[0].Properties.Address.AddressLine);
245+
}
240246
```
241247

242248
## Get polygons for a given location
243249

244250
This sample demonstrates how to search polygons.
245251

246252
```csharp
247-
using system;
248-
using Azure;
253+
using System;
249254
using Azure.Core.GeoJson;
250-
using Azure.Maps.Search;
251255
using Azure.Maps.Search.Models;
256+
using Azure.Maps.Search.Models.Options;
252257

253258
// Use Azure Maps subscription key authentication
254259
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;

0 commit comments

Comments
 (0)