1

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 i want display relative location when the user give the location name in Edittext..Please give me any reference.....

   i try this code of button click
     if (v == search) {
        Geocoder geo = new Geocoder(getApplicationContext(),
                Locale.getDefault());
        try {
            List<Address> addresses = geo.getFromLocationName(location
                    .getText().toString(), 5);
            if (addresses.size() > 0) {
                GeoPoint p = new GeoPoint((int) (addresses.get(0)
                        .getLatitude() * 1E6), (int) (addresses.get(0)
                        .getLongitude() * 1E6));

                controller.animateTo(p);
                controller.setZoom(12);
                MapOverlay mapOverlay = new MapOverlay(getApplicationContext(),p);
                List<Overlay> lisOverlays = view.getOverlays();
                lisOverlays.clear();
                lisOverlays.add(mapOverlay);

            }

the button search click means it shows location also . i want displays the locations according to user search in edit text

Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160
Vinoth
  • 149
  • 1
  • 3
  • 15
  • http://stackoverflow.com/questions/8428209/show-current-location-and-nearby-places-using-google-maps-api-in-android/8428414#8428414 – MKJParekh Apr 18 '12 at 12:14

1 Answers1

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

Sandip Armal Patil
  • 6,241
  • 21
  • 93
  • 160