nitaliano / react-native-mapbox-gl

A Mapbox GL react native module for creating custom maps
Other
2.16k stars 696 forks source link

Button to center the view on the user #1706

Open NatRousseau opened 3 years ago

NatRousseau commented 3 years ago

Hi, I want to make a button to center the map on the user, but it doesn't work, it gives me this error

`import React, {useState} from 'react'; import {View, Text, Button, StyleSheet, StatusBar} from 'react-native'; import {useTheme} from '@react-navigation/native'; import Mapbox, {Logger} from '@react-native-mapbox-gl/maps'; import Geolocation from 'react-native-geolocation-service';

Mapbox.setAccessToken( 'mykey', );

Logger.setLogCallback(log => { const {message} = log; return !!( message.match('Request failed due to a permanent error: Canceled') || message.match('Request failed due to a permanent error: Socket Closed') ); });

const HomeScreen = ({navigation}) => {

const [state, setState] = useState({ Position: {}, coordonateLat: '', coordonateLong: '', userCoordonate: [], });

const centerCamera = () => { this.map.setCamera({ centerCoordinate: [2.2976, 48.7712], }) };

const {colors} = useTheme();

const theme = useTheme();

return (

{console.log(state.userCoordonate)}