mapbox / mapbox/mapbox-maps-ios

queryRenderedFeatures not returning features, result is empty

Open
#1,991 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :beetle:
Dominant language
Swift
Stars
601
Forks
196
PR merge metrics
No merged PRs in 30d

Description

I want to query features in a layer but it is returning nothing.

## Environment

- Xcode version: 14.3
- iOS version: iOS 14
- Devices affected: iPhone
- Maps SDK Version: 10.14.0

## Observed behavior and steps to reproduce

```//get the camera bounds
let cameraOptions = CameraOptions(cameraState: map.mapView.mapboxMap.cameraState, anchor: nil)
let cameraBounds = map.mapView.mapboxMap.coordinateBounds(for: cameraOptions)

//create CGRect points from the camerabounds
let point1 = CLLocationCoordinate2D(latitude: cameraBounds.northwest.latitude, longitude: cameraBounds.northwest.longitude)
let point2 = CLLocationCoordinate2D(latitude: cameraBounds.northeast.latitude, longitude: cameraBounds.northeast.longitude)
let point3 = CLLocationCoordinate2D(latitude: cameraBounds.southwest.latitude, longitude: cameraBounds.southwest.longitude)
let point4 = CLLocationCoordinate2D(latitude: cameraBounds.southeast.latitude, longitude: cameraBounds.southeast.longitude)

//build the CGRect
let pointRect = map.mapView.mapboxMap.points(for: [point1, point2, point3, point4])

//layerID taken from mapbox studio style layer ID
let options = RenderedQueryOptions(layerIds: ["seating-locations"], filter: nil)

//query map layer
map.mapView.mapboxMap.queryRenderedFeatures(with: pointRect, options: options) { results in
switch results {
case .failure(let error):
print(error.localizedDescription)
case .success(let features):
print("Querying bench layer went to success object. There are \(features) features")
}
}
```

There are no results printing to console.

queryRenderedFeatures

## Expected behavior

Returns properties of queried features.

https://github.com/mapbox/mapbox-maps-ios/blob/69e9d106028090929340b717776c3e9f4ccb1750/Apps/Examples/Examples/All%20Examples/FeaturesAtPointExample.swift

## Notes / preliminary analysis

I used the DataAPI to query the source "Seating-Locations". Data is there.

```
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"stsendist":"26","@computed_region_yeji_bk3q":"4","siteid":"980.0","street":"Canal Street","geocodeadd":"431 Canal Street","ntaname":"SoHo-Little Italy-Hudson Square","@computed_region_sbqj_enih":"1","comdist":"102.0","femafldt":null,"busroute":"Not Applicable","@computed_region_92fq_4b7q":"32","borocd":"102","congdist":"10","coundist":"1","latitude":"40.7229308992","borough":"Manhattan","hrcevac":"2","objectid_1":"946.0","seatingtyp":"BACKED 1.0","@computed_region_efsh_h5xi":"12076","assemdist":"66","femafldz":"AE","longitude":"-74.0066503437","crossstree":"Varick Street & Hudson Street","@computed_region_f5dn_yrer":"57","address":"431 Canal Street","boroname":"Manhattan","borocode":"1","installati":"2012-07-03T00:00:00.000","bid":"Hudson Square Connection","category":"BID"},"geometry":{"coordinates":[-74.00665,40.72293],"type":"Point"},"id":"00341ac879759708135cf75a96ab8a94"}]}%
```

I removed and added back the layer in studio. The data is within the map style.

benchData

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the queryRenderedFeatures call shown in the issue and compare its usage with Apps/Examples/Examples/All Examples/FeaturesAtPointExample.swift. Reproduce the query with the reported iOS and Maps SDK versions, then verify that the seating-locations layer returns its rendered feature properties.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, swift
Domain
mobile
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.