Problem with crash with ItemizedOverlay

前端 未结 3 485
滥情空心
滥情空心 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:32

    if you make important changes on your ItemizedOverlay you have every time to do

    1. delete_usrer_Marker_from_Overlays(myitemizedoverlay);
    2. create_user_Marker(myitemizedoverlay);
    3. mapView.getOverlays().add(myitemizedoverlay);

    with

    private void delete_usrer_Marker_from_Overlays(MyOverlays myio){
    
        List<Overlay> mapOverlays = mapView.getOverlays();
        if (mapOverlays != null) 
            {
              for (int i = 0;i< mapOverlays.size();i++)
              {
                  Overlay x = mapOverlays.get(i);
                  if (x.hashCode() == myio.hashCode())
                  {
                      mapOverlays.remove(x);
                  }                     
              }
            }       
        }
    
    0 讨论(0)
  • 2020-12-14 06:35

    The itemized overlay needs the 2nd 2 paramters because it uses them for click events. When you click one of the itemized overlays, it has a title and a description associated with it, which are the 2nd and 3rd parameters in your overlay item

    0 讨论(0)
  • 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<OverlayItem> {
    
        private Context context;
        private ArrayList<OverlayItem> mOverlays = new ArrayList<OverlayItem>();
    
        LocationItemizedOverlay(Drawable defaultMarker, Context context) {
            super(boundCenterBottom(defaultMarker));
            this.context = context;
            populate(); // Add this
        }
    }
    
    0 讨论(0)
提交回复
热议问题