docs: private void generateMap() {
  
          if (getActivity()==null)  //java.lang.IllegalStateException: Fragment HeatMap{44f341d0} not attached to Activity
              return;
          if (renderJobActive)
              return;
          renderJobActive = true;
  
  
  
          int densityDpi = (int) (dm.density * cellSizeInDp);
          //10 dpi sized cells
  
          IGeoPoint iGeoPoint = mMapView.getProjection().fromPixels(0, 0);
          IGeoPoint iGeoPoint2 = mMapView.getProjection().fromPixels(densityDpi, densityDpi);
          //delta is the size of our cell in lat,lon
          //since this is zoom dependent, rerun the calculations on zoom changes
          double xCellSizeLongitude = Math.abs(iGeoPoint.getLongitude() - iGeoPoint2.getLongitude());
          double yCellSizeLatitude = Math.abs(iGeoPoint.getLatitude() - iGeoPoint2.getLatitude());
  
          BoundingBox view = mMapView.getBoundingBox();
          //a set of a GeoPoints representing what we want a heat map of.
          List<IGeoPoint> pts = loadPoints(view);
  
          //the highest value in our collection of stuff
          int maxHeat = 0;
          //a temp container of all grid cells and their hit count (which turns into a color on render)
  
          //the lower the cell size the more cells and items in the map.
          Map<BoundingBox, Integer> heatmap = new HashMap<BoundingBox, Integer>();
          //create the grid
  
          Log.i(TAG, "heatmap builder " + yCellSizeLatitude + " " + xCellSizeLongitude);
          Log.i(TAG, "heatmap builder " + view);
  
          //populate the cells
          for (double lat = view.getLatNorth(); lat >= view.getLatSouth(); lat = lat - yCellSizeLatitude) {
              for (double lon = view.getLonEast(); lon >= view.getLonWest(); lon = lon - xCellSizeLongitude) {
                  //Log.i(TAG,"heatmap builder " + lat + "," + lon);
                  heatmap.put(new BoundingBox(lat, lon, lat - yCellSizeLatitude, lon - xCellSizeLongitude), 0);
              }
          }
  
  
          Log.i(TAG, "generating the heatmap");
          long now = System.currentTimeMillis();
  
          //generate the map, put the items in each cell
          for (int i = 0; i < pts.size(); i++) {
              //get the box for this pt's coordinates
              int x = increment(pts.get(i), heatmap);
              if (x > maxHeat)
                  maxHeat = x;
  
          }
          Log.i(TAG, "generating the heatmap, done " + (System.currentTimeMillis() - now));
  
          //figure out the color scheme
          //if you need a more logirthmic scale, this is the place to do it.
          //cells with a 0 value are blank
          //cells 1 to 1/3 of the max value are yellow
          //cells from 1/3 to 2/3 are organge
          //cells 2/3 or higher are red
          int redthreshold = maxHeat * 2 / 3; //upper 1/3
          int orangethreshold = maxHeat * 1 / 3; //middle 1/3
  
          //render the map
          Log.i(TAG, "rendering");
          now = System.currentTimeMillis();
          //each bounding box if the hit count > 0 create a polygon with the bounding box coordinates with the right fill color
          final FolderOverlay group = new FolderOverlay();
          Iterator<Map.Entry<BoundingBox, Integer>> iterator = heatmap.entrySet().iterator();
          while (iterator.hasNext()) {
              Map.Entry<BoundingBox, Integer> next = iterator.next();
              if (next.getValue() > 0) {
                  group.add(createPolygon(next.getKey(), next.getValue(), redthreshold, orangethreshold));
              }
          }
          Log.i(TAG, "render done , done " + (System.currentTimeMillis() - now));
          if (getActivity()==null)    //java.lang.IllegalStateException: Fragment HeatMap{44f341d0} not attached to Activity
              return;
          if (mMapView==null)  //java.lang.IllegalStateException: Fragment HeatMap{44f341d0} not attached to Activity
              return;
          mMapView.post(new Runnable() {
              @Override
              public void run() {
                  if (heatmapOverlay != null)
                      mMapView.getOverlayManager().remove(heatmapOverlay);
                  mMapView.getOverlayManager().add(group);
                  heatmapOverlay = group;
  
                  mMapView.invalidate();
                  renderJobActive = false;
              }
          });
      }