Button that click sends to location?

Asked

Viewed 143 times

1

How to set a button so that when clicked open the maps and send the user to an address?

  • 2

    What do you mean: teleportation?

  • Gps, when you click on send pro maps

  • It should help you: http://www.coders-hub.com/2015/02/advance-android-google-map-2-tutorial-with-example.html#. Wtgxjuvyuuk https://stackoverflow.com/questions/4446811/how-to-get-the-latitude-and-longitude-on-map-in-android https://stackoverflow.com/questions/24302112/how-to-get-the-latitude-and-longitude-of-location-wherer-user-taps-onthe-map-in

2 answers

3

First, create map activity, here’s a Example.

Then create a method to open the activity and associate to onClick button, something like

public void getLocalizacao(View view) {
    Intent i = new Intent(getApplication(), Mapa.class);
    startActivity(i);
}

Returning to map activity, you can set the location:

public void onMapReady(GoogleMap googleMap) {
    LatLng congresso = new LatLng(-15.7997586, -47.8647535);

And to be cool, add an animation to where you set the location

CameraPosition cameraPosition = new CameraPosition.Builder() .target(congresso) .zoom(16).bearing(0) .build(); mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

1


Try it this way:

private void abrirRota(){

    /**
     * Nossa intenção será um google.navigation
     * Temos os seguintes parametros:
     * q= [Destino, endereço ou Latitude e longitude]; OBRIGATÓRIO!
     * mode= [define o método de transporte] {d= condução, w = caminhada, b = bicicleta}; OPCIONAL
     * avoid=[define os recursos que a rota deve tentar evitar] {t = pedágios, h = estradas, f=  balsas} OPCIONAL
     */

    final String url = String.format(Locale.getDefault(),  "google.navigation:q=Heitor+Stockler+de+França,+470+-+Centro+Cívico,+Curitiba+-+PR");
    final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    startActivity(intent);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.