我在google map android中使用了5个标记,并且每5秒标记位置也会随着动画而变化。在这种情况下,我想根据缩放级别动态调整图标的大小。
答案 0 :(得分:2)
只需尝试下面的代码片段,它就会被我使用。此方法将返回适合您的缩放级别,预期的高度和宽度的图像。
public T Do<T>(Func<X, T> something)
{
try
{
var manager = CoreInfrastructure.GetManager(Prefix, Config.Param1, Config.Param2); //******
if (manager != null) return something(manager);
LoggingHandler.LogWarning(LogTitle, $"manager ({this}) is null.");
}
catch (MyException exp)
{
ExceptionHandler.HandleRecoverableException(exp, LogTitle,
$"query on manager ({this}) failed.");
}
var msg = $"failed to query using manager ({this})!";
LoggingHandler.LogCritical(LogTitle, msg);
throw new MyException(msg);
}
public T Do<T>(Func<Y, T> something)
{
try
{
var manager = CoreInfrastructure.GetManager(Prefix, Config.Param3); //******
if (manager != null) return something(manager);
LoggingHandler.LogWarning(LogTitle, $"manager ({this}) is null.");
}
catch (MyException exp)
{
ExceptionHandler.HandleRecoverableException(exp, LogTitle,
$"query on manager ({this}) failed.");
}
var msg = $"failed to query using manager ({this})!";
LoggingHandler.LogCritical(LogTitle, msg);
throw new MyException(msg);
}
答案 1 :(得分:0)
您可以通过创建具有自定义高度的位图来实现
Configuration.assertionMode = AssertionMode.SOFT;
然后将此位图添加到地图上。
int height = 100;// resize according to your zooming level
int width = 100;// resize according to your zooming level
BitmapDrawable bitmapdraw = (BitmapDrawable)getResources().getDrawable(R.mipmap.marker);
Bitmap b=bitmapdraw.getBitmap();
Bitmap finalMarker= Bitmap.createScaledBitmap(b, width, height, false);
希望这行得通!