salaheddine chebil Posted September 30, 2012 Share Posted September 30, 2012 bonjour tout le monde,j'ai cree une application android qui est en faite la geolocalisation. j'ai un probleme au geocodage ,en faite j'ai cree un bouton de recherche lorsque l'utilisateur saisi un endroit dans un editText et appuie sur ce bouton le resultat sera la position de cet endroid dans le map , bref voici mon code et j'espere que vous m'aidiez.: RechercheListener=new View.onclickListener() { public void onclick(View v) { String a=Recherche1.getText().toString(); MotionEvent event; String staddress = a; ProgressDialog dialog ; /* dialog = ProgressDialog.show(MenuActivity.this, "", "la valeur de a est: "+a, true);*/ try { List<Address> loc = geocoder.getFromLocationName(staddress, 5); dialog = ProgressDialog.show(MenuActivity.this, "", "size est : "+loc.size(), true); if (loc.size()==0) { Toast.makeText(MenuActivity.this, "Dsl, Saisir Un Endroit.",Toast.LENGTH_LONG).show(); /*ProgressDialog dialog dialog = ProgressDialog.show(MenuActivity.this, "", "Loading. Please wait...", true);*/ } else if (loc.size()>0) { // Address addr = loc.get(0); // ((Address) loc).setLatitude(addr.getLatitude()); // ((Address) loc).setLongitude(addr.getLongitude()); Geocoder gc = new Geocoder(context); //ProgressDialog dialog ; dialog = ProgressDialog.show(MenuActivity.this, "", "Loading. Please wait...", true); //if(gc.isPresent()){ List<Address> list = gc.getFromLocationName(a, 1); Address address = list.get(0); double lat = address.getLatitude(); double lng = address.getLongitude(); // ProgressDialog dialog ; Toast.makeText(getBaseContext(),"Latitude = " + lat + " Longitude = " + lng, Toast.LENGTH_SHORT).show(); Intent intent = new Intent(MenuActivity.this, GoogleMapActivity.class); intent.putExtra("longitude", lng); intent.putExtra("latitude", lat); startActivity(intent); } } // } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.