Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Calling MapView.queryRenderedFeaturesInRect without optional layerIDs param crash #3177

Closed
andrei-tofan opened this issue Nov 15, 2023 · 1 comment · Fixed by #3205

Comments

@andrei-tofan
Copy link
Contributor

andrei-tofan commented Nov 15, 2023

Mapbox Implementation

Mapbox

Mapbox Version

default

Platform

Android

@rnmapbox/maps version

10.1.0-beta.20

Standalone component to reproduce

import React from 'react';
import {
  MapView,
  ShapeSource,
  LineLayer,
  Camera,
UserLocation
} from '@rnmapbox/maps';

const getBBox = (
  screenPointX: number,
  screenPointY: number,
  tapMargin: number,
) => [
  screenPointY + tapMargin,
  screenPointX + tapMargin,
  screenPointY - tapMargin,
  screenPointX - tapMargin,
];

class BugReportExample extends React.Component {
  render() {
  const mapRef = React.useRef<MapView>(null);

  return (
    <>
      <MapView
        style={{flex: 1}}
        ref={mapRef}
        onPress={async (event: any) => {
          console.log('Map.onPress', event);
          const {screenPointX, screenPointY} = event.properties as any;
          const bbox = getBBox(screenPointX, screenPointY, 1);

          const filter = ['==', 'type', 'Point'];
          const featureCollection =
            await mapRef.current?.queryRenderedFeaturesInRect(
              bbox as [],
              filter,
            );
          console.log('Features found: ', featureCollection?.features.length);
        }}>
        <UserLocation visible showsUserHeadingIndicator />
      </MapView>
    </>
  );
  }
}

Observed behavior and steps to reproduce

On pressing on the map and queryRenderedFeaturesInRect is used to query features without the optional param layerIDs triggers a crash on android.
Screenshot_20231115-210220_MyMapProject

Expected behavior

The method should work without passing the optional param.

Notes / preliminary analysis

No response

Additional links and references

No response

@andrei-tofan
Copy link
Contributor Author

Anyone else experiencing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant