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

标签 android mapbox drawable qemu mapbox-android

我正在尝试为 map 中用户的位置标记添加自定义图标。但图标显示为黑白。

enter image description here

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);

我尝试了 this question 中选择的答案,但没有成功。我尝试使用 jpg 而不是 png,仍然没有任何变化。

如果我在实际设备上运行它,它工作得很好。所以我猜问题出在模拟器上。

最佳答案

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

关于android - 在 map 框中添加自定义位置图标 - 图像显示为黑白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57742123/

相关文章:

java - Android匿名asyncTask方法中的返回值

android - Ionic cordova 构建 android 失败 - 由于某些路径错误

android - 从 2.0 SDK 定位到 Android 1.5 和 1.6

php - 从 MySql 在 php 中创建 GeoJson 以与 MapBox javascript API 一起使用

javascript - Mapbox GL JS : Animate several lines from geoJSON

android - 从 ImageView 获取可绘制对象

android - 离线创建cordova 5.x android gradle build

ios - Mapbox iOS : User location not showing after turning device location service on

Android:在运行时更改形状颜色

android - 如何在 Android 中动态合并两个 Drawable?