bing map API を使用して、サーバー側の呼び出しを行い、特定の都市の緯度/経度を取得できますか?
JavaScript を使用してクライアント側で実行できますが、この場合はより堅牢なものが必要であり、サーバー側を使用したいと考えています。
これを投稿して、誰にとっても答えを見つけやすくします。
Bing Maps SOAP サービス API ( http://msdn.microsoft.com/en-us/library/cc980922.aspx ) を使用します。これは、Bing Maps API のほとんどを実装し、静的マップを提供するパブリック Web サービスです (申し訳ありませんが、ユーザーからの対話機能はありません)。提供された Microsoft SDK から (わずかに変更: サービス参照をプロジェクトに追加した後、次のコードを実行します。
プライベート GeocodeResponse GeocodeAddress(文字列アドレス) { GeocodeRequest geocodeRequest = new GeocodeRequest();
// Set the credentials using a valid Bing Maps key
geocodeRequest.Credentials = new GeocodeService.Credentials();
geocodeRequest.Credentials.ApplicationId = BingMapsAPIKey;
// Set the full address query
geocodeRequest.Query = address;
// Set the options to only return high confidence results
ConfidenceFilter[] filters = new ConfidenceFilter[1];
filters[0] = new ConfidenceFilter();
filters[0].MinimumConfidence = GeocodeService.Confidence.High;
// Add the filters to the options
GeocodeOptions geocodeOptions = new GeocodeOptions();
geocodeOptions.Filters = filters;
geocodeRequest.Options = geocodeOptions;
// Make the geocode request
GeocodeServiceClient geocodeService = new GeocodeServiceClient("BasicHttpBinding_IGeocodeService");
GeocodeResponse geocodeResponse = geocodeService.Geocode(geocodeRequest);
return geocodeResponse;
}
次のコード スニペットで戻り値を確認できます。
result.Locations[0].Latitude.ToString();
result.Locations[0].Longitude.ToString();