问题
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