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.

visibleFeatures not returning annotation for current zoom level #14192

Closed

Description

@otusweb

In my iOS app, I added a mapbox view in which I load a VectorStyleSource

   ``` func mapView(_: MGLMapView, didFinishLoading style: MGLStyle) {
    let source = MGLVectorTileSource(identifier: "export-ddqmvm",
                                     configurationURL: URL(string: "mapbox://xxx.xxx")!)
    style.addSource(source)```

As I move the map around I get the notification that the map is done loading, but If I query for the visible annotations at this point:

```let annotations = mapView.visibleFeatures(in: mapView.bounds,
                                              styleLayerIdentifiers: Set([playgroundStyleLayerIdentifier]))```

The list of annotation at this point is not updated with the new map bound,but instead with the previous map bound. This is especially a problem when zooming in from zoom level where those annotations are not shows to a zoom level where they are shown. At this point the map show the annotation but the visibleFeatures call comes back empty

Steps to reproduce

  1. add a MGLVectorTileSource to a map
  2. call mapView.visibleFeatures in ViewDidChange delegate callback
  3. launch the app and zoom in until you reach a zoom level where the annotations are shown

Expected behavior

mapView.visibleFeatures returns an array containing the visible annotations

Actual behavior

mapView.visibleFeatures returns an empty array

Configuration

Mapbox SDK versions: pod 'Mapbox-iOS-SDK', '~> 4.9'
iOS/macOS versions: 10.12
Device/simulator models: iphone XR 12.1
Xcode version: XCode 10.1

Activity

  1. added
    iOS
    on Mar 21, 2019
  2. victorlsn commented on Jul 2, 2019

    @victorlsn

    I'm also having that problem. Did you find any solution?

  3. otusweb commented on Jul 2, 2019

    @otusweb
    Author
  4. julianrex commented on Jul 2, 2019

    @julianrex
    Contributor

    As I move the map around I get the notification that the map is done loading

    @otusweb can you try moving your logic to either of these delegate methods:

    • func mapViewDidFinishRenderingFrame(_ mapView: MGLMapView, fullyRendered: Bool) where fullyRendered == true
    • func mapViewDidBecomeIdle(_ mapView: MGLMapView)

    visibleFeatures requires rendering to have occurred, and it's sounds like you're calling it too early in the cycle. See this related comment for some additional background: #14531 (comment)

  5. victorlsn commented on Jul 2, 2019

    @victorlsn

    @julianrex that actually solved that issue on my side.
    Thank you very much.

  6. julianrex commented on Jul 2, 2019

    @julianrex
    Contributor

    Excellent to hear @victorlsn!

  7. chloekraw commented on Jul 6, 2019

    @chloekraw
    Contributor

    Thanks @julianrex! Closing this issue as it looks like there's no bug.

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

    iOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions