问题描述
我有身体的方法是这样的:
地址地址=新的地缘codeR(上下文).getFromLocation(纬度,经度,5)获得(0);
返回address.getThoroughfare()+,+ address.getSubThoroughfare()+,+ address.getSubLocality();
当我打印结果, address.getSubLocality的值()
显示的字符串日本。
为什么这个happnes?
和我怎么才能解决这个问题?
感谢您!
修改
我的完整的例子项目:
公共类MainActivity扩展活动实现View.OnClickListener {
的EditText ED1,ED2;
TextView的TV1;
按钮BT1;
@覆盖
保护无效的onCreate(包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 =(按钮)findViewById(R.id.bt1);
ed1.setText( - 23.50282);
ed2.setText( - 46.84905);
bt1.setOnClickListener(本);
}
公共静态字符串getAddressFromLocation(上下文的背景下,双纬度,双经度)抛出IOException异常{
地址地址=新的地缘codeR(背景下,Locale.ENGLISH).getFromLocation(纬度,经度,5)获得(0);
返回address.getThoroughfare()+,+ address.getSubThoroughfare()+,+ address.getSubLocality()+ - + address.getAdminArea();
}
@覆盖
公共无效的onClick(视图v){
字符串的地址=街;
如果(v.getId()== R.id.bt1){
尝试 {
地址= getAddressFromLocation(。此,Double.parseDouble(ed1.getText()的toString()),Double.parseDouble(ed2.getText()的toString()));
}赶上(IOException异常E){
e.printStackTrace();
}
tv1.setText(地址);
}
}
}
它返回的方式,因为那是它是如何标记的<一个href="https://maps.google.com/maps?q=-23.50282,%20-46.84905&hl=en&ll=-23.506976,-46.848536&spn=0.032467,0.055747&sll=30.46714,-84.256856&sspn=0.488261,0.891953&t=h&z=15&iwloc=A&layer=c&cbll=-23.502742,-46.848994&panoid=T8RPc6NBj_jBMD-dhqkqlA&cbp=12,191.75,,0,12.47"相对=nofollow>谷歌地图。日本字符,你看(アウファヴィーレ
)是重presentation为的,开发公司在该地区。
在日本为什么有人标记它,我不知道。这里没有什么可以做这件事,虽然。其它地点附近没有标签这种方式。
I have a method with body like this:
Address address = new Geocoder(context).getFromLocation(latitude, longitude, 5).get(0);
return address.getThoroughfare() + ", " + address.getSubThoroughfare() + ", " + address.getSubLocality();
When I print the result, the value of address.getSubLocality()
shows a string in Japanese.
Why this happnes?
And how can I fix this?
Thank you!
EDIT
My full example project:
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);
}
}
}
It returns that way because that's how it's labeled in Google Maps. The Japanese characters you see(アウファヴィーレ
) are the representation for Alphaville, a development company in that area.
Why someone labeled it in Japanese, I don't know. There's not much you can do about it, though. Other locations nearby aren't labeled this way.
这篇关于为什么从谷歌地图地理codeR正在返回日本的人物?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!