Yahoo SDK(Java)を使用して地図情報を取得

移転しました。

1. SDKをダウンロード

http://developer.yahoo.com/download/download.html

※日本Yahooのサイトには無いため注意

2. yahoo_search-dev.jar をクラスパスに追加

1で落としたSDKを解凍すると、yahoo_search-dev.jarが取得できるため、
これを実行するJavaのクラスパスに追加する。

3. サンプル文

以下のようにLocalSearchRequestに必要な検索条件を指定し、SearchClient.localSearch()で実際に検索。
値はLocalSearchResultsに格納される。

ただし、米国だけのMAP情報しか得られないもよう orz

日本版MAP情報は別の機会に記載する。

try {
    // Yahooに登録したアプリケーションIDを設定 
	String key = "yahooapiid";
    // Yahoo Webサービスにアクセスするクライアント 
	SearchClient client = new SearchClient(key);
	LocalSearchRequest searchRequest = new LocalSearchRequest();
	searchRequest.setLocation(data.searchStr);
	searchRequest.setQuery("*");
	searchRequest.setLatitude("111.1111");
	searchRequest.setLocation("222.2222");
	searchRequest.setRadius(new Float(data.radius));
	LocalSearchResults results = client.localSearch(searchRequest);
	LocalSearchResult[] result = results.listResults();
	List<GeoaddrDto> rtnList = new ArrayList<GeoaddrDto>();
	for (int i = 0; i < result.length; i++) {
		System.out.println(searchResult.getAddress() + " " + searchResult.getCity() + " " + searchResult.getState());
	}
} catch (SearchException e) {
        // 検索時のException
	return new ArrayList();
} catch (Exception e){
	throw e;
}