Click on a Mark to open it in Google Maps? Android Studio

0

Is it possible that by clicking on a "mark" of my app, it can be redirected to the Google Maps App?

public class UbicacionFragment extends Fragment implements OnMapReadyCallback {

GoogleMap map;
public UbicacionFragment() {
    // Required empty public constructor
}


@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View v =  inflater.inflate(R.layout.fragment_ubicacion, container, false);

    return v;
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    SupportMapFragment mapFragment = (SupportMapFragment)
            getChildFragmentManager().findFragmentById(R.id.map1);
    mapFragment.getMapAsync(this);

}

@Override
public void onMapReady(GoogleMap googleMap) {
    map = googleMap;

    LatLng a = new LatLng(25.666376, -100.26546559999997);
    MarkerOptions options = new MarkerOptions();
    options.position(a).title("HR DESECHABLES GUADALUPE");
    options.position(a).snippet("José Sixto Verduzco 800, Central de Abastos, 67147 Monterrey, N.L.");
    map.addMarker(options);
    map.moveCamera(CameraUpdateFactory.newLatLng(a));

    LatLng d = new LatLng(25.5920038565153, -100.00365257263184 );
    MarkerOptions options3 = new MarkerOptions();
    options3.position(d).title("HR DESECHABLES CADEREYTA");
    options3.position(d).snippet("Av. Benito Juárez, 67450 Cadereyta Jiménez, N.L, México ");
    map.addMarker(options3);
    map.moveCamera(CameraUpdateFactory.newLatLng(d));

    LatLng f = new LatLng( 22.7619524, -102.54727409999998);
    MarkerOptions options5 = new MarkerOptions();
    options5.position(f).title("HR DESECHABLES ZACATECAS");
    options5.position(f).snippet("José López Portillo 1, Tres Cruces, 98064 Zacatecas, Zac., México");
    map.addMarker(options5);
    map.moveCamera(CameraUpdateFactory.newLatLng(f));

    LatLng g = new LatLng(25.747448 , -100.198314 );
    MarkerOptions options6 = new MarkerOptions();
    options6.position(g).title("HR DESECHABLES APODACA");
    options6.position(g).snippet("Blvrd Julian Treviño Elizondo 222A, El Milagro, 66634 Cd Apodaca, N.L., México");
    map.addMarker(options6);
    map.moveCamera(CameraUpdateFactory.newLatLng(g));


}}
    
asked by Cesar Perez 06.11.2017 в 20:34
source

2 answers

1

San Google gives you the option in the bottom corner.

1. I show you in my app I have this default address

2. Now pressing the address (The market) at the bottom in the corner shows you

Between the + and - (Zoom) and sharing is the option to go to Google maps with your address.

    
answered by 06.11.2017 / 21:11
source
-1

You can use a listener setOnInfoWindowClickListener to detect a click on the bookmark and open the url you want:

map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
    @Override
    public void onInfoWindowClick(Marker marker) {
        Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.google.com"));
        startActivity(intent);
    }
});
    
answered by 06.11.2017 в 21:17