【发布时间】:2015-03-26 03:56:29
【问题描述】:
我正在使用谷歌地图 v2,我的问题是:
当用户当时输入位置时,我想检查艾哈迈达巴德的位置。
提前谢谢你。
【问题讨论】:
标签: android google-maps google-maps-api-3 dictionary android-maps
我正在使用谷歌地图 v2,我的问题是:
当用户当时输入位置时,我想检查艾哈迈达巴德的位置。
提前谢谢你。
【问题讨论】:
标签: android google-maps google-maps-api-3 dictionary android-maps
Nirmal:第一步需要获取纬度和经度。然后通过以下方法传递坐标。然后将城市的值与艾哈迈达巴德进行比较。
public void getAddress(double lat, double lng) { Geocoder geocoder = new Geocoder(HomeActivity.mContext, Locale.getDefault()); try { List<Address> addresses = geocoder.getFromLocation(lat, lng, 1); Address obj = addresses.get(0); String add = obj.getAddressLine(0); GUIStatics.currentAddress = obj.getSubAdminArea() + "," + obj.getAdminArea(); GUIStatics.latitude = obj.getLatitude(); GUIStatics.longitude = obj.getLongitude(); GUIStatics.currentCity= obj.getSubAdminArea(); GUIStatics.currentState= obj.getAdminArea(); add = add + "\n" + obj.getCountryName(); add = add + "\n" + obj.getCountryCode(); add = add + "\n" + obj.getAdminArea(); add = add + "\n" + obj.getPostalCode(); add = add + "\n" + obj.getSubAdminArea(); add = add + "\n" + obj.getLocality(); add = add + "\n" + obj.getSubThoroughfare(); Log.v("IGA", "Address" + add); // Toast.makeText(this, "Address=>" + add, // Toast.LENGTH_SHORT).show(); // TennisAppActivity.showDialog(add); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); } }
【讨论】: