Skip to content Skip to sidebar Skip to footer

How To Get The Name Entered By The User And Search That Respective Location In Edittext

i can place Google map in my android mobile. i put search option for google map. if the user give the location and click button search means it find the location in google map. now

Solution 1:

Use following code to accept input from user and search place on map.

          String value = editText1.getText().toString();
          // Do something with value!
          Log.d("value", value);

          Geocoder geoCoder = new Geocoder(getBaseContext(), Locale.getDefault());    
            try {
                List<Address> addresses = geoCoder.getFromLocationName(
                    value, 5);
                String add = "";
                if (addresses.size() > 0) {
                    p = new GeoPoint(
                            (int) (addresses.get(0).getLatitude() * 1E6), 
                            (int) (addresses.get(0).getLongitude() * 1E6));
                    mc.animateTo(p);    
                    mapView.invalidate();
                }    
            } catch (IOException e) {
                e.printStackTrace();
            }

Some changes required

Post a Comment for "How To Get The Name Entered By The User And Search That Respective Location In Edittext"