DJI Mobile SDK Documentation

class MapWidget

class MapWidget extends FrameLayoutWidget implements View.OnTouchListener, View.OnClickListener
Package:dji.ux.widget
Inherits From:FrameLayoutWidget implements View.OnTouchListener, View.OnClickListener
Display:

Widget that displays the aircraft's state and information on the map this includes aircraft location, home location, aircraft trail path, aircraft heading, and No Fly Zones.

Usage:

Preferred Aspect Ratio: 1:1

Class Members:
method getFlightPathWidth
float getFlightPathWidth()
Package:dji.ux.widget
Description:

Gets the line width, in pixels, of the flight path. Valid range is 0-100.

Return:
floatThe width in pixels of the flight path.
method initHereMap
void initHereMap(final OnMapReadyListener listener)
Package:dji.ux.widget
Description:

Initializes the MapWidget with Here Maps.

Note: Here Maps currently only works on arm v7 devices, and you must sign up for their premium package.

Input Parameters:
final OnMapReadyListener listenerThe OnMapReadyListener which will invoke the onMapReady method when the map has finished initializing.
method initGoogleMap
void initGoogleMap(final OnMapReadyListener listener)
Package:dji.ux.widget
Description:

Initializes the MapWidget with Google Maps.

Note: Google Maps only works on devices with Google Play Services (not Crystal Sky).
Important: The following lifecycle methods in your activity must call the corresponding methods in MapWidget in order for the map to render correctly: {@link #onCreate(Bundle)}, {@link #onResume()}, {@link #onPause()}, {@link #onDestroy()}, {@link #onSaveInstanceState(Bundle)}, and {@link #onLowMemory()}.

Input Parameters:
final OnMapReadyListener listenerThe OnMapReadyListener which will invoke the onMapReady method when the map has finished initializing.
method
method initAMap
void initAMap(final OnMapReadyListener listener)
Package:dji.ux.widget
Description:

Initializes the MapWidget with AMaps.

Input Parameters:
final OnMapReadyListener listenerThe OnMapReadyListener which will invoke the onMapReady method when the map has finished initializing.
method initMapboxMap
void initMapboxMap(final OnMapReadyListener listener, String mapboxAccessToken)
Package:dji.ux.widget
Description:

Initializes the MapWidget with Mapbox.
Important: The following lifecycle methods in your activity must call the corresponding methods in MapWidget in order for the map to render correctly: {@link #onCreate(Bundle)}, {@link #onResume()}, {@link #onPause()}, {@link #onDestroy()}, {@link #onSaveInstanceState(Bundle)}, and {@link #onLowMemory()}.

Input Parameters:
final OnMapReadyListener listenerThe OnMapReadyListener which will invoke the onMapReady method when the map has finished initializing.
String mapboxAccessTokenThe API access token from Mapbox.
method
method getMap
DJIMap getMap()
Package:dji.ux.widget
Description:

Get the DJIMap object.

Return:
DJIMapA DJIMap object.
method hideAllFlyZones
void hideAllFlyZones()
Package:dji.ux.widget
Description:

Hides all fly zones.

method clearFlightPath
void clearFlightPath()
Package:dji.ux.widget
Description:

Clears the flight path up to the current location. The flight path is removed even if it is hidden.

method setFlightPathColor
void setFlightPathColor(@ColorInt int color)
Package:dji.ux.widget
Description:

Sets the color of the flight path.

Input Parameters:
@ColorInt int colorThe color of the flight path.
method setMapCenterLock
void setMapCenterLock(MapCenterLock mapCenterLock)
Package:dji.ux.widget
Description:

Sets the lock on the aircraft or the home location to be in center.

Input Parameters:
MapCenterLock mapCenterLockParameter to select the mode of centering.
method setOnMarkerClickListener
void setOnMarkerClickListener(DJIMap.OnMarkerClickListener onMarkerClickListener)
Package:dji.ux.widget
Description:

Sets the OnMarkerClickListener for this widget.

Input Parameters:
DJIMap.OnMarkerClickListener onMarkerClickListenerThe listener that is added to this widget.
method setAutoFrameMap
void setAutoFrameMap(boolean isEnabled)
Package:dji.ux.widget
Description:

Keeps the home location and the aircraft location visible and adjust the map bounds when set true.

Input Parameters:
boolean isEnabledParameter to enable or disable the map bounds lock.
method setHomeBitmap
void setHomeBitmap(Bitmap bitmap)
Package:dji.ux.widget
Description:

Changes the icon of the home marker.

Input Parameters:
Bitmap bitmapThe image to be set to.
method setHomeBitmap
void setHomeBitmap(Bitmap bitmap, float x, float y)
Package:dji.ux.widget
Description:

Changes the icon of the home marker.

Input Parameters:
Bitmap bitmapThe image to be set to.
float xSpecifies the x axis value of anchor to be at a particular point in the marker image.
float ySpecifies the y axis value of anchor to be at a particular point in the marker image.
method getHomeBitmap
Bitmap getHomeBitmap()
Package:dji.ux.widget
Description:

Gets the icon of the home marker.

Return:
BitmapThe icon of the home marker.
method setFlyZoneColor
void setFlyZoneColor(FlyZoneCategory category, @ColorInt int color)
Package:dji.ux.widget
Description:

Sets the color of the given fly zone category.

Input Parameters:
FlyZoneCategory categoryThe fly zone category.
@ColorInt int colorThe new border color.
method getFlyZoneColor
@ColorInt
int getFlyZoneColor(FlyZoneCategory category)
Package:dji.ux.widget
Description:

Get the color of the given fly zone category.

Input Parameters:
FlyZoneCategory categoryThe fly zone category.
Return:
intA color int.
method setFlyZoneAlpha
void setFlyZoneAlpha(FlyZoneCategory category, int alpha)
Package:dji.ux.widget
Description:

Set the alpha of the given fly zone category.

Input Parameters:
FlyZoneCategory categoryThe fly zone category.
int alphaAn alpha value from 0-255.
method getFlyZoneAlpha
int getFlyZoneAlpha(FlyZoneCategory category)
Package:dji.ux.widget
Description:

Get the alpha of the given fly zone category.

Input Parameters:
FlyZoneCategory categoryThe fly zone category.
Return:
intAn alpha value from 0-255.
method setFlyZoneBorderWidth
void setFlyZoneBorderWidth(float width)
Package:dji.ux.widget
Description:

Set the border width of all fly zones.

Input Parameters:
float widthThe width in pixels of the fly zone borders.
method getFlyZoneBorderWidth
float getFlyZoneBorderWidth()
Package:dji.ux.widget
Description:

Get the border width of all fly zones.

Return:
floatThe width in pixels of the fly zone borders.
method getSelfUnlockColor
@ColorInt
int getSelfUnlockColor()
Package:dji.ux.widget
Description:

Get the color of the self-unlock fly zones.

Return:
intA color int.
method setSelfUnlockColor
void setSelfUnlockColor(@ColorInt int selfUnlockColor)
Package:dji.ux.widget
Description:

Set the color of the self-unlock fly zones.

Input Parameters:
@ColorInt int selfUnlockColorThe new color.
method getSelfUnlockAlpha
int getSelfUnlockAlpha()
Package:dji.ux.widget
Description:

Get the alpha of the self-unlock fly zones.

Return:
intThe alpha of the self-unlock fly zones.
method setSelfUnlockAlpha
void setSelfUnlockAlpha(int selfUnlockAlpha)
Package:dji.ux.widget
Description:

Set the alpha of the self unlock fly zones.

Input Parameters:
int selfUnlockAlphaThe new alpha.
method setCustomUnlockFlyZoneOverlayColor
void setCustomUnlockFlyZoneOverlayColor(@ColorInt int customUnlockColor)
Package:dji.ux.widget
Description:

Set the color of the custom unlock fly zones.

Input Parameters:
@ColorInt int customUnlockColorThe new color.
method setCustomUnlockFlyZoneSentToAircraftOverlayColor
void setCustomUnlockFlyZoneSentToAircraftOverlayColor(@ColorInt int customUnlockSentToAircraftColor)
Package:dji.ux.widget
Description:

Set the color of the custom unlock fly zones that have been sent to the aircraft.

Input Parameters:
@ColorInt int customUnlockSentToAircraftColorThe new color.
method setCustomUnlockFlyZoneEnabledOverlayColor
void setCustomUnlockFlyZoneEnabledOverlayColor(@ColorInt int customUnlockEnabledColor)
Package:dji.ux.widget
Description:

Set the color of the currently enabled custom unlock fly zones.

Input Parameters:
@ColorInt int customUnlockEnabledColorThe new color.
method getCustomUnlockFlyZoneOverlayColor
@ColorInt
int getCustomUnlockFlyZoneOverlayColor()
Package:dji.ux.widget
Description:

Get the color of the custom unlock zone.

Return:
intA color int.
method getCustomUnlockFlyZoneSentToAircraftOverlayColor
@ColorInt
int getCustomUnlockFlyZoneSentToAircraftOverlayColor()
Package:dji.ux.widget
Description:

Get the color of the custom unlock zones sent to the aircraft.

Return:
intA color int.
method getCustomUnlockFlyZoneEnabledOverlayColor
@ColorInt
int getCustomUnlockFlyZoneEnabledOverlayColor()
Package:dji.ux.widget
Description:

Get the color of the currently enabled custom unlock fly zone.

Return:
intA color int.
method setCustomUnlockFlyZoneOverlayAlpha
void setCustomUnlockFlyZoneOverlayAlpha(int customUnlockColorAlpha)
Package:dji.ux.widget
Description:

Set the alpha of the custom unlock fly zones.

Input Parameters:
int customUnlockColorAlphaThe new alpha.
method setCustomUnlockFlyZoneSentToAircraftOverlayAlpha
void setCustomUnlockFlyZoneSentToAircraftOverlayAlpha(int customUnlockSentToAircraftColorAlpha)
Package:dji.ux.widget
Description:

Set the alpha of the custom unlock fly zones sent to the aircraft.

Input Parameters:
int customUnlockSentToAircraftColorAlphaThe new alpha.
method setCustomUnlockFlyZoneEnabledOverlayAlpha
void setCustomUnlockFlyZoneEnabledOverlayAlpha(int customUnlockEnabledColorAlpha)
Package:dji.ux.widget
Description:

Set the alpha of the currently enabled custom unlock fly zones.

Input Parameters:
int customUnlockEnabledColorAlphaThe new alpha.
method getCustomUnlockFlyZoneOverlayAlpha
int getCustomUnlockFlyZoneOverlayAlpha()
Package:dji.ux.widget
Description:

Get the alpha of the custom unlock fly zones.

Return:
intThe alpha.
method getCustomUnlockFlyZoneSentToAircraftOverlayAlpha
int getCustomUnlockFlyZoneSentToAircraftOverlayAlpha()
Package:dji.ux.widget
Description:

Get the alpha of the custom unlock fly zones sent to the aircraft.

Return:
intThe alpha.
method getCustomUnlockFlyZoneEnabledOverlayAlpha
int getCustomUnlockFlyZoneEnabledOverlayAlpha()
Package:dji.ux.widget
Description:

Get the alpha of the currently enabled custom unlock fly zone.

Return:
intThe alpha.
method getMaximumHeightColor
@ColorInt
int getMaximumHeightColor()
Package:dji.ux.widget
Description:

Get the color of the maximum height fly zones.

Return:
intThe color of the maximum height fly zones.
method setMaximumHeightColor
void setMaximumHeightColor(@ColorInt int limitedHeightColor)
Package:dji.ux.widget
Description:

Set the color of the maximum height fly zones.

Input Parameters:
@ColorInt int limitedHeightColorThe new color.
method getMaximumHeightAlpha
int getMaximumHeightAlpha()
Package:dji.ux.widget
Description:

Get the alpha of the maximum height fly zones.

Return:
intThe alpha.
method setMaximumHeightAlpha
void setMaximumHeightAlpha(int maximumHeightAlpha)
Package:dji.ux.widget
Description:

Set the alpha of the maximum height fly zones.

Input Parameters:
int maximumHeightAlphaThe new alpha.
method setFlyZoneVisible
void setFlyZoneVisible(FlyZoneCategory flyZoneCategory, boolean isVisible)
Package:dji.ux.widget
Description:

Set selected fly zone visibility on the map.

Input Parameters:
FlyZoneCategory flyZoneCategoryRepresents the category of fly zone to show/hide.
boolean isVisibletrue to show fly zones.
method isFlyZoneVisible
boolean isFlyZoneVisible(FlyZoneCategory flyZoneCategory)
Package:dji.ux.widget
Description:

Get selected fly zone visibility on the map.

Input Parameters:
FlyZoneCategory flyZoneCategoryThe category of the fly zone.
Return:
booleanWhether the given fly zone category is visible on the map.
method setTapToUnlockEnabled
void setTapToUnlockEnabled(boolean isFlyZonesUnlockingEnabled)
Package:dji.ux.widget
Description:

This will enable the unlocking of fly zones by clicking on them.

Input Parameters:
boolean isFlyZonesUnlockingEnabledA boolean value that determines whether to enable Fly Zones Unlocking.
method isTapToUnlockEnabled
boolean isTapToUnlockEnabled()
Package:dji.ux.widget
Description:

Gets whether tap to unlock is enabled.

Return:
booleantrue if tapping to unlock select fly zones is enabled.
method setSelfUnlockedBitmap
void setSelfUnlockedBitmap(Bitmap bitmap)
Package:dji.ux.widget
Description:

Changes the icon of the unlocked self-unlock zones.

Input Parameters:
Bitmap bitmapThe image to be set.
method setSelfUnlockedBitmap
void setSelfUnlockedBitmap(Bitmap bitmap, float x, float y)
Package:dji.ux.widget
Description:

Changes the icon of the unlocked self-unlock zones.

Input Parameters:
Bitmap bitmapThe image to be set.
float xSpecifies the x axis value of anchor to be at a particular point in the marker image.
float ySpecifies the y axis value of anchor to be at a particular point in the marker image.
method setSelfLockedBitmap
void setSelfLockedBitmap(Bitmap bitmap)
Package:dji.ux.widget
Description:

Changes the icon of the locked self-unlock zones

Input Parameters:
Bitmap bitmapThe image to be set.
method setSelfLockedBitmap
void setSelfLockedBitmap(Bitmap bitmap, float x, float y)
Package:dji.ux.widget
Description:

Changes the icon of the locked self-unlock zones

Input Parameters:
Bitmap bitmapThe image to be set.
float xSpecifies the x axis value of anchor to be at a particular point in the marker image.
float ySpecifies the y axis value of anchor to be at a particular point in the marker image.
method setCustomUnlockEnabledBitmap
void setCustomUnlockEnabledBitmap(Bitmap bitmap)
Package:dji.ux.widget
Description:

Changes the icon of the custom unlock zone which is enabled.

Input Parameters:
Bitmap bitmapThe image to be set.
method setCustomUnlockEnabledBitmap
void setCustomUnlockEnabledBitmap(Bitmap bitmap, float x, float y)
Package:dji.ux.widget
Description:

Changes the icon of the custom unlock zone which is enabled.

Input Parameters:
Bitmap bitmapThe image to be set.
float xSpecifies the x axis value of anchor to be at a particular point in the marker image.
float ySpecifies the y axis value of anchor to be at a particular point in the marker image.
method setCustomUnlockSentToAircraftBitmap
void setCustomUnlockSentToAircraftBitmap(Bitmap bitmap)
Package:dji.ux.widget
Description:

Changes the icon of the custom unlock zone which is on aircraft but not enabled.

Input Parameters:
Bitmap bitmapThe image to be set.
method setCustomUnlockSentToAircraftBitmap
void setCustomUnlockSentToAircraftBitmap(Bitmap bitmap, float x, float y)
Package:dji.ux.widget
Description:

Changes the icon of the custom unlock zone which is on aircraft but not enabled.

Input Parameters:
Bitmap bitmapThe image to be set.
float xSpecifies the x axis value of anchor to be at a particular point in the marker image.
float ySpecifies the y axis value of anchor to be at a particular point in the marker image.
method setDirectionToHomeVisible
void setDirectionToHomeVisible(boolean isVisible)
Package:dji.ux.widget
Description:

Sets the visibility of the path from aircraft to home point.

Input Parameters:
boolean isVisibleA boolean value that determines whether to show the path from aircraft to home point.
method isDirectionToHomeVisible
boolean isDirectionToHomeVisible()
Package:dji.ux.widget
Description:

Defaults to false. A Boolean value indicating whether the map displays a line showing the direction to home.

Return:
booleantrue if direction to home is visible.
method setDirectionToHomeColor
void setDirectionToHomeColor(@ColorInt int color)
Package:dji.ux.widget
Description:

Sets the color of the path from aircraft to home point.

Input Parameters:
@ColorInt int colorThe new color of the path.
method getDirectionToHomeColor
@ColorInt
int getDirectionToHomeColor()
Package:dji.ux.widget
Description:

Gets the color of the path from aircraft to home point.

Return:
intThe color of the path.
method setDirectionToHomeWidth
void setDirectionToHomeWidth(float width)
Package:dji.ux.widget
Description:

Sets the width of the path from aircraft to home point.

Input Parameters:
float widthThe width of the path.
method getDirectionToHomeWidth
float getDirectionToHomeWidth()
Package:dji.ux.widget
Description:

Gets the width of the path from aircraft to home point.

Return:
floatThe width of the path.
method setFlightPathVisible
void setFlightPathVisible(boolean isVisible)
Package:dji.ux.widget
Description:

Sets the flight path visibility.

Input Parameters:
boolean isVisibleA boolean value that determines whether to show the flight path.
method isFlightPathVisible
boolean isFlightPathVisible()
Package:dji.ux.widget
Description:

true if the flight path is visible. The default value is false

Return:
booleanA boolean value indicating if the flight path is visible.
method getFlightPathColor
@ColorInt
int getFlightPathColor()
Package:dji.ux.widget
Description:

Gets the color of the flight path.

Return:
intThe color of the flight path.
method setFlightPathWidth
void setFlightPathWidth(float width)
Package:dji.ux.widget
Description:

Sets a line width, in pixels, for the flight path. Valid range is 0-100.

Input Parameters:
float widthThe width in pixels of the flight path.
method setGimbalAttitudeVisible
void setGimbalAttitudeVisible(boolean isVisible)
Package:dji.ux.widget
Description:

Sets the visibility of the gimbal attitude marker.

Input Parameters:
boolean isVisibleA boolean value that determines whether to show the gimbal attitude marker.
method isGimbalAttitudeVisible
boolean isGimbalAttitudeVisible()
Package:dji.ux.widget
Description:

Gets the visibility of the gimbal attitude marker.

Return:
booleantrue if the gimbal attitude marker is visible.
method setAircraftBitmap
void setAircraftBitmap(Bitmap bitmap, float x, float y)
Package:dji.ux.widget
Description:

Set the icon of the aircraft marker.

Input Parameters:
Bitmap bitmapThe image to be set.
float xSpecifies the x axis value of anchor to be at a particular point in the marker image.
float ySpecifies the y axis value of anchor to be at a particular point in the marker image.
method setAircraftBitmap
void setAircraftBitmap(Bitmap bitmap)
Package:dji.ux.widget
Description:

Changes the icon of the aircraft marker.

Input Parameters:
Bitmap bitmapThe image to be set to.
method getAircraftBitmap
Bitmap getAircraftBitmap()
Package:dji.ux.widget
Description:

Gets the icon of the aircraft marker.

Return:
BitmapThe icon of the aircraft marker.
method setGimbalAttitudeBitmap
void setGimbalAttitudeBitmap(Bitmap bitmap)
Package:dji.ux.widget
Description:

Changes the icon of the gimbal attitude marker.

Input Parameters:
Bitmap bitmapThe image to be set to.
method getGimbalAttitudeBitmap
Bitmap getGimbalAttitudeBitmap()
Package:dji.ux.widget
Description:

Gets the icon of the gimbal attitude marker.

Return:
BitmapThe icon of the gimbal attitude marker.
method setHomeVisible
void setHomeVisible(boolean isVisible)
Package:dji.ux.widget
Description:

Sets the visibility of the home marker if present on the map.

Input Parameters:
boolean isVisibleA boolean value to determine if the home marker is visible.
method isHomeVisible
boolean isHomeVisible()
Package:dji.ux.widget
Description:

true if the map displays the home point of the aircraft. The default value of this property is true.

Return:
booleanThe icon of the home point marker.
method setDialogTheme
void setDialogTheme(@StyleRes int dialogTheme)
Package:dji.ux.widget
Description:

Sets the theme of all dialogs launched by this widget, such as self-unlock and custom unlock prompts. The theme must be an AppCompat theme since the AlertDialog is from the support library.

Input Parameters:
@StyleRes int dialogThemeThe theme set for all dialogs launched by this widget.
enum MapCenterLock
enum MapCenterLock
Package:dji.ux.widget
Description:

Map Centering Options.

Enum Members:
NONEThis will disable the centering of map on any markers.
AIRCRAFTThis will keep the aircraft icon always in center of the screen and keep following it during flight.
HOMEThis will keep the home icon always in center of the screen. The aircraft icon will disappear from view bounds if the aircraft travels that distance
Class Members:
method showAllFlyZones
void showAllFlyZones()
Package:dji.ux.widget
Description:

Make all Fly zones visible on the map.

method showFlyZoneLegend
void showFlyZoneLegend(boolean showFlyZoneLegend)
Package:dji.ux.widget
Description:

Shows the fly zone legend. The fly zone legend indicates the color for all zone categories and self-unlock zones.

Input Parameters:
boolean showFlyZoneLegendtrue to show the legend, false to hide.
method showDJIAccountLoginIndicator
void showDJIAccountLoginIndicator(boolean isLoginIndicatorVisible)
Package:dji.ux.widget
Description:

Defaults to false. Show a small indicator displaying the latest DJI account login state. Useful if using FlySafe features.

Input Parameters:
boolean isLoginIndicatorVisibletrue if visible, false if hidden.
method isDJIAccountLoginIndicatorVisible
boolean isDJIAccountLoginIndicatorVisible()
Package:dji.ux.widget
Description:

Get current visibility of DJI Account Login Indicator.

Return:
booleantrue if visible, false if hidden.
method showCustomUnlockZones
void showCustomUnlockZones(boolean isVisible)
Package:dji.ux.widget
Description:

Defaults to false. Shows custom unlock zones if any are available for the currently connected aircraft.

Input Parameters:
boolean isVisibletrue to show fly zones.
method isCustomUnlockZonesVisible
boolean isCustomUnlockZonesVisible()
Package:dji.ux.widget
Description:

Returns flag for the current visibility of Custom Unlock FlyZones

Return:
booleantrue if custom unlock fly zones are visible.
method syncCustomUnlockZones
void syncCustomUnlockZones()
Package:dji.ux.widget
Description:

Call this to sync currently shown custom unlock zones to aircraft. They will still need to be manually enabled.

interface OnMapReadyListener
interface OnMapReadyListener
Package:dji.ux.widget
Description:

When added to the MapWidget, the OnMapReadyListener can be used to determine when the map is ready to modify. No modifications should be done to the MapWidget before the map is initialized using one of the initialization methods.

Interface Methods:
method onMapReady
void onMapReady(@NonNull DJIMap map)
Package:dji.ux.widget
Description:

A callback indicating that the map is finished initializing.

Input Parameters:
@NonNull DJIMap mapThe object of DJIMap.
class