View Route Google Maps button automatically

Asked

Viewed 380 times

0

I have the following method for creating the Marker in the App:

private void createMarker()
{
    MarkerOptions mo = new MarkerOptions();
    LatLng latLng = new LatLng(mObjetoResumo.getLatitude(), mObjetoResumo.getLongitude());
    mo.position(latLng);
    mo.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE));
    final Marker m = mMap.addMarker(mo);
    mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, Constants.MAX_ZOOM));
    m.showInfoWindow();

} 

What do I call the showInfoWindow Pin information is displayed smoothly, my question and how do I automatically display the route button?

map

This, appears only after the user clicks on the Marker.

I would like to know how to display these buttons without the need for another click by the user?

1 answer

0


I decided as follows.

I removed the default map option :

mMap.getUiSettings().setMapToolbarEnabled(false);

And I implemented two buttons to perform the actions:

ImageView routeButton = (ImageView)findViewById(R.id.routeButton);
    routeButton.setOnClickListener(new View.OnClickListener(){
        @Override
        public void onClick(final View v) {
            final String url = String.format(Locale.getDefault(), "https://maps.google.com?saddr=Current+Location&daddr=%s,%s",  mObjetoResumo.getLatitude().toString(), mObjetoResumo.getLongitude().toString() );
            final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
            startActivity(intent);
        }
    });


ImageView gMapButton =(ImageView)findViewById(R.id.gMapButton);
       gMapButton.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(final View v) {
                final String url = String.format(Locale.getDefault(), "http://maps.google.com/maps?z=%s&q=loc:%s+%s", (Constants.MAX_ZOOM+""),  mObjetoResumo.getLatitude().toString(), mObjetoResumo.getLongitude().toString() );
                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.