Show Google Maps Route button automatically

0

I have the following method for creating Marker in 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();

} 

As I call showInfoWindow the Pin information is displayed without problems, my question and how do I get the route button to appear automatically?

This appears only after the user clicks on Marker .

Would you like to know how to display these buttons without the need for another user click?

    
asked by anonymous 22.02.2016 / 12:27

1 answer

0

I solved it 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);
            }
        });
    
22.02.2016 / 16:59