It is possible to remove the Shadow of the Icons (items) on a googlemap?

纵然是瞬间 提交于 2019-11-30 09:02:33

问题


I have a Google map with these kind of items on it:

drawable3 = this.getResources().getDrawable(R.drawable.trazeicon);

but automatically, Android draws a shadow of the image trazeicon on the map, and I don't want to have that shadow.

How can I remove it?

EDIT:

I got the error: Syntax error, insert "}" to complete ClassBody

Here is the full code:

package com.GPSLoc;

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

public class MyItemizedOverlay extends ItemizedOverlay {


    private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
    private Context mContext;

    public MyItemizedOverlay(Drawable defaultMarker) {
        super(boundCenterBottom(defaultMarker));
    }

    protected OverlayItem createItem(int i) {
      return mOverlays.get(i);
    }

    public int size() {
      return mOverlays.size();
    }

    public void addOverlay(OverlayItem overlay) {
        mOverlays.add(overlay);
        populate();
    }

    public MyItemizedOverlay(Drawable defaultMarker, Context context) {
          //super(defaultMarker);
          super(boundCenterBottom(defaultMarker));
          mContext = context;
    }
    public void clear()
    {
        mOverlays.clear();
    }

    protected boolean onTap(int index) {
      OverlayItem item = mOverlays.get(index);
      AlertDialog.Builder dialog = new AlertDialog.Builder(mContext);
      dialog.setTitle(item.getTitle());
      dialog.setMessage(item.getSnippet());
      dialog.show();
      return true;
    }

    public void draw(Canvas canvas, MapView mapView, boolean shadow)
    {
        if(!shadow)
        {
            super.draw(canvas, mapView, false);
        }
    }
}

回答1:


You need to override the draw() method when you extend ItemizedOverlay. Like this:

public class MyItemizedOverlay extends ItemizedOverlay {
    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow) {
        if(!shadow) {
            super.draw(canvas, mapView, false);
        }
    }
    ....
}


来源:https://stackoverflow.com/questions/4327733/it-is-possible-to-remove-the-shadow-of-the-icons-items-on-a-googlemap

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