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.

Markers flickering in/out #8367

Closed
Closed

Description

@yperess

Platform: Android
Mapbox SDK version:5.0.0. beta 2

Demo: video

Steps to trigger behavior

  1. Add several markers via addMarker(MarkerViewOptions)
  2. Override map rotation/zooming to manually alter the camera
  3. Move the camera around until markers begin clipping

Expected behavior

Markers that are in the visible region should remain visible

Actual behavior

Markers appear to be randomly being removed.

I traced this down to a specific region: invalidateMarkersInVisibleRegion

In here, getMarkerViewsInRect returns an incorrect list of marker views. I verified this by attaching a OnGlobalLayoutListener to the view and noticing that some times when I run:

boolean visible = mMapboxMap.getProjection()
        .getVisibleRegion()
        .latLngBounds
        .contains(markerView);
PointF screenPoint = mMapboxMap.getProjection()
        .toScreenLocation(markerView.getPosition());
boolean screenVisible = viewRectF.contains(screenPoint.x, screenPoint.y)
// visible != screenVisible

Unfortunately, even if I then override the view's visibility according to screenVisible (which seems to be more accurate) the marker still flickers out.

Activity

  1. added
    Android
    annotations
    on Mar 13, 2017
  2. self-assigned this
    on Mar 13, 2017
  3. tobrun commented on Mar 13, 2017

    @tobrun
    Member

    @yperess do you have some code to reproduce this with? Tried reproducing this with the test app MarkerView setup without any luck. Are you using anchoring/offset? Large icons?

  4. yperess commented on Mar 13, 2017

    @yperess
    Author

    @tobrun I'll try to get you a sample. Unfortunately our code is in a private repo right now and I can't just share it. I'll try to extract a sample tonight and post a link to it here. For now here's a very rough sample of what we're doing. The images coming in from the network are capped at around 100x100 px (depending on screen density)

    final MarkerView marker = mMap.addMarker(new MarkerViewOptions()
            .flat(false)
            .position(new LatLng(pin.latitude, pin.longitude));
    Picasso.with(getContext())
            .load(url)
            .into(new Target() {
                @Override
                public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
                    // Here I add some code that manipulates the bitmap by using a canvas and
                    // adding multiple extra bits to it (such as a base that lays flat on the
                    // map).
                    marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(bitmap));
                    marker.setAnchor(0.5f, baseOffsetRatio);
                }
                @Override
                public void onBitmapFailed(Drawable errorDrawable) {
                }
                @Override
                public void onPrepareLoad(Drawable placeHolderDrawable) {
                }
            });
    
  5. tobrun commented on Mar 14, 2017

    @tobrun
    Member

    Haven't been able to reproduce the issue, would you be able to retest with the latest SNAPSHOT?
    Since beta.2 the underlying code has changed a bit.

    ezgif com-video-to-gif 14

    ezgif com-video-to-gif 12

  6. yperess commented on Mar 14, 2017

    @yperess
    Author
  7. yperess commented on Mar 15, 2017

    @yperess
    Author

    https://github.com/yperess/MapboxClippingDemo

    Notice that it takes me about 60+ seconds to find the right combination of zoom/orientation where the views get clipped

    Video

  8. galacticappster04 commented on Mar 16, 2017

    @galacticappster04

    @tobrun, where is this add markers in bulk sample? How are you able to add multiple marker views (1000) on the map? I have markerviews a custom one and I just have 180+ markers and it was very slow.

  9. removed their assignment
    on Apr 19, 2017
  10. tobrun commented on Apr 19, 2017

    @tobrun
    Member

    @neonwarge04 the system will keep inflating views if it needs to display a MarkerView. The key is to not show them all at once ( this will make the system recycle the views instead of inflating new ones).

    Related to the issue, haven't seen any reports and underlying logic has changed.
    Feel free to reach out if this is still an issue. Closing for now.

  11. yperess commented on Apr 19, 2017

    @yperess
    Author

    It's a blocking issue which has left us with migrating off your product and over to Google Maps until this can be resolved. Did you have no luck with the sample app I provided?

  12. tobrun commented on Apr 24, 2017

    @tobrun
    Member

    Thank you for the additional ping, been looking a bit more in this issue and believe the source will be related to #8799. Thank again for reaching out and reporting your issue.

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

    Androidannotationsbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions