how to get the name entered by the user and search that respective location in edittext

后端 未结 1 528
既然无缘
既然无缘 2021-01-23 06:48

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.

1条回答
  •  甜味超标
    2021-01-23 07:18

    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
    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

    0 讨论(0)
提交回复
热议问题