为什么 Google 地图的地理编码器返回日文字符?

2023-12-02

我有一个像这样的方法:

Address address = new Geocoder(context).getFromLocation(latitude, longitude, 5).get(0);
return address.getThoroughfare() + ", " + address.getSubThoroughfare() + ", " + address.getSubLocality();

当我打印结果时,值address.getSubLocality()显示日语字符串。

为什么会出现这种情况?

我该如何解决这个问题?

谢谢你!

EDIT

我的完整示例项目:

public class MainActivity extends Activity implements View.OnClickListener {

    EditText ed1, ed2;
    TextView tv1;
    Button bt1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ed1 = (EditText) findViewById(R.id.ed1);
        ed2 = (EditText) findViewById(R.id.ed2);
        tv1 = (TextView) findViewById(R.id.tv1);
        bt1 = (Button) findViewById(R.id.bt1);

        ed1.setText("-23.50282");
        ed2.setText("-46.84905");

        bt1.setOnClickListener(this);
    }

    public static String getAddressFromLocation(Context context, Double latitude, Double longitude) throws IOException {
        Address address = new Geocoder(context, Locale.ENGLISH).getFromLocation(latitude, longitude, 5).get(0);
        return address.getThoroughfare() + ", " + address.getSubThoroughfare() + ", " + address.getSubLocality() + " - " + address.getAdminArea();
    }

    @Override
    public void onClick(View v) {
        String address = "Street";
        if (v.getId() == R.id.bt1) {
            try {
                address = getAddressFromLocation(this, Double.parseDouble(ed1.getText().toString()), Double.parseDouble(ed2.getText().toString()));
            } catch (IOException e) {
                e.printStackTrace();
            }
            tv1.setText(address);
        }
    }
}

它以这种方式返回,因为这就是它的标签方式谷歌地图。您看到的日语字符(アウファヴィーレ) 是表示阿尔法城,该地区的一家开发公司。

为什么有人用日语标记它,我不知道。不过,你对此无能为力。附近的其他地点没有这样标记。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么 Google 地图的地理编码器返回日文字符? 的相关文章

随机推荐