Skip to content

Showing the User's Location

MapLayr includes a LocationMarker class which can be added to the MapView to display the user's location.

Add the positionlayr-google Dependency

The LocationMarker class takes a LocationProvider parameter, which is provided by the positionlayr-google library. In your module build.gradle file add the following dependency:

implementation "io.attractions:positionlayr-google:0.0.86"

An example can be found here: app/build.gradle

Add a Location Marker

Then construct a LocationMarker instance using either GoogleLocationId.HighAccuracy, GoogleLocationId.Balanced or GoogleLocationId.Passive and add it to the map view. The position of the location marker will then automatically update with the user's location provided by Google location services.

val locationMarker = LocationMarker(GoogleLocationId.HighAccuracy)

mapView.addLocationMarker(locationMarker)

Location Permission

The MapLayr SDK does not handle location permissions so these must be implemented by the consuming application.

An example can be found here: ExtendedSampleActivity.kt

User Location Marker