gpt4 book ai didi

android - 为什么来自 Google map 的 Geocoder 返回日文字符?

转载 作者:太空狗 更新时间:2023-10-29 14:18:39 26 4
gpt4 key购买 nike

我有一个方法体是这样的:

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

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

为什么会这样?

我该如何解决这个问题?

谢谢!

编辑

我的完整示例项目:

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);
}
}
}

最佳答案

它以这种方式返回,因为这就是它在 Google Maps 中的标记方式.你看到的日语字符(アウフヴイーレ)是Alphaville的代表。 ,该地区的一家开发公司。

为什么有人用日文标记它,我不知道。不过,您对此无能为力。附近的其他位置没有这样标记。

关于android - 为什么来自 Google map 的 Geocoder 返回日文字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19059948/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com