问题
I want to change the marker in the MyLocationOverlay. What I've tried so far is subclassing OSMDroid's MyLocationOverlay and overriding the default marker, using code provided in this answer. However, it didn't work properly (I got the error: method drawMyLocation must override or implement a supertype method but commenting @Override
solved it).
However, the marker image stays the same (the question asked about Google Maps API, whereas I'm using OSMDroid) - how can I solve it?
回答1:
You have a few options here. First, let me suggest you use MyLocationNewOverlay in osmdroid. The original MyLocationOverlay has been deprecated. You then can
- Create your own ResourceProxy that provides your custom bitmap.person resource.
- Create a subclass and modify the mPersonBitmap and optionally the mPersonHotspot to make sure your custom image is aligned properly.
The method signature you are looking to override as per the linked answer is:
protected void drawMyLocation(final ISafeCanvas canvas, final MapView mapView, final Location lastFix)
来源:https://stackoverflow.com/questions/18615849/changing-osmdroids-mylocationoverlay-marker