Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MapScreen.js 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. // @flow
  2. import * as React from 'react';
  3. import {View} from 'react-native';
  4. import {withTheme} from 'react-native-paper';
  5. import {StackNavigationProp} from "@react-navigation/stack";
  6. import type {CustomTheme} from "../../managers/ThemeManager";
  7. import MapboxGL from "@react-native-mapbox-gl/maps";
  8. import exampleIcon from '../../../assets/icon-notification.png';
  9. type Props = {
  10. navigation: StackNavigationProp,
  11. theme: CustomTheme,
  12. }
  13. type State = {
  14. featureCollection: Array<Object>,
  15. }
  16. MapboxGL.setAccessToken("sk.eyJ1IjoiYW1pY2FsZS1pbnNhdCIsImEiOiJja2JpM212Z3QwYmxmMnhsc3RxZWYza2Q5In0.og84RKRa6-vr3qRA1qU9Aw");
  17. const styles = {
  18. icon: {
  19. iconImage: exampleIcon,
  20. iconAllowOverlap: true,
  21. },
  22. };
  23. const FEATURES = [{
  24. type: 'Feature',
  25. geometry: {
  26. type: 'Point',
  27. coordinates: [1.4669608, 43.5698867],
  28. }
  29. }]
  30. /**
  31. * Class defining the app's map screen.
  32. */
  33. class MapScreen extends React.Component<Props, State> {
  34. map: { current: null | MapboxGL.MapView };
  35. constructor() {
  36. super();
  37. this.map = React.createRef();
  38. this.state = {
  39. featureCollection: [],
  40. };
  41. }
  42. componentDidMount() {
  43. MapboxGL.setTelemetryEnabled(false);
  44. }
  45. onSymbolPress = (feature) => {
  46. console.log("coucou");
  47. }
  48. onSourceLayerPress = ({features, coordinates, point}) => {
  49. console.log(
  50. 'You pressed a layer here are your features:',
  51. features,
  52. coordinates,
  53. point,
  54. );
  55. }
  56. render() {
  57. return (
  58. <View style={{flex: 1}}>
  59. <MapboxGL.MapView
  60. style={{flex: 1}}
  61. ref={this.map}
  62. styleURL={MapboxGL.StyleURL.Outdoors}
  63. surfaceView={true}
  64. onPress={(e) => {
  65. console.log(e)
  66. }}
  67. >
  68. <MapboxGL.Camera
  69. zoomLevel={15}
  70. centerCoordinate={[1.4669608, 43.5698867]}
  71. pitch={30}
  72. />
  73. {/*<MapboxGL.ShapeSource*/}
  74. {/* id="symbolLocationSource"*/}
  75. {/* shape={{ type: 'FeatureCollection', features: FEATURES }}*/}
  76. {/*>*/}
  77. {/* <MapboxGL.SymbolLayer*/}
  78. {/* id="symbolLocationSymbols"*/}
  79. {/* minZoomLevel={15}*/}
  80. {/* style={styles.icon}*/}
  81. {/* />*/}
  82. {/*</MapboxGL.ShapeSource>*/}
  83. </MapboxGL.MapView>
  84. </View>
  85. );
  86. }
  87. }
  88. export default withTheme(MapScreen);