Skip to content

fix(android): withLayerIDs: is optional#3205

Merged
mfazekas merged 1 commit intomainfrom
optional-layer-ids
Nov 27, 2023
Merged

fix(android): withLayerIDs: is optional#3205
mfazekas merged 1 commit intomainfrom
optional-layer-ids

Conversation

@mfazekas
Copy link
Contributor

@mfazekas mfazekas commented Nov 27, 2023

Fixes: #3177

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,
];

export default function BugReportExample() {
  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>
    </>
  );
}

export default BugReportExample;

@mfazekas mfazekas merged commit cbfba84 into main Nov 27, 2023
@mfazekas mfazekas deleted the optional-layer-ids branch November 27, 2023 21:05
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 this pull request may close these issues.

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

1 participant