gpt4 book ai didi

android自定义 map 标记边界

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

您好,我正在使用此标记的调整大小版本(http://www.clker.com/clipart-orange-pin-4.html)在 Android 上的谷歌地图中显示标记。

问题是我不知道如何使标记点与坐标匹配。箭头点位于 Width 坐标的 1/5 和 Height 的 MAX 处。

这是我的类(class)

public class GestionaleItemizedOverlay extends com.google.android.maps.ItemizedOverlay {

public GestionaleItemizedOverlay(Drawable defaultMarker, Context context) {
//super(boundCenterBottom(defaultMarker));
super(boundCenter(defaultMarker));
this.mContext = context;
}
...

还有这个

    this.marker_poi = this.getContext().getResources().getDrawable(R.drawable.marker);
this.marker_poi.setBounds(this.marker_poi.getIntrinsicWidth() / 2, this.marker_poi.getIntrinsicHeight(), this.marker_poi.getIntrinsicWidth() / 2, 0);
new GestionaleItemizedOverlay(this.poi, this.context);

在将标记传递给构造函数之前,我需要在标记上设置边界吗?以及为什么 super(defaultMarker) 使所有标记都不显示?

最佳答案

前面的答案是正确的,你需要玩你的标记的 BOUNDS 值。

我相信您知道边界矩形决定了对象的大小...您 map 上的标记将根据 GPS 坐标中标记的左上角坐标自行布局设置图像大小的界限。

您需要做的是修改图像的边界,使您想要的图像部分位于 map 上您想要的点之上。

因此,如果您调整大小的图像是 20 x 20,并且您的实际箭头尖端(假设图像是一个箭头,并且您希望它与 map 上的点完全对齐)在 X=4 和 Y= 10,您需要相应地修改图像的边界,以将图像“移动”到您想要的位置。

由于 0,0 会将图像向右放置 4 个像素,并在 map 上与其关联的实际点下方 10 个像素,因此您的边界不应为 0,0,X,Y,而应为 -4, -10,X size of image-4,Y size of image-10(在本例中,图像的 x 尺寸和图像的 ys 尺寸均为 20,但应使用适合您的情况的值。)

关于android自定义 map 标记边界,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9975553/

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