LocationIndicator
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
mapViewThe
MapViewBaseinstance. -
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 tofalse. In this case the accuracy indicator halo has a fixed and zoom level independent size. When set totrue, the radius of the halo corresponds to the value ofLocation.horizontalAccuracyInMeterspassed toLocationIndicator.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
nilwill keep the halo at that size.If the location indicator is set to inactive (which can be checked via
LocationIndicator.isActiveflag), 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 withLocation.horizontalAccuracyInMetersin 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 withLocation.horizontalAccuracyInMetersin 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.
- If the accuracy visualization is set to
Declaration
Swift
public var isAccuracyVisualized: Bool { get set } - Built-in location indicators:
-
The visual style of location indicator. By default, it is set to
LocationIndicator.IndicatorStyle.navigation.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
falseto 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 material reflectivity properties of the location indicator. Enables per‑pixel lighting for all internal markers (navigation, pedestrian, inactive variants) and the halo when assigned. While
materialReflectivityis non‑null the markers are shaded by scene lights using the provided ambient / diffuse factors. When set back tonil, lighting is disabled and markers revert to unlit (emissive) rendering. This value also applies to any custom markers set withsetMarker3dModel. Default value isnil.Declaration
Swift
public var materialReflectivity: MaterialReflectivity? { get set } -
The predefined styles for the location indicator which are pedestrian and navigation mode.
See moreDeclaration
Swift
public enum IndicatorStyle : UInt32, CaseIterable, Codable -
Enum to identify different types of markers of the location indicator.
See moreDeclaration
Swift
public enum MarkerType : UInt32, CaseIterable, Codable -
Enables
LocationIndicatorfor providedMapViewBase. IfLocationIndicatoris already enabled (added to map view) for passed map view, this function does nothing. IfLocationIndicatoris added to differentMapViewBase, this function removes firstLocationIndicatorfrom previous map view before adding to new one.Declaration
Swift
public func enable(for mapView: MapViewBase)Parameters
mapViewThe
MapViewBaseinstance. -
This function removes
LocationIndicatorfrom map view. IfLocationIndicatorwas 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
truethe fieldLocation.horizontalAccuracyInMeterscontrols the size of the accuracy indicator halo.The altitude of the location is ignored.
Declaration
Swift
public func updateLocation(_ location: Location)Parameters
locationThe 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
truethe fieldLocation.horizontalAccuracyInMeterscontrols the size of the accuracy indicator halo.The altitude of the location is ignored.
Declaration
Swift
public func updateLocation(_ location: Location, cameraUpdate: MapCameraUpdate)Parameters
locationThe updated location of the user.
cameraUpdateThe 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
@available(*, deprecated, message: "Will be removed in v4.27.0. Please use the overloaded method with `RenderSize.Unit` instead.") public func setMarker3dModel(_ model: MapMarker3DModel, scale: Double, type: LocationIndicator.MarkerType)Parameters
modelThe MapMarker3DModel object to be displayed for the specified type. Only models created from obj files are supported. Those created from mesh will be ignored.
scaleThe 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
MapMarker3Dobjects. Meter is used for the unit of the map marker 3d model coordinate system. For historical reason, the scale factor is internally devided by 6. To display a unit qube of 1x1x1 meter as is, please use a scale value of 6.0.typeThe type of location marker for which the marker 3d model should be replaced.
-
Sets the
MapMarker3DModelasset 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 onlyMapMarker3DModelcreated fromobjfiles are supported. Models created from Mesh will be ignored.Declaration
Swift
public func setMarker3dModel(_ model: MapMarker3DModel, scale: Double, type: LocationIndicator.MarkerType, renderSizeUnit: RenderSize.Unit)Parameters
modelThe
MapMarker3DModelobject to be displayed for the specified type. Only models created fromobjfiles are supported. Those created from mesh will be ignored.scaleA scale factor applied to the marker model.
typeThe type of location marker for which the marker 3d model should be replaced.
renderSizeUnitThe
RenderSize.Unitspecifying how the vertex coordinates of the 3D model are being interpreted. It specifies whether the 3D model is placed in world or screen coordinate space. -
Sets the color of the accuracy indicator halo for a given style.
Declaration
Swift
public func setHaloColor(_ style: LocationIndicator.IndicatorStyle, color: UIColor)Parameters
styleThe type of IndicatorStyle for which the color should be assigned.
colorThe 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) -> UIColorParameters
styleThe 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.