私はDD3 7BNなどのポストコードを変更するソリューションを探していますが、地理的位置は使用していません。 URL http://maps.googleapis.com/maps/api/geocode/json?address=DD37bnを使って解決策を見つけました。 1人の男が別の解決策を提供しましたが、私にとってはうまく機能しません。マップAPIを使用して郵便番号から通り名を取得するにはどうすればいいですか?
しかし、GRPS Failedというエラーが表示されます。私の問題に最適な解決策は何ですか?
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getAddressByPostalCode("");
}
public void getAddressByPostalCode(String val_pcode) {
Geocoder geocoder = new Geocoder(this.getApplicationContext(), Locale.getDefault());
try {
List<Address> addresses1 = geocoder.getFromLocationName (val_pcode, 1);
Address obj1 = addresses1.get(0);
List<Address> addresses = geocoder.getFromLocation(obj1.getLatitude(), obj1.getLongitude(), 1);
Address obj = addresses.get(0);
/*TextView street = (TextView)findViewById(R.id.editText1);
TextView pcode = (TextView)findViewById(R.id.editText2);
TextView blk = (TextView)findViewById(R.id.editText3);
TextView build = (TextView)findViewById(R.id.editText4);
street.setText(obj.getThoroughfare());
pcode.setText(obj.getPostalCode());
blk.setText(obj.getSubThoroughfare());
build.setText(obj.getPremises());*/
} catch (IOException e) {
Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}
私は自分自身で1つの都市でのみ使用する必要があります。それ以上の結果やnullがあることはわかっています。しかし、私は解決策を探しています。後で私がチェックできるので、私はこのリンクを使って通りを取る方法を探しています。それは私が期待していたこの記録です。 –
Googleを使用している場合は、 "タイプ"配列の "ルート"を含む "address_components"配列内のオブジェクトを探します。 –
あなたはどのようにexaplesコードでGoogleを使用するか、私はそれについての詳細を見つけることができます与えることができますか? –