rnmapbox / rnmapbox/maps

[Android] ShapeSource onPress handler not working

Open
#3,332 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug 🪲
Dominant language
Kotlin
Stars
2.9k
Forks
947
Avg merge
6d 37m
Merged PRs (30d)
1

Description

Environment

I have a very simple demo map colouring in Australia. For some reason, the onPress handler on ShapeSource is not working when I press on the coloured area. I am very new to map box so may be missing something? Using the latest RN 0.73.2 on Android, "@rnmapbox/maps": "^10.1.6".

image

Steps to reproduce

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 */

import Mapbox from '@rnmapbox/maps';
import React from 'react';
import {Dimensions, StyleSheet, View} from 'react-native';

Mapbox.setAccessToken('');

const {width, height} = Dimensions.get('window');

function App(): React.JSX.Element {
  return (
    <View style={styles.page}>
      <View style={styles.container}>
        <Mapbox.MapView
          style={styles.map}
          scaleBarEnabled={false}
          logoEnabled={false}>
          <Mapbox.Camera centerCoordinate={[135, -30]} zoomLevel={2.75} />
          <Mapbox.ShapeSource
            onPress={e => console.log(e)}
            id="states"
            url="https://raw.githubusercontent.com/rowanhogan/australian-states/master/states.geojson"
          />
          <Mapbox.FillLayer id="states-lines" sourceID="states" />
        </Mapbox.MapView>
      </View>
    </View>
  );
}

const styles = StyleSheet.create({
  page: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  container: {
    height,
    width,
  },
  map: {
    flex: 1,
  },
});

export default App;

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 by running the supplied React Native App reproduction on Android and inspect the ShapeSource with its onPress handler and FillLayer. Confirm whether pressing the coloured Australia area produces the expected console event; done means the handler reliably logs the press event in the stated environment.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, react-native, typescript
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.