0
我從用戶輸入的是經度和緯度的兩個值,並且有一個顯示位置按鈕,單擊它時會使用這兩個經度和緯度值顯示位置。 我只需要使用上showlocation()的意圖或按鈕Android Intent for google.maps onclick
請檢查我的代碼
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/lat"
android:layout_weight="50"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:hint="@string/lat" />
<EditText
android:id="@+id/longi"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="50"
android:ems="10"
android:hint="@string/longi" >
<requestFocus />
</EditText>
<Button
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_weight="100"
android:text="@string/button_send"
android:onClick="showlocation()" />
</LinearLayout>
public void showlocation(){
String uri = "http://maps.google.com/maps?saddr=" + "9982878"+","+"76285774"+"&daddr="+"9992084"+","+"76286455";
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(uri));
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
}
讓我說清楚。 我從用戶的2個輸入,這將是經度和緯度。 如果他們點擊按鈕,它會顯示地圖或maps.google.com顯示他們的位置。我是新手,所以不太瞭解。 將不勝感激 –