mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
4.34k stars 1.33k forks source link

Can't get MGLFeature from "visibleFeaturesInRect: inStyleLayersWithIdentifiers:" #16637

Open codevond opened 2 years ago

codevond commented 2 years ago

This is my code

` if (tap.state == UIGestureRecognizerStateEnded) {

    CGPoint touchpoint = [tap locationInView:self];

    CGRect fishRect = CGRectMake(Tp.x-1, Tp.y-1, 2, 2);
    NSSet *fishSet = [NSSet setWithObject:self.fishLay.identifier];
    NSArray<id<MGLFeature>> * fishFeatures = [self visibleFeaturesInRect:fishRect inStyleLayersWithIdentifiers:fishSet];
    if (fishFeatures.count > 0) {
       /// do something
        }
    }`

But the MGLFeature alway is empty, even if I click exactly. And there is also a issue of offset, the direction is random.