I'm trying to add a custom icon for the user's location marker in the map. But the icon shows up as black and white.
LocationComponentOptions customLocationComponentOptions = LocationComponentOptions.builder(this)
.foregroundDrawable(R.drawable.android)
.build();
// Get an instance of the component
LocationComponent locationComponent = mapboxMap.getLocationComponent();
// Activate with options
locationComponent.activateLocationComponent(
LocationComponentActivationOptions.builder(this, loadedMapStyle)
.locationComponentOptions(customLocationComponentOptions)
.build());
// Enable to make component visible
locationComponent.setLocationComponentEnabled(true);
// Set the component's camera mode
locationComponent.setCameraMode(CameraMode.TRACKING);
// Set the component's render mode
locationComponent.setRenderMode(RenderMode.COMPASS);
I tried the chosen answer in this question, but it didn't work. I tried using a jpg instead of a png, and again nothing changed.
If I run it on an actual device, it works fine. So I guess the issue is with the emulator.
Correct, this is an issue with an emulator only. Check out this workaround - https://github.com/mapbox/mapbox-gl-native/issues/10829#issuecomment-441021598.