Change marker bounds for android google maps

…衆ロ難τιáo~ 提交于 2019-12-12 20:00:06

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/8433983/change-marker-bounds-for-android-google-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!