我想从我的位置向目标位置显示方向,我为目标位置制作了一个微调器,然后当我点击它时,有一条从我的位置到那里的路线..但是有一个错误,我不能解决它...有没有人帮我展示我的错误在哪里,并帮我解决它..?因为我需要它来完成我的作业..
这是我的源代码:
public class MapRouteActivity extends MapActivity {
private SQLiteDatabase db = null;
private Cursor tmiiCursor = null;
private DataTmii datatmii = null;
private LinearLayout Linear01;
private Spinner dari,ke;
public static final String ID = "id";
public static final String KODE = "kode";
public static final String OBJ = "obj";
public static final String KET = "ket";
public static final String LAT = "lat";
public static final String LNG = "lng";
static final String[] TMII= new String[] {"Anjungan","Museum","Tempat Ibadah","Taman","Wahana Rekreasi","Kereta Gantung","SHS-23 Aeromovel Indonesia","Kereta Api Mini","Mobil Keliling"
,"Perahu Angsa","Sepeda Keliling","Graha Wisata Remaja","Hotel Desa Wisata","Puri Caping Gunung","Pondok Pecel Madiun","Pasar Tiban","Gerbang Kalamakara"};
static final String[] ANJUNGAN= new String[] {"Anjungan NAD","Anjungan Sumatra Utara","Anjungan Sumatra Barat","Anjungan Sumatra Selatan","Anjungan Kepulauan Riau","Anjungan Jambi","Anjungan Bengkulu","Anjungan Riau","Anjungan Bangka Belitung","Anjungan Lampung","Anjungan Banten"
,"Anjungan DKI Jakarta","Anjungan Jawa Barat","Anjungan Jawa Tengah","Anjungan DI Yogyakarta","Anjungan Jawa Timur","Anjungan Bali","Anjungan Nusa Tenggara Barat","Anjungan Nusa Tenggara Timur","Anjungan Kalimantan Barat","Anjungan Kalimantan Selatan","Anjungan Kalimantan Timur"
,"Anjungan Kalimantan Tengah","Anjungan Sulawesi Utara","Anjungan Gorontalo","Anjungan Sulawesi Tengah","Anjungan Sulawesi Barat","Anjungan Sulawesi Tenggara","Anjungan Maluku","Anjungan Maluku Utara","Anjungan Papua Barat","Anjungan Papua","Anjungan Sulawesi Selatan"};
static final String[] MUSEUM= new String[] {"Museum Indonesia","Museum Asmat","Museum Pusaka","Museum Timor Timur","Museum Penerangan","Museum Perangko Indonesia","Museum Keprajuritan Indonesia","Museum Olahraga"
,"Museum Fauna Komodo Indonesia","Museum Serangga","Museum Minyak Gas & Bumi","Museum Listrik dan Energi Baru","Museum Telekomunikasi","Museum Bayt Al Qur'an & Museum Istiqlal","Museum Museum Purna Bhakti Pertiwi","Museum Transportasi",};
static final String[] TEMPATIBADAH= new String[] {"Masjid Pangeran Diponegoro","Gereja Katolik Santa Catharina","Gereja Kristen Protestan Haleluya","Pura Penataran Agung Kertabhumi","Wihara Arya Dwipa Arama","Sasono Adiroso Pangeran Sambernyowo","Klenteng Kong Miao"};
static final String[] TAMAN= new String[] {"Taman Prasasti APEC","Taman Reptilia","Taman Akuarium Air Tawar","Monumen Persahabatan Negara Non Blok","Taman Budaya Tionghoa","Taman Melati"
,"Taman Kupu-Kupu","Taman Apotik Hidup","Taman Bekisar","Taman Burung","Taman Bunga Keong Mas","Taman Kaktus"};
static final String[] REKREASI= new String[] {"Teater Tanah Airku","Desa Seni","Sasana Kriya","Snowbay","Istana Anak Indonesia","Pusat Peragaan IPTEK"
,"Pemancingan Telaga Mina","Teater IMAX Keong Mas","Teater 4 Dimensi","Balon Udara Raksasa","Pasar Buku Langka"};
String loadata;
String dlat = "";
String dlng = "";
String klat ="";
String klng ="";
String spin_dari,spin_ke;
TextView textView, keterangan;
LinearLayout linearLayout;
MapView mapView;
View view;
private Road mRoad;
double ke_lat, ke_lng, dari_lat, dari_lng;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ProgressDialog myProgressDialog = ProgressDialog.show(MapRouteActivity.this, "Loading", "Mohon Tunggu...!!!", true);
new Thread() {
public void run() {
try{
loadata = ListPeta.petapa;
datatmii = new DataTmii(MapRouteActivity.this);
db = datatmii.getWritableDatabase();
datatmii.createTable(db);
datatmii.generateData(db);
} catch (Exception e) { }
// Dismiss the Dialog
}
}.start();
myProgressDialog.dismiss();
setContentView(R.layout.rutemap);
ke = (Spinner) findViewById(R.id.spin_ke);
if (loadata=="tmii"){
ArrayAdapter adapter_ke = new ArrayAdapter(this,android.R.layout.simple_spinner_item, TMII);
adapter_ke.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ke.setAdapter(adapter_ke);
}
else if (loadata=="anjungan"){
ArrayAdapter adapter_ke = new ArrayAdapter(this,android.R.layout.simple_spinner_item, ANJUNGAN);
adapter_ke.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ke.setAdapter(adapter_ke);
}
else if (loadata=="museum"){
ArrayAdapter adapter_ke = new ArrayAdapter(this,android.R.layout.simple_spinner_item, MUSEUM);
adapter_ke.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ke.setAdapter(adapter_ke);
}
else if (loadata=="tempatibadah"){
ArrayAdapter adapter_ke = new ArrayAdapter(this,android.R.layout.simple_spinner_item, TEMPATIBADAH);
adapter_ke.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ke.setAdapter(adapter_ke);
}
else if (loadata=="taman"){
ArrayAdapter adapter_dari = new ArrayAdapter(this,android.R.layout.simple_spinner_item, TAMAN);
adapter_dari.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dari.setAdapter(adapter_dari);
ArrayAdapter adapter_ke = new ArrayAdapter(this,android.R.layout.simple_spinner_item, TAMAN);
adapter_ke.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ke.setAdapter(adapter_ke);
}
else if (loadata=="rekreasi"){
ArrayAdapter adapter_ke = new ArrayAdapter(this,android.R.layout.simple_spinner_item, REKREASI);
adapter_ke.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
ke.setAdapter(adapter_ke);
}
}
public void Rutekan(final View view){
final ProgressDialog myProgressDialog = ProgressDialog.show(MapRouteActivity.this, "Loading", "Mohon Tunggu...!!!", true);
new Thread() {
public void run() {
try{
Thread.sleep(1000);
spin_ke = ke.getSelectedItem().toString();
tmiiCursor = db.rawQuery("SELECT ID, OBJ, KET, LAT, LNG "
+ "FROM tmii where OBJ='" + spin_ke
+ "' ORDER BY OBJ", null);
if (tmiiCursor.moveToFirst()) {
klat = tmiiCursor.getString(3);
klng = tmiiCursor.getString(4);
for (; !tmiiCursor.isAfterLast(); tmiiCursor.moveToNext()) {
klat = tmiiCursor.getString(3);
klng = tmiiCursor.getString(4);
}
}
ke_lat = Double.parseDouble(klat);
ke_lng = Double.parseDouble(klng);
double toLat = ke_lat, toLon = ke_lng;
String url = RoadProvider.getUrl(toLat, toLon);
InputStream is = getConnection(url);
mRoad = RoadProvider.getRoute(is);
mHandler.sendEmptyMessage(0);
} catch (Exception e) { }
// Dismiss the Dialog
myProgressDialog.dismiss();
}
}.start();
Linear01.setVisibility(view.GONE);
}
public static void tampilDriveMap(double userLat, double userLng,
double obLatitude, double obLongitude) {
// TODO Auto-generated method stub
Uri uri = Uri.parse("http://maps.google.com/maps?&saddr="+userLat+","+userLng+"&daddr="+obLatitude+","+obLongitude+"");
Intent i_drive_map = new Intent(Intent.ACTION_VIEW,uri);
startActivity(i_drive_map);
}
我很高兴,如果有人帮助我,我会感激不尽...谢谢你
答案 0 :(得分:0)