react-native-maps-navigation icon indicating copy to clipboard operation
react-native-maps-navigation copied to clipboard

Problems with function based React Native

Open SArrueLorca opened this issue 3 years ago • 1 comments

Hi. I want to make an app that uses Turn by Turn navigation exclusively. However my code is function based instead of using classes as the provided example, due to limitations with React Navigation. That's the code that i used:

                          <MapView
                              ref={ref => this.refMap = ref}
                              provider={PROVIDER_GOOGLE}
                              style={{  flex: 1}}

                              initialRegion={{
                                  latitude: 37.78825,
                                  longitude: -122.4324,
                                  latitudeDelta: 0.0922,
                                  longitudeDelta: 0.0421,
                              }}
                          >
                              <MapViewNavigation
                                  origin={coordenada}
                                  destination='132 Wilmot St, San Francisco, CA 94115'
                                  navigationMode= {NavigationModes.IDLE}
                                  travelMode= {TravelModes.DRIVING}
                                  ref={ref => this.refNavigation = ref}
                                  map={() => this.refMap}
                                  apiKey={GOOGLE_API_KEY}
                                  simulate={true}
                                  onRouteChange={route => console.log(route)}
                                  onStepChange={(step, nextStep) => console.log(step)}
                                  displayDebugMarkers={true}
                                  onNavigationStarted={route => console.log("Navigation Started")}
                                  onNavigationCompleted={console.log("Pendiente")}
                              />
                          </MapView>

And i receive an error related to this.refMap, this.refNavigation and navigator.geolocation.watchposition. So i want to know: Is there an alternative to repair/avoid this ref dependent code without using classes?. Thanks in advance. Cierto

SArrueLorca avatar Dec 29 '21 16:12 SArrueLorca

Could you solve the problem

meerbex avatar Jun 28 '22 11:06 meerbex