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

Deprecate MarkerView / Introduce IconGenerator #9365

@tobrun

Description

@tobrun

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    AndroidMapbox Maps SDK for Android

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions