#region GEOコーディングの値取得 internal static GeoResult GetCoding(string address) { //GeoResultクラスをインスタンス化(実体化)する GeoResult result = new GeoResult(); //問合せURLの生成 string geoUrl = "http://www.geocoding.jp/api/?v=1.1&q="+ HttpUtility.UrlEncode(address); //xmlの読み込み XmlTextReader readerGeo = new XmlTextReader(geoUrl); //データセットを準備して、読み込んだxmlをセットする DataSet dsGeo = new DataSet(); dsGeo.ReadXml(readerGeo); //成功時はTableが2件戻る if (dsGeo.Tables.Count == 2) { //緯度・経度をGeoResultクラスのresultにセットする result.Lat = dsGeo.Tables[1].Rows[0]["lat"].ToString(); result.Lng = dsGeo.Tables[1].Rows[0]["lng"].ToString(); } //メソッドを終了する return result; } #endregion