Code example for Marker

Methods: equals, setIcon

0
    // Marker related listeners. 
    // 
 
    @Override 
    public boolean onMarkerClick(final Marker marker) {
        if (marker.equals(mPerth)) {
            // This causes the marker at Perth to bounce into position when it is clicked. 
            final Handler handler = new Handler();
            final long start = SystemClock.uptimeMillis();
            final long duration = 1500;
 
            final Interpolator interpolator = new BounceInterpolator();
 
            handler.post(new Runnable() {
                @Override 
                public void run() { 
                    long elapsed = SystemClock.uptimeMillis() - start;
                    float t = Math.max(1 - interpolator
                            .getInterpolation((float) elapsed / duration), 0);
                    marker.setAnchor(0.5f, 1.0f + 2 * t);
 
                    if (t > 0.0) {
                        // Post again 16ms later. 
                        handler.postDelayed(this, 16);
                    } 
                } 
            }); 
        } else if (marker.equals(mAdelaide)) {
            // This causes the marker at Adelaide to change color. 
            marker.setIcon(BitmapDescriptorFactory.defaultMarker(new Random().nextFloat() * 360));
        } 
        // We return false to indicate that we have not consumed the event and that we wish 
        // for the default behavior to occur (which is for the camera to move such that the 
        // marker is centered and for the marker's info window to open, if it has one). 
        return false;