mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Ability to remove LocationPuck

Open okcoker opened this issue 2 years ago • 3 comments

New Feature

I would like the ability to remove the LocationPuck entirely

SDK v10.12.2

Why

In my app I render a custom puck icon. I noticed in order to achieve this, I started to do the following:

locationComponentPlugin.updateSettings {
    this.enabled = true
    this.locationPuck = LocationPuck2D()
}

But this still leaves a memory footprint under the hood which I was not happy with. I then starting doing:

map.getStyle()?.removeStyleLayer("mapbox-location-indicator-layer")

This feels better but now I'm left with a littered console of warning messages:

[maps-android\MapboxLocationLayerWrapper]: Skip updating layer property location, layer mapbox-location-indicator-layer not ready yet.
[maps-android\MapboxLocationLayerWrapper]: Skip updating layer property bearing, layer mapbox-location-indicator-layer not ready yet.
[maps-android\MapboxLocationLayerWrapper]: Skip updating layer property accuracy-radius, layer mapbox-location-indicator-layer not ready yet.

This feels like a gap in functionality to me, especially since iOS allows you to do:

mapView.location.options.puckType = .none

okcoker avatar Jul 13 '23 19:07 okcoker

hey @okcoker - if you don't need to see the the puck, why not disable location component? it actually represents the puck + customisations related to puck:

locationComponentPlugin.updateSettings {
    this.enabled = false
}

kiryldz avatar Jul 14 '23 07:07 kiryldz

I still want the user location updates and locationComponentPlugin.addOnIndicatorPositionChangedListener(onIndicatorPositionChangedListener) doesn't fire when enabled = false

When my app loads, I use that listener to center the map where the user is

okcoker avatar Jul 14 '23 16:07 okcoker

When my app loads, I use that listener to center the map where the user is

You could separately subscribe to location provider and move map as you wish.

dryaz avatar Sep 12 '23 23:09 dryaz