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.

Customized marker disappeared after running for a while. #4189

Closed

Description

@Zeshengx

[Android] I use MapboxGLAndroidSDK and I need to update a customized marker every 100ms to change its position and orientation. The orientation is changed by rotating the bitmap. And I use Mapview.setPosition(currentlocation), Mapview.setIcon(icon). But the marker will disappear after running 2-3mins and get no warning or error in the logcat. If I comment Mapview.setIcon(icon) (no orientation change), the marker won't disappear. Is there a way that I can updating both position and orientation?

IconFactory mIconFactory = IconFactory.getInstance(getApplicationContext());
BitmapFactory.Options options = new BitmapFactory.Options();
        public void setOptions(BitmapFactory.Options options) {
            this.options = options;
            this.options.inDither = false;
            this.options.inTempStorage = new byte[18 * 23];
        }
Bitmap boatarrow = RotateBitmap(BitmapFactory.decodeResource(getResources(),    R.drawable.pointarrow,options), degree + bias);
Icon Iboat = mIconFactory.fromBitmap(boatarrow);
Mapview.setPosition(currentLocation);
Mapview.setIcon(Iboat);

Activity

  1. added
    Android
    on Mar 3, 2016
  2. tobrun commented on Mar 4, 2016

    @tobrun
    Member

    @Zeshengx
    which version of the SDK are you using?
    I wanted to point out that the 4.0.0 version of the SDK will improve the updating dynamic markers.
    You can already test this functionality out in the the related SNAPSHOT.
    For installation instructions see https://www.mapbox.com/android-sdk/#gradle

  3. Zeshengx commented on Mar 4, 2016

    @Zeshengx
    Author

    @tobrun
    I clone the source code from mapbox-gl-native master branch, I am not sure which version is. I will try the SNAPSHOT version, thanks.

  4. Zeshengx commented on Mar 4, 2016

    @Zeshengx
    Author

    @tobrun I tried 4.0.0 version, but the marker still disappears after several minutes. I update marker in the AsyncTask, and I continually get this info in the logcat:

    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2499'
    
    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2519'
    
    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2519'
    
    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2520'
    
    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2520'
    
    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2522'
    
    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2522'
    
    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2620'
    
    I/mbgl: {Worker}[Sprite]: Can't find sprite named 'com.mapbox.icons.icon_2620'
    
    
  5. added this to the android-v4.0.0 milestone on Mar 5, 2016
  6. tobrun commented on Mar 5, 2016

    @tobrun
    Member

    @Zeshengx
    The SNAPHOT is being build daily from master so it's logical you are seeing the same result.

    Related to the issue:

    You are constantly creating new icons and after a couple of minutes you are (probably) running into a OutOfMemory exception. Having trouble creating and loading in 2620 bitmaps is a typical issue with Android development. Google has dedicated whole pages to this subject.

    Workaround for now:

    Load 8 icons into memory, one for each direction (eg. N, NE, E, SE, S, SW, W, NW) and use those fixed set of icons instead of constantly creating new ones. If needed you could increase this icon set to achieve a better animation.

    In future releases:

    Just to be clear, we don't support this feature at this time but proposed hack above should work. For future releases we are thinking about supporting rotation as a dynamic marker attribute. With this implemented you can reuse the same bitmap over and over again.

    I'm going to close this in favour of feature request in #4207.
    Reach out if you have any other questions.

  7. chandreshandroid commented on May 11, 2017

    @chandreshandroid

    i am getting same issue in version 5.0

  8. KuboStraka commented on May 25, 2017

    @KuboStraka

    Hi, @chandreshandroid
    Have you resolved this issue please? Because I am getting it also.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Android

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions