You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
Querying for features using source.features(matching: nil) (or anything else) returns 0 features.
This seems like a regression of #9767, but presumably it could also be me not using the library correctly, because Swift.
Steps to reproduce
Given some features constructed like so....
/// somewhere above
letpoints= lineString.asCoordinates
letfeature=MGLPolylineFeature(coordinates: points, count:UInt(points.count))
feature.attributes["featureType"]=self.featureType
for attr in self.featureAttributes {
feature.attributes[attr.name]= attr.value
}print("Feature(\(feature.id)): \(feature.attributes)")
Add them to the map some long time after didFinishLoading
if let mapStyle = mapView.style {
mapStyle.addSource(source)
for layer in layers.values {
mapStyle.addLayer(layer)
if let style = layer as?MGLVectorStyleLayer{letcollection=(source.shape as!MGLShapeCollectionFeature)print("Predicate for \(layer.identifier): \(style.predicate)")print("Matching features for \(layer.identifier): \(source.features(matching: style.predicate).count)"+"of \(source.features(matching:nil).count) or \(collection.shapes.count)")}}}
Expected behavior
It returns more than 0 features.
Actual behavior
It returns 0 features.
Log Output:
Feature(lofeature_Krg4rQm6CyQySqmNWL5C9Z): ["featureType": "FiberCable", "measured_length": "5130", "placement": "Underground"]
...
Predicate for Cable (Other): Optional(featureType == "FiberCable")
Matching features for Cable (Other): 0 of 0 or 3775
It looks like you’re querying the source layer immediately, synchronously, after adding the source to the style. Other feature querying methods like MGLVectorTileSource.features(matching:) only return features in tiles that have already loaded for display in a style layer, which means there would need to be time for a network request and response. This is a shape source, so a network request wouldn’t be necessary, but the interface might still be asynchronous. Can you try querying after a delay?
@1ec5: as additional information, this further presents itself in having no features visible on the map.
By instead using MGLMapViewDelegate's ____ColorForShapeAnnotation, the features appear but can't be styled as expected via a Mapbox Style document (I think we might also be adding the shapes differently).
With the additional context, are there any other debugging steps / information you might recommend to see what my be the cause of the issue we're experiencing?
I'll try the querying after a delay to see if that issue is a red herring.
Querying for features using
source.features(matching: nil)
(or anything else) returns0
features.This seems like a regression of #9767, but presumably it could also be me not using the library correctly, because Swift.
Steps to reproduce
Given some features constructed like so....
And source created like so...
Add them to the map some long time after
didFinishLoading
Expected behavior
It returns more than 0 features.
Actual behavior
It returns 0 features.
Log Output:
Configuration
Mapbox SDK versions: 4.6.0
iOS/macOS versions: iOS 12.1
Device/simulator models: iPhone XR, SimulatorApp-877 CoreSimulator-581.2
Xcode version: 10.1
The text was updated successfully, but these errors were encountered: