1

I am adding a marker to my map. Simultaneously showing the marker info. But i want to simulate a click event on my marker, so the google-maps-options /icons (calculate route and open google maps) are display on the screen.

  public void onMapReady(GoogleMap googleMap) {
        final int randomKey = new Random().nextInt(MainActivity.randomDestination.size());
        map = googleMap;
        Destination selectedDest = MainActivity.randomDestination.get(randomKey);
        Marker marker = map.addMarker(new MarkerOptions().position(selectedDest.getLatLng()).title(selectedDest.getName()));
        marker.showInfoWindow();
        map.moveCamera(CameraUpdateFactory.newLatLng(selectedDest.getLatLng()));
    }


public class Destination {
    private String name;
    private LatLng latLng;

    Destination(String name, LatLng latLng){
        this.name = name;
        this.latLng = latLng;
    }
    public String getName(){return name;};
    public LatLng getLatLng(){return latLng;};
}
Luke
  • 23
  • 7
  • 1
    Look at this answer : https://stackoverflow.com/questions/6794405/trigger-google-maps-marker-click – pheromix Sep 19 '19 at 13:43

0 Answers0