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

[Android] ShapeSource onPress handler not working #1738

Open
jsindos opened this issue Jan 19, 2024 · 0 comments
Open

[Android] ShapeSource onPress handler not working #1738

jsindos opened this issue Jan 19, 2024 · 0 comments

Comments

@jsindos
Copy link

jsindos commented Jan 19, 2024

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".

Screenshot_20240119-125706

/**
 * 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;
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

No branches or pull requests

1 participant