OSMDroid - 在 Android API 28 上缩小时移动的默认标记 [英] OSMDroid - Default marker moving when zooming out on Android API 28

查看:42
本文介绍了OSMDroid - 在 Android API 28 上缩小时移动的默认标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始使用 OSMDroid,但我很难在 Android API 28 上的特定地理点处获得默认标记.我按照 OSMDroid 的 Github 上的教程编写了如下代码:

I recently started to use OSMDroid, but I struggle to get a default marker at a specific Geopoint on Android API 28. I followed the tutorial from the OSMDroid's Github and wrote a code like this:

    //Making a Mapbox TileSource
    MapBoxTileSource mbTest = new MapBoxTileSource("mapbox.streets", ACCESS_TOKEN);
    map = (MapView) findViewById(R.id.map);
    map.setTileSource(mbTest);

    //Setting up map
    map.setVisibility(View.VISIBLE);
    map.setMultiTouchControls(true);
    map.getController().setCenter(new GeoPoint(latitude,longitude));
    map.getController().setZoom(14d);

    //Create a marker where the user is
    Marker positionMarker = new Marker(map);
    positionMarker.setDefaultIcon();
    positionMarker.setPosition(new GeoPoint(latitude, longitude));
    map.getOverlays().add(positionMarker);

当我测试我的应用程序时,我得到以下结果(我使用 OSMDroid 绘制了一个多边形,它似乎工作正常):

And I have the following result when i test my app (i draw a polygon using OSMDroid and it seems to work fine):

我在 Android API 22 设备上测试了同一个应用,并且标记工作正常,在缩放级别的同时保持并保持在正确的位置.

I tested the same app on an Android API 22 device and the marker worked fine, being and staying at the right location while scaling with the zoom level.

有什么方法可以修复或改进我的代码以使标记在 API 28 上工作?

Is there any way to fix or improve my code to make the marker work on API 28 ?

推荐答案

我阅读了一些关于 OSMDroid 的文档,似乎硬件加速并不总是稳定的.我试图停用它,它起作用了.

I read some documentation about OSMDroid, and it seems that hardware acceleration is not always stable with it. I tried to deactivate it and it worked.

因此,如果您的标记似乎不在正确的位置并且在您放大或缩小时移动,只需在 Android Manifest 中停用此活动的硬件加速:

So if your marker seems to not be at the right location and moving when you zoom in or out, just deactivate hardware acceleration for this activity in the Android Manifest:

<activity
    android:name=".MapActivity"
    android:hardwareAccelerated="false"/>

我与 OSMDroid 进一步合作,当我为标记使用自定义图标时不会出现此问题,因此对于您的应用而言,这不是一个大问题.

I've worked further with OSMDroid and this issue does not occur when I use custom icons for my markers, so it shouldn't be a big concern for your apps.

这篇关于OSMDroid - 在 Android API 28 上缩小时移动的默认标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆