Skip to content

Commit dd53f0a

Browse files
Update how-to-dev-guide-csharp-sdk.md
1 parent 4d3650e commit dd53f0a

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

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

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ var client = new MapsSearchClient(credential);
152152
Response<GeocodingResponse> searchResult = client.GetGeocoding(
153153
"1 Microsoft Way, Redmond, WA 98052");
154154

155-
Console.WriteLine($"The Coordinate: ({searchResult.Value.Features[0].Geometry.Coordinates})");
155+
for (int i = 0; i < searchResult.Value.Features.Count; i++)
156+
{
157+
Console.WriteLine("Coordinate:" + string.Join(",", searchResult.Value.Features[i].Geometry.Coordinates));
158+
}
156159
```
157160

158161
## Batch geocode addresses
@@ -186,9 +189,12 @@ List<GeocodingQuery> queries = new List<GeocodingQuery>
186189
Response<GeocodingBatchResponse> results = client.GetGeocodingBatch(queries);
187190

188191
//Print coordinates
189-
for (var i = 0; i < results.Value.BatchItems[0].Features.Count; i++)
192+
for (var i = 0; i < results.Value.BatchItems.Count; i++)
190193
{
191-
Console.WriteLine("Coordinates", results.Value.BatchItems[0].Features[i].Geometry.Coordinates);
194+
for (var j = 0; j < results.Value.BatchItems[i].Features.Count; j++)
195+
{
196+
Console.WriteLine("Coordinates: " + string.Join(",", results.Value.BatchItems[i].Features[j].Geometry.Coordinates));
197+
}
192198
}
193199
```
194200

@@ -214,7 +220,7 @@ Response<GeocodingResponse> result = client.GetReverseGeocoding(coordinates);
214220
//Print addresses
215221
for (int i = 0; i < result.Value.Features.Count; i++)
216222
{
217-
Console.WriteLine(result.Value.Features[i].Properties.Address.AddressLine);
223+
Console.WriteLine(result.Value.Features[i].Properties.Address.FormattedAddress);
218224
}
219225
```
220226

@@ -244,8 +250,8 @@ List<ReverseGeocodingQuery> items = new List<ReverseGeocodingQuery>
244250
},
245251
new ReverseGeocodingQuery()
246252
{
247-
Coordinates = new GeoPosition(-122.138679, 47.630356)
248-
ResultTypes = new List<ReverseGeocodingResultTypeEnum>(){ ReverseGeocodingResultTypeEnum.Address, ReverseGeocodingResultTypeEnum.Neighborhood}
253+
Coordinates = new GeoPosition(-122.138679, 47.630356),
254+
ResultTypes = new List<ReverseGeocodingResultTypeEnum>(){ ReverseGeocodingResultTypeEnum.Address, ReverseGeocodingResultTypeEnum.Neighborhood }
249255
},
250256
};
251257
Response<GeocodingBatchResponse> result = client.GetReverseGeocodingBatch(items);
@@ -276,14 +282,21 @@ var client = new MapsSearchClient(credential);
276282

277283
GetPolygonOptions options = new GetPolygonOptions()
278284
{
279-
Coordinates = new GeoPosition(121.5, 25.0)
285+
Coordinates = new GeoPosition(-122.204141, 47.61256),
286+
ResultType = BoundaryResultTypeEnum.Locality,
287+
Resolution = ResolutionEnum.Small,
280288
};
281289
Response<Boundary> result = client.GetPolygon(options);
282290

283-
Console.WriteLine(result.Value.Name);
284-
Console.WriteLine(result.Value.Copyright);
285-
Console.WriteLine(result.Value.CopyrightUrl);
286-
Console.WriteLine(result.Value.BoundingBox);
291+
var count = ((GeoJsonPolygon)((GeoJsonGeometryCollection)result.Value.Geometry).Geometries[0]).Coordinates.Count;
292+
for (var i = 0; i < count; i++)
293+
{
294+
var coorCount = ((GeoJsonPolygon)((GeoJsonGeometryCollection)result.Value.Geometry).Geometries[0]).Coordinates[i].Count;
295+
for (var j = 0; j < coorCount; j++)
296+
{
297+
Console.WriteLine(string.Join(",",((GeoJsonPolygon)((GeoJsonGeometryCollection)result.Value.Geometry).Geometries[0]).Coordinates[i][j]));
298+
}
299+
}
287300
```
288301

289302
## Using V1 SDKs for Search and Render

0 commit comments

Comments
 (0)