在 mapbox 中添加自定义位置图标 - 图像显示为黑白

Adding custom location icon in mapbox - Image appears 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);

我尝试了 中选择的答案,但没有成功。我尝试使用 jpg 而不是 png,但同样没有任何改变。

如果我 运行 它在实际设备上,它工作正常。所以我想问题出在模拟器上。

正确,这只是模拟器的问题。查看此解决方法 - https://github.com/mapbox/mapbox-gl-native/issues/10829#issuecomment-441021598.