0
我正在研究android地圖應用程序。我從經度和緯度獲取方向。 但問題是這是我想更新地圖方向一段時間後或位置更改後。 我的代碼如下,任何人都可以幫助我。更新地圖在特定時間之後android的dircetions?
Button.OnClickListener addressclick = new Button.OnClickListener(){
@Override
public void onClick(View v) {
/*TextView tv = (TextView)v;
String latitude ="0";
String longitude = "0";
String label = "Location";
String uriBegin = "geo:" + latitude + "," + longitude;
String query = tv.getText().toString() + "(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery+"&z=10";
Uri uri = Uri.parse(uriString);
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, uri);
startActivity(intent);*/
TextView tv = (TextView)v;
String addressStr = tv.getText().toString();
Geocoder geoCoder = new Geocoder(context);
try {
List<Address> addresses =
geoCoder.getFromLocationName(addressStr, 1);
if (addresses.size() > 0) {
latitude = addresses.get(0).getLatitude();
longitude =addresses.get(0).getLongitude(); }
} catch (IOException e) { // TODO Auto-generated catch block
e.printStackTrace();
}
String directionweburl = "http://maps.google.com/maps?daddr="+Double.toString(latitude)+","+Double.toString(longitude)+"&saddr="+Double.toString(currentlat)+","+Double.toString(currentlong);
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(directionweburl));
myIntent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(myIntent);
}
};
我在這裏失蹤了什麼?