Android Google Map - Clicked marker opens new activity or bigger window

前端 未结 5 1637
梦毁少年i
梦毁少年i 2020-12-14 02:41

I\'ve been searching for help on implementing OnMarkerClickListener but nothing I\'ve found has worked. This is my marker below and when clicked it only changes colour(light

5条回答
  •  半阙折子戏
    2020-12-14 02:51

    I suggest use of OnInfoWindowClickListener, it will trigger when you click on marker and then the snippet. Use setTag to attach any object with the marker.

        Marker marker = mMap.addMarker(markerOptions);
        marker.setTag(myObject);
    

    and the listener

          mMap.setOnInfoWindowClickListener(new OnInfoWindowClickListener() {
    
            @Override
            public void onInfoWindowClick(Marker arg0) {
    
             MyObject mo =  (MyObject )arg0.getTag();
    
    
               }
           });
    

提交回复
热议问题