AI-generated Key Takeaways
-
BitmapDescriptorFactory is used to define Bitmap images for marker icons and ground overlays.
-
The class must be initialized by waiting for a GoogleMap to become available or by calling MapsInitializer.initialize(Context).
-
You can create BitmapDescriptors from various sources, including default markers, assets, Bitmaps, files, paths, PinConfigs, and resource IDs.
-
The class provides predefined hue values for coloring default markers.
Used to create a definition of a Bitmap image, used for marker icons and ground overlays.
Prior to using any methods from this class, you must do one of the following to ensure that this class is initialized:
- Wait for a
GoogleMapto become available from aMapFragmentorMapViewthat you have added to your application. You can obtain theGoogleMapinstance by callinggetMapAsync()and waiting for theonMapReady(GoogleMap map)callback. - Call
MapsInitializer.initialize(Context). As long as aGooglePlayServicesNotAvailableExceptionisn't thrown, this class will be correctly initialized.
Constant Summary
| float | HUE_AZURE | |
| float | HUE_BLUE | |
| float | HUE_CYAN | |
| float | HUE_GREEN | |
| float | HUE_MAGENTA | |
| float | HUE_ORANGE | |
| float | HUE_RED | |
| float | HUE_ROSE | |
| float | HUE_VIOLET | |
| float | HUE_YELLOW |
Public Method Summary
| static BitmapDescriptor |
defaultMarker(float hue)
Creates a
BitmapDescriptor
that refers to a colorization of the default marker image.
|
| static BitmapDescriptor |
defaultMarker()
Creates a
BitmapDescriptor
that refers to the default marker image.
|
| static BitmapDescriptor |
fromAsset(String assetName)
Creates a
BitmapDescriptor
using the name of a Bitmap image in the assets directory.
|
| static BitmapDescriptor | |
| static BitmapDescriptor |
fromFile(String fileName)
Creates a
BitmapDescriptor
using the name of a Bitmap image file located in the internal storage.
|
| static BitmapDescriptor |
fromPath(String
absolutePath)
Creates a
BitmapDescriptor
from the absolute file path of a Bitmap image.
|
| static BitmapDescriptor | |
| static BitmapDescriptor |
fromResource(int resourceId)
Creates a
BitmapDescriptor
using the resource ID of a Bitmap image.
|
Inherited Method Summary
Constants
public static final float HUE_AZURE
public static final float HUE_BLUE
public static final float HUE_CYAN
public static final float HUE_GREEN
public static final float HUE_MAGENTA
public static final float HUE_ORANGE
public static final float HUE_RED
public static final float HUE_ROSE
public static final float HUE_VIOLET
public static final float HUE_YELLOW
Public Methods
public static BitmapDescriptor defaultMarker (float hue)
Creates a BitmapDescriptor
that refers to a colorization of the default marker image. For convenience, there is a
predefined set of hue values. See example
HUE_YELLOW.
Parameters
| hue | The hue of the marker. Value must be greater or equal to 0 and less than 360. |
|---|
Returns
- the
BitmapDescriptorfor the colored marker image.
public static BitmapDescriptor defaultMarker ()
Creates a BitmapDescriptor
that refers to the default marker image.
public static BitmapDescriptor fromAsset (String assetName)
Creates a BitmapDescriptor
using the name of a Bitmap image in the assets directory.
Parameters
| assetName | The name of a Bitmap image in the assets directory. Must not be
null. |
|---|
Returns
- the
BitmapDescriptorthat was loaded from the asset.
public static BitmapDescriptor fromBitmap (Bitmap image)
Creates a BitmapDescriptor
from a given Bitmap image.
Parameters
| image | The image referenced in the descriptor. Must not be null. |
|---|
Returns
- the
BitmapDescriptorfor the image.
public static BitmapDescriptor fromFile (String fileName)
Creates a BitmapDescriptor
using the name of a Bitmap image file located in the internal storage. In particular,
this calls
Context.openFileInput(String).
Parameters
| fileName | The name of the Bitmap image file. Must not be null. |
|---|
Returns
- the
BitmapDescriptorfor the image in the app's internal storage.
See Also
public static BitmapDescriptor fromPath (String absolutePath)
Creates a BitmapDescriptor
from the absolute file path of a Bitmap image.
Parameters
| absolutePath | The absolute path of the Bitmap image. Must not be null. |
|---|
Returns
- the
BitmapDescriptorthat was loaded from the absolute path.
public static BitmapDescriptor fromPinConfig (PinConfig pinConfig)
Creates a BitmapDescriptor
from a given PinConfig.
Parameters
| pinConfig | instance to create a bitmap for |
|---|
Returns
- a
BitmapDescriptorthat will be created using the givenPinConfig
public static BitmapDescriptor fromResource (int resourceId)
Creates a BitmapDescriptor
using the resource ID of a Bitmap image.
Parameters
| resourceId | The resource ID of a Bitmap image. |
|---|
Returns
- the
BitmapDescriptorfor the image with the given resource ID.