Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[android] #5279 - expose MarkerView alpha #5329

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public abstract class BaseMarkerViewOptions<U extends MarkerView, T extends Base
protected float rotation;
protected boolean visible = true;
protected boolean selected;
protected float alpha = 1.0f;

/**
* Default constructor
Expand Down Expand Up @@ -132,13 +133,24 @@ public T rotation(float rotation) {
* Set the visibility state of the MarkerView.
*
* @param visible the visible state
* @return the object for which the method was calleds
* @return the object for which the method was called
*/
public T visible(boolean visible) {
this.visible = visible;
return getThis();
}

/**
* Set the alpha of the MarkerView.
*
* @param alpha the alpha value
* @return the object for which the method was called
*/
public T alpha(float alpha) {
this.alpha = alpha;
return getThis();
}

/**
* Get the geographical location of the MarkerView.
*
Expand Down Expand Up @@ -238,6 +250,15 @@ public boolean isVisible() {
return visible;
}

/**
* Get the alpha of the MarkerView.
*
* @return the alpha value
*/
public float getAlpha() {
return alpha;
}

/**
* Get the instance of the object for which this method was called.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected MarkerViewOptions(Parcel in) {
infoWindowAnchor(in.readFloat(), in.readFloat());
rotation(in.readFloat());
visible(in.readByte() != 0);
alpha(in.readFloat());
if (in.readByte() != 0) {
// this means we have an icon
String iconId = in.readString();
Expand Down Expand Up @@ -61,6 +62,7 @@ public void writeToParcel(Parcel out, int flags) {
out.writeFloat(getInfoWindowAnchorV());
out.writeFloat(getRotation());
out.writeByte((byte) (isVisible() ? 1 : 0));
out.writeFloat(alpha);
Icon icon = getIcon();
out.writeByte((byte) (icon != null ? 1 : 0));
if (icon != null) {
Expand All @@ -80,6 +82,7 @@ public MarkerView getMarker() {
marker.setInfoWindowAnchor(infoWindowAnchorU, infoWindowAnchorV);
marker.setRotation(rotation);
marker.setVisible(visible);
marker.setAlpha(alpha);
return marker;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void onMapReady(@NonNull MapboxMap mapboxMap) {
mMapboxMap.addMarker(new MarkerViewOptions()
.position(LAT_LNGS[i])
.title(String.valueOf(i))
.alpha(0.5f)
.icon(usFlag)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.MarkerView;
import com.mapbox.mapboxsdk.geometry.LatLng;

public class CountryMarkerViewOptions extends BaseMarkerViewOptions<CountryMarkerView, CountryMarkerViewOptions> {
Expand All @@ -23,8 +24,10 @@ protected CountryMarkerViewOptions(Parcel in) {
title(in.readString());
flat(in.readByte() != 0);
anchor(in.readFloat(), in.readFloat());
selected = in.readByte() != 0;
infoWindowAnchor(in.readFloat(), in.readFloat());
rotation(in.readFloat());
visible(in.readByte() != 0);
alpha(in.readFloat());
if (in.readByte() != 0) {
// this means we have an icon
String iconId = in.readString();
Expand Down Expand Up @@ -56,8 +59,9 @@ public void writeToParcel(Parcel out, int flags) {
out.writeFloat(getAnchorV());
out.writeFloat(getInfoWindowAnchorU());
out.writeFloat(getInfoWindowAnchorV());
out.writeByte((byte) (selected ? 1 : 0));
out.writeFloat(getRotation());
out.writeByte((byte) (isVisible() ? 1 : 0));
out.writeFloat(getAlpha());
Icon icon = getIcon();
out.writeByte((byte) (icon != null ? 1 : 0));
if (icon != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.MarkerView;
import com.mapbox.mapboxsdk.geometry.LatLng;

public class TextMarkerViewOptions extends BaseMarkerViewOptions<TextMarkerView, TextMarkerViewOptions> {
Expand All @@ -24,6 +25,8 @@ protected TextMarkerViewOptions(Parcel in) {
anchor(in.readFloat(), in.readFloat());
infoWindowAnchor(in.readFloat(), in.readFloat());
rotation(in.readFloat());
visible(in.readByte() != 0);
alpha(in.readFloat());
if (in.readByte() != 0) {
// this means we have an icon
String iconId = in.readString();
Expand Down Expand Up @@ -55,6 +58,8 @@ public void writeToParcel(Parcel out, int flags) {
out.writeFloat(getInfoWindowAnchorU());
out.writeFloat(getInfoWindowAnchorV());
out.writeFloat(getRotation());
out.writeByte((byte) (isVisible() ? 1 : 0));
out.writeFloat(alpha);
Icon icon = getIcon();
out.writeByte((byte) (icon != null ? 1 : 0));
if (icon != null) {
Expand Down