gpt4 book ai didi

android - 不理解 com.google.android.maps.Overlay 的 drawAt() 方法

转载 作者:太空宇宙 更新时间:2023-11-03 12:43:30 25 4
gpt4 key购买 nike

尝试在 Android 程序中制作谷歌地图叠加层。在叠加层的绘制方法中,我有两种添加图钉的方法。其中一种有效,另一种无效。可惜,不起作用的也是唯一有加影能力的!有什么帮助吗?

@Override
public void draw(android.graphics.Canvas canvas, MapView mapView,
boolean shadow) {

Point po = mapView.getProjection().toPixels(mapView.getMapCenter(),
null);

// This does _not_ work, but I would really like it to!
drawAt(canvas, mapView.getResources().getDrawable(R.drawable.map_marker_v),
po.x, po.y, false);

// This does work, but only does half the job
canvas.drawBitmap(BitmapFactory.decodeResource(mapView.getResources(),
R.drawable.map_marker_v), po.x, po.y, null);


}

编辑:固定类型

最佳答案

我认为您的问题可能仅仅是因为您没有在drawAt() 中为drawable 设置边界。您可以使用 Drawable.setBounds() 手动设置边界,或者您可以使用 ItemizedOverlay 的便捷方法 boundCenter()boundCenterBottom() .

我认为第二种方法之所以有效,是因为使用解码后的位图,您不必指定 Drawable 的边界。

关于android - 不理解 com.google.android.maps.Overlay 的 drawAt() 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2095751/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com