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.

getAnnotationsInBounds not returning in bounds annotations #3643

Closed

Description

@tobrun

Prior

In the Android release 3.1.0 we made the touch target of touch event smaller #3156.

2d48ad00-be8c-11e5-94a4-57b2f20b8cd8

This was needed to be able to properly select annotations when they are just side by side.

screen shot 2016-01-21 at 10 22 47

See the result from that issue here.

Issue

While making touch target smaller was great for selecting annotations side by side. It did make selecting annotations in general more difficult. I believe the source of this problem can be found in C++ implementation of getAnnotationsInBounds.

Visual

In next screenshot I visualised the BoundingBox passed to the getAnnotationsInBounds:

screen shot 2016-01-21 at 10 39 54

In that case an InfoWindow is not shown because getAnnotationsInBounds returns an empty list.

More examples shown in this clip.

Problem

I'm currently not sure where to pinpoint this on:

  • Is the C++ code not taking the size of the Marker image in account? only the base of the marker?
  • Is the C++ code not taking in account the current zoom level when determining?
  • Should the java code calculate a different bounding box based on zoom level?

Activity

  1. tobrun commented on Jan 21, 2016

    @tobrun
    MemberAuthor

    Let's take a trip down to C++ land and figure this out:

    • getAnnotationsInBounds() is calling nativeGetAnnotationsInBounds() in jni.cpp
    • nativeGetAnnotationsInBounds() is calling getMap().getPointAnnotationsInBounds() on native_map_view.cpp / map.cpp
    • getPointsAnnotationsInBounds() is calling getPointAnnotationsInBounds in annotation_manager.cpp
    AnnotationIDs AnnotationManager::getPointAnnotationsInBounds(const LatLngBounds& bounds) const {
        AnnotationIDs result;
    
        pointTree.query(boost::geometry::index::intersects(bounds),
            boost::make_function_output_iterator([&](const auto& val){
                result.push_back(val->id);
            }));
    
        return result;
    }

    The code above is used for all annotations and doesn't take in account the height/width of a Marker icon.

  2. added this to the android-v4.0.0 milestone on Jan 25, 2016
  3. added
    Android
    on Jan 25, 2016
  4. tobrun commented on Mar 3, 2016

    @tobrun
    MemberAuthor

    As mentioned in the follow up ticket, we should look into fixing this at the Android SDK level by introducing appropriate padding. We used to do fixed padding but that is not the way iOS or OS X are handling this.

  5. tobrun commented on Mar 5, 2016

    @tobrun
    MemberAuthor

    To resolve above I will calculate the average width and average height of a marker icon and take that in account when calculation the touch area.

  6. tobrun commented on Mar 5, 2016

    @tobrun
    MemberAuthor

    I initially wanted to manage this in IconFactory, but this will indicate the average will be used in all maps in one application. The average should only be used per map.

  7. tobrun commented on Mar 5, 2016

    @tobrun
    MemberAuthor

    I'm starting to understand why I was not really able to get the same ux with the default marker vs custom:

    screen shot 2016-03-05 at 11 01 32

    This should be changed to a normal image as a end developer would also use.

  8. tobrun commented on Mar 5, 2016

    @tobrun
    MemberAuthor

    After changing the default marker image, the markers are placed to low on the map.
    To workaround this I used setTopOffsetPixels with the height of the marker.
    In the same way an end developer would do.

  9. tobrun commented on Mar 5, 2016

    @tobrun
    MemberAuthor

    It seems I'm currently not able to use setTopOffsetPixels.. this is one adjustment needed for dynamic marker support.

  10. tobrun commented on Mar 5, 2016

    @tobrun
    MemberAuthor

    Since there are a lot of moving pieces and this fits more in the story of 4.1.0, I'm going to postpone this.

  11. added a commit that references this issue on Mar 5, 2016
  12. added a commit that references this issue on Mar 8, 2016
  13. modified the milestone: android-v4.1.0 on Mar 18, 2016
  14. added a commit that references this issue on Mar 23, 2016
  15. vfaSonnt commented on Mar 31, 2016

    @vfaSonnt

    Hope this will be released soon.

  16. added this to the android-v4.1.0 milestone on Apr 6, 2016
  17. tobrun commented on Apr 6, 2016

    @tobrun
    MemberAuthor

    The idea here is to add a fixed amount of padding + an average padding calculated from all the different icons used. For the default icon (that has extra whitespace to work around not having the anchor method from #2916) I'm just subtracting the whitespace from it before calculating the average padding (iOS is doing the same).

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

Metadata

Metadata

Assignees

Labels

Androidbug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions