更改android google地图的标记边界 [英] Change marker bounds for android google maps

查看:93
本文介绍了更改android google地图的标记边界的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个自定义覆盖,它扩展了itemizedoverlay,以便在地图上放置一个标记。我的问题是,我想调整标记,以便绘制的边界与boundCenterBottm和boundCenter值不同(在我的情况下,如果存在,我想要有类似boundLeftBottom的东西)。我如何实现这一目标?我想达到这个目的的原因是因为我有一个可绘制的点,它指向左下角。



我在网上搜索过干,任何帮助都非常感谢。



建议使左侧的透明空间不被接受。我认为这是一种不正当的解决方法



编辑;



我最终得到这个结果:

  public class CustomOverlay扩展了ItemizedOverlay< CustomOverlayItem> {
private ArrayList< CustomOverlayItem> mOverlays = new ArrayList< CustomOverlayItem>();
private Context mContext;

public CustomOverlay(可绘制的defaultMarker,上下文上下文){
// super(boundCenterBottom(defaultMarker));
super(defaultMarker);
defaultMarker.setBounds(0,-defaultMarker.getIntrinsicHeight(),defaultMarker.getIntrinsicWidth(),0); // TODO实验
mContext = context;





这是正确的,但它没有解决我的问题,因为grafic没有在角落里完美,并有3个不同的drawables,这将是一个痛苦的解决(所以最终的解决办法是,我要修复drawable)。 方法

boundCenterBottom和boundCenter是辅助函数,它调用drawable上的setBounds ...您可以自己调用它。



对于左下角,I认为它看起来像这样:



pre $ drawable.setBounds(0,-drawable.getIntrinsicHeight(),drawable.getIntrinsicWidth() ,0);

但那只是我的头顶。


So I have a customoverlay which extend itemizedoverlay in order to place a marker on the map. My problem is that I'd like to adjust the marker so the drawable's bounds are different from the boundCenterBottm and boundCenter values (in my case I'd like to have something like boundLeftBottom if it existed). How do I achieve this? The reason I want to achieve this is because I have a drawable which points down to the left bottom corner.

I've searched the web dry, any help is greatly appreciated.

Suggesting making even transparent space to the left side will not be accepted. I consider this an improper workaround

Edit;

I ended up with this:

public class CustomOverlay extends ItemizedOverlay<CustomOverlayItem> {
    private ArrayList<CustomOverlayItem> mOverlays = new ArrayList<CustomOverlayItem>();
    private Context mContext;

    public CustomOverlay(Drawable defaultMarker, Context context) {
//      super(boundCenterBottom(defaultMarker));
        super(defaultMarker);
        defaultMarker.setBounds(0, -defaultMarker.getIntrinsicHeight(), defaultMarker.getIntrinsicWidth(), 0);  //TODO experiment
        mContext = context;
    }

This is correct though it didn't fix my problem due to the grafic not being perfect in the corner and with 3 different drawables that would be a pain to fix (so final solution is that I'm going to fix the drawable).

解决方案

boundCenterBottom and boundCenter are helper functions that call setBounds on the drawable... You can just call that yourself.

For bottom left, I think it will look something like this:

drawable.setBounds(0, -drawable.getIntrinsicHeight(), drawable.getIntrinsicWidth(), 0);

But that was just off the top of my head.

这篇关于更改android google地图的标记边界的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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