Skip to content

Commit accf632

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

File tree

1 file changed

+87
-1
lines changed

1 file changed

+87
-1
lines changed

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

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ 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;
146+
using Azure.Maps.Search.Models;
142147
// Use Azure Maps subscription key authentication
143148
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;
144149
var credential = new AzureKeyCredential(subscriptionKey);
@@ -150,6 +155,59 @@ Response<GeocodingResponse> searchResult = client.GetGeocoding(
150155
Console.WriteLine($"The Coordinate: ({searchResult.Value.Features[0].Geometry.Coordinates})");
151156
```
152157

158+
## Batch geocode addresses
159+
160+
This sample demonstrates how to perform batch search address.
161+
162+
```csharp
163+
using system;
164+
using Azure;
165+
using Azure.Core.GeoJson;
166+
using Azure.Maps.Search;
167+
using Azure.Maps.Search.Models;
168+
// Use Azure Maps subscription key authentication
169+
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;
170+
var credential = new AzureKeyCredential(subscriptionKey);
171+
var client = new MapsSearchClient(credential);
172+
173+
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+
};
184+
Response<GeocodingBatchResponse> results = client.GetGeocodingBatch(queries);
185+
Console.WriteLine(results.Value.Summary);
186+
```
187+
188+
## Reverse geocode a coordinates
189+
190+
You can translate coordinates into human-readable street addresses. This process is also called reverse geocoding.
191+
192+
```csharp
193+
using system;
194+
using Azure;
195+
using Azure.Core.GeoJson;
196+
using Azure.Maps.Search;
197+
using Azure.Maps.Search.Models;
198+
// Use Azure Maps subscription key authentication
199+
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;
200+
var credential = new AzureKeyCredential(subscriptionKey);
201+
var client = new MapsSearchClient(credential);
202+
203+
GeoPosition coordinates = new GeoPosition(-122.138685, 47.6305637);
204+
Response<GeocodingResponse> result = client.GetReverseGeocoding(coordinates);
205+
for (int i = 0; i < result.Value.Features.Count; i++)
206+
{
207+
Console.WriteLine(result.Value.Features[i].Geometry);
208+
}
209+
```
210+
153211
## Batch reverse geocode a set of coordinates
154212

155213
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.
@@ -177,9 +235,37 @@ List<ReverseGeocodingQuery> items = new List<ReverseGeocodingQuery>
177235
Coordinates = new GeoPosition(-122.34255, 47.0)
178236
},
179237
};
180-
Response<GeocodingBatchResponse> = client.GetReverseGeocodingBatch(items);
238+
Response<GeocodingBatchResponse> result = client.GetReverseGeocodingBatch(items);
239+
Console.WriteLine(result.Value.Summary);
181240
```
182241

242+
## Get polygons for a given location
243+
244+
This sample demonstrates how to search polygons.
245+
246+
```csharp
247+
using system;
248+
using Azure;
249+
using Azure.Core.GeoJson;
250+
using Azure.Maps.Search;
251+
using Azure.Maps.Search.Models;
252+
253+
// Use Azure Maps subscription key authentication
254+
var subscriptionKey = Environment.GetEnvironmentVariable("SUBSCRIPTION_KEY") ?? string.Empty;
255+
var credential = new AzureKeyCredential(subscriptionKey);
256+
var client = new MapsSearchClient(credential);
257+
258+
GetPolygonOptions options = new GetPolygonOptions()
259+
{
260+
Coordinates = new GeoPosition(121.5, 25.0)
261+
};
262+
Response<Boundary> result = client.GetPolygon(options);
263+
Console.WriteLine(result.Value.Geometry);
264+
```
265+
266+
## Using V1 SDKs for Search and Render
267+
268+
To use Search V1 and Render V1 SDK, please refer to Search V1 SDK [package](https://www.nuget.org/packages/Azure.Maps.Search/1.0.0-beta.5) page and Render V1 SDK [package](https://www.nuget.org/packages/Azure.Maps.Rendering/1.0.0-beta.3) for more information.
183269

184270
## Additional information
185271

0 commit comments

Comments
 (0)