I have an application, which uses a custom implementation of MyLocationOverlay.
In the implementation I set a Bitmap property that is used when it has been specified, by an overload of Draw.
It works nicely, using my custom image, but it doesn't display a shadow - as is done automatically in an ItemizedOverlay.
Can anyone help?
Here is (the relevant code from) my class:
public class LocationOverlay: MyLocationOverlay
{
/// <summary>Bitmap to use for indicating the current fixed location.</summary>
public Bitmap LocationMarker { get; set; }
/// <summary>Uses the custom marker bitmap if one has been specified. Otherwise, the default is used.</summary>
/// <param name="canvas"></param>
/// <param name="mapView"></param>
/// <param name="shadow"></param>
/// <param name="when"></param>
/// <returns></returns>
public override bool Draw(Canvas canvas, MapView mapView, bool shadow, long when)
{
var drawShadow = shadow;
if (LocationMarker != null && LastFix != null)
{
var screenPoint = new Point();
var geoPoint = new GeoPoint((int)(LastFix.Latitude * 1E6), (int)(LastFix.Longitude * 1E6));
mapView.Projection.ToPixels(geoPoint, screenPoint);
canvas.DrawBitmap(LocationMarker, screenPoint.X, screenPoint.Y - 32, null);
drawShadow = true;
}
base.Draw(canvas, mapView, drawShadow);
return true;
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…