Problem with crash with ItemizedOverlay

前端 未结 3 496
滥情空心
滥情空心 2020-12-14 06:23

I have been trying for hours to figure out why I can not use an Itemized Map overlay without doing this before adding it to the ovelays of the map:

GeoPoint po

3条回答
  •  别那么骄傲
    2020-12-14 06:37

    I recently came across this problem. The issue is outlined in this bug report.

    To fix it you should call populate() in your ItemizedOverlay before any data is populated. I added it to the constructor:

    private class MyItemizedOverlay extends ItemizedOverlay {
    
        private Context context;
        private ArrayList mOverlays = new ArrayList();
    
        LocationItemizedOverlay(Drawable defaultMarker, Context context) {
            super(boundCenterBottom(defaultMarker));
            this.context = context;
            populate(); // Add this
        }
    }
    

提交回复
热议问题