OSM - Show current location with custom icon

杀马特。学长 韩版系。学妹 提交于 2019-12-08 04:37:37

问题


Can anyone tell me how can I show my current location on OSM map with custom icon?


回答1:


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'


来源:https://stackoverflow.com/questions/47093133/osm-show-current-location-with-custom-icon

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