Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android,定制项目化Overlay_Android_Google Maps_Itemizedoverlay_Overlayitem - Fatal编程技术网

android,定制项目化Overlay

android,定制项目化Overlay,android,google-maps,itemizedoverlay,overlayitem,Android,Google Maps,Itemizedoverlay,Overlayitem,已经有一个覆盖,在地图视图上绘制一些东西。我想在地图视图中添加另一个覆盖和自定义项。什么也看不出来。我的代码怎么了?谢谢你 我的ItemizedOverlay子类 public class PinItemizedOverlay extends ItemizedOverlay { private static int MAX_PIN = 3; private OverlayItem overlays[] = new OverlayItem[MAX_PIN]; private int index

已经有一个覆盖,在地图视图上绘制一些东西。我想在地图视图中添加另一个覆盖和自定义项。什么也看不出来。我的代码怎么了?谢谢你

我的ItemizedOverlay子类

public class PinItemizedOverlay extends ItemizedOverlay {
private static int MAX_PIN = 3;
private OverlayItem overlays[] = new OverlayItem[MAX_PIN];

private int index = 0;
private boolean full = false;
private Context context;

public PinItemizedOverlay(Context context, Drawable defaultMarker) {
    //super(boundCenterBottom(defaultMarker));
    super(boundCenterBottom(defaultMarker));
    this.context = context;
}

@Override
public OverlayItem createItem(int index) {
    return overlays[index];
}

public int size(){
    if (full) {
        return overlays.length;
    } else {
        return index;
    }
}

public void addOverlay(OverlayItem overlay) {
    if (index <     MAX_PIN) {
        overlays[index] = overlay;
    } else {
        return;
    }
    index++;
    populate();
}
}
以及我添加自定义项目(它是一个插针)的功能:


没关系,我想出来了:新添加的覆盖层阻挡了前一个覆盖层

 public class LocationPinItem extends OverlayItem{

    public LocationEntity location;

    public LocationPinItem(GeoPoint point, int iconRes, LocationEntity location){
        //super(point,null,null);
        super(point, null, null);
        Drawable marker = getApplicationContext().getResources().getDrawable(iconRes);
        super.setMarker(marker );
        this.location = location;

    }

}
private void createMarkerAt(LocationEntity location, String extra, int iconRes, boolean clear, boolean animate) {
    if(location == null) {
        return;
    }
    GeoPoint point = new GeoPoint((int) (location.latitude * 1E6), (int) (location.longitude * 1E6));

    LocationPinItem pinItem = new LocationPinItem(point,R.drawable.ic_swap,location);
    PinItemizedOverlay pinOverlay = new PinItemizedOverlay(getApplicationContext(),mMapDrawable) ;
    pinOverlay.addOverlay(pinItem);


mMapView.removeAllViews();
mMapView.postInvalidate();

    mMapView.getOverlays().add(pinOverlay);

    if(animate) {
        mMapView.getController().animateTo(location.toGeoPoint());
    }


}