Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Deprecate MarkerView / Introduce IconGenerator #9365

Closed
tobrun opened this issue Jun 26, 2017 · 1 comment
Closed

Deprecate MarkerView / Introduce IconGenerator #9365

tobrun opened this issue Jun 26, 2017 · 1 comment
Labels
Android Mapbox Maps SDK for Android

Comments

@tobrun
Copy link
Member

tobrun commented Jun 26, 2017

MarkerView

The concept of MarkerView relies on synchronising Android SDK views on top of the GL surface. At time of implementing, we were using TextureView as rendering surface but since a couple of releases, we migrated to SurfaceView for improved GL rendering performance. This introduced degraded view synchronisation for our MarkerView implementation (a.k.a MarkerView jiggling).

Besides degraded performance, MarkerViews rely on estimating the map transformation matrix, this estimation will not match the actual transformation 100%.

IconGenerator

Instead of synchronising Android SDK views on top of the GL Surface. We should look into rendering views to bitmaps instead and fallback on the base Marker Icon implementation (SymbolAnnotation in core). Code for generating a Bitmap look like this:

    public Bitmap makeIcon() {
        int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
        mContainer.measure(measureSpec, measureSpec);

        int measuredWidth = mContainer.getMeasuredWidth();
        int measuredHeight = mContainer.getMeasuredHeight();

        mContainer.layout(0, 0, measuredWidth, measuredHeight);

        if (mRotation == 1 || mRotation == 3) {
            measuredHeight = mContainer.getMeasuredWidth();
            measuredWidth = mContainer.getMeasuredHeight();
        }

        Bitmap r = Bitmap.createBitmap(measuredWidth, measuredHeight, Bitmap.Config.ARGB_8888);
        r.eraseColor(Color.TRANSPARENT);

        Canvas canvas = new Canvas(r);

        if (mRotation == 0) {
            // do nothing
        } else if (mRotation == 1) {
            canvas.translate(measuredWidth, 0);
            canvas.rotate(90);
        } else if (mRotation == 2) {
            canvas.rotate(180, measuredWidth / 2, measuredHeight / 2);
        } else {
            canvas.translate(0, measuredHeight);
            canvas.rotate(270);
        }
        mContainer.draw(canvas);
        return r;
    }

device-2017-06-26-125833

source

Before we would start with this migration, we will need to add some additional API to SymbolAnnotations to match the API exposed by MarkerView. Some examples of these are:

  • alpha
  • anchor
  • TBD

cc @mapbox/android

@tobrun
Copy link
Member Author

tobrun commented Oct 10, 2017

This landed in #9782

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

1 participant