com.mapbox.mapboxsdk.location.LocationComponent Java Examples

The following examples show how to use com.mapbox.mapboxsdk.location.LocationComponent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AirMapMapView.java    From AirMapSDK-Android with Apache License 2.0 6 votes vote down vote up
@Override
public void onDidFinishLoadingStyle() {
    // add my location w/ permission check
    LocationComponent locationComponent = map.getLocationComponent();
    if (ActivityCompat.checkSelfPermission(getContext(), Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        ActivityCompat.requestPermissions((Activity) getContext(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, MyLocationMapActivity.REQUEST_LOCATION_PERMISSION);
        return;
    }
    LocationComponentOptions options = LocationComponentOptions.builder(getContext())
            .elevation(2f)
            .accuracyAlpha(0f)
            .enableStaleState(false)
            .build();

    locationComponent.activateLocationComponent(getContext(), map.getStyle(), options);
    locationComponent.setLocationComponentEnabled(true);
}
 
Example #2
Source File: MapDataManager.java    From deltachat-android with GNU General Public License v3.0 6 votes vote down vote up
public MapDataManager(Context context, @NonNull Style mapboxMapStyle, LocationComponent locationComponent, int chatId, MapDataState updateCallback) {
    Log.d(TAG, "performance test - create map manager");
    this.mapboxStyle = mapboxMapStyle;
    this.context = context;
    this.dcContext = DcHelper.getContext(context);
    this.chatId = chatId;
    boundingBuilder = new LatLngBounds.Builder();
    this.callback = updateCallback;
    this.locationComponent = locationComponent;

    initInfoWindowLayer();
    initLastPositionLayer();
    initLocationComponent();

    filterProvider.setMessageFilter(true);
    filterProvider.setLastPositionFilter(System.currentTimeMillis() - DEFAULT_LAST_POSITION_DELTA);
    applyLastPositionFilter();

    updateSources();
    dcContext.eventCenter.addObserver(DC_EVENT_LOCATION_CHANGED, this);

    Log.d(TAG, "performance test - create map manager finished");
}
 
Example #3
Source File: PlacePickerActivity.java    From mapbox-plugins-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings( {"MissingPermission"})
private void enableLocationComponent(@NonNull Style loadedMapStyle) {
  // Check if permissions are enabled and if not request
  if (PermissionsManager.areLocationPermissionsGranted(this)) {

    // Get an instance of the component
    LocationComponent locationComponent = mapboxMap.getLocationComponent();

    // Activate with options
    locationComponent.activateLocationComponent(
      LocationComponentActivationOptions.builder(this, loadedMapStyle).build());

    // Enable to make component visible
    locationComponent.setLocationComponentEnabled(true);

    // Set the component's camera mode
    locationComponent.setCameraMode(CameraMode.NONE);

    // Set the component's render mode
    locationComponent.setRenderMode(RenderMode.NORMAL);

    addUserLocationButton();
  } else {
    permissionsManager = new PermissionsManager(this);
    permissionsManager.requestLocationPermissions(this);
  }
}