From 1af468832984acaa9668fdc872d244c3f1a7643e Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Mon, 22 Jun 2020 16:04:08 +0200 Subject: [PATCH] Tried implementing basic map markers --- src/screens/Services/MapScreen.js | 62 +++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 11 deletions(-) diff --git a/src/screens/Services/MapScreen.js b/src/screens/Services/MapScreen.js index a660b5d..ff9bcf7 100644 --- a/src/screens/Services/MapScreen.js +++ b/src/screens/Services/MapScreen.js @@ -6,32 +6,48 @@ import {withTheme} from 'react-native-paper'; import {StackNavigationProp} from "@react-navigation/stack"; import type {CustomTheme} from "../../managers/ThemeManager"; import MapboxGL from "@react-native-mapbox-gl/maps"; +import exampleIcon from '../../../assets/icon-notification.png'; type Props = { navigation: StackNavigationProp, theme: CustomTheme, } +type State = { + featureCollection: Array, +} + MapboxGL.setAccessToken("sk.eyJ1IjoiYW1pY2FsZS1pbnNhdCIsImEiOiJja2JpM212Z3QwYmxmMnhsc3RxZWYza2Q5In0.og84RKRa6-vr3qRA1qU9Aw"); -const layerStyles = { - smileyFace: { - fillAntialias: true, - fillColor: 'white', - fillOutlineColor: 'rgba(255, 255, 255, 0.84)', +const styles = { + icon: { + iconImage: exampleIcon, + iconAllowOverlap: true, }, }; +const FEATURES = [{ + type: 'Feature', + geometry: { + type: 'Point', + coordinates: [1.4669608, 43.5698867], + } +}] + /** * Class defining the app's map screen. */ -class MapScreen extends React.Component { +class MapScreen extends React.Component { - map : { current: null | MapboxGL.MapView }; + map: { current: null | MapboxGL.MapView }; constructor() { super(); this.map = React.createRef(); + + this.state = { + featureCollection: [], + }; } componentDidMount() { @@ -39,23 +55,47 @@ class MapScreen extends React.Component { } + onSymbolPress = (feature) => { + console.log("coucou"); + } + + + onSourceLayerPress = ({features, coordinates, point}) => { + console.log( + 'You pressed a layer here are your features:', + features, + coordinates, + point, + ); + } + render() { return ( { - const center = await this.map.current.getCenter(); - console.log(center); + onPress={(e) => { + console.log(e) }} > + {/**/} + {/* */} + {/**/} );