1

我使用HelloItemizedOverlayGoogle 的代码创建和覆盖项目,它可以工作,但现在我需要使图像半透明并更改边界,我不知道它是如何工作的。

我找到了该方法getOpacity(),但我不知道如何在我的ItemizedOverlay班级或班级中实现它Map。我也知道getIntrinsicHeight()getIntrinsicWidth()方法,但像getOpacity()我不知道如何正确使用它。我用于我的代码ItemizedOverlay是:

import java.util.ArrayList;

import android.app.AlertDialog;
import android.content.Context;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;

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

public class ContourItemizedOverlay extends ItemizedOverlay {

    Context mContext;

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

public ContourItemizedOverlay(Drawable defaultMarker, Context context) {
    super(boundCenter(defaultMarker));
    mContext = context;
    // TODO Auto-generated constructor stub
}

public int getOpacity()
{
    return PixelFormat.TRANSPARENT;
}

@Override
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 addOverlay(OverlayItem overlay) {
    mOverlays.add(overlay);
    populate();
}

@Override
protected OverlayItem createItem(int i) {
    // TODO Auto-generated method stub
    return mOverlays.get(i);
}

@Override
public int size() {
    // TODO Auto-generated method stub
    return mOverlays.size();
} 

}
4

0 回答 0