Show device location

Most devices provide information about their own location. Each platform has API interfaces on the device that abstract how the location is retrieved, whether through Wi-Fi, cellular networks, or GPS.

Device location can be displayed in the following ways:

  • On a map
  • As coordinates listed on the screen

Display the location on a map

Common elements of a map location display are as follows:

  • Current location
  • Previous track points
  • Trail connecting the track points

Optional settings available for a map location display include the following:

  • Automatic panning to keep the latest point location visible
  • Change of symbol based on the status of the device's location
  • Display of metadata, for example, satellite information
  • Set the zoom scale so in automatic panning or navigation mode the user can control the extent to which the map zooms to the current location
  • Set opacity for the default, navigation and course symbols

Current location display

By default, the map uses a blue, round symbol to display the device's current location. The map always tries to get the most accurate location available. Depending on signal strength, satellite positions, and other factors, the reported location could be the best approximation. The map displays a blue circle around the location symbol to indicate the range of accuracy.

As the device moves, the map responds to location updates and appropriately updates the location symbol's position.

Location data sources

Stored either in memory or in a file, location can be displayed on the map by stepping through each of the points that make up the polyline in consecutive order at a predefined time interval.

Autopan modes

The map provides a number of presets that define how the map behaves when location updates are received:

  • Off
  • Recenter
  • Navigation
  • Compass navigation

Off mode

In this mode, the map only updates the position of the location symbol on the map. It does not recenter. Therefore, it is possible that the location symbol may move off the screen in response to location updates.

Recenter mode

In this mode, the map attempts to keep the location symbol on-screen by recentering the location symbol when the symbol moves outside a wander extent. Therefore, the location symbol may move freely within the wander extent, but as soon as the symbol exits the wander extent, the map view pans to recenter itself on the symbol.

By default, the wander extent is half the size of the map's viewable extent, but it can be customized. A value of 1 implies a wander extent equal to the size of the map's viewable extent, and the location symbol may move up to the edge of the map before the map recenters. A value of 0 implies an infinitesimal wander extent, and the map recenters on every location update.

If a user pans the map in this mode, the mode automatically changes its Autopan mode to Off, preventing the map from unwanted recentering based on future location updates.

Navigation mode

This mode is best for in-vehicle navigation. In this mode, the location symbol is pinned to a point on the screen and always points toward the top edge of the device. The map pans and rotates based on location updates and the direction the device is traveling in. Therefore, the location symbol appears stationary, while the map underneath it appears to be moving and rotating.

The position of the location symbol can be adjusted. A value of 0 implies the location symbol should be positioned at the bottom edge of the map, and 1 implies the top edge. A value between 0 and 1 positions the symbol somewhere along the centerline from the bottom edge to the top edge.

If a user pans the map in this mode, the mode automatically changes to Off.

Compass Navigation mode

This mode is better when the user is walking. As in Navigation mode, the location symbol is pinned to a point on the screen and always points toward the top edge of the device. However, the map rotates based on the user's bearing relative to magnetic north, and not based on the direction the device travels in, which is the case in Navigation mode. Therefore, the map reflects what lies ahead of the user as the user pivots around their location.

The location symbol position can be adjusted. A value of 0 implies the location symbol should be positioned at the bottom edge of the map, and 1 implies the top edge. A value between 0 and 1 positions the symbol somewhere between the bottom and top edges.

If a user pans the map in this mode, the mode automatically changes to Off.

Customizing the location symbol

The SDK provides default images that are used for the location symbol. These images are included as resources in the arcgis-android-api.jar.

  • The location acquiring symbol (arcgisruntime_location_display_acquiring_symbol.png) is designed to be shown while the location is still being acquired
  • The heading symbol (arcgisruntime_location_display_compass_symbol.png) is designed to be shown while in compass navigation mode
  • The course symbol (arcgisruntime_location_display_course_symbol.png) is designed to be shown in navigation mode
  • The default symbol (arcgisruntime_location_display_default_symbol.png) is designed to be shown while the location is known

Depending on the autopan mode in use, and the type of information provided by the location updates, one of the default images will be used for the location symbol.

In the off, recenter, and navigation modes, the default image is used only when location information is available. The course symbol is used if both location information and course (direction of travel) information are available. In the off and recenter modes, the course symbol is appropriately rotated by an amount specified by the course to display the direction in which the device is traveling; however, in Navigation mode, the map rotates instead.

Note:

Course information is only available when the device is moving at some nontrivial velocity. This is why the map typically only displays the course symbol when the device is traveling in a vehicle.

In the Compass Navigation mode, the heading image is used to display the device's location and bearing.

Displaying the location as coordinates on the screen

Maps are not always the focus of your application, yet device location can still matter. You may require location to populate fields in a form, display the current coordinates on the screen, or show a scrolling list of coordinates to represent movement. When coordinates are displayed on the screen, you can use the color, size, or font of the text to convey additional information.