我想制作一个应用程序来显示旅行时间和距离以及用户位置到目的地位置的路径。
这是我的 TampilkanMap 课程:
public class TampilkanMap extends FragmentActivity {
GoogleMap googleMap;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
SupportMapFragment fm = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
googleMap = fm.getMap();
// Enabling MyLocation Layer of Google Map
googleMap.setMyLocationEnabled(true);
// lokasi wisata
Marker GunungButtuKabombong = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-3.568419, 119.777141)).title("Enrekang")
.snippet("Gunung Buttu kabobong"));
Marker HutanMalino = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-5.296776, 119.740562)).title("Gowa")
.snippet("Hutan Malino"));
Marker SombaOpu = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-5.191144, 119.407899)).title("Makassar")
.snippet("Benteng Somba Opu"));
Marker Londa = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-2.968156, 119.900479)).title("Rantepao")
.snippet("Londa"));
Marker Jompie = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-4.005563, 119.634331)).title("Parepare")
.snippet("Hutan Jompie"));
Marker Lumpue = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-4.057233, 119.622411)).title("Parepare")
.snippet("Pantai Lumpue"));
Marker Bira = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-5.550204, 120.206166)).title("Bulukumba")
.snippet("Pantai Tanjung Bira"));
Marker Losari = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-5.133219, 119.41662)).title("Makassar")
.snippet("Pantai Losari"));
Marker Bantimurung = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-5.006130, 119.650970)).title("Maros")
.snippet("Air Terjun Bantimurung"));
Marker Kelelawar = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-4.349835, 119.927759)).title("Soppeng")
.snippet("Kelelawar"));
Marker DanauTempe = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-4.110587, 119.953579)).title("Wajo")
.snippet("Danau Tempe"));
Marker FortRotterdam = googleMap.addMarker(new MarkerOptions()
.position(new LatLng(-5.134148, 119.405276)).title("Makassar")
.snippet("Benteng Fort Rotterdam"));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.opt_menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.satelit:
googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
return true;
case R.id.street:
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
如果用户从我的位置触摸标记,我想制作一条路径,我该如何制作?