I'm finalizing an application where I need to use Google Maps API
for two things: select an address from the user's choice (example: user navigates to the desired address and chooses it) and show the map based on the location of a example (open the map at the address that the user chose earlier).
I have read that it is possible to receive the selected address using the following code:
private GoogleMap mMap;
{...}
mMap.setOnMapClickListener(new OnMapClickListener() {
@Override
public void onMapClick(LatLng newLatLon) {
Toast.makeText(getApplicationContext(), point.toString(), Toast.LENGTH_SHORT).show();
}
});
But I would like to pass this function to a button outside the map. How can I do this? And although I looked for how do I open a map using a pre-defined address, I could not find anything straightforward. Is it possible to pass a parameter of type String
to the API?