Issue
I am using Osmdroid for the map in an activity, but I cannot change the default icon of a yellow person. Currently what I am trying, but nothing is shown on the map.
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_truck);
mLocationOverlay.setPersonIcon(bitmap);
map.getOverlays().add(mLocationOverlay);
in console this comes out.
E/OsmDroid: error dispatchDraw, probably in edit mode
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference
at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:54)
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:226)
at android.view.RecordingCanvas.drawBitmap(RecordingCanvas.java:78)
Solution
See if you missed some context on your code:
map.getOverlays().add(mLocationOverlay);
Here is an example:
//My Location
//note you have handle the permissions yourself, the overlay did not do it for you
mLocationOverlay = new MyLocationNewOverlay(new GpsMyLocationProvider(context), mMapView);
mLocationOverlay.enableMyLocation();
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_menu_compass);
mLocationOverlay.setPersonIcon(bitmap);
mMapView.getOverlays().add(this.mLocationOverlay);
Where
private MyLocationNewOverlay mLocationOverlay;
Answered By - Feria
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.