Java Code Examples for com.google.android.gms.maps.model.Marker#equals()

The following examples show how to use com.google.android.gms.maps.model.Marker#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomInfoWindowAdapter.java    From Complete-Google-Map-API-Tutorial with Apache License 2.0 6 votes vote down vote up
private void render(Marker marker, View view)
{
	int badge;
	if (marker.equals(brisbane))
	{
		badge = R.drawable.brisbane;
	} else if (marker.equals(adelaide))
	{
		badge = R.drawable.adelaide;
	} else
	{
		// Passing 0 to setImageResource will clear the image view.
		badge = 0;
	}
	((ImageView) view.findViewById(R.id.badge)).setImageResource(badge);

	String title = marker.getTitle();
	TextView tvTitle = view.findViewById(R.id.tvTitle);
	tvTitle.setText(title);

	String snippet = marker.getSnippet();
	TextView tvSnippet = view.findViewById(R.id.tvSnippet);
	tvSnippet.setText(snippet);
}
 
Example 2
Source File: GeofenceCircle.java    From MarkerBuilder with Apache License 2.0 6 votes vote down vote up
/**
 * This modifies circle according to marker's type and position
 *
 * if the marker is position marker (from this circle), the circle will be moved according to marker's position
 * if the marker is resizing marker (from this circle), the circle will be resized according to marker's position
 *
 * If the marker is not in this circle (it's not the position or resizing marker) no action will be done
 *
 * @param marker
 *
 * @return flag indicating which action was done.
 * When the marker is not in this circle returned action is MarkerMoveResult.none
 */
public MarkerMoveResult onMarkerMoved(Marker marker) {
    if (marker.equals(centerMarker)) {
        onCenterUpdated(marker.getPosition());
        return MarkerMoveResult.moved;
    }

    if (marker.equals(resizerMarker)) {
        double newRadius = MarkerAreasUtils.toRadiusMeters(centerMarker.getPosition(), marker.getPosition());

        if (minRadius != -1 && newRadius < minRadius) {
            return MarkerMoveResult.minRadius;

        } else if (maxRadius != -1 && newRadius > maxRadius) {
            return MarkerMoveResult.maxRadius;

        } else {
            setRadius(newRadius);

            return MarkerMoveResult.radiusChange;
        }

    }
    return MarkerMoveResult.none;
}
 
Example 3
Source File: MarkerCloseInfoWindowOnRetapDemoActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onMarkerClick(final Marker marker) {
    // The user has re-tapped on the marker which was already showing an info window.
    if (marker.equals(mSelectedMarker)) {
        // The showing info window has already been closed - that's the first thing to happen
        // when any marker is clicked.
        // Return true to indicate we have consumed the event and that we do not want the
        // 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).
        mSelectedMarker = null;
        return true;
    }

    mSelectedMarker = marker;

    // Return false to indicate that we have not consumed the event and that we wish
    // for the default behavior to occur.
    return false;
}
 
Example 4
Source File: EstablishmentInteractorImpl.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
@Nullable
@Override
public Establishment getEstablishmentFromMarker(Marker marker) {
    for (Map.Entry entry : mDeviceMarkerHash.entrySet()) {
        if (marker.equals(entry.getValue())) {
            return (Establishment) entry.getKey();
        }
    }
    return null;
}
 
Example 5
Source File: EmergencyInteractorImpl.java    From Saude-no-Mapa with MIT License 5 votes vote down vote up
@Nullable
@Override
public Establishment getEstablishmentFromMarker(Marker marker) {
    for (Map.Entry entry : mDeviceMarkerHash.entrySet()) {
        if (marker.equals(entry.getValue())) {
            return (Establishment) entry.getKey();
        }
    }
    return null;
}
 
Example 6
Source File: CircleDemoActivity.java    From android-samples with Apache License 2.0 5 votes vote down vote up
public boolean onMarkerMoved(Marker marker) {
    if (marker.equals(centerMarker)) {
        circle.setCenter(marker.getPosition());
        radiusMarker.setPosition(toRadiusLatLng(marker.getPosition(), radiusMeters));
        return true;
    }
    if (marker.equals(radiusMarker)) {
        radiusMeters =
                toRadiusMeters(centerMarker.getPosition(), radiusMarker.getPosition());
        circle.setRadius(radiusMeters);
        return true;
    }
    return false;
}
 
Example 7
Source File: RMBTMapFragment.java    From open-rmbt with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onMarkerClick(Marker marker)
{
    if (myLocationMarker != null && marker.equals(myLocationMarker))
    {
        // redirect to map click
        onMapClick(marker.getPosition());
        return true;
    }
    return false;
}
 
Example 8
Source File: MarkerDemoActivity.java    From android-samples with Apache License 2.0 4 votes vote down vote up
private void render(Marker marker, View view) {
    int badge;
    // Use the equals() method on a Marker to check for equals.  Do not use ==.
    if (marker.equals(mBrisbane)) {
        badge = R.drawable.badge_qld;
    } else if (marker.equals(mAdelaide)) {
        badge = R.drawable.badge_sa;
    } else if (marker.equals(mSydney)) {
        badge = R.drawable.badge_nsw;
    } else if (marker.equals(mMelbourne)) {
        badge = R.drawable.badge_victoria;
    } else if (marker.equals(mPerth)) {
        badge = R.drawable.badge_wa;
    } else if (marker.equals(mDarwin1)) {
        badge = R.drawable.badge_nt;
    } else if (marker.equals(mDarwin2)) {
        badge = R.drawable.badge_nt;
    } else if (marker.equals(mDarwin3)) {
        badge = R.drawable.badge_nt;
    } else if (marker.equals(mDarwin4)) {
        badge = R.drawable.badge_nt;
    } else {
        // Passing 0 to setImageResource will clear the image view.
        badge = 0;
    }
    ((ImageView) view.findViewById(R.id.badge)).setImageResource(badge);

    String title = marker.getTitle();
    TextView titleUi = ((TextView) view.findViewById(R.id.title));
    if (title != null) {
        // Spannable string allows us to edit the formatting of the text.
        SpannableString titleText = new SpannableString(title);
        titleText.setSpan(new ForegroundColorSpan(Color.RED), 0, titleText.length(), 0);
        titleUi.setText(titleText);
    } else {
        titleUi.setText("");
    }

    String snippet = marker.getSnippet();
    TextView snippetUi = ((TextView) view.findViewById(R.id.snippet));
    if (snippet != null && snippet.length() > 12) {
        SpannableString snippetText = new SpannableString(snippet);
        snippetText.setSpan(new ForegroundColorSpan(Color.MAGENTA), 0, 10, 0);
        snippetText.setSpan(new ForegroundColorSpan(Color.BLUE), 12, snippet.length(), 0);
        snippetUi.setText(snippetText);
    } else {
        snippetUi.setText("");
    }
}
 
Example 9
Source File: MarkerDemoActivity.java    From android-samples with Apache License 2.0 4 votes vote down vote up
@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 and alpha.
        marker.setIcon(BitmapDescriptorFactory.defaultMarker(mRandom.nextFloat() * 360));
        marker.setAlpha(mRandom.nextFloat());
    }

    // Markers have a z-index that is settable and gettable.
    float zIndex = marker.getZIndex() + 1.0f;
    marker.setZIndex(zIndex);
    Toast.makeText(this, marker.getTitle() + " z-index set to " + zIndex,
            Toast.LENGTH_SHORT).show();

    mLastSelectedMarker = marker;
    // 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;
}