react-native-maps: TypeError undefined is not an object (evaluating 'this.map.setNativeProps')

Bug

We see this bug showing up in Sentry, but haven’t been able to reproduce it ourselves. It’s only occuring in a small percentage of our userbase, but occured about 275 times. It looks like the map ref isn’t checked before calling methods in _onMapReady, so I think these refs should be checked before we use them? This issue only occurs on Android.

Stacktrace on Sentry: https://sentry.io/share/issue/c6af900e656a4c2f91f027ff3075fef4/

Environment info

React native info output:

info 
  React Native Environment Info:
    System:
      OS: macOS 10.14.5
      CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
      Memory: 99.61 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.9.4 - ~/.nvm/versions/node/v8.9.4/bin/node
      Yarn: 1.16.0 - /usr/local/bin/yarn
      npm: 5.6.0 - ~/.nvm/versions/node/v8.9.4/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
    IDEs:
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.9 => 0.59.9 

Library version: 0.24.2

Steps To Reproduce

Unable to reproduce by following specific steps, but I guess it happens when _onMapReady is called before the this.map is set.

Reproducible sample code

Unable to reproduce by following specific steps.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 25 (3 by maintainers)

Most upvoted comments

@archanashokeeniitg Remove “provider={PROVIDER_GOOGLE}” and run. I think, problem is ‘provider’ prop.

I solved this by manually install this package. Open your Podfile, below use_react_native add this line. And run pod install

  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  # react-native-maps dependencies
  pod 'react-native-maps', path: rn_maps_path
  pod 'react-native-google-maps', path: rn_maps_path  # Uncomment this line if you want to support GoogleMaps on iOS
  pod 'GoogleMaps'  # Uncomment this line if you want to support GoogleMaps on iOS
  pod 'Google-Maps-iOS-Utils' # Uncomment this line if you want to support GoogleMaps on iOS

We’re experiencing the same issue, Android only and running the latest react-native (v0.63.4) and v0.26.1 of react-native-maps (but according to the changelog, there hasn’t been any change related to this in the latest (v0.27.1).

In our case we’re just drawing a map with a circle on it:

<MapView
  zoomEnabled={true}
  maxZoomLevel={15}
  rotateEnabled={false}
  scrollEnabled={true}
  pitchEnabled={false}
  toolbarEnabled={false}
  provider="google"
  region={{
    latitude,
    longitude,
    latitudeDelta: 0.02,
    longitudeDelta: 0.02,
  }}
>
  <MapView.Circle
    center={{
      latitude,
      longitude,
    }}
    radius={500}
    strokeColor={Colors.orange}
    fillColor={Colors.orangeTransparent}
  />
</MapView>

So we’re not doing anything with the map ref, it must be the library itself which is trying to set the region before the map is actually ready 🤔 .

thanks for clarifying @javiercr this issue will be closed for now.

I solved this by manually install this package. Open your Podfile, below use_react_native add this line. And run pod install

  rn_path = '../node_modules/react-native'
  rn_maps_path = '../node_modules/react-native-maps'

  # react-native-maps dependencies
  pod 'react-native-maps', path: rn_maps_path
  pod 'react-native-google-maps', path: rn_maps_path  # Uncomment this line if you want to support GoogleMaps on iOS
  pod 'GoogleMaps'  # Uncomment this line if you want to support GoogleMaps on iOS
  pod 'Google-Maps-iOS-Utils' # Uncomment this line if you want to support GoogleMaps on iOS

this line is not required -> pod ‘react-native-maps’, path: rn_maps_path’

pod ‘react-native-google-maps’, :path => ‘…/node_modules/react-native-maps’ pod ‘GoogleMaps’ pod ‘Google-Maps-iOS-Utils’`

@Jense5 Same error still exists after more than year of opening this ticket. Do we have any solution to this?