オプション
家 Skill API開発 azure-maps-search-dotnet

azure-maps-search-dotnet

microsoft/skills microsoft/skills

Azure Mapsの位置情報ベースのサービスを.NETアプリケーションに統合し、ジオコーディング、ルート検索、レンダリング、位置特定、および気象データを利用できるようにします。

...すべて拡張します
1
更新された時間 2026年9月14日

Azure Maps (.NET)

Azure Maps SDK for .NET は、ジオコーディング、ルート検索、レンダリング、位置情報取得、天気情報といった位置情報ベースのサービスを提供します。

インストール

# 検索(ジオコーディング、リバースジオコーディング)
dotnet add package Azure.Maps.Search --prerelease

# ルート検索(経路案内、ルートマトリックス)
dotnet add package Azure.Maps.Routing --prerelease

# レンダリング(マップタイル、静的画像)
dotnet add package Azure.Maps.Rendering --prerelease

# 位置特定(IP から位置情報)
dotnet add package Azure.Maps.Geolocation --prerelease

# 天気
dotnet add package Azure.Maps.Weather --prerelease

# リソース管理(アカウント管理、SAS トークン)
dotnet add package Azure.ResourceManager.Maps --prerelease

# 認証に必要
dotnet add package Azure.Identity

現在のバージョン:

  • Azure.Maps.Search: v2.0.0-beta.5
  • Azure.Maps.Routing: v1.0.0-beta.4
  • Azure.Maps.Rendering: v2.0.0-beta.1
  • Azure.Maps.Geolocation: v1.0.0-beta.3
  • Azure.ResourceManager.Maps: v1.1.0-beta.2

環境変数

AZURE_MAPS_SUBSCRIPTION_KEY= # AzureKeyCredential 認証の場合にのみ必要
AZURE_MAPS_CLIENT_ID= # 必須: Azure Maps クライアント ID
AZURE_TOKEN_CREDENTIALS=prod  # 本番環境で DefaultAzureCredential を使用する場合にのみ必要

認証

サブスクリプション キー(共有キー)

using Azure;
using Azure.Maps.Search;

var subscriptionKey = Environment.GetEnvironmentVariable("AZURE_MAPS_SUBSCRIPTION_KEY");
var credential = new AzureKeyCredential(subscriptionKey);

var client = new MapsSearchClient(credential);

Microsoft Entra トークン資格情報

using Azure.Identity;
using Azure.Maps.Search;

// ローカル開発環境: DefaultAzureCredential。 本番環境:AZURE_TOKEN_CREDENTIALS=prod または AZURE_TOKEN_CREDENTIALS=を設定
var credential = new DefaultAzureCredential(
    DefaultAzureCredential.DefaultEnvironmentVariableName
);
// または、本番環境では特定の認証情報を直接使用します:
// https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes を参照してください
// var credential = new ManagedIdentityCredential();
var clientId = Environment.GetEnvironmentVariable("AZURE_MAPS_CLIENT_ID");

var client = new MapsSearchClient(credential, clientId);

共有アクセス署名 (SAS)

using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Maps;
using Azure.ResourceManager.Maps.Models;
using Azure.Maps.Search;

// Azure Resource Manager による認証
ArmClient armClient = new ArmClient(new DefaultAzureCredential());

// Maps アカウントリソースの取得
ResourceIdentifier mapsAccountResourceId = MapsAccountResource.CreateResourceIdentifier(
    subscriptionId, resourceGroupName, accountName);
MapsAccountResource mapsAccount = armClient.GetMapsAccountResource(mapsAccountResourceId);

// SASトークンの生成
MapsAccountSasContent sasContent = new MapsAccountSasContent(
    MapsSigningKey.PrimaryKey, 
    principalId, 
    maxRatePerSecond: 500, 
    start: DateTime.UtcNow.ToString("O"), 
    expiry: DateTime.UtcNow.AddDays(1).ToString("O"));

Response sas = mapsAccount.GetSas(sasContent);

// SASトークンを使用してクライアントを作成
var sasCredential = new AzureSasCredential(sas.Value.AccountSasToken);
var client = new MapsSearchClient(sasCredential);

クライアントの階層

Azure.Maps.Search
└── MapsSearchClient
    ├── GetGeocoding()                    → 住所のジオコーディング
    ├── GetGeocodingBatch()               → バッチジオコーディング
    ├── GetReverseGeocoding()             → 座標から住所への変換
    ├── GetReverseGeocodingBatch()        → バッチ逆ジオコーディング
    └── GetPolygon()                      → 境界ポリゴンの取得

Azure.Maps.Routing
└── MapsRoutingClient
    ├── GetDirections()                   → 経路案内
    ├── GetImmediateRouteMatrix()         → ルートマトリックス(同期、≤100)
    ├── GetRouteMatrix()                  → ルートマトリックス (非同期、≤700)
    └── GetRouteRange()                   → 等時間範囲/到達可能範囲

Azure.Maps.Rendering
└── MapsRenderingClient
    ├── GetMapTile()                      → 地図タイル
    ├── GetMapStaticImage()               → 静的な地図画像
    └── GetCopyrightCaption()             → 著作権情報

Azure.Maps.Geolocation
└── MapsGeolocationClient
    └── GetCountryCode()                  → IP から国/地域

Azure.Maps.Weather
└── MapsWeatherClient
    ├── GetCurrentWeatherConditions()     → 現在の天気
    ├── GetDailyForecast()                → 日別予報
    ├── GetHourlyForecast()               → 1時間ごとの予報
    └── GetSevereWeatherAlerts()          → 気象警報

主要なワークフロー

1. ジオコーディング(住所から座標へ)

using Azure;
using Azure.Maps.Search;

var credential = new AzureKeyCredential(subscriptionKey);
var client = new MapsSearchClient(credential);

Response result = client.GetGeocoding("1 Microsoft Way, Redmond, WA 98052");

foreach (var feature in result.Value.Features)
{
    Console.WriteLine($"座標: {string.Join(",", feature.Geometry.Coordinates)}");
    Console.WriteLine($"住所: {feature.Properties.Address.FormattedAddress}");
    Console.WriteLine($"信頼度: {feature.Properties.Confidence}");
}

2. バッチジオコーディング

using Azure.Maps.Search.Models.Queries;

List queries = new List{
    new GeocodingQuery() { Query = "400 Broad St, Seattle, WA" },
    new GeocodingQuery() { Query = "1 Microsoft Way, Redmond, WA" },
    new GeocodingQuery() { AddressLine = "Space Needle", Top = 1 },
};

レスポンス results = client.GetGeocodingBatch(queries);

foreach (var batchItem in results.Value.BatchItems)
{
    foreach (var feature in batchItem.Features)
    {
        Console.WriteLine($"座標: {string.Join(",", feature.Geometry.Coordinates)}");
    }
}

3. リバースジオコーディング(座標から住所への変換)

using Azure.Core.GeoJson;

GeoPosition coordinates = new GeoPosition(-122.138685, 47.6305637);
Response result = client.GetReverseGeocoding(coordinates);

foreach (var feature in result.Value.Features)
{
    Console.WriteLine($"住所: {feature.Properties.Address.FormattedAddress}");
    Console.WriteLine($"地域: {feature.Properties.Address.Locality}");
}

4. 境界ポリゴンの取得

using Azure.Maps.Search.Models;

GetPolygonOptions options = new GetPolygonOptions()
{
    Coordinates = new GeoPosition(-122.204141, 47.61256),
    ResultType = BoundaryResultTypeEnum.Locality,
    Resolution = ResolutionEnum.Small,
};

Response result = client.GetPolygon(options);

Console.WriteLine($"境界の著作権: {result.Value.Properties?.Copyright}");
Console.WriteLine($"ポリゴンの数: {result.Value.Geometry.Count}");

5. 経路案内

using Azure;
using Azure.Core.GeoJson;
using Azure.Maps.Routing;
using Azure.Maps.Routing.Models;

var client = new MapsRoutingClient(new AzureKeyCredential(subscriptionKey));

List routePoints = new List()
{
    new GeoPosition(-122.34, 47.61),  // シアトル
    new GeoPosition(-122.13, 47.64)   // レドモンド
};

RouteDirectionQuery query = new RouteDirectionQuery(routePoints);
Response result = client.GetDirections(query);

foreach (var route in result.Value.Routes)
{
    Console.WriteLine($"距離: {route.Summary.LengthInMeters} メートル");
    Console.WriteLine($"所要時間: {route.Summary.TravelTimeDuration}");
    
    foreach (RouteLeg leg in route.Legs)
    {
        Console.WriteLine($"区間のポイント数: {leg.Points.Count}");
    }
}

6. オプション付きルート案内

RouteDirectionOptions options = new RouteDirectionOptions()
{
    RouteType = RouteType.Fastest,
    UseTrafficData = true,
    TravelMode = TravelMode.Bicycle,
    Language = RoutingLanguage.EnglishUsa,
    InstructionsType = RouteInstructionsType.Text,
};

RouteDirectionQuery query = new RouteDirectionQuery(routePoints)
{
    RouteDirectionOptions = options
};

Response result = client.GetDirections(query);

7. ルートマトリックス

RouteMatrixQuery routeMatrixQuery = new RouteMatrixQuery
{
    Origins = new List()
    {
        new GeoPosition(-122.34, 47.61),
        new GeoPosition(-122.13, 47.64)
    },
    Destinations = new List () 
    { 
        new GeoPosition(-122.20, 47.62),
        new GeoPosition(-122.40, 47.65)
    },
};

// 同期処理(最大100通りのルート組み合わせ)
Response result = client.GetImmediateRouteMatrix(routeMatrixQuery);

foreach (var cell in result.Value.Matrix.SelectMany(row => row))
{
    Console.WriteLine($"距離: {cell.Response?.RouteSummary?.LengthInMeters}");
    Console.WriteLine($"所要時間: {cell.Response?.RouteSummary?.TravelTimeDuration}");
}

// 非同期 (最大 700 通りのルート組み合わせ)
RouteMatrixOptions routeMatrixOptions = new RouteMatrixOptions(routeMatrixQuery)
{
    TravelTimeType = TravelTimeType.All,
};
GetRouteMatrixOperation asyncResult = client.GetRouteMatrix(WaitUntil.Completed, routeMatrixOptions);

8. 経路範囲(等時間)

RouteRangeOptions options = new RouteRangeOptions(-122.34, 47.61)
{
    TimeBudget = new TimeSpan(0, 20, 0)  // 20分
};

Response result = client.GetRouteRange(options);

// result.Value.ReachableRange にポリゴンが格納される
Console.WriteLine($"境界点数: {result.Value.ReachableRange.Boundary.Count}");

9. マップタイルの取得

using Azure;
using Azure.Maps.Rendering;

var client = new MapsRenderingClient(new AzureKeyCredential(subscriptionKey));

int zoom = 10;
int tileSize = 256;

// 座標をタイルインデックスに変換
MapTileIndex tileIndex = MapsRenderingClient.PositionToTileXY(
    new GeoPosition(13.3854, 52.517), zoom, tileSize);

// マップタイルを取得
GetMapTileOptions options = new GetMapTileOptions(
    MapTileSetId.MicrosoftImagery,
    new MapTileIndex(tileIndex.X, tileIndex.Y, zoom)
);

Response mapTile = client.GetMapTile(options);

// ファイルに保存
using (FileStream fileStream = File.Create("./MapTile.png"))
{
    mapTile.Value.CopyTo(fileStream);
}

10. IP ジオロケーション

using System.Net;
using Azure;
using Azure.Maps.Geolocation;

var client = new MapsGeolocationClient(new AzureKeyCredential(subscriptionKey));

IPAddress ipAddress = IPAddress.Parse("2001:4898:80e8:b::189");
Response result = client.GetCountryCode(ipAddress);

Console.WriteLine($"国の ISO コード: {result.Value.IsoCode}");

11. 現在の天気

using Azure;
using Azure.Core.GeoJson;
using Azure.Maps.Weather;

var client = new MapsWeatherClient(new AzureKeyCredential(subscriptionKey));

var position = new GeoPosition(-122.13071, 47.64011);
var options = new GetCurrentWeatherConditionsOptions(position);

Response result = client.GetCurrentWeatherConditions(options);

foreach (var condition in result.Value.Results)
{
    Console.WriteLine($"気温: {condition.Temperature.Value} {condition.Temperature.Unit}");
    Console.WriteLine($"天気: {condition.Phrase}");
    Console.WriteLine($"湿度: {condition.RelativeHumidity}%");
}

キー型のリファレンス

パッケージの検索

目的
MapsSearchClient 検索操作のメインクライアント
GeocodingResponse ジオコーディング結果
GeocodingBatchResponse 一括ジオコーディングの結果
GeocodingQuery バッチジオコーディングのクエリ
ReverseGeocodingQuery バッチ逆ジオコーディングのクエリ
GetPolygonOptions ポリゴン取得のオプション
境界 境界ポリゴンの結果
BoundaryResultTypeEnum 境界タイプ(Locality、AdminDistrict など)
解像度列挙型 ポリゴンの解像度(小、中、大)

ルーティング・パッケージ

タイプ 目的
MapsRoutingClient ルーティング操作用のメインクライアント
RouteDirectionQuery 経路の方向に関するクエリ
RouteDirectionOptions 経路計算のオプション
RouteDirections ルート案内結果
ルート区間 ルートの区間
RouteMatrixQuery ルートマトリクスの照会
ルートマトリックス結果 ルートマトリックスの結果
ルート範囲オプション 等時線に関するオプション
ルート範囲の結果 等時線の結果
ルートタイプ ルートタイプ(最速、最短、エコ、スリル)
TravelMode 移動モード(乗用車、トラック、自転車、徒歩)

レンダリングパッケージ

タイプ 目的
MapsRenderingClient レンダリング用のメインクライアント
GetMapTileOptions マップタイルのオプション
MapTileIndex タイル座標 (X, Y, ズーム)
MapTileSetId タイルセット識別子

一般的なタイプ

タイプ 目的
GeoPosition 地理的位置(経度、緯度)
GeoBoundingBox 地理的エリアの境界ボックス

ベストプラクティス

  1. 本番環境ではEntra IDを使用してください— サブスクリプションキーよりも優先して使用してください
  2. バッチ処理— 複数の住所にはバッチジオコーディングを使用する
  3. 結果のキャッシュ— ジオコーディングの結果は頻繁に変化しない
  4. 適切なタイルサイズを使用する— 表示に応じて256または512ピクセル
  5. レート制限への対応— 指数関数的バックオフを実装する
  6. 非同期ルートマトリックスの使用— 大規模なマトリックス計算(100以上)の場合
  7. 交通データを考慮する— 正確な到着予定時刻(ETA)を得るために、UseTrafficData = trueに設定する

エラー処理

try
{
    Response result = client.GetGeocoding(address);
}
catch (RequestFailedException ex)
{
    Console.WriteLine($"ステータス: {ex.Status}");
    Console.WriteLine($"エラー: {ex.Message}");
    
    switch (ex.Status)
    {
        case 400:
            // 無効なリクエストパラメータ
            break;
        case 401:
            // 認証失敗
            break;
        case 429:
            // レート制限 - バックオフを実装
            break;
    }
}

関連する SDK

SDK 目的 インストール
Azure.Maps.Search ジオコーディング、検索 dotnet add package Azure.Maps.Search --prerelease
Azure.Maps.Routing 経路案内、マトリックス dotnet add package Azure.Maps.Routing --prerelease
Azure.Maps.Rendering マップタイル、画像 dotnet add package Azure.Maps.Rendering --prerelease
Azure.Maps.Geolocation IP 位置情報 dotnet add package Azure.Maps.Geolocation --prerelease
Azure.Maps.Weather 天気データ dotnet add package Azure.Maps.Weather --prerelease
Azure.ResourceManager.Maps アカウント管理 dotnet add package Azure.ResourceManager.Maps --prerelease

参考リンク

リソース URL
Azure Maps ドキュメント https://learn.microsoft.com/azure/azure-maps/
検索 API リファレンス https://learn.microsoft.com/dotnet/api/azure.maps.search
ルート検索 API リファレンス https://learn.microsoft.com/dotnet/api/azure.maps.routing
GitHubのソースコード https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/maps
価格 https://azure.microsoft.com/pricing/details/azure-maps/
GitHubで見る
---
name: azure-maps-search-dotnet
description: Integrate Azure Maps location-based services into .NET applications for geocoding, routing, rendering, geolocation, and weather data.
license: MIT
---

# Azure Maps (.NET)

Azure Maps SDK for .NET providing location-based services: geocoding, routing, rendering, geolocation, and weather.

## Installation

```bash
# Search (geocoding, reverse geocoding)
dotnet add package Azure.Maps.Search --prerelease

# Routing (directions, route matrix)
dotnet add package Azure.Maps.Routing --prerelease

# Rendering (map tiles, static images)
dotnet add package Azure.Maps.Rendering --prerelease

# Geolocation (IP to location)
dotnet add package Azure.Maps.Geolocation --prerelease

# Weather
dotnet add package Azure.Maps.Weather --prerelease

# Resource Management (account management, SAS tokens)
dotnet add package Azure.ResourceManager.Maps --prerelease

# Required for authentication
dotnet add package Azure.Identity
```

**Current Versions**:
- `Azure.Maps.Search`: v2.0.0-beta.5
- `Azure.Maps.Routing`: v1.0.0-beta.4
- `Azure.Maps.Rendering`: v2.0.0-beta.1
- `Azure.Maps.Geolocation`: v1.0.0-beta.3
- `Azure.ResourceManager.Maps`: v1.1.0-beta.2

## Environment Variables

```bash
AZURE_MAPS_SUBSCRIPTION_KEY=<your-subscription-key>  # Only required for AzureKeyCredential auth
AZURE_MAPS_CLIENT_ID=<your-client-id>  # Required: Azure Maps client ID
AZURE_TOKEN_CREDENTIALS=prod  # Required only if DefaultAzureCredential is used in production
```

## Authentication

### Subscription Key (Shared Key)

```csharp
using Azure;
using Azure.Maps.Search;

var subscriptionKey = Environment.GetEnvironmentVariable("AZURE_MAPS_SUBSCRIPTION_KEY");
var credential = new AzureKeyCredential(subscriptionKey);

var client = new MapsSearchClient(credential);
```

### Microsoft Entra Token Credential

```csharp
using Azure.Identity;
using Azure.Maps.Search;

// Local dev: DefaultAzureCredential. Production: set AZURE_TOKEN_CREDENTIALS=prod or AZURE_TOKEN_CREDENTIALS=<specific_credential>
var credential = new DefaultAzureCredential(
    DefaultAzureCredential.DefaultEnvironmentVariableName
);
// Or use a specific credential directly in production:
// See https://learn.microsoft.com/dotnet/api/overview/azure/identity-readme?view=azure-dotnet#credential-classes
// var credential = new ManagedIdentityCredential();
var clientId = Environment.GetEnvironmentVariable("AZURE_MAPS_CLIENT_ID");

var client = new MapsSearchClient(credential, clientId);
```

### Shared Access Signature (SAS)

```csharp
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Maps;
using Azure.ResourceManager.Maps.Models;
using Azure.Maps.Search;

// Authenticate with Azure Resource Manager
ArmClient armClient = new ArmClient(new DefaultAzureCredential());

// Get Maps account resource
ResourceIdentifier mapsAccountResourceId = MapsAccountResource.CreateResourceIdentifier(
    subscriptionId, resourceGroupName, accountName);
MapsAccountResource mapsAccount = armClient.GetMapsAccountResource(mapsAccountResourceId);

// Generate SAS token
MapsAccountSasContent sasContent = new MapsAccountSasContent(
    MapsSigningKey.PrimaryKey, 
    principalId, 
    maxRatePerSecond: 500, 
    start: DateTime.UtcNow.ToString("O"), 
    expiry: DateTime.UtcNow.AddDays(1).ToString("O"));

Response<MapsAccountSasToken> sas = mapsAccount.GetSas(sasContent);

// Create client with SAS token
var sasCredential = new AzureSasCredential(sas.Value.AccountSasToken);
var client = new MapsSearchClient(sasCredential);
```

## Client Hierarchy

```
Azure.Maps.Search
└── MapsSearchClient
    ├── GetGeocoding()                    → Geocode addresses
    ├── GetGeocodingBatch()               → Batch geocoding
    ├── GetReverseGeocoding()             → Coordinates to address
    ├── GetReverseGeocodingBatch()        → Batch reverse geocoding
    └── GetPolygon()                      → Get boundary polygons

Azure.Maps.Routing
└── MapsRoutingClient
    ├── GetDirections()                   → Route directions
    ├── GetImmediateRouteMatrix()         → Route matrix (sync, ≤100)
    ├── GetRouteMatrix()                  → Route matrix (async, ≤700)
    └── GetRouteRange()                   → Isochrone/reachable range

Azure.Maps.Rendering
└── MapsRenderingClient
    ├── GetMapTile()                      → Map tiles
    ├── GetMapStaticImage()               → Static map images
    └── GetCopyrightCaption()             → Copyright info

Azure.Maps.Geolocation
└── MapsGeolocationClient
    └── GetCountryCode()                  → IP to country/region

Azure.Maps.Weather
└── MapsWeatherClient
    ├── GetCurrentWeatherConditions()     → Current weather
    ├── GetDailyForecast()                → Daily forecast
    ├── GetHourlyForecast()               → Hourly forecast
    └── GetSevereWeatherAlerts()          → Weather alerts
```

## Core Workflows

### 1. Geocoding (Address to Coordinates)

```csharp
using Azure;
using Azure.Maps.Search;

var credential = new AzureKeyCredential(subscriptionKey);
var client = new MapsSearchClient(credential);

Response<GeocodingResponse> result = client.GetGeocoding("1 Microsoft Way, Redmond, WA 98052");

foreach (var feature in result.Value.Features)
{
    Console.WriteLine($"Coordinates: {string.Join(",", feature.Geometry.Coordinates)}");
    Console.WriteLine($"Address: {feature.Properties.Address.FormattedAddress}");
    Console.WriteLine($"Confidence: {feature.Properties.Confidence}");
}
```

### 2. Batch Geocoding

```csharp
using Azure.Maps.Search.Models.Queries;

List<GeocodingQuery> queries = new List<GeocodingQuery>
{
    new GeocodingQuery() { Query = "400 Broad St, Seattle, WA" },
    new GeocodingQuery() { Query = "1 Microsoft Way, Redmond, WA" },
    new GeocodingQuery() { AddressLine = "Space Needle", Top = 1 },
};

Response<GeocodingBatchResponse> results = client.GetGeocodingBatch(queries);

foreach (var batchItem in results.Value.BatchItems)
{
    foreach (var feature in batchItem.Features)
    {
        Console.WriteLine($"Coordinates: {string.Join(",", feature.Geometry.Coordinates)}");
    }
}
```

### 3. Reverse Geocoding (Coordinates to Address)

```csharp
using Azure.Core.GeoJson;

GeoPosition coordinates = new GeoPosition(-122.138685, 47.6305637);
Response<GeocodingResponse> result = client.GetReverseGeocoding(coordinates);

foreach (var feature in result.Value.Features)
{
    Console.WriteLine($"Address: {feature.Properties.Address.FormattedAddress}");
    Console.WriteLine($"Locality: {feature.Properties.Address.Locality}");
}
```

### 4. Get Boundary Polygon

```csharp
using Azure.Maps.Search.Models;

GetPolygonOptions options = new GetPolygonOptions()
{
    Coordinates = new GeoPosition(-122.204141, 47.61256),
    ResultType = BoundaryResultTypeEnum.Locality,
    Resolution = ResolutionEnum.Small,
};

Response<Boundary> result = client.GetPolygon(options);

Console.WriteLine($"Boundary copyright: {result.Value.Properties?.Copyright}");
Console.WriteLine($"Polygon count: {result.Value.Geometry.Count}");
```

### 5. Route Directions

```csharp
using Azure;
using Azure.Core.GeoJson;
using Azure.Maps.Routing;
using Azure.Maps.Routing.Models;

var client = new MapsRoutingClient(new AzureKeyCredential(subscriptionKey));

List<GeoPosition> routePoints = new List<GeoPosition>()
{
    new GeoPosition(-122.34, 47.61),  // Seattle
    new GeoPosition(-122.13, 47.64)   // Redmond
};

RouteDirectionQuery query = new RouteDirectionQuery(routePoints);
Response<RouteDirections> result = client.GetDirections(query);

foreach (var route in result.Value.Routes)
{
    Console.WriteLine($"Distance: {route.Summary.LengthInMeters} meters");
    Console.WriteLine($"Duration: {route.Summary.TravelTimeDuration}");
    
    foreach (RouteLeg leg in route.Legs)
    {
        Console.WriteLine($"Leg points: {leg.Points.Count}");
    }
}
```

### 6. Route Directions with Options

```csharp
RouteDirectionOptions options = new RouteDirectionOptions()
{
    RouteType = RouteType.Fastest,
    UseTrafficData = true,
    TravelMode = TravelMode.Bicycle,
    Language = RoutingLanguage.EnglishUsa,
    InstructionsType = RouteInstructionsType.Text,
};

RouteDirectionQuery query = new RouteDirectionQuery(routePoints)
{
    RouteDirectionOptions = options
};

Response<RouteDirections> result = client.GetDirections(query);
```

### 7. Route Matrix

```csharp
RouteMatrixQuery routeMatrixQuery = new RouteMatrixQuery
{
    Origins = new List<GeoPosition>()
    {
        new GeoPosition(-122.34, 47.61),
        new GeoPosition(-122.13, 47.64)
    },
    Destinations = new List<GeoPosition>() 
    { 
        new GeoPosition(-122.20, 47.62),
        new GeoPosition(-122.40, 47.65)
    },
};

// Synchronous (up to 100 route combinations)
Response<RouteMatrixResult> result = client.GetImmediateRouteMatrix(routeMatrixQuery);

foreach (var cell in result.Value.Matrix.SelectMany(row => row))
{
    Console.WriteLine($"Distance: {cell.Response?.RouteSummary?.LengthInMeters}");
    Console.WriteLine($"Duration: {cell.Response?.RouteSummary?.TravelTimeDuration}");
}

// Asynchronous (up to 700 route combinations)
RouteMatrixOptions routeMatrixOptions = new RouteMatrixOptions(routeMatrixQuery)
{
    TravelTimeType = TravelTimeType.All,
};
GetRouteMatrixOperation asyncResult = client.GetRouteMatrix(WaitUntil.Completed, routeMatrixOptions);
```

### 8. Route Range (Isochrone)

```csharp
RouteRangeOptions options = new RouteRangeOptions(-122.34, 47.61)
{
    TimeBudget = new TimeSpan(0, 20, 0)  // 20 minutes
};

Response<RouteRangeResult> result = client.GetRouteRange(options);

// result.Value.ReachableRange contains the polygon
Console.WriteLine($"Boundary points: {result.Value.ReachableRange.Boundary.Count}");
```

### 9. Get Map Tiles

```csharp
using Azure;
using Azure.Maps.Rendering;

var client = new MapsRenderingClient(new AzureKeyCredential(subscriptionKey));

int zoom = 10;
int tileSize = 256;

// Convert coordinates to tile index
MapTileIndex tileIndex = MapsRenderingClient.PositionToTileXY(
    new GeoPosition(13.3854, 52.517), zoom, tileSize);

// Fetch map tile
GetMapTileOptions options = new GetMapTileOptions(
    MapTileSetId.MicrosoftImagery,
    new MapTileIndex(tileIndex.X, tileIndex.Y, zoom)
);

Response<Stream> mapTile = client.GetMapTile(options);

// Save to file
using (FileStream fileStream = File.Create("./MapTile.png"))
{
    mapTile.Value.CopyTo(fileStream);
}
```

### 10. IP Geolocation

```csharp
using System.Net;
using Azure;
using Azure.Maps.Geolocation;

var client = new MapsGeolocationClient(new AzureKeyCredential(subscriptionKey));

IPAddress ipAddress = IPAddress.Parse("2001:4898:80e8:b::189");
Response<CountryRegionResult> result = client.GetCountryCode(ipAddress);

Console.WriteLine($"Country ISO Code: {result.Value.IsoCode}");
```

### 11. Current Weather

```csharp
using Azure;
using Azure.Core.GeoJson;
using Azure.Maps.Weather;

var client = new MapsWeatherClient(new AzureKeyCredential(subscriptionKey));

var position = new GeoPosition(-122.13071, 47.64011);
var options = new GetCurrentWeatherConditionsOptions(position);

Response<CurrentConditionsResult> result = client.GetCurrentWeatherConditions(options);

foreach (var condition in result.Value.Results)
{
    Console.WriteLine($"Temperature: {condition.Temperature.Value} {condition.Temperature.Unit}");
    Console.WriteLine($"Weather: {condition.Phrase}");
    Console.WriteLine($"Humidity: {condition.RelativeHumidity}%");
}
```

## Key Types Reference

### Search Package

| Type | Purpose |
|------|---------|
| `MapsSearchClient` | Main client for search operations |
| `GeocodingResponse` | Geocoding result |
| `GeocodingBatchResponse` | Batch geocoding result |
| `GeocodingQuery` | Query for batch geocoding |
| `ReverseGeocodingQuery` | Query for batch reverse geocoding |
| `GetPolygonOptions` | Options for polygon retrieval |
| `Boundary` | Boundary polygon result |
| `BoundaryResultTypeEnum` | Boundary type (Locality, AdminDistrict, etc.) |
| `ResolutionEnum` | Polygon resolution (Small, Medium, Large) |

### Routing Package

| Type | Purpose |
|------|---------|
| `MapsRoutingClient` | Main client for routing operations |
| `RouteDirectionQuery` | Query for route directions |
| `RouteDirectionOptions` | Route calculation options |
| `RouteDirections` | Route directions result |
| `RouteLeg` | Segment of a route |
| `RouteMatrixQuery` | Query for route matrix |
| `RouteMatrixResult` | Route matrix result |
| `RouteRangeOptions` | Options for isochrone |
| `RouteRangeResult` | Isochrone result |
| `RouteType` | Route type (Fastest, Shortest, Eco, Thrilling) |
| `TravelMode` | Travel mode (Car, Truck, Bicycle, Pedestrian) |

### Rendering Package

| Type | Purpose |
|------|---------|
| `MapsRenderingClient` | Main client for rendering |
| `GetMapTileOptions` | Map tile options |
| `MapTileIndex` | Tile coordinates (X, Y, Zoom) |
| `MapTileSetId` | Tile set identifier |

### Common Types

| Type | Purpose |
|------|---------|
| `GeoPosition` | Geographic position (longitude, latitude) |
| `GeoBoundingBox` | Bounding box for geographic area |

## Best Practices

1. **Use Entra ID for production** — Prefer over subscription keys
2. **Batch operations** — Use batch geocoding for multiple addresses
3. **Cache results** — Geocoding results don't change frequently
4. **Use appropriate tile sizes** — 256 or 512 pixels based on display
5. **Handle rate limits** — Implement exponential backoff
6. **Use async route matrix** — For large matrix calculations (>100)
7. **Consider traffic data** — Set `UseTrafficData = true` for accurate ETAs

## Error Handling

```csharp
try
{
    Response<GeocodingResponse> result = client.GetGeocoding(address);
}
catch (RequestFailedException ex)
{
    Console.WriteLine($"Status: {ex.Status}");
    Console.WriteLine($"Error: {ex.Message}");
    
    switch (ex.Status)
    {
        case 400:
            // Invalid request parameters
            break;
        case 401:
            // Authentication failed
            break;
        case 429:
            // Rate limited - implement backoff
            break;
    }
}
```

## Related SDKs

| SDK | Purpose | Install |
|-----|---------|---------|
| `Azure.Maps.Search` | Geocoding, search | `dotnet add package Azure.Maps.Search --prerelease` |
| `Azure.Maps.Routing` | Directions, matrix | `dotnet add package Azure.Maps.Routing --prerelease` |
| `Azure.Maps.Rendering` | Map tiles, images | `dotnet add package Azure.Maps.Rendering --prerelease` |
| `Azure.Maps.Geolocation` | IP geolocation | `dotnet add package Azure.Maps.Geolocation --prerelease` |
| `Azure.Maps.Weather` | Weather data | `dotnet add package Azure.Maps.Weather --prerelease` |
| `Azure.ResourceManager.Maps` | Account management | `dotnet add package Azure.ResourceManager.Maps --prerelease` |

## Reference Links

| Resource | URL |
|----------|-----|
| Azure Maps Documentation | https://learn.microsoft.com/azure/azure-maps/ |
| Search API Reference | https://learn.microsoft.com/dotnet/api/azure.maps.search |
| Routing API Reference | https://learn.microsoft.com/dotnet/api/azure.maps.routing |
| GitHub Source | https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/maps |
| Pricing | https://azure.microsoft.com/pricing/details/azure-maps/ |

すべてのファイル

0件のファイル

azure-maps-search-dotnetをインストール

スキルファイルをダウンロードし、.claude/skills/ ディレクトリに解凍してください。

ZIPをダウンロード

リポジトリをクローンし、スキルファイルをプロジェクトにコピーしてください。

git clone https://github.com/microsoft/skills/tree/main/.github/plugins/azure-sdk-dotnet/skills/azure-maps-search-dotnet # Copy SKILL.md to your .claude/skills/ directory

コピー コピー
クイックセットアップ: スキルフォルダを .claude/skills/ にコピーしてください。 Claude が自動的にそのスキルを検出して使用します。
リポジトリ microsoft/skills

関連スキル

brightdata-cli
更新された時間 2026年6月29日
humanize
更新された時間 2026年7月7日
agentwallet
更新された時間 2026年7月7日
korean-stock-search
更新された時間 2026年7月8日
OR