public class LocationIndicator
extension LocationIndicator: NativeBase
extension LocationIndicator: Hashable

Graphical object to represent the location of the user on the map.

It is either a green dot for pedestrian style or a triangular arrow for vehicle navigation style. This style can be changed by LocationIndicator.locationIndicatorStyle

The location is made available to an instance of this class by calling LocationIndicator.updateLocation(Location, MapCameraUpdate).

Use LocationIndicator.enable(...) to add this object to the map and LocationIndicator.disable(...) to remove it.

Note: The LocationIndicator is always rendered at a fixed altitude near 0. Changing the MapCamera to look at geographic coordinates with an altitude that is higher can cause the following behavior: If the MapCamera angle is tilted and altitude is too high, the LocationIndicator can unexpectedly disappear from the viewport due to the new perspective.

  • Creates an instance of LocationIndicator.

    Declaration

    Swift

    public init()
  • Creates an instance of LocationIndicator and adds it to provided MapViewBase.

    Declaration

    Swift

    public init(for mapView: MapViewBase)

    Parameters

    mapView

    The MapViewBase instance.

  • A Boolean value that determines whether the horizontal accuracy passed to LocationIndicator.updateLocation(Location, MapCameraUpdate) is visualized by scaling the accuracy indicator halo accordingly. By default, it is set to false. In this case the accuracy indicator halo has a fixed and zoom level independent size. When set to true, the radius of the halo corresponds to the value of Location.horizontalAccuracyInMeters passed to LocationIndicator.updateLocation(Location, MapCameraUpdate) and scales in world coordinates.

    For values smaller than 20 meters the halo is hidden. The radius of the halo is limited to 500 meters and values higher than that or nil will keep the halo at that size.

    If the location indicator is set to inactive (which can be checked via LocationIndicator.isActive flag), then the halo is always hidden. The value of this property remains unchanged regardless of the flag’s value. If the location indicator is set to active:

    • Built-in location indicators:
      • The halo is always shown.
      • If the accuracy visualization is set to true, the size of the halo scales with Location.horizontalAccuracyInMeters in world coordinates.
      • If the accuracy visualization is set to false, halo displays at a default size.
    • Custom location indicator:
      • If the accuracy visualization is set to true, halo is shown and the size of the halo scales with Location.horizontalAccuracyInMeters in world coordinates.
      • If the accuracy visualization is set to false, no halo is shown since it might not fit together with the custom 3d model.

    Declaration

    Swift

    public var isAccuracyVisualized: Bool { get set }
  • The visual style of location indicator. By default, it is set to LocationIndicator.IndicatorStyle.pedestrian.

    Declaration

    Swift

    public var locationIndicatorStyle: LocationIndicator.IndicatorStyle { get set }
  • A Boolean value that determines whether the active on inactive version of location indicator is shown. By default, it is set to true.

    Set to false to show the inactive version of the indicator which is typically represented by a grayed out version of the indicator. This can be used in case the location of the indicator might be outdated or positioning on the device is disabled.

    Declaration

    Swift

    public var isActive: Bool { get set }
  • The factor applied to the alpha channel of both the location indicator’s texture and the accuracy indicator’s halo color. The value is clamped in range [0.0, 1.0]. Default value is 1.0 which means location indicator is displayed with the default alpha channel of the texture.

    Declaration

    Swift

    public var opacity: Double { get set }
  • The predefined styles for the location indicator which are pedestrian and navigation mode.

    See more

    Declaration

    Swift

    public enum IndicatorStyle : UInt32, CaseIterable, Codable
  • Enum to identify different types of markers of the location indicator.

    See more

    Declaration

    Swift

    public enum MarkerType : UInt32, CaseIterable, Codable
  • Enables LocationIndicator for provided MapViewBase. If LocationIndicator is already enabled (added to map view) for passed map view, this function does nothing. If LocationIndicator is added to different MapViewBase, this function removes first LocationIndicator from previous map view before adding to new one.

    Declaration

    Swift

    public func enable(for mapView: MapViewBase)

    Parameters

    mapView

    The MapViewBase instance.

  • This function removes LocationIndicator from map view. If LocationIndicator was not added to any map view yet, this function does nothing.

    Declaration

    Swift

    public func disable()
  • Updates the indicator to a new location. If accuracy visualized is set to true the field Location.horizontalAccuracyInMeters controls the size of the accuracy indicator halo.

    The altitude of the location is ignored.

    Declaration

    Swift

    public func updateLocation(_ location: Location)

    Parameters

    location

    The updated location of the user.

  • Updates the indicator to a new location and applies a camera update at the same time.

    Does nothing if the indicator instance is not enabled. If accuracy visualized is set to true the field Location.horizontalAccuracyInMeters controls the size of the accuracy indicator halo.

    The altitude of the location is ignored.

    Declaration

    Swift

    public func updateLocation(_ location: Location, cameraUpdate: MapCameraUpdate)

    Parameters

    location

    The updated location of the user.

    cameraUpdate

    The update to apply to the camera.

  • Sets the MapMarker3DModel asset to be displayed as location indicator for a specified type. The 3D model should be oriented with y axis up and thus standing on the x/z plane where the z axis is the depth. The direction in which the location indicator is pointing is the positive z axis. Please note that only MapMarker3DModel created from *.obj files are supported. Models created from Mesh will be ignored.

    Declaration

    Swift

    public func setMarker3dModel(_ model: MapMarker3DModel, scale: Double, type: LocationIndicator.MarkerType)

    Parameters

    model

    The MapMarker3DModel object to be displayed for the specified type. Only models created from obj files are supported. Those created from mesh will be ignored.

    scale

    The scaling which will be applied to the marker model. As the size of the location marker should be aligned on devices with different resolutions the scale factor is applied relative to the ppi value and thus differs from the scale which is passed to MapMarker3D objects. For the default marker models a value of 5.0 was used.

    type

    The type of location marker for which the marker 3d model should be replaced.

  • Sets the color of the accuracy indicator halo for a given style.

    Declaration

    Swift

    public func setHaloColor(_ style: LocationIndicator.IndicatorStyle, color: UIColor)

    Parameters

    style

    The type of IndicatorStyle for which the color should be assigned.

    color

    The color to be applied to the halo for a specified IndicatorStyle. Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.

  • Retrieves the color of the accuracy indicator halo for the requested IndicatorStyle. The default color is a translucent turquoise (rgba(0, 199, 194, 76)) for all IndicatorStyle settings.

    Declaration

    Swift

    public func getHaloColor(_ style: LocationIndicator.IndicatorStyle) -> UIColor

    Parameters

    style

    The type of IndicatorStyle for which the color should be returned.

    Return Value

    The color of the halo for the specified IndicatorStyle. Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.