【发布时间】:2021-06-16 01:16:10
【问题描述】:
我最近开始使用 OSMDroid,但我很难在 Android API 28 上的特定地理点获得默认标记。 我按照 OSMDroid 的 Github 上的教程编写了这样的代码:
//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 绘制了一个多边形,它似乎工作正常):
我在 Android API 22 设备上测试了相同的应用程序,并且标记工作正常,在缩放级别缩放时保持在正确的位置。
有什么方法可以修复或改进我的代码以使标记在 API 28 上工作?
【问题讨论】: