@@ -139,10 +139,7 @@ var client = new MapsSearchClient(credential);
139
139
Call the ` GetGeocoding ` method to get the coordinate of an address.
140
140
141
141
``` csharp
142
- using system ;
143
- using Azure ;
144
- using Azure .Core .GeoJson ;
145
- using Azure .Maps .Search ;
142
+ using System ;
146
143
using Azure .Maps .Search .Models ;
147
144
// Use Azure Maps subscription key authentication
148
145
var subscriptionKey = Environment .GetEnvironmentVariable (" SUBSCRIPTION_KEY" ) ?? string .Empty ;
@@ -160,51 +157,56 @@ Console.WriteLine($"The Coordinate: ({searchResult.Value.Features[0].Geometry.Co
160
157
This sample demonstrates how to perform batch search address.
161
158
162
159
``` 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 ;
167
162
using Azure .Maps .Search .Models ;
163
+ using Azure .Maps .Search .Models .Queries ;
168
164
// Use Azure Maps subscription key authentication
169
165
var subscriptionKey = Environment .GetEnvironmentVariable (" SUBSCRIPTION_KEY" ) ?? string .Empty ;
170
166
var credential = new AzureKeyCredential (subscriptionKey );
171
167
var client = new MapsSearchClient (credential );
172
168
173
169
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
+ };
184
180
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
+ }
186
187
```
187
188
188
189
## Reverse geocode a coordinates
189
190
190
191
You can translate coordinates into human-readable street addresses. This process is also called reverse geocoding.
191
192
192
193
``` csharp
193
- using system ;
194
- using Azure ;
194
+ using System ;
195
195
using Azure .Core .GeoJson ;
196
- using Azure .Maps .Search ;
197
196
using Azure .Maps .Search .Models ;
197
+
198
198
// Use Azure Maps subscription key authentication
199
199
var subscriptionKey = Environment .GetEnvironmentVariable (" SUBSCRIPTION_KEY" ) ?? string .Empty ;
200
200
var credential = new AzureKeyCredential (subscriptionKey );
201
201
var client = new MapsSearchClient (credential );
202
202
203
203
GeoPosition coordinates = new GeoPosition (- 122 . 138685 , 47 . 6305637 );
204
204
Response < GeocodingResponse > result = client .GetReverseGeocoding (coordinates );
205
+
206
+ // Print addresses
205
207
for (int i = 0 ; i < result .Value .Features .Count ; i ++ )
206
208
{
207
- Console .WriteLine (result .Value .Features [i ].Geometry );
209
+ Console .WriteLine (result .Value .Features [i ].Properties . Address . AddressLine );
208
210
}
209
211
```
210
212
@@ -213,11 +215,11 @@ for (int i = 0; i < result.Value.Features.Count; i++)
213
215
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.
214
216
215
217
``` csharp
216
- using system ;
217
- using Azure ;
218
+ using System ;
219
+ using System . Collections . Generic ;
218
220
using Azure .Core .GeoJson ;
219
- using Azure .Maps .Search ;
220
221
using Azure .Maps .Search .Models ;
222
+ using Azure .Maps .Search .Models .Queries ;
221
223
222
224
// Use Azure Maps subscription key authentication
223
225
var subscriptionKey = Environment .GetEnvironmentVariable (" SUBSCRIPTION_KEY" ) ?? string .Empty ;
@@ -236,19 +238,22 @@ List<ReverseGeocodingQuery> items = new List<ReverseGeocodingQuery>
236
238
},
237
239
};
238
240
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
+ }
240
246
```
241
247
242
248
## Get polygons for a given location
243
249
244
250
This sample demonstrates how to search polygons.
245
251
246
252
``` csharp
247
- using system ;
248
- using Azure ;
253
+ using System ;
249
254
using Azure .Core .GeoJson ;
250
- using Azure .Maps .Search ;
251
255
using Azure .Maps .Search .Models ;
256
+ using Azure .Maps .Search .Models .Options ;
252
257
253
258
// Use Azure Maps subscription key authentication
254
259
var subscriptionKey = Environment .GetEnvironmentVariable (" SUBSCRIPTION_KEY" ) ?? string .Empty ;
0 commit comments