Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

My Location not updating #8307

Closed
en-archx opened this issue Mar 8, 2017 · 1 comment
Closed

My Location not updating #8307

en-archx opened this issue Mar 8, 2017 · 1 comment

Comments

@en-archx
Copy link

en-archx commented Mar 8, 2017

Platform: Android
Mapbox SDK version: Mapbox GL 5.0.0-SNAPSHOT

Just a simple mapbox application
map.setMyLocationEnabled(true); was set.

mapView lifecycle omitted

public class MainActivity extends AppCompatActivity implements OnMapReadyCallback {

private static final int PERMISSIONS_LOCATION = 9910;
private static final String TAG = MainActivity.class.getSimpleName();
private MapboxMap map;
private MapView mapView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Mapbox.getInstance(this, "TOKEN");

    setContentView(R.layout.activity_main);

    findViewById(R.id.go_to).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            map.getTrackingSettings()
                    .setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
        }
    });

    mapView = (MapView) findViewById(R.id.map_view);
    mapView.onCreate(savedInstanceState);
    mapView.getMapAsync(this);
}

@Override
public void onMapReady(MapboxMap mapboxMap) {
    map = mapboxMap;
    Log.d(TAG, "Map ready");
    checkPermissionAndEnableLocation();
}

private void checkPermissionAndEnableLocation() {
    if (!PermissionsManager.areLocationPermissionsGranted(this)) {
        ActivityCompat.requestPermissions(this, new String[]{
                Manifest.permission.ACCESS_COARSE_LOCATION,
                Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
    } else {
        enableLocation();
    }
}

private void enableLocation() {
    map.setMyLocationEnabled(true);
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    if (requestCode == PERMISSIONS_LOCATION) {
        if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
            enableLocation();
            Toast.makeText(this, "Location permission granted", Toast.LENGTH_LONG).show();
        }
    }
}
} 

Expected behavior

A blue dot should appear on the map, indicating user location.

Actual behavior

No blue dot appearance

I'm sceptical if #8255 is also talking about this, so to save time I'm still posting this.

@tobrun
Copy link
Member

tobrun commented Mar 8, 2017

Hey @novo-dimaporo, thank you for trying out the SNAPSHOT and reporting your issue. It's correct that #8255 will resolve the issue. Feel free to retest when that PR is merged!

@tobrun tobrun closed this as completed Mar 8, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants