OSM - Show current location with custom icon

微笑、不失礼 提交于 2019-12-08 14:29:42

With default person icon ::

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

With custom icon ::

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

I am using updated OSM dependency

compile 'org.osmdroid:osmdroid-android:5.6.5'
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!