谁能告诉我如何使用自定义图标在OSM地图上显示我的当前位置?

最佳答案

使用默认人物图标::

MyLocationNewOverlay myLocationoverlay = new MyLocationNewOverlay(mapView);
myLocationoverlay.enableFollowLocation();
myLocationoverlay.enableMyLocation();
mapView.getOverlays().add(myLocationoverlay);


带有自定义图标::

MyLocationNewOverlay myLocationoverlay = new MyLocationNewOverlay(mapView);
myLocationoverlay.enableFollowLocation();
 Drawable currentDraw = ResourcesCompat.getDrawable(getResources(), R.mipmap.ic_launcher, null);
            Bitmap currentIcon = null;
            if (currentDraw != null) {
                currentIcon = ((BitmapDrawable) currentDraw).getBitmap();
            }
myLocationoverlay.enableMyLocation();
mapView.getOverlays().add(myLocationoverlay);


我正在使用更新的OSM依赖项

compile 'org.osmdroid:osmdroid-android:5.6.5'

09-30 23:31