@Override
 public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
   if (tileBox.getZoom() >= startZoom) {
     DataTileManager<Recording> recs = plugin.getRecordings();
     final QuadRect latlon = tileBox.getLatLonBounds();
     List<Recording> objects =
         recs.getObjects(latlon.top, latlon.left, latlon.bottom, latlon.right);
     for (Recording o : objects) {
       int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
       int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
       Bitmap b;
       if (o.isPhoto()) {
         b = photo;
       } else if (o.isAudio()) {
         b = audio;
       } else {
         b = video;
       }
       canvas.drawBitmap(b, x - b.getWidth() / 2, y - b.getHeight() / 2, paintIcon);
     }
   }
 }
Exemple #2
0
  @Override
  public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    if (tileBox.getZoom() >= startZoom) {
      // request to load
      final QuadRect latLonBounds = tileBox.getLatLonBounds();
      for (FavouritePoint o : favorites.getFavouritePoints()) {

        if (o.getLatitude() >= latLonBounds.bottom
            && o.getLatitude() <= latLonBounds.top
            && o.getLongitude() >= latLonBounds.left
            && o.getLongitude() <= latLonBounds.right) {
          int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
          int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
          FavoriteImageDrawable fid =
              FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor());
          fid.drawBitmapInCenter(canvas, x, y);
          //					canvas.drawBitmap(favoriteIcon, x - favoriteIcon.getWidth() / 2,
          //							y - favoriteIcon.getHeight(), paint);
        }
      }
    }
  }
  public void openDialog() {
    BaseMapLayer mainLayer = mapView.getMainLayer();
    if (!(mainLayer instanceof MapTileLayer) || !((MapTileLayer) mainLayer).isVisible()) {
      AccessibleToast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT)
          .show();
    }
    final ITileSource mapSource = ((MapTileLayer) mainLayer).getMap();
    if (mapSource == null || !mapSource.couldBeDownloadedFromInternet()) {
      AccessibleToast.makeText(ctx, R.string.maps_could_not_be_downloaded, Toast.LENGTH_SHORT)
          .show();
      return;
    }
    final RotatedTileBox rb = mapView.getCurrentRotatedTileBox();
    final int max = mapSource.getMaximumZoomSupported();
    // get narrow zoom
    final int zoom = rb.getZoom();

    // calculate pixel rectangle
    AlertDialog.Builder builder = new AlertDialog.Builder(ctx);
    LayoutInflater inflater =
        (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.download_tiles, null);

    ((TextView) view.findViewById(R.id.MinZoom)).setText(zoom + ""); // $NON-NLS-1$
    ((TextView) view.findViewById(R.id.MaxZoom)).setText(max + ""); // $NON-NLS-1$
    final SeekBar seekBar = (SeekBar) view.findViewById(R.id.ZoomToDownload);
    seekBar.setMax(max - zoom);
    seekBar.setProgress((max - zoom) / 2);

    final TextView downloadText = ((TextView) view.findViewById(R.id.DownloadDescription));
    final String template = ctx.getString(R.string.tiles_to_download_estimated_size);

    updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, seekBar.getProgress());
    seekBar.setOnSeekBarChangeListener(
        new SeekBar.OnSeekBarChangeListener() {

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            updateLabel(zoom, rb.getLatLonBounds(), downloadText, template, progress);
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {}
        });

    builder.setPositiveButton(
        R.string.shared_string_download,
        new DialogInterface.OnClickListener() {
          @Override
          public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
            run(zoom, seekBar.getProgress(), rb.getLatLonBounds(), mapSource);
          }
        });
    builder.setNegativeButton(R.string.shared_string_cancel, null);
    builder.setView(view);
    builder.show();
  }