I asked one question about how to get a Google Map V2
in android application. Now i want to put one functionality on that Google Map. Anyone can suggeset me a good answer, I m trying to get it with Geocode. Thanks in advance.
Asked
Active
Viewed 1,734 times
1

Padmani Bhoomi
- 25
- 6
-
Have you heard about `PlaceAPI`??? Or familiar with `GeoCoder`??? – Piyush Nov 28 '14 at 10:06
-
Check this best example as per your requirement http://wptrafficanalyzer.in/blog/android-autocompletetextview-with-google-places-autocomplete-api/ – Piyush Nov 28 '14 at 10:24
-
Do Googling...http://bit.ly/121TNt3 – Pratik Butani Nov 28 '14 at 10:37
-
possible duplicate of [Using Google Places API](http://stackoverflow.com/questions/5551028/using-google-places-api) – Pratik Butani Nov 28 '14 at 10:39
1 Answers
0
This code you can put in your onCreateOptionMenu of your activity
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.show_map, menu);
SearchManager searchManger = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
searchView.setSearchableInfo(searchManger.getSearchableInfo(getComponentName()));
//searchView.setIconifiedByDefault(false);
SearchView.OnQueryTextListener queryTextListener = new SearchView.OnQueryTextListener()
{
@Override
public boolean onQueryTextSubmit(String newText)
{
return true;
}
@Override
public boolean onQueryTextChange(String query)
{
Geocoder geocoder = new Geocoder(CreateReminderActivity.this);
List<Address> addresses;
String areaname = edLocation.getText().toString();
addresses = geocoder.getFromLocationName(areaname, 1);
if(addresses.size() > 0) {
double latitude= addresses.get(0).getLatitude();
double longitude= addresses.get(0).getLongitude();
insLat = latitude;
insLong = longitude;
String statename = addresses.get(0).getAdminArea();
googleMap.addMarker(new MarkerOptions()
.title(areaname)
.snippet("SNIPPET")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.ic_launcher))
.anchor(0.0f, 1.0f) // Anchors the marker on the bottom left
.position(new LatLng(latitude, longitude)));
LatLng latLng = new LatLng(latitude, longitude);
googleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
// Zoom in the Google Map
googleMap.animateCamera(CameraUpdateFactory.zoomTo(10));
Toast.makeText(getApplicationContext(), statename, 20).show();
return true;
}
};
searchView.setOnQueryTextListener(queryTextListener);
return true;
}

Pratik Butani
- 60,504
- 58
- 273
- 437

Gulnaz Ghanchi
- 485
- 3
- 14
-
i have one default searchview in my activity, can u give me the search click how to that.. ? – Padmani Bhoomi Nov 28 '14 at 10:19
-