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

Commit

Permalink
[android] #5276 - icon should be optional for MarkerView
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Jun 13, 2016
1 parent c9d78f3 commit b1afa8a
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public final class IconFactory {
private Context mContext;
private static IconFactory sInstance;
private Icon mDefaultMarker;
private Icon mDefaultMarkerView;
private BitmapFactory.Options mOptions;

private int mNextId = 0;
Expand Down Expand Up @@ -121,6 +122,13 @@ public Icon defaultMarker() {
return mDefaultMarker;
}

public Icon defaultMarkerView() {
if (mDefaultMarkerView == null) {
mDefaultMarkerView = fromResource(R.drawable.default_markerview);
}
return mDefaultMarkerView;
}

private Icon fromInputStream(@NonNull InputStream is) {
Bitmap bitmap = BitmapFactory.decodeStream(is, null, mOptions);
return fromBitmap(bitmap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.InfoWindow;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;
Expand Down Expand Up @@ -1208,7 +1209,12 @@ private Marker prepareMarker(BaseMarkerOptions markerOptions) {

private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) {
MarkerView marker = markerViewOptions.getMarker();
marker.setIcon(markerViewOptions.getIcon());

Icon icon = markerViewOptions.getIcon();
if (icon == null) {
icon = IconFactory.getInstance(mMapView.getContext()).defaultMarkerView();
}
marker.setIcon(icon);
return marker;
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b1afa8a

Please sign in to comment.