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

queryPointAnnottions don't return recently added PointAnnotations #7074

Closed
tobrun opened this issue Nov 15, 2016 · 4 comments
Closed

queryPointAnnottions don't return recently added PointAnnotations #7074

tobrun opened this issue Nov 15, 2016 · 4 comments
Assignees
Labels
Android Mapbox Maps SDK for Android

Comments

@tobrun
Copy link
Member

tobrun commented Nov 15, 2016

When looking into #7072, I noticed that a recently added point annotation isn't returned as a result of queryPointAnnotations.

What I do is add a point annotation to the map and almost immediately execute a query with:

nativeMapView.queryPointAnnotations(rect)

This currently results in returning 0 annotations,
if I delay this action this results in returning 1 annotation.

cc @brunoabinader

@tobrun tobrun added the Core The cross-platform C++ core, aka mbgl label Nov 15, 2016
@jfirebaugh
Copy link
Contributor

Pretty sure this is expected behavior. queryPointAnnotations relies on queryRenderedFeatures, and a point annotation isn't rendered until it has a chance to pass through the worker layout step, which is an asynchronous operation.

@tobrun
Copy link
Member Author

tobrun commented Nov 16, 2016

Thank you for the explanation, makes sense that the marker will not show up until they are actually rendered. I'm converting this issue to an android-docs issue.

@tobrun tobrun added Android Mapbox Maps SDK for Android documentation and removed Core The cross-platform C++ core, aka mbgl labels Nov 16, 2016
@tobrun tobrun added this to the android-v5.0.0 milestone Nov 16, 2016
@tobrun tobrun modified the milestones: android-v4.2.0, android-v5.0.0 Nov 30, 2016
@tobrun tobrun self-assigned this Nov 30, 2016
@tobrun
Copy link
Member Author

tobrun commented Nov 30, 2016

Changing this to the 4.2.0 milestone since this behavior affects our examples and code we have been using so far in relation to MarkerView.

We used to be able to:

MarkerView markerView = mapboxMap.addMarker(markerViewOptions);
View view = markerViewManager.getView(markerView);

And the returned View wouldn't be null if the MarkerView was found in the current Viewport. With above described behavior the user needs to wait since adding one is a asynchronous operation. To make this easier for integrating I'm providing an additional addMarker method with a callback interface that is invoked when getView() wouldn't return null anymore. This would end up in using an API as:

createCarMarker(getLatLngInBounds(), R.drawable.ic_car_top, new MarkerViewManager.OnMarkerViewAddedListener(){
      @Override
      public void onViewAdded(@NonNull MarkerView markerView) {
          randomlyMoveMarker(markerView);
      }
});

Besides above we need tests for regressions and an update to documentation around the asynchronous behavior of adding markers for the 4.2.0-release.

@tobrun
Copy link
Member Author

tobrun commented Dec 6, 2016

Related PR for this has landed on release branch, closing

@tobrun tobrun closed this as completed Dec 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

No branches or pull requests

2 participants