gpt4 book ai didi

android - 在谷歌地图上添加多个覆盖项目

转载 作者:行者123 更新时间:2023-11-29 22:29:18 26 4
gpt4 key购买 nike

我想使用 overlayitem 类在谷歌地图上的多个位置标记图钉图像..或者简单的如何在 map 上添加多个叠加项..

到目前为止,我只能通过覆盖 mapoverlay 子类的 draw 方法来标记一个地方...这是我的代码

class MapOverlay extends com.google.android.maps.Overlay
{
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow, long when)
{
super.draw(canvas, mapView, shadow);

//---translate the GeoPoint to screen pixels---
Point screenPts = new Point();
mapView.getProjection().toPixels(p, screenPts);

//---add the marker---
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.pushpin);
canvas.drawBitmap(bmp, screenPts.x, screenPts.y-24, null);

return true;
}
}

最佳答案

您可以在 draw() 方法中绘制任意多的东西,因此只需遍历循环中的所有点并一个一个地绘制它们。

关于android - 在谷歌地图上添加多个覆盖项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4815568/

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