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.

Make InfoWindow dynamically updatable #5237

Closed

Description

@tobrun

We expose setTitle and setSnippet on Marker to set the contents of the default InfoWindow. At this point you can only set them once. Calling these methods consecutively will not always result in changing the contents of the InfoWindow (eg. when it's already open). We have been hearing about the requirement to do this and this follows the line set in 4.1.0 to make other Marker attributes updatable.

We should also look into the possibility to expose an InfoWindowAdapter equivalent for this use-case by exposing an invalidate method on InfoWindowAdapter (this will result in recreating the InfoWindow).

Activity

  1. added
    Android
    on Jun 4, 2016
  2. added this to the android-v4.2.0 milestone on Jun 4, 2016
  3. added a commit that references this issue on Jun 6, 2016
  4. bleege commented on Jun 6, 2016

    @bleege
    Contributor

    I've started work on this functionality by re-enabling access to Marker.setTitle() and Marker.setSnippet() to be the API for updating this content as this is consistent with how the other dynamic marker APIs work (Marker.setPosition() and Marker.setIcon() API ). I've also updated the test case for this in the TestApp's DynamicMarkerChangeActivity so that work on this can commence. So far the InfoWindow moves from location to location just fine, but the content doesn't update. As shown below, when the FAB is originally pressed to do the initial toggle Chelsea's content appears above Arsensal's marker and icon (sorry @jacquestardie ).

    device-2016-06-06-161305
    Original State

    device-2016-06-06-161328
    State After First Toggle

  5. added 2 commits that reference this issue on Jun 6, 2016
  6. jqtrde commented on Jun 6, 2016

    @jqtrde

    @bleege I hope this is at the top top top of your list of things to do 😄

  7. bleege commented on Jun 6, 2016

    @bleege
    Contributor

    I've now added the functionality to update the existing InfoWindow that uses the default InfoWindow for setTitle() and setSnippet(). There's a bit of race condition causing the InfoWindow content to be updated a split second before the InfoWindow is moved to it's new location. I think this has to do with the update process and the (likely unusual) use case as this case is setting all four properties at once and then calling updateMarker() after each property is set.

    The next steps are to:

    1. Verify that updated title and snippet works in InfoWindow when the InfoWindow is closed between FAB toggles
    2. Verify that the updated title and snippet works in InfoWindow when the InfoWindow isn't moved
    3. Try to minimize the number of updateMarker() calls
       // Use Case Updating all four 4 items
        private void updateMarker() {
            // update model
            boolean first = (boolean) mMapView.getTag();
            mMapView.setTag(!first);
    
            // update marker
            mMarker.setPosition(first ? LAT_LNG_CHELSEA : LAT_LNG_ARSENAL);
            mMarker.setIcon(mIconFactory.fromResource(first ? R.drawable.ic_chelsea : R.drawable.ic_arsenal));
            mMarker.setTitle(first ? getString(R.string.dynamic_marker_chelsea_title) : getString(R.string.dynamic_marker_arsenal_title));
            mMarker.setSnippet(first ? getString(R.string.dynamic_marker_chelsea_snippet) :  getString(R.string.dynamic_marker_arsenal_snippet));
        }
    
    // Update being run after each setXXX() method is called
    MapboxMap map = getMapboxMap();
    if (map != null) {
        map.updateMarker(this);
    }

    ezgif com-video-to-gif 1

  8. bleege commented on Jun 6, 2016

    @bleege
    Contributor

    Verify that updated title and snippet works in InfoWindow when the InfoWindow is closed between FAB toggles

    ☑️

    ezgif com-video-to-gif

  9. bleege commented on Jun 7, 2016

    @bleege
    Contributor

    Verify that the updated title and snippet works in InfoWindow when the InfoWindow isn't moved

    ☑️

    location-stays-same

  10. bleege commented on Jun 7, 2016

    @bleege
    Contributor

    Commenting out the updateMarker code from refreshInfoWindowContent() still updates the InfoWindow content (yay!), but I'm also still seeing a bit of lag between the two. I'm going to try removing the updateMarker() calls that are generated by the setPosition() and setIcon() that are part of this test.

                MapboxMap map = getMapboxMap();
                if (map != null) {
                    map.updateMarker(this);
                }

    2016-06-07 11_04_02

  11. bleege commented on Jun 7, 2016

    @bleege
    Contributor

    Discussed the split second offset issue with @zugaldia @cammace @ivovandongen this morning and we decided to ship with this to start with and look to refine over time. The fundamental issue is that the InfoWindow is rendered at the Java View level while the annotation is rendered in Core GL.

  12. added a commit that references this issue on Jun 7, 2016
  13. bleege commented on Jun 7, 2016

    @bleege
    Contributor

    Squashed and Merged into release-android-v4.1.0.

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