Skip to content

Location Widget

Siddharth Utgikar edited this page Dec 22, 2020 · 1 revision

The Location Widget is a TEXT_IMAGE_LEFT type of Base Telemetry Widget. It shows the current geo location which constitutes the latitude and longitude as reported by the drone. It updates the coordinates in real time and provides a precision up to 6 decimal places.

State Image
Disconnected or Location Unavailable
Location Available

Usage

<dji.ux.beta.core.widget.location.LocationWidget
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>

Customizations

The UI elements can be customized to match the style of the user's application. The widget supports all the Text Customizations and Icon Customizations provided in the Base Telemetry Widget.

XML Example

<dji.ux.beta.core.widget.location.LocationWidget
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:background="@color/white"
     app:uxsdk_widget_icon="@drawable/ic_custom_location"
     app:uxsdk_value_text_color="@color/blue"/>
State Image
Disconnected or Location Unavailable
Location Available

Kotlin Example

val locationWidget: LocationWidget = findViewById(R.id.widget_location)
locationWidget.setBackgroundColor(resources.getColor(R.color.white))
locationWidget.valueTextColor = resources.getColor(R.color.blue)
locationWidget.widgetIcon = resources.getDrawable(R.drawable.ic_custom_location)

Java Example

LocationWidget locationWidget = findViewById(R.id.widget_location);
locationWidget.setBackgroundColor(getResources().getColor(R.color.white));
locationWidget.setValueTextColor(getResources().getColor(R.color.blue));
locationWidget.setWidgetIcon(getResources().getDrawable(R.drawable.ic_custom_location));

Hooks

The widget provides hooks for the users to add functionality based on the state changes in the widget. The LocationWidget provides the following hooks

  1. ModelState - Provides hooks in events received by the widget from the widget model.
    • data class ProductConnected(val isConnected: Boolean) : ModelState() - Event when the product is connected or disconnected.
    • data class LocationStateUpdated(val locationState: LocationState) : ModelState() - Event when the aircraft location is updated.

The user can subscribe to this using public override fun getWidgetStateUpdate(): Flowable<ModelState>.

Clone this wiki locally