Android的自定义地图标记范围 [英] android custom map marker bounds

查看:243
本文介绍了Android的自定义地图标记范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我使用这个标记的调整版本( HTTP:// WWW .clker.com /剪贴画 - 橙 - 针4.html )用于显示Android上的谷歌地图标记。

Hello i am using a resized version of this marker( http://www.clker.com/clipart-orange-pin-4.html ) for showing markers in google maps on android.

问题是我不知道如何使标记点相匹配的坐标。
箭头点在高度的宽度坐标和MAX的1/5左右。

The problem is i don't know how to make the marker point match the coordinates. The arrow point is at about 1/5 of the Width coordinates and MAX of the Height.

这是我的班

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);

我是否需要在标记的setBounds将它传递给构造函数之前?为什么不超(defaultMarker)使所有的标记不显示?

Do i need to setBounds on the marker before passing it to the constructor? and why does super(defaultMarker) makes all the markers not to show ?

推荐答案

在previous答案是正确的,你需要用标志物的界限值的发挥。

The previous answer is right, you need to play with the BOUNDS value of your marker.

我确信你知道的边框确定对象的大小...你的地图上的标记是要自己制定出与左上角您在GPS标记坐标坐标如果你只是会叫一个正常在你的图像的大小的setBounds。

As I am sure you know the bounding rectangle determines the size of the object... The marker on your map is going to lay itself out with upper left coordinate of your marker at the GPS coordinate if you just would call a normal setbounds on the size of your image.

您需要做的是改变你的形象的界限,使图像的一部分,你wnat是在您要在地图上的位置。

What you need to do is modify the bounds on your image so that the part of the image you wnat is over the point on the map you want.

所以说,20×20,您的实际箭头提示,如果你的调整后的图像是(假设图像是箭头,你希望它在地图上的点一字排开完全一致)是说X = 4和Y = 10,你需要修改图像的边界相应地移动,你想要的形象。

So if your resized image is say 20 x 20, and your actual arrow tip (assuming the image is an arrow, and you want it lined up exactly with the point on the map) is at say X=4 and Y=10, you need to modify the bounds of your image accordingly to "move" the image where you want it.

由于0,0会把图像4像素的权利,和10个像素低于实际一点,你与它关联的地图上,你的界限不应该是0,0,X,Y而应该是-4, -10,图像-4的X规格,图像-10 Y规格(在这种情况下,exampe图像和图像的ysize的xsize都是20,但应该使用合适的值,你的情况。)

Since 0,0 would put the image 4 pixels to the right, and 10 pixels below the actual point on the map you associate it with, your bounds should not be 0,0,X,Y but should be -4,-10,X size of image-4,Y size of image-10 (in this exampe case the xsize of image and ysize of image are both 20, but should use the values appropriate for your case.)

这篇关于Android的自定义地图标记范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆